use of org.olat.modules.assessment.AssessmentEntry in project openolat by klemens.
the class ConvertToGTACourseNode method convertAssessmentDatas.
private void convertAssessmentDatas(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
CourseEnvironment courseEnv = course.getCourseEnvironment();
CoursePropertyManager propertyMgr = courseEnv.getCoursePropertyManager();
Map<Long, AssessmentEntry> datas = new HashMap<>();
List<AssessmentEntry> properties = courseEnv.getAssessmentManager().getAssessmentEntries(sourceNode);
for (AssessmentEntry property : properties) {
Identity identity = property.getIdentity();
datas.put(identity.getKey(), property);
}
properties = null;
DBFactory.getInstance().getCurrentEntityManager().clear();
AssessmentManager assessmentMgr = courseEnv.getAssessmentManager();
for (AssessmentEntry assessmentData : datas.values()) {
Identity assessedIdentity = securityManager.loadIdentityByKey(assessmentData.getIdentity().getKey());
if (assessmentData.getPassed() != null || assessmentData.getScore() != null) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
Float score = assessmentData.getScore() == null ? null : assessmentData.getScore().floatValue();
ScoreEvaluation scoreEval = new ScoreEvaluation(score, assessmentData.getPassed());
assessmentMgr.saveScoreEvaluation(gtaNode, null, assessedIdentity, scoreEval, userCourseEnv, false, Role.auto);
// set graded
Task task = gtaManager.getTask(assessedIdentity, taskList);
if (task == null) {
gtaManager.createTask(null, taskList, TaskProcess.graded, null, assessedIdentity, gtaNode);
} else {
gtaManager.updateTask(task, TaskProcess.graded, gtaNode, Role.auto);
}
}
if (assessmentData.getAttempts() != null) {
assessmentMgr.saveNodeAttempts(gtaNode, null, assessedIdentity, assessmentData.getAttempts().intValue(), Role.auto);
}
if (StringHelper.containsNonWhitespace(assessmentData.getCoachComment())) {
assessmentMgr.saveNodeCoachComment(gtaNode, assessedIdentity, assessmentData.getCoachComment());
}
if (StringHelper.containsNonWhitespace(assessmentData.getComment())) {
assessmentMgr.saveNodeComment(gtaNode, null, assessedIdentity, assessmentData.getComment());
}
}
DBFactory.getInstance().getCurrentEntityManager().clear();
// copy log entries
List<Property> logEntries = propertyMgr.listCourseNodeProperties(sourceNode, null, null, UserNodeAuditManager.LOG_IDENTIFYER);
for (Property logEntry : logEntries) {
String logText = logEntry.getTextValue();
Identity identity = securityManager.loadIdentityByKey(logEntry.getIdentity().getKey());
Property targetProp = propertyMgr.findCourseNodeProperty(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER);
if (targetProp == null) {
targetProp = propertyMgr.createCourseNodePropertyInstance(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER, null, null, null, logText);
} else {
targetProp.setTextValue(logText);
}
propertyMgr.saveProperty(targetProp);
}
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentEntryDAOTest method removeEntryForReferenceEntry.
@Test
public void removeEntryForReferenceEntry() {
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-18");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-19");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
AssessmentEntry nodeAssessment1 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry);
AssessmentEntry nodeAssessment2 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
AssessmentEntry nodeAssessment3 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, null, entry, 3.0f, Boolean.FALSE, null, null);
AssessmentEntry nodeAssessment4 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, refEntry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
dbInstance.commitAndCloseSession();
// delete by reference
int affectedRows = assessmentEntryDao.removeEntryForReferenceEntry(refEntry);
dbInstance.commitAndCloseSession();
Assert.assertEquals(3, affectedRows);
// check
AssessmentEntry deletedAssessmentEntry1 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment1.getKey());
Assert.assertNotNull(deletedAssessmentEntry1);
Assert.assertNull(deletedAssessmentEntry1.getReferenceEntry());
AssessmentEntry deletedAssessmentEntry2 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment2.getKey());
Assert.assertNotNull(deletedAssessmentEntry2);
Assert.assertNull(deletedAssessmentEntry2.getReferenceEntry());
AssessmentEntry deletedAssessmentEntry3 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment3.getKey());
Assert.assertNotNull(deletedAssessmentEntry3);
Assert.assertNotNull(deletedAssessmentEntry3.getReferenceEntry());
Assert.assertEquals(entry, deletedAssessmentEntry3.getReferenceEntry());
AssessmentEntry deletedAssessmentEntry4 = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment4.getKey());
Assert.assertNotNull(deletedAssessmentEntry4);
Assert.assertNull(deletedAssessmentEntry4.getReferenceEntry());
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentEntryDAOTest method loadAssessmentEntry.
@Test
public void loadAssessmentEntry() {
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-3");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
AssessmentEntry nodeAssessment = assessmentEntryDao.createAssessmentEntry(assessedIdentity, null, entry, subIdent, entry);
dbInstance.commitAndCloseSession();
AssessmentEntry reloadedAssessment = assessmentEntryDao.loadAssessmentEntry(assessedIdentity, null, entry, subIdent);
Assert.assertEquals(nodeAssessment.getKey(), reloadedAssessment.getKey());
Assert.assertEquals(nodeAssessment, reloadedAssessment);
Assert.assertEquals(assessedIdentity, reloadedAssessment.getIdentity());
Assert.assertEquals(entry, reloadedAssessment.getRepositoryEntry());
Assert.assertEquals(subIdent, reloadedAssessment.getSubIdent());
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentEntryDAOTest method loadAssessmentEntries_subIdent.
@Test
public void loadAssessmentEntries_subIdent() {
Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-7");
Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-8");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
AssessmentEntry nodeAssessmentId1 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry);
AssessmentEntry nodeAssessmentId2 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
AssessmentEntry nodeAssessmentId3 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, null, entry, 3.0f, Boolean.FALSE, null, null);
AssessmentEntry nodeAssessmentId4 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, refEntry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
dbInstance.commitAndCloseSession();
// load with our subIdent above
List<AssessmentEntry> assessmentEntries = assessmentEntryDao.loadAssessmentEntryBySubIdent(entry, subIdent);
Assert.assertNotNull(assessmentEntries);
Assert.assertEquals(2, assessmentEntries.size());
Assert.assertTrue(assessmentEntries.contains(nodeAssessmentId1));
Assert.assertTrue(assessmentEntries.contains(nodeAssessmentId2));
Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId3));
Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId4));
}
use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.
the class AssessmentEntryDAOTest method loadCourseNodeAssessmentById.
@Test
public void loadCourseNodeAssessmentById() {
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-2");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
AssessmentEntry nodeAssessment = assessmentEntryDao.createAssessmentEntry(assessedIdentity, null, entry, subIdent, entry);
dbInstance.commitAndCloseSession();
AssessmentEntry reloadedAssessment = assessmentEntryDao.loadAssessmentEntryById(nodeAssessment.getKey());
Assert.assertEquals(nodeAssessment.getKey(), reloadedAssessment.getKey());
Assert.assertEquals(nodeAssessment, reloadedAssessment);
Assert.assertEquals(assessedIdentity, reloadedAssessment.getIdentity());
Assert.assertEquals(entry, reloadedAssessment.getRepositoryEntry());
Assert.assertEquals(subIdent, reloadedAssessment.getSubIdent());
}
Aggregations