Search in sources :

Example 1 with IQEvent

use of org.olat.course.nodes.iq.IQEvent in project openolat by klemens.

the class IQDisplayController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (retrievedFlag) {
        fireEvent(ureq, new IQEvent(IQEvent.TEST_PULLED));
        return;
    } else if (retrievedFlag || stoppedFlag) {
        fireEvent(ureq, new IQEvent(IQEvent.TEST_STOPPED));
        return;
    }
    if (source == myContent || source == qticomp) {
        // those must be links
        String wfCommand = event.getCommand();
        // process workflow
        AssessmentInstance ai = qticomp.getAssessmentInstance();
        if (qticomp == null || ai == null) {
            throw new RuntimeException("AssessmentInstance not valid.");
        }
        Navigator navig = ai.getNavigator();
        if (wfCommand.equals("mark")) {
            ai.mark(ureq.getParameter("id"), "true".equals(ureq.getParameter("p")));
            ai.persist();
            return;
        }
        if (wfCommand.equals("memo")) {
            try {
                String memo = java.net.URLDecoder.decode(ureq.getParameter("p"), "UTF-8");
                ai.setMemo(ureq.getParameter("id"), memo);
                ai.persist();
                return;
            } catch (UnsupportedEncodingException ex) {
                log.info("Could not decode memo text " + ureq.getParameter("p"));
            }
        }
        logAudit(ureq);
        if (wfCommand.equals("sitse")) {
            // submitItemorSection
            ItemsInput iInp = iqm.getItemsInput(ureq);
            if (iInp.getItemCount() > 0) {
                navig.submitItems(iInp);
            }
            if (ai.isClosed()) {
                // do all the finishing stuff
                if (navig.getInfo().isFeedback()) {
                // render the feedback
                } else {
                    event(ureq, source, new Event(QTIConstants.QTI_WF_SUBMIT));
                    return;
                }
            }
        } else if (wfCommand.equals("sitsec")) {
            // submit
            if (ai.isClosed()) {
                // do all the finishing stuff
                if (!qtistatus.isSurvey()) {
                    // for test and self-assessment, generate detailed results
                    generateDetailsResults(ureq, ai);
                } else {
                    // Send also finished event in case of survey
                    fireEvent(ureq, new IQSubmittedEvent());
                }
                return;
            }
        } else if (wfCommand.equals("sflash")) {
            // submit flash answer
            // 
            navig.submitItems(iqm.getItemsInput(ureq));
            if (ai.isClosed()) {
                // do all the finishing stuff
                event(ureq, source, new Event(QTIConstants.QTI_WF_SUBMIT));
                return;
            }
        } else if (wfCommand.equals("git")) {
            // goToItem
            String seid = ureq.getParameter("seid");
            String itid = ureq.getParameter("itid");
            if (seid != null && seid.length() != 0 && itid != null && itid.length() != 0) {
                int sectionPos = Integer.parseInt(seid);
                int itemPos = Integer.parseInt(itid);
                navig.goToItem(sectionPos, itemPos);
                // fxdiff BAKS-7 Resume function
                OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
                WindowControl bwControl = addToHistory(ureq, sres, null, getWindowControl(), false);
                OLATResourceable ires = OresHelper.createOLATResourceableInstance("git", new Long(itemPos));
                addToHistory(ureq, ires, null, bwControl, true);
            }
        } else if (wfCommand.equals("gse")) {
            // goToSection
            String seid = ureq.getParameter("seid");
            if (seid != null && seid.length() != 0) {
                int sectionPos = Integer.parseInt(seid);
                navig.goToSection(sectionPos);
                // fxdiff BAKS-7 Resume function
                OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
                addToHistory(ureq, sres, null);
            }
        } else if (wfCommand.equals(QTIConstants.QTI_WF_SUBMIT)) {
            // submit
            // Assessment
            navig.submitAssessment();
            postSubmitAssessment(ureq, ai);
        } else if (wfCommand.equals(QTIConstants.QTI_WF_CANCEL)) {
            // cancel
            // assessment
            navig.cancelAssessment();
        } else if (wfCommand.equals(QTIConstants.QTI_WF_SUSPEND)) {
            // suspend
            // assessment
            // just close the controller
            fireEvent(ureq, Event.DONE_EVENT);
            return;
        } else if (wfCommand.equals("close")) {
            qtistatus.update(null);
            // Parent controller need to pop, if they pushed previously
            fireEvent(ureq, Event.DONE_EVENT);
            return;
        }
        qtistatus.update(ai);
        if (!qtistatus.isSurvey())
            qtiscoreprogress.setActual(ai.getAssessmentContext().getScore());
        updateQuestionProgressDisplay(ai);
    } else if (source == closeButton) {
        // close component
        qtistatus.update(null);
        // Parent controller need to pop, if they pushed previously
        fireEvent(ureq, Event.DONE_EVENT);
        return;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Navigator(org.olat.ims.qti.navigator.Navigator) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WindowControl(org.olat.core.gui.control.WindowControl) ItemsInput(org.olat.ims.qti.container.ItemsInput) IQEvent(org.olat.course.nodes.iq.IQEvent) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance) IQEvent(org.olat.course.nodes.iq.IQEvent) Event(org.olat.core.gui.control.Event) AssessmentModeNotificationEvent(org.olat.course.assessment.AssessmentModeNotificationEvent)

Example 2 with IQEvent

use of org.olat.course.nodes.iq.IQEvent in project OpenOLAT by OpenOLAT.

