Examples of AssessmentInstance


Examples of org.olat.ims.qti.process.AssessmentInstance

    myContent.contextPut("qtistatus", qtistatus);

    setInitialComponent(myContent);

    // get the assessment
    AssessmentInstance ai = null;
    //
    // IQManagers synchronizes display controller creation with qti editor, please see comment in qti editor
    //
    //synchronized (QTIEditorMainController.IS_SAVING) {
    //QTIEditorMainController.IS_SAVING_RWL.readLock().lock();
    //lock is now checked in the IQManager -> see there
    //try{
      if (repositorySoftkey != null) { // instantiate from repository
        // build path information which will be used to store tempory qti file
        String resourcePathInfo = this.callingResId + File.separator + this.callingResDetail;
        ai = AssessmentFactory.createAssessmentInstance(ureq.getIdentity(), modConfig, iqsec.isPreview(),resourcePathInfo);
      } else if (resolver != null) { // instantiate from given resolver
        ai = AssessmentFactory.createAssessmentInstance(resolver, persister, modConfig);
      }
    //}finally{
      //QTIEditorMainController.IS_SAVING_RWL.readLock().unlock();
    //}   
    //}
    // check for null instance or instance with no items
    if (ai == null || ai.getAssessmentContext().getSectionContext(0).getItemContextCount() == 0) throw new AssertException(
        "Assessment Instance was null or no sections/items found.");

    if (!iqsec.isAllowed(ai)) { // security check
      getWindowControl().setError(translator.translate("status.notallowed"));
      return;
    }

    if (iqsec.attemptsLeft(ai) < 1) { // security check
      // note: important: do not check on == 0 since the nr of attempts can be
      // republished for the same test with a smaller number as the latest time.
      getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.nomoreattempts" : "status.assess.nomoreattempts"));
      return;
    }

    if (ai.isResuming()) {
      getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.resumed" : "status.assess.resumed"));
    }

    ai.setPreview(iqsec.isPreview());

    /*
     * menu render option: render only section titles or titles and questions.
     */
    Object tmp = modConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION);
    Boolean renderSectionsOnly;
    if (tmp == null) {
      // migration
      modConfig.set(IQEditController.CONFIG_KEY_RENDERMENUOPTION, Boolean.FALSE);
      renderSectionsOnly = Boolean.FALSE;
    }else {
      renderSectionsOnly = (Boolean)tmp;
    }
    boolean enabledMenu = ((Boolean)modConfig.get(IQEditController.CONFIG_KEY_ENABLEMENU)).booleanValue();
    boolean itemPageSequence = ((String)modConfig.get(IQEditController.CONFIG_KEY_SEQUENCE)).equals(AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM);
    IQMenuDisplayConf mdc = new IQMenuDisplayConf(renderSectionsOnly.booleanValue(), enabledMenu, itemPageSequence);

    qticomp = new IQComponent("qticomponent", translator, ai,mdc);
    qticomp.addListener(this);
    myContent.put("qticomp", qticomp);
    if (!ai.isResuming()) {
      Navigator navigator = ai.getNavigator();
      navigator.startAssessment();
    }

    qtistatus.update(ai);
    if (!qtistatus.isSurvey()) {
      qtiscoreprogress.setMax(ai.getAssessmentContext().getMaxScore());
      qtiscoreprogress.setActual(ai.getAssessmentContext().getScore());
    }
    qtiquestionprogress.setMax(Integer.parseInt(qtistatus.getMaxQuestions()));
    qtiquestionprogress.setActual(Integer.parseInt(qtistatus.getQuestionPos()));
    ready = true;
  }
View Full Code Here

