Search in sources :

Example 16 with AssessmentNodeData

use of org.olat.course.assessment.model.AssessmentNodeData in project OpenOLAT by OpenOLAT.

the class GenericArchiveController method doNodeChoose.

/**
 * @param ureq
 */
private void doNodeChoose(UserRequest ureq, VelocityContainer nodeChoose) {
    // table configuraton
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("nodesoverview.nonodes"));
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    tableConfig.setDisplayTableHeader(true);
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    removeAsListenerAndDispose(nodeListCtr);
    nodeListCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(nodeListCtr);
    // table columns
    nodeListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.node", 0, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new IndentedNodeRenderer()));
    nodeListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.action.select", 1, CMD_SELECT_NODE, getLocale()));
    // get list of course node data and populate table data model
    ICourse course = CourseFactory.loadCourse(ores);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List<AssessmentNodeData> nodesTableObjectArrayList = addNodesAndParentsToList(0, rootNode);
    // only populate data model if data available
    if (nodesTableObjectArrayList == null) {
        nodeChoose.contextPut("hasNodes", Boolean.FALSE);
    } else {
        nodeChoose.contextPut("hasNodes", Boolean.TRUE);
        nodeTableModel = new NodeTableDataModel(nodesTableObjectArrayList, getTranslator());
        nodeListCtr.setTableDataModel(nodeTableModel);
        nodeChoose.put("nodeTable", nodeListCtr.getInitialComponent());
    }
    // set main content to nodechoose, do not use wrapper
    main.setContent(nodeChoose);
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) ICourse(org.olat.course.ICourse) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) IndentedNodeRenderer(org.olat.course.assessment.IndentedNodeRenderer) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Example 17 with AssessmentNodeData

use of org.olat.course.assessment.model.AssessmentNodeData in project OpenOLAT by OpenOLAT.

the class AssessmentHelper method getAssessmentNodeDataList.

public static int getAssessmentNodeDataList(int recursionLevel, CourseNode courseNode, ScoreAccounting scoreAccounting, UserCourseEnvironment userCourseEnv, boolean followUserVisibility, boolean discardEmptyNodes, boolean discardComments, List<AssessmentNodeData> data, AssessmentNodesLastModified lastModifications) {
    // 1) Get list of children data using recursion of this method
    AssessmentNodeData assessmentNodeData = new AssessmentNodeData(recursionLevel, courseNode);
    data.add(assessmentNodeData);
    int numOfChildren = 0;
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        numOfChildren += getAssessmentNodeDataList(recursionLevel + 1, child, scoreAccounting, userCourseEnv, followUserVisibility, discardEmptyNodes, discardComments, data, lastModifications);
    }
    // 2) Get data of this node only if
    // - it has any wrapped children  or
    // - it is of an assessable course node type
    boolean hasDisplayableValuesConfigured = false;
    boolean hasDisplayableUserValues = false;
    if (numOfChildren > 0 || courseNode instanceof AssessableCourseNode) {
        if (courseNode instanceof ProjectBrokerCourseNode) {
            // ProjectBroker : no assessment-tool in V1.0 , remove project broker completely form assessment-tool gui
            assessmentNodeData.setSelectable(false);
        } else if (courseNode instanceof AssessableCourseNode) {
            AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
            AssessmentEvaluation scoreEvaluation = scoreAccounting.evalCourseNode(assessableCourseNode);
            if (scoreEvaluation != null) {
                assessmentNodeData.setAssessmentStatus(scoreEvaluation.getAssessmentStatus());
                assessmentNodeData.setNumOfAssessmentDocs(scoreEvaluation.getNumOfAssessmentDocs());
            }
            assessmentNodeData.setUserVisibility(scoreEvaluation.getUserVisible());
            assessmentNodeData.setLastModified(scoreEvaluation.getLastModified());
            assessmentNodeData.setLastUserModified(scoreEvaluation.getLastUserModified());
            assessmentNodeData.setLastCoachModified(scoreEvaluation.getLastCoachModified());
            if (lastModifications != null) {
                lastModifications.addLastModified(scoreEvaluation.getLastModified());
                lastModifications.addLastUserModified(scoreEvaluation.getLastUserModified());
                lastModifications.addLastCoachModified(scoreEvaluation.getLastCoachModified());
            }
            if (!followUserVisibility || scoreEvaluation.getUserVisible() == null || scoreEvaluation.getUserVisible().booleanValue()) {
                // details
                if (assessableCourseNode.hasDetails()) {
                    hasDisplayableValuesConfigured = true;
                    String detailValue = assessableCourseNode.getDetailsListView(userCourseEnv);
                    if (detailValue == null) {
                        // ignore unset details in discardEmptyNodes mode
                        assessmentNodeData.setDetails(AssessmentHelper.DETAILS_NA_VALUE);
                    } else {
                        assessmentNodeData.setDetails(detailValue);
                        hasDisplayableUserValues = true;
                    }
                }
                // attempts
                if (assessableCourseNode.hasAttemptsConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Integer attemptsValue = scoreEvaluation.getAttempts();
                    if (attemptsValue != null) {
                        assessmentNodeData.setAttempts(attemptsValue);
                        if (attemptsValue.intValue() > 0) {
                            // ignore attempts = 0  in discardEmptyNodes mode
                            hasDisplayableUserValues = true;
                        }
                    }
                }
                // score
                if (assessableCourseNode.hasScoreConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Float score = scoreEvaluation.getScore();
                    if (score != null) {
                        assessmentNodeData.setRoundedScore(AssessmentHelper.getRoundedScore(score));
                        assessmentNodeData.setScore(score);
                        hasDisplayableUserValues = true;
                    }
                    if (!(assessableCourseNode instanceof STCourseNode)) {
                        assessmentNodeData.setMaxScore(assessableCourseNode.getMaxScoreConfiguration());
                        assessmentNodeData.setMinScore(assessableCourseNode.getMinScoreConfiguration());
                    }
                }
                // passed
                if (assessableCourseNode.hasPassedConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Boolean passed = scoreEvaluation.getPassed();
                    if (passed != null) {
                        assessmentNodeData.setPassed(passed);
                        hasDisplayableUserValues = true;
                    }
                }
            }
            // selection command available
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            if (acn.isEditableConfigured()) {
                // Assessable course nodes are selectable
                assessmentNodeData.setSelectable(true);
            } else {
                // assessable nodes that do not have score or passed are not selectable
                // (e.g. a st node with no defined rule
                assessmentNodeData.setSelectable(false);
            }
            if (!hasDisplayableUserValues && assessableCourseNode.hasCommentConfigured() && !discardComments) {
                // comments are invisible in the table but if configured the node must be in the list
                // for the efficiency statement this can be ignored, this is the case when discardComments is true
                hasDisplayableValuesConfigured = true;
                if (assessableCourseNode.getUserUserComment(userCourseEnv) != null) {
                    hasDisplayableUserValues = true;
                }
            }
        } else {
            // Not assessable nodes are not selectable. (e.g. a node that
            // has an assessable child node but is itself not assessable)
            assessmentNodeData.setSelectable(false);
        }
    }
    // 3) Add data of this node to mast list if node assessable or children list has any data.
    // Do only add nodes when they have any assessable element, otherwhise discard (e.g. empty course,
    // structure nodes without scoring rules)! When the discardEmptyNodes flag is set then only
    // add this node when there is user data found for this node.
    boolean addNode = (numOfChildren > 0 || (discardEmptyNodes && hasDisplayableValuesConfigured && hasDisplayableUserValues) || (!discardEmptyNodes && hasDisplayableValuesConfigured));
    if (!addNode) {
        data.remove(assessmentNodeData);
        return 0;
    }
    // add itself
    return numOfChildren + 1;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode)

