use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConfirmReopenController method formOK.
@Override
protected void formOK(UserRequest ureq) {
testSession = qtiService.reopenAssessmentTestSession(testSession, getIdentity());
if (testSession == null) {
showWarning("");
} else {
UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(testSession.getIdentity(), courseEnv);
ScoreEvaluation scoreEval = courseNode.getUserScoreEvaluation(assessedUserCourseEnv);
ScoreEvaluation reopenedScoreEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), AssessmentEntryStatus.inProgress, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), AssessmentRunStatus.running, testSession.getKey());
courseNode.updateUserScoreEvaluation(reopenedScoreEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
ThreadLocalUserActivityLogger.log(QTI21LoggingAction.QTI_REOPEN_IN_COURSE, getClass());
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class PassedRuleSPI method filter.
@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String nodeIdent = r.getLeftOperand();
String status = r.getRightOperand();
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if (courseNode == null) {
identities.clear();
log.error("Passed rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
return;
}
Map<Long, Boolean> passeds;
if (courseNode instanceof STCourseNode) {
passeds = new HashMap<>();
STCourseNode structureNode = (STCourseNode) courseNode;
if (structureNode.hasPassedConfigured()) {
for (Identity identity : identities) {
UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
Boolean passed = scoreEval.getPassed();
if (passed != null) {
passeds.put(identity.getKey(), passed);
}
}
}
} else {
passeds = helperDao.getPassed(entry, courseNode, identities);
}
if ("passed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed == null || !passed.booleanValue()) {
identityIt.remove();
}
}
} else if ("failed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed != null && passed.booleanValue()) {
identityIt.remove();
}
}
}
}
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class QTI21ResetDataController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (courseNode instanceof IQTESTCourseNode) {
IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
RepositoryEntry testEntry = courseNode.getReferencedRepositoryEntry();
RepositoryEntry courseEntry = courseEnv.getCourseGroupManager().getCourseEntry();
ICourse course = CourseFactory.loadCourse(courseEntry);
archiveData(course, options);
qtiService.deleteAssessmentTestSession(identities, testEntry, courseEntry, courseNode.getIdent());
for (Identity identity : identities) {
ScoreEvaluation scoreEval = new ScoreEvaluation(null, null, AssessmentEntryStatus.notStarted, null, Boolean.FALSE, 0.0d, AssessmentRunStatus.notStarted, null);
IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
testCourseNode.updateUserScoreEvaluation(scoreEval, uce, getIdentity(), false, Role.coach);
testCourseNode.updateCurrentCompletion(uce, getIdentity(), null, AssessmentRunStatus.notStarted, Role.coach);
}
} else if (assessedEntry != null) {
archiveData(assessedEntry);
qtiService.deleteAssessmentTestSession(identities, assessedEntry, null, null);
}
fireEvent(ureq, Event.CHANGED_EVENT);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class IdentityListCourseNodeController method doSetDone.
private void doSetDone(UserRequest ureq) {
Set<Integer> selections = tableEl.getMultiSelectedIndex();
List<AssessedIdentityElementRow> rows = new ArrayList<>(selections.size());
for (Integer i : selections) {
AssessedIdentityElementRow row = usersTableModel.getObject(i.intValue());
if (row != null && row.getAssessmentStatus() != AssessmentEntryStatus.done) {
rows.add(row);
}
}
if (rows == null || rows.isEmpty()) {
showWarning("warning.bulk.done");
} else if (courseNode instanceof AssessableCourseNode) {
ICourse course = CourseFactory.loadCourse(courseEntry);
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
for (AssessedIdentityElementRow row : rows) {
Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentityKey());
Roles roles = securityManager.getRoles(assessedIdentity);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment(), coachCourseEnv.isCourseReadOnly());
assessedUserCourseEnv.getScoreAccounting().evaluateAll();
ScoreEvaluation scoreEval = assessableCourseNode.getUserScoreEvaluation(assessedUserCourseEnv);
ScoreEvaluation doneEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), AssessmentEntryStatus.done, null, scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
assessableCourseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
}
loadModel(ureq);
}
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class IdentityCertificatesController method doGenerateCertificate.
private void doGenerateCertificate(UserRequest ureq) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
Roles roles = securityManager.getRoles(assessedIdentity);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
ScoreAccounting scoreAccounting = assessedUserCourseEnv.getScoreAccounting();
scoreAccounting.evaluateAll();
ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode((AssessableCourseNode) rootNode);
CertificateTemplate template = null;
Long templateKey = course.getCourseConfig().getCertificateTemplate();
if (templateKey != null) {
template = certificatesManager.getTemplateById(templateKey);
}
Float score = scoreEval == null ? null : scoreEval.getScore();
Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
loadList();
showInfo("msg.certificate.pending");
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations