Search in sources :

Example 1 with HighScoreRunController

use of org.olat.course.highscore.ui.HighScoreRunController in project OpenOLAT by OpenOLAT.

the class CheckListRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean readOnly = isReadOnly();
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
            layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
            if (dueDate.compareTo(new Date()) < 0) {
                layoutCont.contextPut("afterDueDate", Boolean.TRUE);
            }
        }
        layoutCont.contextPut("withScore", new Boolean(withScore));
        if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                layoutCont.put("highScore", highScoreComponent);
            }
        }
        List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            layoutCont.add(wrapper.getCheckboxEl());
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
        if (withScore || withPassed) {
            layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
            exposeConfigToVC(ureq, layoutCont);
            exposeUserDataToVC(ureq, layoutCont);
        } else {
            layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
        }
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Date(java.util.Date) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Component(org.olat.core.gui.components.Component)

Example 2 with HighScoreRunController

use of org.olat.course.highscore.ui.HighScoreRunController in project OpenOLAT by OpenOLAT.

the class ScormRunController method doStartPage.

private void doStartPage(UserRequest ureq) {
    // push title and learning objectives, only visible on intro page
    startPage.contextPut("menuTitle", scormNode.getShortTitle());
    startPage.contextPut("displayTitle", scormNode.getLongTitle());
    // Adding learning objectives
    String learningObj = scormNode.getLearningObjectives();
    if (learningObj != null) {
        Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
        startPage.put("learningObjectives", learningObjectives);
        startPage.contextPut("hasObjectives", Boolean.TRUE);
    } else {
        startPage.contextPut("hasObjectives", Boolean.FALSE);
    }
    if (isAssessable) {
        ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
        Float score = scoreEval.getScore();
        if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
            startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
        }
        startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        startPage.contextPut("passed", scoreEval.getPassed());
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        if (resultsVisible && scormNode.hasCommentConfigured()) {
            StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
            startPage.contextPut("comment", StringHelper.xssScan(comment));
        }
        startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
        if (ureq == null) {
            // High score need one
            ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
        }
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
    main.setContent(startPage);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) SyntheticUserRequest(org.olat.core.gui.util.SyntheticUserRequest) Component(org.olat.core.gui.components.Component)

Example 3 with HighScoreRunController

use of org.olat.course.highscore.ui.HighScoreRunController in project openolat by klemens.

the class CheckListRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean readOnly = isReadOnly();
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
        if (dueDate != null) {
            layoutCont.contextPut("dueDate", dueDate);
            layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
            if (dueDate.compareTo(new Date()) < 0) {
                layoutCont.contextPut("afterDueDate", Boolean.TRUE);
            }
        }
        layoutCont.contextPut("withScore", new Boolean(withScore));
        if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                layoutCont.put("highScore", highScoreComponent);
            }
        }
        List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
        Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
        for (DBCheck check : checks) {
            uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
        }
        List<Checkbox> list = checkboxList.getList();
        List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
        for (Checkbox checkbox : list) {
            DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
            CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
            layoutCont.add(wrapper.getCheckboxEl());
            wrappers.add(wrapper);
        }
        layoutCont.contextPut("checkboxList", wrappers);
        if (withScore || withPassed) {
            layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
            exposeConfigToVC(ureq, layoutCont);
            exposeUserDataToVC(ureq, layoutCont);
        } else {
            layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
        }
    }
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Date(java.util.Date) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Component(org.olat.core.gui.components.Component)

Example 4 with HighScoreRunController

use of org.olat.course.highscore.ui.HighScoreRunController in project openolat by klemens.

the class ScormRunController method doStartPage.

private void doStartPage(UserRequest ureq) {
    // push title and learning objectives, only visible on intro page
    startPage.contextPut("menuTitle", scormNode.getShortTitle());
    startPage.contextPut("displayTitle", scormNode.getLongTitle());
    // Adding learning objectives
    String learningObj = scormNode.getLearningObjectives();
    if (learningObj != null) {
        Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
        startPage.put("learningObjectives", learningObjectives);
        startPage.contextPut("hasObjectives", Boolean.TRUE);
    } else {
        startPage.contextPut("hasObjectives", Boolean.FALSE);
    }
    if (isAssessable) {
        ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
        Float score = scoreEval.getScore();
        if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
            startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
        }
        startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        startPage.contextPut("passed", scoreEval.getPassed());
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        if (resultsVisible && scormNode.hasCommentConfigured()) {
            StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
            startPage.contextPut("comment", StringHelper.xssScan(comment));
        }
        startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
        if (ureq == null) {
            // High score need one
            ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
        }
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
    main.setContent(startPage);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) SyntheticUserRequest(org.olat.core.gui.util.SyntheticUserRequest) Component(org.olat.core.gui.components.Component)

Example 5 with HighScoreRunController

use of org.olat.course.highscore.ui.HighScoreRunController in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentRunController method initAssessment.

