Skip to content
Snippets Groups Projects
Commit 426f5630 authored by srosse's avatar srosse
Browse files

Merge OpenOLAT 10.4 to OpenOLAT default branch with aab6b3f87cbc262d877ff98c181950972ed2b5d5

parents 4d5318f9 fb6942f3
No related branches found
No related tags found
No related merge requests found
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.projectbroker.service;
import java.util.List;
import org.olat.core.commons.persistence.DB;
import org.olat.course.nodes.projectbroker.datamodel.Project;
import org.olat.course.nodes.projectbroker.datamodel.ProjectImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Project queries must migrate here.
*
*
* Initial date: 01.02.2016<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
@Service
public class ProjectDAO {
@Autowired
private DB dbInstance;
/**
* The method load the project or return null if not found. The query fetch
* all dependencies but the custom fields.
*
* @param projectKey
* @return The project
*/
public Project loadProject(Long projectKey) {
StringBuilder sb = new StringBuilder();
sb.append("select project from ").append(ProjectImpl.class.getName()).append(" as project ")
.append(" left join fetch project.projectGroup pGroup")
.append(" left join fetch pGroup.baseGroup bGroup")
.append(" left join fetch project.candidateGroup cGroup")
.append(" left join fetch project.projectBroker pBroker")
.append(" where project.key=:projectKey");
List<Project> projects = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Project.class)
.setParameter("projectKey", projectKey)
.getResultList();
return projects == null || projects.isEmpty() ? null : projects.get(0);
}
}
......@@ -68,6 +68,8 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
@Autowired
private DB dbInstance;
@Autowired
private ProjectDAO projectDao;
@Autowired
private BaseSecurity securityManager;
@Autowired
private ProjectBrokerManager projectBrokerManager;
......@@ -260,7 +262,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou
@Override
public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) {
final Project reloadedProject = (Project) dbInstance.loadObject(project, true);
final Project reloadedProject = projectDao.loadProject(project.getKey());
final BusinessGroupAddResponse response = new BusinessGroupAddResponse();
BusinessGroupAddResponse state = businessGroupService.addParticipants(actionIdentity, null, identities, reloadedProject.getProjectGroup(), null);
response.getAddedIdentities().addAll(state.getAddedIdentities());
......
......@@ -372,8 +372,7 @@ public class CSVToQuestionConverter {
private void processPoints(String[] parts) {
if(currentItem == null) return;
String pointsStr = parts[1];
float points = Float.parseFloat(pointsStr);
float points = parseFloat(parts[1], 1.0f);
Question question = currentItem.getItem().getQuestion();
int type = question.getType();
......@@ -402,7 +401,7 @@ public class CSVToQuestionConverter {
Question question = currentItem.getItem().getQuestion();
int type = question.getType();
if (type == Question.TYPE_MC || type == Question.TYPE_SC) {
float point = Float.parseFloat(parts[0]);
float point = parseFloat(parts[0], 1.0f);
String content = parts[1];
ChoiceQuestion choice = (ChoiceQuestion)question;
......@@ -424,7 +423,7 @@ public class CSVToQuestionConverter {
response.setContent(mat);
fib.getResponses().add(response);
} else {
float point = Float.parseFloat(parts[0]);
float point = parseFloat(parts[0], 1.0f);
String correctBlank = parts[1];
FIBResponse response = new FIBResponse();
......@@ -451,6 +450,18 @@ public class CSVToQuestionConverter {
}
}
private float parseFloat(String value, float defaultValue) {
float floatValue = defaultValue;
if(value != null) {
if(value.indexOf(",") >= 0) {
value = value.replace(",", ".");
}
floatValue = Float.parseFloat(value);
}
return floatValue;
}
private Material createMaterialWithText(String text) {
Material material = new Material();
material.add(createMattext(text));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment