use of org.olat.course.run.userview.UserCourseEnvironment 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.userview.UserCourseEnvironment 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.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method getAssessmentStatus.
@Override
public AssessmentEntryStatus getAssessmentStatus(Identity assessedIdentity, BinderRef binderRef) {
Binder binder = binderDao.loadByKey(binderRef.getKey());
RepositoryEntry entry = binder.getEntry();
AssessmentEntryStatus status = null;
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);
status = eval.getAssessmentStatus();
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
status = assessmentEntry.getAssessmentStatus();
}
return status;
}
use of org.olat.course.run.userview.UserCourseEnvironment 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.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updateAssessmentEntryLastModification.
private void updateAssessmentEntryLastModification(Binder binder, Identity doer, Role by) {
if (binder.getEntry() == null)
return;
RepositoryEntry entry = binder.getEntry();
List<Identity> assessedIdentities = getMembers(binder, PortfolioRoles.owner.name());
// order status from the entry / section
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;
for (Identity assessedIdentity : assessedIdentities) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateLastModifications(userCourseEnv, doer, by);
}
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
if (by == Role.coach) {
assessmentEntry.setLastCoachModified(new Date());
} else if (by == Role.user) {
assessmentEntry.setLastUserModified(new Date());
}
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
}
Aggregations