Search in sources :

Example 11 with HighScoreRunController

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

the class LTIRunController method doRun.

/**
 * Helper to initialize the LTI run view after user has accepted data exchange.
 * @param ureq
 */
private void doRun(UserRequest ureq) {
    if (display == LTIDisplayOptions.window) {
        // Use other container for popup opening. Rest of code is the same
        run = createVelocityContainer("runPopup");
    } else if (display == LTIDisplayOptions.fullscreen) {
        run = createVelocityContainer("run");
        back = LinkFactory.createLinkBack(run, this);
        run.put("back", back);
    } else {
        run = createVelocityContainer("run");
    }
    // push title and learning objectives, only visible on intro page
    run.contextPut("menuTitle", courseNode.getShortTitle());
    run.contextPut("displayTitle", courseNode.getLongTitle());
    startPage = createVelocityContainer("overview");
    startPage.contextPut("menuTitle", courseNode.getShortTitle());
    startPage.contextPut("displayTitle", courseNode.getLongTitle());
    if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startButton = LinkFactory.createButton("start", startPage, this);
    startButton.setPrimary(true);
    Boolean assessable = config.getBooleanEntry(BasicLTICourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    if (assessable != null && assessable.booleanValue()) {
        startPage.contextPut("isassessable", assessable);
        Integer attempts = courseNode.getUserAttempts(userCourseEnv);
        startPage.contextPut("attempts", attempts);
        ScoreEvaluation eval = courseNode.getUserScoreEvaluation(userCourseEnv);
        Float cutValue = config.getFloatEntry(BasicLTICourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
        if (cutValue != null) {
            startPage.contextPut("hasPassedValue", Boolean.TRUE);
            startPage.contextPut("passed", eval.getPassed());
        }
        startPage.contextPut("score", eval.getScore());
        startPage.contextPut("hasScore", Boolean.TRUE);
        boolean resultsVisible = eval.getUserVisible() == null || eval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        mainPanel.setContent(startPage);
    }
    // only run when user as already accepted to data exchange or no data
    // has to be exchanged or when it is configured to not show the accept
    // dialog,
    createExchangeDataProperties();
    String dataExchangeHash = createHashFromExchangeDataProperties();
    Boolean skipAcceptLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE);
    if (dataExchangeHash == null || checkHasDataExchangeAccepted(dataExchangeHash) || (skipAcceptLaunchPage != null && skipAcceptLaunchPage.booleanValue())) {
        Boolean skipLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE);
        if (skipLaunchPage != null && skipLaunchPage.booleanValue()) {
            // start the content immediately
            openBasicLTIContent(ureq);
        } else {
            // or show the start button
            mainPanel.setContent(startPage);
        }
    } else {
        doAskDataExchange();
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Component(org.olat.core.gui.components.Component)

Example 12 with HighScoreRunController

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

the class PortfolioCourseNodeRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    infosContainer = FormLayoutContainer.createDefaultFormLayout("infos", getTranslator());
    formLayout.add(infosContainer);
    String assessmentPage = velocity_root + "/assessment_infos.html";
    assessmentInfosContainer = FormLayoutContainer.createCustomFormLayout("assessmentInfos", getTranslator(), assessmentPage);
    assessmentInfosContainer.setVisible(false);
    formLayout.add(assessmentInfosContainer);
    VelocityContainer mainVC = ((FormLayoutContainer) formLayout).getFormItemComponent();
    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();
            mainVC.put("highScore", highScoreComponent);
        }
    }
    Object text = config.get(PortfolioCourseNodeConfiguration.NODE_TEXT);
    String explanation = (text instanceof String) ? (String) text : "";
    if (StringHelper.containsNonWhitespace(explanation)) {
        uifactory.addStaticTextElement("explanation.text", explanation, infosContainer);
    }
    String deadlineconfig = (String) config.get(PortfolioCourseNodeConfiguration.DEADLINE_TYPE);
    if (!DeadlineType.none.name().equals(deadlineconfig) && deadlineconfig != null) {
        // show deadline-config
        String deadLineLabel = "map.deadline." + deadlineconfig + ".label";
        String deadLineInfo = "";
        if (deadlineconfig.equals(DeadlineType.absolut.name())) {
            Formatter f = Formatter.getInstance(getLocale());
            deadLineInfo = f.formatDate((Date) config.get(PortfolioCourseNodeConfiguration.DEADLINE_DATE));
        } else {
            deadLineInfo = getDeadlineRelativeInfo();
        }
        deadlineDateText = uifactory.addStaticTextElement("deadline", deadLineLabel, deadLineInfo, infosContainer);
    }
    if (templateMap != null || templateBinder != null) {
        updateUI(ureq);
    }
}
Also used : Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) Component(org.olat.core.gui.components.Component) Date(java.util.Date) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

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