the class IQDisplayController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (retrievedFlag) {
        fireEvent(ureq, new IQEvent(IQEvent.TEST_PULLED));
        return;
    } else if (retrievedFlag || stoppedFlag) {
        fireEvent(ureq, new IQEvent(IQEvent.TEST_STOPPED));
        return;
    }
    if (source == myContent || source == qticomp) {
        // those must be links
        String wfCommand = event.getCommand();
        // process workflow
        AssessmentInstance ai = qticomp.getAssessmentInstance();
        if (qticomp == null || ai == null) {
            throw new RuntimeException("AssessmentInstance not valid.");
        }
        Navigator navig = ai.getNavigator();
        if (wfCommand.equals("mark")) {
            ai.mark(ureq.getParameter("id"), "true".equals(ureq.getParameter("p")));
            ai.persist();
            return;
        }
        if (wfCommand.equals("memo")) {
            try {
                String memo = java.net.URLDecoder.decode(ureq.getParameter("p"), "UTF-8");
                ai.setMemo(ureq.getParameter("id"), memo);
                ai.persist();
                return;
            } catch (UnsupportedEncodingException ex) {
                log.info("Could not decode memo text " + ureq.getParameter("p"));
            }
        }
        logAudit(ureq);
        if (wfCommand.equals("sitse")) {
            // submitItemorSection
            ItemsInput iInp = iqm.getItemsInput(ureq);
            if (iInp.getItemCount() > 0) {
                navig.submitItems(iInp);
            }
            if (ai.isClosed()) {
                // do all the finishing stuff
                if (navig.getInfo().isFeedback()) {
                // render the feedback
                } else {
                    event(ureq, source, new Event(QTIConstants.QTI_WF_SUBMIT));
                    return;
                }
            }
        } else if (wfCommand.equals("sitsec")) {
            // submit
            if (ai.isClosed()) {
                // do all the finishing stuff
                if (!qtistatus.isSurvey()) {
                    // for test and self-assessment, generate detailed results
                    generateDetailsResults(ureq, ai);
                } else {
                    // Send also finished event in case of survey
                    fireEvent(ureq, new IQSubmittedEvent());
                }
                return;
            }
        } else if (wfCommand.equals("sflash")) {
            // submit flash answer
            // 
            navig.submitItems(iqm.getItemsInput(ureq));
            if (ai.isClosed()) {
                // do all the finishing stuff
                event(ureq, source, new Event(QTIConstants.QTI_WF_SUBMIT));
                return;
            }
        } else if (wfCommand.equals("git")) {
            // goToItem
            String seid = ureq.getParameter("seid");
            String itid = ureq.getParameter("itid");
            if (seid != null && seid.length() != 0 && itid != null && itid.length() != 0) {
                int sectionPos = Integer.parseInt(seid);
                int itemPos = Integer.parseInt(itid);
                navig.goToItem(sectionPos, itemPos);
                // fxdiff BAKS-7 Resume function
                OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
                WindowControl bwControl = addToHistory(ureq, sres, null, getWindowControl(), false);
                OLATResourceable ires = OresHelper.createOLATResourceableInstance("git", new Long(itemPos));
                addToHistory(ureq, ires, null, bwControl, true);
            }
        } else if (wfCommand.equals("gse")) {
            // goToSection
            String seid = ureq.getParameter("seid");
            if (seid != null && seid.length() != 0) {
                int sectionPos = Integer.parseInt(seid);
                navig.goToSection(sectionPos);
                // fxdiff BAKS-7 Resume function
                OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
                addToHistory(ureq, sres, null);
            }
        } else if (wfCommand.equals(QTIConstants.QTI_WF_SUBMIT)) {
            // submit
            // Assessment
            navig.submitAssessment();
            postSubmitAssessment(ureq, ai);
        } else if (wfCommand.equals(QTIConstants.QTI_WF_CANCEL)) {
            // cancel
            // assessment
            navig.cancelAssessment();
        } else if (wfCommand.equals(QTIConstants.QTI_WF_SUSPEND)) {
            // suspend
            // assessment
            // just close the controller
            fireEvent(ureq, Event.DONE_EVENT);
            return;
        } else if (wfCommand.equals("close")) {
            qtistatus.update(null);
            // Parent controller need to pop, if they pushed previously
            fireEvent(ureq, Event.DONE_EVENT);
            return;
        }
        qtistatus.update(ai);
        if (!qtistatus.isSurvey())
            qtiscoreprogress.setActual(ai.getAssessmentContext().getScore());
        updateQuestionProgressDisplay(ai);
    } else if (source == closeButton) {
        // close component
        qtistatus.update(null);
        // Parent controller need to pop, if they pushed previously
        fireEvent(ureq, Event.DONE_EVENT);
        return;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Navigator(org.olat.ims.qti.navigator.Navigator) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WindowControl(org.olat.core.gui.control.WindowControl) ItemsInput(org.olat.ims.qti.container.ItemsInput) IQEvent(org.olat.course.nodes.iq.IQEvent) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance) IQEvent(org.olat.course.nodes.iq.IQEvent) Event(org.olat.core.gui.control.Event) AssessmentModeNotificationEvent(org.olat.course.assessment.AssessmentModeNotificationEvent)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Event (org.olat.core.gui.control.Event)2 WindowControl (org.olat.core.gui.control.WindowControl)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 AssessmentModeNotificationEvent (org.olat.course.assessment.AssessmentModeNotificationEvent)2 IQEvent (org.olat.course.nodes.iq.IQEvent)2 ItemsInput (org.olat.ims.qti.container.ItemsInput)2 Navigator (org.olat.ims.qti.navigator.Navigator)2 AssessmentInstance (org.olat.ims.qti.process.AssessmentInstance)2