use of org.olat.course.assessment.model.AssessmentNodeData in project OpenOLAT by OpenOLAT.
the class GenericArchiveController method addNodesAndParentsToList.
/**
* Recursive method that adds nodes and all its parents to a list
*
* @param recursionLevel
* @param courseNode
* @return A list of maps containing the node data
*/
private List<AssessmentNodeData> addNodesAndParentsToList(int recursionLevel, CourseNode courseNode) {
// 1) Get list of children data using recursion of this method
List<AssessmentNodeData> childrenData = new ArrayList<>();
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
List<AssessmentNodeData> childData = addNodesAndParentsToList((recursionLevel + 1), child);
if (childData != null) {
childrenData.addAll(childData);
}
}
boolean matchType = matchTypes(courseNode);
if (childrenData.size() > 0 || matchType) {
// Store node data in map. This map array serves as data model for
// the tasks overview table. Leave user data empty since not used in
// this table. (use only node data)
AssessmentNodeData nodeData = new AssessmentNodeData(recursionLevel, courseNode);
nodeData.setSelectable(matchType);
List<AssessmentNodeData> nodeAndChildren = new ArrayList<>();
nodeAndChildren.add(nodeData);
nodeAndChildren.addAll(childrenData);
return nodeAndChildren;
}
return null;
}
use of org.olat.course.assessment.model.AssessmentNodeData in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method saveScoreEvaluation.
@Override
public void saveScoreEvaluation(AssessableCourseNode courseNode, Identity identity, Identity assessedIdentity, ScoreEvaluation scoreEvaluation, UserCourseEnvironment userCourseEnv, boolean incrementUserAttempts, Role by) {
final ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
final CourseEnvironment courseEnv = userCourseEnv.getCourseEnvironment();
Float score = scoreEvaluation.getScore();
Boolean passed = scoreEvaluation.getPassed();
Long assessmentId = scoreEvaluation.getAssessmentID();
String subIdent = courseNode.getIdent();
RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
AssessmentEntry assessmentEntry = getOrCreate(assessedIdentity, subIdent, referenceEntry);
if (referenceEntry != null && !referenceEntry.equals(assessmentEntry.getReferenceEntry())) {
assessmentEntry.setReferenceEntry(referenceEntry);
}
if (by == Role.coach) {
assessmentEntry.setLastCoachModified(new Date());
} else if (by == Role.user) {
assessmentEntry.setLastUserModified(new Date());
}
if (score == null) {
assessmentEntry.setScore(null);
} else {
assessmentEntry.setScore(new BigDecimal(Float.toString(score)));
}
assessmentEntry.setPassed(passed);
assessmentEntry.setFullyAssessed(scoreEvaluation.getFullyAssessed());
if (assessmentId != null) {
assessmentEntry.setAssessmentId(assessmentId);
}
if (scoreEvaluation.getAssessmentStatus() != null) {
assessmentEntry.setAssessmentStatus(scoreEvaluation.getAssessmentStatus());
}
if (scoreEvaluation.getUserVisible() != null) {
assessmentEntry.setUserVisibility(scoreEvaluation.getUserVisible());
}
if (scoreEvaluation.getCurrentRunCompletion() != null) {
assessmentEntry.setCurrentRunCompletion(scoreEvaluation.getCurrentRunCompletion());
}
if (scoreEvaluation.getCurrentRunStatus() != null) {
assessmentEntry.setCurrentRunStatus(scoreEvaluation.getCurrentRunStatus());
}
Integer attempts = null;
if (incrementUserAttempts) {
attempts = assessmentEntry.getAttempts() == null ? 1 : assessmentEntry.getAttempts().intValue() + 1;
assessmentEntry.setAttempts(attempts);
}
assessmentEntry = assessmentService.updateAssessmentEntry(assessmentEntry);
// commit before sending events
DBFactory.getInstance().commit();
// reevalute the tree
ScoreAccounting scoreAccounting = userCourseEnv.getScoreAccounting();
scoreAccounting.evaluateAll(true);
// commit before sending events
DBFactory.getInstance().commit();
// node log
UserNodeAuditManager am = courseEnv.getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "score set to: " + String.valueOf(scoreEvaluation.getScore()));
if (scoreEvaluation.getPassed() != null) {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "passed set to: " + scoreEvaluation.getPassed().toString());
} else {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "passed set to \"undefined\"");
}
if (scoreEvaluation.getAssessmentID() != null) {
am.appendToUserNodeLog(courseNode, assessedIdentity, assessedIdentity, "assessmentId set to: " + scoreEvaluation.getAssessmentID().toString());
}
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
if (scoreEvaluation.getScore() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore, "", String.valueOf(scoreEvaluation.getScore())));
}
if (scoreEvaluation.getPassed() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", String.valueOf(scoreEvaluation.getPassed())));
} else {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", "undefined"));
}
if (incrementUserAttempts && attempts != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
// write only when enabled for this course
if (courseEnv.getCourseConfig().isEfficencyStatementEnabled()) {
List<AssessmentNodeData> data = new ArrayList<AssessmentNodeData>(50);
AssessmentNodesLastModified lastModifications = new AssessmentNodesLastModified();
AssessmentHelper.getAssessmentNodeDataList(0, courseEnv.getRunStructure().getRootNode(), scoreAccounting, userCourseEnv, true, true, true, data, lastModifications);
efficiencyStatementManager.updateUserEfficiencyStatement(assessedIdentity, courseEnv, data, lastModifications, cgm.getCourseEntry());
}
if (course.getCourseConfig().isAutomaticCertificationEnabled()) {
CourseNode rootNode = courseEnv.getRunStructure().getRootNode();
ScoreEvaluation rootEval = scoreAccounting.evalCourseNode((AssessableCourseNode) rootNode);
if (rootEval != null && rootEval.getPassed() != null && rootEval.getPassed().booleanValue() && certificatesManager.isCertificationAllowed(assessedIdentity, cgm.getCourseEntry())) {
CertificateTemplate template = null;
Long templateId = course.getCourseConfig().getCertificateTemplate();
if (templateId != null) {
template = certificatesManager.getTemplateById(templateId);
}
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, rootEval.getScore(), rootEval.getPassed());
certificatesManager.generateCertificate(certificateInfos, cgm.getCourseEntry(), template, true);
}
}
}
use of org.olat.course.assessment.model.AssessmentNodeData in project OpenOLAT by OpenOLAT.
the class AssessmentHelper method getAssessmentNodeDataList.
/**
* Add all assessable nodes and the scoring data to a list. Each item in the list is an object array
* that has the following data:
* @param recursionLevel
* @param courseNode
* @param userCourseEnv
* @param discardEmptyNodes
* @param discardComments
* @return list of object arrays or null if empty
*/
public static List<AssessmentNodeData> getAssessmentNodeDataList(UserCourseEnvironment userCourseEnv, AssessmentNodesLastModified lastModifications, boolean followUserVisibility, boolean discardEmptyNodes, boolean discardComments) {
List<AssessmentNodeData> data = new ArrayList<AssessmentNodeData>(50);
ScoreAccounting scoreAccounting = userCourseEnv.getScoreAccounting();
scoreAccounting.evaluateAll();
getAssessmentNodeDataList(0, userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode(), scoreAccounting, userCourseEnv, followUserVisibility, discardEmptyNodes, discardComments, data, lastModifications);
return data;
}
use of org.olat.course.assessment.model.AssessmentNodeData in project openolat by klemens.
the class EfficiencyStatementManager method updateUserEfficiencyStatement.
/**
* Updates the users efficiency statement for this course
* @param userCourseEnv
* @param repoEntryKey
* @param courseOres
*/
private void updateUserEfficiencyStatement(final UserCourseEnvironment userCourseEnv, final RepositoryEntry repoEntry) {
// o_clusterOK: by ld
CourseConfig cc = userCourseEnv.getCourseEnvironment().getCourseConfig();
// write only when enabled for this course
if (cc.isEfficencyStatementEnabled()) {
Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
AssessmentNodesLastModified lastModifications = new AssessmentNodesLastModified();
List<AssessmentNodeData> assessmentNodeList = AssessmentHelper.getAssessmentNodeDataList(userCourseEnv, lastModifications, true, true, true);
updateUserEfficiencyStatement(identity, userCourseEnv.getCourseEnvironment(), assessmentNodeList, lastModifications, repoEntry);
}
}
use of org.olat.course.assessment.model.AssessmentNodeData in project openolat by klemens.
the class GenericArchiveController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == nodeListCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(CMD_SELECT_NODE)) {
AssessmentNodeData nodeData = nodeTableModel.getObject(te.getRowId());
doSelectNode(ureq, nodeData);
}
}
} else if (source == chooseGroupCtrl) {
cmc.deactivate();
CourseNode courseNode = chooseGroupCtrl.getCourseNode();
BusinessGroup group = chooseGroupCtrl.getSelectedGroup();
cleanUpPopups();
if (Event.DONE_EVENT == event) {
archiveNode(ureq, courseNode, group);
}
} else if (source == cmc) {
cleanUpPopups();
}
}
Aggregations