Example 18 with AssessmentNodeData

use of org.olat.course.assessment.model.AssessmentNodeData in project openolat by klemens.

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 19 with AssessmentNodeData

use of org.olat.course.assessment.model.AssessmentNodeData in project openolat by klemens.

the class GenericArchiveController method doNodeChoose.

/**
 * @param ureq
 */
private void doNodeChoose(UserRequest ureq, VelocityContainer nodeChoose) {
    // table configuraton
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("nodesoverview.nonodes"));
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    tableConfig.setDisplayTableHeader(true);
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    removeAsListenerAndDispose(nodeListCtr);
    nodeListCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(nodeListCtr);
    // table columns
    nodeListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.node", 0, null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new IndentedNodeRenderer()));
    nodeListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.action.select", 1, CMD_SELECT_NODE, getLocale()));
    // get list of course node data and populate table data model
    ICourse course = CourseFactory.loadCourse(ores);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List<AssessmentNodeData> nodesTableObjectArrayList = addNodesAndParentsToList(0, rootNode);
    // only populate data model if data available
    if (nodesTableObjectArrayList == null) {
        nodeChoose.contextPut("hasNodes", Boolean.FALSE);
    } else {
        nodeChoose.contextPut("hasNodes", Boolean.TRUE);
        nodeTableModel = new NodeTableDataModel(nodesTableObjectArrayList, getTranslator());
        nodeListCtr.setTableDataModel(nodeTableModel);
        nodeChoose.put("nodeTable", nodeListCtr.getInitialComponent());
    }
    // set main content to nodechoose, do not use wrapper
    main.setContent(nodeChoose);
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) TableController(org.olat.core.gui.components.table.TableController) ICourse(org.olat.course.ICourse) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) IndentedNodeRenderer(org.olat.course.assessment.IndentedNodeRenderer) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Example 20 with AssessmentNodeData

use of org.olat.course.assessment.model.AssessmentNodeData in project openolat by klemens.

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)

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