private void initAssessment(UserRequest ureq) {
    // config : show score info
    boolean enableScoreInfo = config.getBooleanSafe(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
    mainVC.contextPut("enableScoreInfo", Boolean.valueOf(enableScoreInfo));
    // configuration data
    int maxAttempts = deliveryOptions.getMaxAttempts();
    if (maxAttempts > 0) {
        mainVC.contextPut("attemptsConfig", Integer.valueOf(maxAttempts));
    } else {
        mainVC.contextPut("attemptsConfig", Boolean.FALSE);
    }
    // configure date period
    mainVC.contextPut("blockDate", Boolean.valueOf(blockedBasedOnDate()));
    // time limit
    Long timeLimit = getAssessmentTestMaxTimeLimit();
    if (timeLimit != null) {
        mainVC.contextPut("timeLimit", Formatter.formatHourAndSeconds(timeLimit.longValue() * 1000l));
    }
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured() || userCourseEnv.isCoach()) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                mainVC.put("highScore", highScoreComponent);
            }
        }
    }
    // user data
    if (courseNode instanceof SelfAssessableCourseNode) {
        SelfAssessableCourseNode acn = (SelfAssessableCourseNode) courseNode;
        ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv);
        Integer attempts = acn.getUserAttempts(userCourseEnv);
        if (scoreEval != null) {
            mainVC.contextPut("resultsVisible", Boolean.TRUE);
            mainVC.contextPut("hasResults", Boolean.TRUE);
            mainVC.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
            mainVC.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
            mainVC.contextPut("passed", scoreEval.getPassed());
            // at least one attempt
            mainVC.contextPut("attempts", attempts);
            mainVC.contextPut("showChangeLog", Boolean.TRUE && enableScoreInfo);
            exposeResults(ureq, true);
        } else {
            exposeResults(ureq, false);
        }
    } else if (courseNode instanceof IQTESTCourseNode) {
        IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
        AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
        if (assessmentEntry == null) {
            mainVC.contextPut("blockAfterSuccess", Boolean.FALSE);
            mainVC.contextPut("score", null);
            mainVC.contextPut("hasPassedValue", Boolean.FALSE);
            mainVC.contextPut("passed", Boolean.FALSE);
            mainVC.contextPut("comment", null);
            mainVC.contextPut("attempts", 0);
            mainVC.contextPut("showChangeLog", Boolean.FALSE);
        } else {
            Boolean passed = assessmentEntry.getPassed();
            // block if test passed (and config set to check it)
            Boolean blocked = Boolean.FALSE;
            boolean blockAfterSuccess = deliveryOptions.isBlockAfterSuccess();
            if (blockAfterSuccess && passed != null && passed.booleanValue()) {
                blocked = Boolean.TRUE;
            }
            mainVC.contextPut("blockAfterSuccess", blocked);
            boolean resultsVisible = assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
            mainVC.contextPut("resultsVisible", resultsVisible);
            mainVC.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
            mainVC.contextPut("hasPassedValue", (passed == null ? Boolean.FALSE : Boolean.TRUE));
            mainVC.contextPut("passed", passed);
            if (resultsVisible) {
                if (testCourseNode.hasCommentConfigured()) {
                    StringBuilder comment = Formatter.stripTabsAndReturns(testCourseNode.getUserUserComment(userCourseEnv));
                    if (comment != null && comment.length() > 0) {
                        mainVC.contextPut("comment", StringHelper.xssScan(comment));
                        mainVC.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
                    }
                }
                if (testCourseNode.hasIndividualAsssessmentDocuments()) {
                    List<File> docs = testCourseNode.getIndividualAssessmentDocuments(userCourseEnv);
                    String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                    mainVC.contextPut("docsMapperUri", mapperUri);
                    mainVC.contextPut("docs", docs);
                    mainVC.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
                }
            }
            Integer attempts = assessmentEntry.getAttempts();
            mainVC.contextPut("attempts", attempts == null ? new Integer(0) : attempts);
            boolean showChangelog = (!anonym && enableScoreInfo && resultsVisible && isResultVisible(config));
            mainVC.contextPut("showChangeLog", showChangelog);
            if (deliveryOptions.isDigitalSignature()) {
                AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
                if (session != null) {
                    File signature = qtiService.getAssessmentResultSignature(session);
                    if (signature != null && signature.exists()) {
                        signatureDownloadLink = LinkFactory.createLink("digital.signature.download.link", mainVC, this);
                        signatureDownloadLink.setIconLeftCSS("o_icon o_icon-fw o_icon_download");
                        signatureDownloadLink.setTarget("_blank");
                        Date issueDate = qtiService.getAssessmentResultSignatureIssueDate(session);
                        if (issueDate != null) {
                            mainVC.contextPut("signatureIssueDate", Formatter.getInstance(getLocale()).formatDateAndTime(issueDate));
                        }
                    }
                }
            }
            exposeResults(ureq, resultsVisible);
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) DocumentsMapper(org.olat.course.nodes.ms.DocumentsMapper) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) List(java.util.List) Component(org.olat.core.gui.components.Component) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) File(java.io.File) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode)

Aggregations

Component (org.olat.core.gui.components.Component)12 HighScoreRunController (org.olat.course.highscore.ui.HighScoreRunController)12 Date (java.util.Date)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)6 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)2 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 SyntheticUserRequest (org.olat.core.gui.util.SyntheticUserRequest)2 Formatter (org.olat.core.util.Formatter)2 PassedCellRenderer (org.olat.course.assessment.bulk.PassedCellRenderer)2 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)2