use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
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.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class QTI12PullTestsToolController method retrieveTest.
private void retrieveTest(Identity assessedIdentity, ICourse course) {
ModuleConfiguration modConfig = courseNode.getModuleConfiguration();
String resourcePathInfo = courseEnv.getCourseResourceableId() + File.separator + courseNode.getIdent();
AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(assessedIdentity, "", modConfig, false, courseEnv.getCourseResourceableId(), courseNode.getIdent(), resourcePathInfo, null);
// close the test
ai.stop();
// persist the results
iqm.persistResults(ai);
// reporting
Document docResReporting = iqm.getResultsReporting(ai, assessedIdentity, I18nModule.getDefaultLocale());
FilePersister.createResultsReporting(docResReporting, assessedIdentity, ai.getFormattedType(), ai.getAssessID());
// olat results
AssessmentContext ac = ai.getAssessmentContext();
Float score = new Float(ac.getScore());
Boolean passed = new Boolean(ac.isPassed());
ScoreEvaluation sceval = new ScoreEvaluation(score, passed, Boolean.FALSE, new Long(ai.getAssessID()));
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
courseNode.updateUserScoreEvaluation(sceval, userCourseEnv, assessedIdentity, true, Role.coach);
// cleanup
ai.cleanUp();
}
use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method setAssessmentStatus.
@Override
public void setAssessmentStatus(Identity assessedIdentity, BinderRef binderRef, AssessmentEntryStatus status, Identity coachingIdentity) {
Boolean fullyAssessed = Boolean.FALSE;
if (status == AssessmentEntryStatus.done) {
fullyAssessed = Boolean.TRUE;
}
Binder binder = binderDao.loadByKey(binderRef.getKey());
RepositoryEntry entry = binder.getEntry();
if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
if (courseNode instanceof PortfolioCourseNode) {
PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
AssessmentEvaluation eval = pfNode.getUserScoreEvaluation(userCourseEnv);
ScoreEvaluation scoreEval = new ScoreEvaluation(eval.getScore(), eval.getPassed(), status, true, fullyAssessed, null, null, binder.getKey());
pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
assessmentEntry.setFullyAssessed(fullyAssessed);
assessmentEntry.setAssessmentStatus(status);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class AssessmentManagerTest method testSaveScoreEvaluation.
/**
* Tests the AssessmentManager methods.
*/
@Test
public void testSaveScoreEvaluation() {
log.info("Start testSaveScoreEvaluation");
assertNotNull(course);
// find an assessableCourseNode
List<CourseNode> assessableNodeList = AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), null);
Iterator<CourseNode> nodesIterator = assessableNodeList.iterator();
boolean testNodeFound = false;
while (nodesIterator.hasNext()) {
CourseNode currentNode = nodesIterator.next();
if (currentNode instanceof AssessableCourseNode) {
if (currentNode.getType().equalsIgnoreCase("iqtest")) {
log.info("Yes, we found a test node! - currentNode.getType(): " + currentNode.getType());
assessableCourseNode = (AssessableCourseNode) currentNode;
testNodeFound = true;
break;
}
}
}
assertTrue("found no test-node of type 'iqtest' (hint: add one to DemoCourse) ", testNodeFound);
assessmentManager = course.getCourseEnvironment().getAssessmentManager();
Long assessmentID = new Long("123456");
Integer attempts = 1;
String coachComment = "SomeUselessCoachComment";
String userComment = "UselessUserComment";
// store ScoreEvaluation for the assessableCourseNode and student
ScoreEvaluation scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(student);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
boolean incrementAttempts = true;
assessmentManager.saveScoreEvaluation(assessableCourseNode, tutor, student, scoreEvaluation, userCourseEnv, incrementAttempts, Role.coach);
DBFactory.getInstance().closeSession();
// the attempts mut have been incremented
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assessmentManager.saveNodeCoachComment(assessableCourseNode, student, coachComment);
assessmentManager.saveNodeComment(assessableCourseNode, tutor, student, userComment);
attempts++;
assessmentManager.saveNodeAttempts(assessableCourseNode, tutor, student, attempts, Role.coach);
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assertEquals(score, assessmentManager.getNodeScore(assessableCourseNode, student));
assertEquals(passed, assessmentManager.getNodePassed(assessableCourseNode, student));
assertEquals(assessmentID, assessmentManager.getAssessmentID(assessableCourseNode, student));
assertEquals(coachComment, assessmentManager.getNodeCoachComment(assessableCourseNode, student));
assertEquals(userComment, assessmentManager.getNodeComment(assessableCourseNode, student));
log.info("Finish testing AssessmentManager read/write methods");
checkEfficiencyStatementManager();
assertNotNull("no course at the end of test", course);
try {
course = CourseFactory.loadCourse(course.getResourceableId());
} catch (Exception ex) {
fail("Could not load course at the end of test Exception=" + ex);
}
assertNotNull("no course after loadCourse", course);
}
use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.
the class QTI12ResultDetailsController method doRetrieveTest.
/**
* Retrieve the test: load the course, close the assessment instamce, persist the QTI
* result set, pass the score to the course node.
* @param ureq
*/
private void doRetrieveTest() {
ICourse course = CourseFactory.loadCourse(courseResourceableId);
AssessableCourseNode testNode = (AssessableCourseNode) course.getRunStructure().getNode(nodeIdent);
ModuleConfiguration modConfig = testNode.getModuleConfiguration();
String resourcePathInfo = courseResourceableId + File.separator + nodeIdent;
AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(assessedIdentity, "", modConfig, false, courseResourceableId, nodeIdent, resourcePathInfo, null);
// close the test
ai.stop();
// persist the results
iqm.persistResults(ai);
// reporting
Document docResReporting = iqm.getResultsReporting(ai, assessedIdentity, I18nModule.getDefaultLocale());
FilePersister.createResultsReporting(docResReporting, assessedIdentity, ai.getFormattedType(), ai.getAssessID());
// olat results
AssessmentContext ac = ai.getAssessmentContext();
Float score = Float.valueOf(ac.getScore());
Boolean passed = Boolean.valueOf(ac.isPassed());
ScoreEvaluation sceval = new ScoreEvaluation(score, passed, Boolean.FALSE, new Long(ai.getAssessID()));
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
testNode.updateUserScoreEvaluation(sceval, userCourseEnv, assessedIdentity, true, Role.coach);
// cleanup
ai.cleanUp();
List<QTIResultSet> resultSets = qrm.getResultSets(courseResourceableId, nodeIdent, repositoryEntry.getKey(), assessedIdentity);
tableModel.setObjects(resultSets);
tableCtr.modelChanged();
}
Aggregations