Examples of org.olat.ims.qti.process.AssessmentInstance

    if (source == myContent || source == qticomp) { // those must be links
      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;
      } 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());
      qtiquestionprogress.setActual(ai.getAssessmentContext().getItemPosWithinAssessment());
    } else if (source == closeButton){ // close component
      qtistatus.update(null);
      // Parent controller need to pop, if they pushed previously
      fireEvent(ureq, Event.DONE_EVENT);
      return;
View Full Code Here

Examples of org.olat.ims.qti.process.AssessmentInstance

   * @return rendered form
   */
  public StringOutput buildForm(IQComponent comp, Translator translator, Renderer renderer, URLBuilder ubu) {
    StringOutput sb = new StringOutput();
    Info info = comp.getAssessmentInstance().getNavigator().getInfo();
    AssessmentInstance ai = comp.getAssessmentInstance();
    int status = info.getStatus();
    int message = info.getMessage();
    boolean renderItems = info.isRenderItems();
    AssessmentContext act = ai.getAssessmentContext();

    // first treat messages and errors
    if (info.containsMessage()) {
      switch (message) {
        case QTIConstants.MESSAGE_ITEM_SUBMITTED :         
          //item hints?
          if (info.isHint()) {
            Hint el_hint = info.getCurrentOutput().getHint();
            if (el_hint.getFeedbackstyle() == Hint.FEEDBACKSTYLE_INCREMENTAL) {
              // increase the hint level so we know which hint to display
              ItemContext itc = act.getCurrentSectionContext().getCurrentItemContext();
              int nLevel = itc.getHintLevel() + 1;
              int numofhints = el_hint.getChildCount();
              if (nLevel > numofhints) nLevel = numofhints;
              itc.setHintLevel(nLevel);
              //<!ELEMENT hint (qticomment? , hintmaterial+)>
             
              displayFeedback(sb, (GenericQTIElement)el_hint.getChildAt(nLevel-1), ai, translator.getLocale());
            } else {
              displayFeedback(sb, el_hint, ai, translator.getLocale());
            }
          }
          //item solution?
          if (info.isSolution()) {
            Solution el_solution = info.getCurrentOutput().getSolution();
            displayFeedback(sb, el_solution, ai, translator.getLocale());
          }
          // item fb?
          if (info.isFeedback()) {
            if (info.getCurrentOutput().hasItem_Responses()) {
              int fbcount = info.getCurrentOutput().getFeedbackCount();
              int i=0;
              while (i < fbcount) {
                Element el_anschosen = info.getCurrentOutput().getItemAnswerChosen(i);
                if (el_anschosen != null) {
                  sb.append("<br /><br /><i>");
                  displayFeedback(sb, new Material(el_anschosen), ai, translator.getLocale());
                  sb.append("</i>");
                }
                Element el_resp= info.getCurrentOutput().getItemFeedback(i);
                displayFeedback(sb, new ItemFeedback(el_resp), ai, translator.getLocale());
                i++;
              }
            }
          }
          if(!comp.getMenuDisplayConf().isEnabledMenu() && comp.getMenuDisplayConf().isItemPageSequence() && !info.isRenderItems()) {
            //if item was submitted and sequence is pageSequence and menu not enabled and isRenderItems returns false show section info
            SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
            displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          }
          break;

        case QTIConstants.MESSAGE_SECTION_SUBMITTED :
          //  provide section feedback if enabled and existing
          //SectionContext sc = act.getCurrentSectionContext();         
          if (info.isFeedback()) {
            Output outp = info.getCurrentOutput();
            GenericQTIElement el_feedback = outp.getEl_response();
            if (el_feedback != null) displayFeedback(sb, el_feedback, ai, translator.getLocale());
          }
          if(!comp.getMenuDisplayConf().isEnabledMenu() && !comp.getMenuDisplayConf().isItemPageSequence()) {
            SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
            displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          }
          break;

        case QTIConstants.MESSAGE_ASSESSMENT_SUBMITTED :
          //  provide assessment feedback if enabled and existing
          if (info.isFeedback()) {
            Output outp = info.getCurrentOutput();
            GenericQTIElement el_feedback = outp.getEl_response();
            if (el_feedback != null) displayFeedback(sb, el_feedback, ai, translator.getLocale());
          }
          break;

        case QTIConstants.MESSAGE_SECTION_INFODEMANDED : // for menu item navigator
          // provide some stats maybe
          SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
          displaySectionInfo(sb, sc, ai, comp, ubu, translator);
          break;

        case QTIConstants.MESSAGE_ASSESSMENT_INFODEMANDED : // at the start of the test
          displayAssessmentInfo(sb, act, ai, comp, ubu, translator);
          break;
      }
    }

    if (renderItems) {
      boolean displayForm = true;
      // First check wether we need to render a form.
      // No form is needed if the current item has a matapplet object to be displayed.
      // Matapplets will send their response back directly.
      SectionContext sct = act.getCurrentSectionContext();
      ItemContext itc = null;
      if (sct != null && !ai.isSectionPage()) {
        itc = sct.getCurrentItemContext();
        if (itc != null) {
          Item item = itc.getQtiItem();
          if (item.getQTIIdent().startsWith("QTIEDIT:FLA:")) displayForm = false;
        }
      }
     
      sb.append("<form action=\"");
      ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sitse" });
     
      sb.append("\" id=\"ofo_iq_item\" method=\"post\">");

      if (!ai.isSectionPage()) {
        if (itc != null) displayItem(sb, renderer, ubu, itc, ai);
      } else {
        if (sct != null && sct.getItemContextCount() != 0)
          displayItems(sb, renderer, ubu, sct, ai);
      }
     
      sb.append("<div class=\"b_button_group\"><input class=\"b_button\" type=\"submit\" name=\"olat_fosm\" value=\"");
      if (ai.isSectionPage())
        sb.append(StringEscapeUtils.escapeHtml(translator.translate("submitMultiAnswers")));
      else
        sb.append(StringEscapeUtils.escapeHtml(translator.translate("submitSingleAnswer")));
      sb.append("\"");
      if (!displayForm) sb.append(" style=\"display: none;\"");
View Full Code Here

Examples of org.olat.ims.qti.process.AssessmentInstance

   *
   * @return DOCUMENT ME!
   */
  private StringOutput buildMenu(IQComponent comp, Translator translator, Renderer r, URLBuilder ubu) {
    StringOutput sb = new StringOutput();
    AssessmentInstance ai = comp.getAssessmentInstance();
    AssessmentContext ac = ai.getAssessmentContext();
    boolean renderSectionTitlesOnly = comp.getMenuDisplayConf().isRenderSectionsOnly();

    sb.append("<h4>");
    sb.append(ac.getTitle());
    sb.append("</h4>");

    // append assessment navigation
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    int scnt = ac.getSectionContextCount();
    for (int i = 0; i < scnt; i++) {
      SectionContext sc = ac.getSectionContext(i);
      boolean clickable = (ai.isSectionPage() && sc.isOpen()) || (!ai.isSectionPage());
      clickable = clickable && !ai.isClosed();
      clickable = clickable && ai.isMenu();
      sb.append("<ul><li class=\"o_qti_menu_section\">");
      sb.append(addSectionLink(r, ubu, formatter, sc, i, clickable, ac.getCurrentSectionContextPos() == i));
      sb.append("</li>");
     
      if (!renderSectionTitlesOnly) {
        //not only sections, but render questions to
        int icnt = sc.getItemContextCount();
        for (int j = 0; j < icnt; j++) {
          ItemContext itc = sc.getItemContext(j);
          clickable = !ai.isSectionPage() && sc.isOpen() && itc.isOpen();
          clickable = clickable && !ai.isClosed();
          clickable = clickable && ai.isMenu();
          sb.append("<li class=\"o_qti_menu_item\">");
          sb.append(addItemLink(r, ubu, formatter, itc, i, j, clickable,
              (ac.getCurrentSectionContextPos() == i && sc.getCurrentItemContextPos() == j), !ai.isSurvey()));
          sb.append("</li>");
        }
      }
      sb.append("</ul>");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.