use of org.olat.course.nodes.AssessableCourseNode 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);
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class DropboxController method getConfirmation.
private String getConfirmation(UserRequest ureq, String filename) {
// grab confirmation-text from bb-config
String confirmation = config.getStringValue(TACourseNode.CONF_DROPBOX_CONFIRMATION);
Context c = new VelocityContext();
Identity identity = ureq.getIdentity();
c.put("login", identity.getName());
c.put("first", identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()));
c.put("last", identity.getUser().getProperty(UserConstants.LASTNAME, getLocale()));
c.put("email", UserManager.getInstance().getUserDisplayEmail(identity, getLocale()));
c.put("filename", filename);
Date now = new Date();
Formatter f = Formatter.getInstance(ureq.getLocale());
c.put("date", f.formatDate(now));
c.put("time", f.formatTime(now));
// update attempts counter for this user: one file - one attempts
AssessableCourseNode acn = (AssessableCourseNode) node;
acn.incrementUserAttempts(userCourseEnv, Role.user);
// log entry for this file
UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(node, identity, identity, "FILE UPLOADED: " + filename);
return VelocityHelper.getInstance().evaluateVTL(confirmation, c);
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class AssessmentNotificationsHandler method createSubscriptionInfo.
/**
* @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
* java.util.Locale, java.util.Date)
*/
public SubscriptionInfo createSubscriptionInfo(final Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
if (!NotificationsUpgradeHelper.checkCourse(p)) {
// course don't exist anymore
notificationsManager.deactivate(p);
return notificationsManager.getNoSubscriptionInfo();
}
try {
Date latestNews = p.getLatestNewsDate();
Identity identity = subscriber.getIdentity();
// can't be loaded when already deleted
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
Long courseId = new Long(p.getData());
final ICourse course = loadCourseFromId(courseId);
if (courseStatus(course)) {
// course admins or users with the course right to have full access to
// the assessment tool will have full access to user tests
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
final boolean hasFullAccess = (cgm.isIdentityCourseAdministrator(identity) ? true : cgm.hasRight(identity, CourseRights.RIGHT_ASSESSMENT));
final Set<Identity> coachedUsers = new HashSet<Identity>();
if (!hasFullAccess) {
// initialize list of users, only when user has not full access
List<BusinessGroup> coachedGroups = cgm.getOwnedBusinessGroups(identity);
List<Identity> coachedIdentites = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
coachedUsers.addAll(coachedIdentites);
}
List<AssessableCourseNode> testNodes = getCourseTestNodes(course);
Translator translator = Util.createPackageTranslator(AssessmentManager.class, locale);
for (AssessableCourseNode test : testNodes) {
List<AssessmentEntry> assessments = courseNodeAssessmentDao.loadAssessmentEntryBySubIdent(cgm.getCourseEntry(), test.getIdent());
for (AssessmentEntry assessment : assessments) {
Date modDate = assessment.getLastModified();
Identity assessedIdentity = assessment.getIdentity();
if (modDate.after(compareDate) && (hasFullAccess || coachedUsers.contains(assessedIdentity))) {
BigDecimal score = assessment.getScore();
if (test instanceof ScormCourseNode) {
ScormCourseNode scormTest = (ScormCourseNode) test;
// check if completed or passed
String status = ScormAssessmentManager.getInstance().getLastLessonStatus(assessedIdentity.getName(), course.getCourseEnvironment(), scormTest);
if (!"passed".equals(status) && !"completed".equals(status)) {
continue;
}
}
String desc;
String type = translator.translate("notifications.entry." + test.getType());
if (score == null) {
desc = translator.translate("notifications.entry.attempt", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), type });
} else {
String scoreStr = AssessmentHelper.getRoundedScore(score);
desc = translator.translate("notifications.entry", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), scoreStr, type });
}
String urlToSend = null;
String businessPath = null;
if (p.getBusinessPath() != null) {
businessPath = p.getBusinessPath() + "[Users:0][Node:" + test.getIdent() + "][Identity:" + assessedIdentity.getKey() + "]";
urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
}
SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, CSS_CLASS_USER_ICON);
if (si == null) {
String title = translator.translate("notifications.header", new String[] { course.getCourseTitle() });
String css = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(test.getType()).getIconCSSClass();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, css), null);
}
si.addSubscriptionListItem(subListItem);
}
}
}
}
}
if (si == null) {
si = notificationsManager.getNoSubscriptionInfo();
}
return si;
} catch (Exception e) {
log.error("Error while creating assessment notifications", e);
checkPublisher(p);
return notificationsManager.getNoSubscriptionInfo();
}
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class BulkAssessmentTask method doProcess.
private void doProcess(List<BulkAssessmentFeedback> feedbacks) {
final DB dbInstance = DBFactory.getInstance();
final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
final Identity coachIdentity = securityManager.loadIdentityByKey(coachedIdentity);
final ICourse course = CourseFactory.loadCourse(courseRes);
final AssessableCourseNode courseNode = getCourseNode();
final Roles studentRoles = new Roles(false, false, false, false, false, false, false, false);
final boolean hasUserComment = courseNode.hasCommentConfigured();
final boolean hasScore = courseNode.hasScoreConfigured();
final boolean hasPassed = courseNode.hasPassedConfigured();
final boolean hasReturnFiles = (StringHelper.containsNonWhitespace(datas.getReturnFiles()) && (courseNode instanceof TACourseNode || courseNode instanceof GTACourseNode));
if (hasReturnFiles) {
try {
OlatRootFileImpl returnFilesZipped = new OlatRootFileImpl(datas.getReturnFiles(), null);
String tmp = FolderConfig.getCanonicalTmpDir();
unzipped = new File(tmp, UUID.randomUUID().toString() + File.separatorChar);
unzipped.mkdirs();
ZipUtil.unzip(returnFilesZipped.getBasefile(), unzipped);
} catch (Exception e) {
log.error("Cannot unzip the return files during bulk assessment", e);
}
}
Float min = null;
Float max = null;
Float cut = null;
if (hasScore) {
min = courseNode.getMinScoreConfiguration();
max = courseNode.getMaxScoreConfiguration();
}
if (hasPassed) {
cut = courseNode.getCutValueConfiguration();
}
int count = 0;
List<BulkAssessmentRow> rows = datas.getRows();
for (BulkAssessmentRow row : rows) {
Long identityKey = row.getIdentityKey();
if (identityKey == null) {
feedbacks.add(new BulkAssessmentFeedback("bulk.action.no.such.user", row.getAssessedId()));
// nothing to do
continue;
}
Identity identity = securityManager.loadIdentityByKey(identityKey);
IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// update comment, empty string will reset comment
String userComment = row.getComment();
if (hasUserComment && userComment != null) {
// Update userComment in db
courseNode.updateUserUserComment(userComment, uce, coachIdentity);
// LD: why do we have to update the efficiency statement?
// EfficiencyStatementManager esm = EfficiencyStatementManager.getInstance();
// esm.updateUserEfficiencyStatement(uce);
}
// update score
Float score = row.getScore();
if (hasScore && score != null) {
// score < minimum score
if ((min != null && score.floatValue() < min.floatValue()) || (score.floatValue() < AssessmentHelper.MIN_SCORE_SUPPORTED)) {
// "bulk.action.lessThanMin";
} else // score > maximum score
if ((max != null && score.floatValue() > max.floatValue()) || (score.floatValue() > AssessmentHelper.MAX_SCORE_SUPPORTED)) {
// "bulk.action.greaterThanMax";
} else {
// score between minimum and maximum score
ScoreEvaluation se;
if (hasPassed && cut != null) {
Boolean passed = (score.floatValue() >= cut.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
se = new ScoreEvaluation(score, passed);
} else {
se = new ScoreEvaluation(score, null);
}
// Update score,passed properties in db, and the user's efficiency statement
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, false, Role.auto);
}
}
Boolean passed = row.getPassed();
if (hasPassed && passed != null && cut == null) {
// Configuration of manual assessment --> Display passed/not passed: yes, Type of display: Manual by tutor
ScoreEvaluation seOld = courseNode.getUserScoreEvaluation(uce);
Float oldScore = seOld.getScore();
ScoreEvaluation se = new ScoreEvaluation(oldScore, passed);
// Update score,passed properties in db, and the user's efficiency statement
boolean incrementAttempts = false;
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, incrementAttempts, Role.auto);
}
boolean identityHasReturnFile = false;
if (hasReturnFiles && row.getReturnFiles() != null && row.getReturnFiles().size() > 0) {
String assessedId = row.getAssessedId();
File assessedFolder = new File(unzipped, assessedId);
identityHasReturnFile = assessedFolder.exists();
if (identityHasReturnFile) {
processReturnFile(courseNode, row, uce, assessedFolder);
}
}
if (courseNode instanceof GTACourseNode) {
// push the state further
GTACourseNode gtaNode = (GTACourseNode) courseNode;
if ((hasScore && score != null) || (hasPassed && passed != null)) {
// pushed to graded
updateTasksState(gtaNode, uce, TaskProcess.grading);
} else if (hasReturnFiles) {
// push to revised
updateTasksState(gtaNode, uce, TaskProcess.correction);
}
}
if (count++ % 5 == 0) {
dbInstance.commitAndCloseSession();
} else {
dbInstance.commit();
}
}
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method updateLastModifications.
@Override
public void updateLastModifications(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv, Role by) {
AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
if (by == Role.coach) {
nodeAssessment.setLastCoachModified(new Date());
} else if (by == Role.user) {
nodeAssessment.setLastUserModified(new Date());
}
assessmentService.updateAssessmentEntry(nodeAssessment);
DBFactory.getInstance().commit();
userCourseEnv.getScoreAccounting().evaluateAll(true);
if (courseNode instanceof AssessableCourseNode) {
// Update users efficiency statement
efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
}
}
Aggregations