Search in sources :

Example 1 with AssessmentNodeData

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;
}
Also used : ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Example 2 with AssessmentNodeData

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);
        }
    }
}
Also used : AssessmentNodesLastModified(org.olat.course.assessment.model.AssessmentNodesLastModified) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) CertificateTemplate(org.olat.course.certificate.CertificateTemplate) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) BigDecimal(java.math.BigDecimal) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) CourseNode(org.olat.course.nodes.CourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode)

Example 3 with AssessmentNodeData

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;
}
Also used : ArrayList(java.util.ArrayList) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Example 4 with AssessmentNodeData

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);
    }
}
Also used : AssessmentNodesLastModified(org.olat.course.assessment.model.AssessmentNodesLastModified) Identity(org.olat.core.id.Identity) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData) CourseConfig(org.olat.course.config.CourseConfig)

Example 5 with AssessmentNodeData

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();
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessGroup(org.olat.group.BusinessGroup) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Aggregations

AssessmentNodeData (org.olat.course.assessment.model.AssessmentNodeData)22 CourseNode (org.olat.course.nodes.CourseNode)14 ArrayList (java.util.ArrayList)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)6 TACourseNode (org.olat.course.nodes.TACourseNode)6 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 ICourse (org.olat.course.ICourse)4 AssessmentNodesLastModified (org.olat.course.assessment.model.AssessmentNodesLastModified)4 ScoreAccounting (org.olat.course.run.scoring.ScoreAccounting)4 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Map (java.util.Map)2 CustomRenderColumnDescriptor (org.olat.core.gui.components.table.CustomRenderColumnDescriptor)2 DefaultColumnDescriptor (org.olat.core.gui.components.table.DefaultColumnDescriptor)2 TableController (org.olat.core.gui.components.table.TableController)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableGuiConfiguration (org.olat.core.gui.components.table.TableGuiConfiguration)2 Identity (org.olat.core.id.Identity)2 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)2 IndentedNodeRenderer (org.olat.course.assessment.IndentedNodeRenderer)2