String wfCommand = event.getCommand();
logAudit(ureq);
// process workflow
if (qticomp == null || qticomp.getAssessmentInstance() == null) { throw new RuntimeException("AssessmentInstance not valid."); }
AssessmentInstance ai = qticomp.getAssessmentInstance();
Navigator navig = ai.getNavigator();
if (wfCommand.equals("sitse")) { // submitItemorSection
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("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);
}
} 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);
}
} else if (wfCommand.equals(QTIConstants.QTI_WF_SUBMIT)) { // submit
// Assessment
navig.submitAssessment();
// Persist data in all cases: test, selftest, surveys except previews
// In case of survey, data will be anonymized when reading from the
// table (using the archiver)
if (!qtistatus.isPreview()) {
iqm.persistResults(ai, callingResId, callingResDetail, ureq);
getWindowControl().setInfo(translator.translate("status.results.saved"));
} else {
getWindowControl().setInfo(translator.translate("status.results.notsaved"));
}
if (!qtistatus.isSurvey()) { // for test and self-assessment, generate
// detailed results
Document docResReporting = iqm.getResultsReporting(ai, ureq);
if (!iqsec.isPreview()) {
FilePersister.createResultsReporting(docResReporting, ureq.getIdentity(), ai.getFormattedType(), ai.getAssessID());
// Send score and passed to parent controller. Maybe it is necessary
// to save some data there
// Do this now and not later, maybe user will never click on
// 'close'...
AssessmentContext ac = ai.getAssessmentContext();
fireEvent(ureq, new IQSubmittedEvent(ac.getScore(), ac.isPassed(), ai.getAssessID()));
}
Boolean showResultsOnFinishObj = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_FINISH);
boolean showResultsOnFinish = showResultsOnFinishObj==null || showResultsOnFinishObj!=null && showResultsOnFinishObj.booleanValue();
if (ai.getSummaryType() == AssessmentInstance.SUMMARY_NONE || !showResultsOnFinish) {
// do not display results reporting
myContent.contextPut("displayreporting", Boolean.FALSE);
} else { // display results reporting
String resReporting = iqm.transformResultsReporting(docResReporting, ureq.getLocale(), ai.getSummaryType() );
myContent.contextPut("resreporting", resReporting);
myContent.contextPut("displayreporting", Boolean.TRUE);
}
myContent.setPage(VELOCITY_ROOT + "/result.html");
} else {
// Send also finished event in case of survey
fireEvent(ureq, new IQSubmittedEvent());
}
} 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;