Package org.olat.ims.qti.container

Examples of org.olat.ims.qti.container.AssessmentContext


            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) {
View Full Code Here


   * @param resDetail
   * @param ureq
   */

  public void persistResults(AssessmentInstance ai, long resId, String resDetail, UserRequest ureq) {
    AssessmentContext ac = ai.getAssessmentContext();
   
    QTIResultSet qtiResultSet = new QTIResultSet();
    qtiResultSet.setLastModified(new Date(System.currentTimeMillis()));
    qtiResultSet.setOlatResource(resId);
    qtiResultSet.setOlatResourceDetail(resDetail);
    qtiResultSet.setRepositoryRef(ai.getRepositoryEntryKey());
    qtiResultSet.setIdentity(ureq.getIdentity());
    qtiResultSet.setQtiType(ai.getType());
    qtiResultSet.setAssessmentID(ai.getAssessID());
   
    qtiResultSet.setDuration(new Long(ai.getAssessmentContext().getDuration()));
    // TODO qtiResultSet.setLastModified();
   
    if (ai.isSurvey()){
      qtiResultSet.setScore(0);
      qtiResultSet.setIsPassed(true);
    } else {
      qtiResultSet.setScore(ac.getScore());
      qtiResultSet.setIsPassed(ac.isPassed());
    }
   
    DBFactory.getInstance().saveObject(qtiResultSet);
   
    // Loop over all sections in this assessment
    int sccnt = ac.getSectionContextCount();
    for (int i = 0; i < sccnt; i++) {
      // Loop over all items in this section
      SectionContext sc = ac.getSectionContext(i);
      int iccnt = sc.getItemContextCount();
      for (int j = 0; j < iccnt; j++) {
        ItemContext ic = sc.getItemContext(j);
        // Create new result item for this item
        QTIResult qtiResult = new QTIResult();
View Full Code Here

    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();
View Full Code Here

   * @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

    // show button to navigate to the first question of the current section     
    IQMenuDisplayConf menuDisplayConfig = comp.getMenuDisplayConf();
    if (!menuDisplayConfig.isEnabledMenu() && menuDisplayConfig.isItemPageSequence()) {
      sb.append("<a onclick=\"return o2cl()\" href=\"");
      ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "git" });
      AssessmentContext ac = ai.getAssessmentContext();
      int sectionPos = ac.getCurrentSectionContextPos();
      sb.append("?itid=" + 0 + "&seid=" + sectionPos);
      String title = translator.translate("next");
      sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
      sb.append(title);
      sb.append("</a>");
View Full Code Here

  /**
   * @see org.olat.qti.process.Navigator#submitAssessment()
   */
  public void submitAssessment() {
    getAssessmentInstance().close();
    AssessmentContext ac = getAssessmentContext();
    if (ac.isFeedbackavailable()) {
      Output outp = ac.getOutput();
      getInfo().setCurrentOutput(outp);
      getInfo().setFeedback(true);
    }
    info.clear();
    info.setMessage(QTIConstants.MESSAGE_ASSESSMENT_SUBMITTED);
View Full Code Here

      else if (confSummary.equals(QMD_ENTRY_SUMMARY_COMPACT)) summaryType = SUMMARY_COMPACT;
      else if (confSummary.equals(QMD_ENTRY_SUMMARY_DETAILED)) summaryType = SUMMARY_DETAILED;
      else if (confSummary.equals(QMD_ENTRY_SUMMARY_SECTION)) summaryType = SUMMARY_SECTION;
    }
   
    assessmentContext = new AssessmentContext();
    assessmentContext.setUp(this);
    createNavigator();
  }
View Full Code Here

      getInfo().setMessage(QTIConstants.MESSAGE_SECTION_SUBMITTED);
      getInfo().setRenderItems(true);
    }

    // find next section
    AssessmentContext ac = getAssessmentContext();
    int secPos = ac.getCurrentSectionContextPos();
    int secPosMax = ac.getSectionContextCount() - 1;
    if (!ac.isOpen()) {
      getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
      getInfo().setRenderItems(false);
      submitAssessment();
    } else if (secPos == secPosMax) submitAssessment();
    else {
      while (secPos < secPosMax) { // there are still further section(s)
        secPos++;
        if (ac.getSectionContext(secPos).getItemContextCount() != 0) break;
      }

      if (secPos == secPosMax && ac.getSectionContext(secPos).getItemContextCount() == 0) {
        // reached last section but section is empty -> finish assessment
        submitAssessment();
      } else {
        ac.setCurrentSectionContextPos(secPos);
        startSection(ac.getCurrentSectionContext());       
      }
    }
    getAssessmentInstance().persist();
  }
View Full Code Here

  /**
   * @see org.olat.qti.process.Navigator#goToSection(int)
   */
  public void goToSection(int sectionPos) {   
    AssessmentContext ac = getAssessmentContext();
    ac.setCurrentSectionContextPos(sectionPos);
    getInfo().setMessage(QTIConstants.MESSAGE_SECTION_INFODEMANDED); //show the section title and description
    getInfo().setRenderItems(true); //show the items as well
  }
View Full Code Here

   * @param locale The users locale
   * @param identity
   * @return Document The XML document
   */
  public Document getResDoc(AssessmentInstance ai, Locale locale, Identity identity) {
    AssessmentContext ac = ai.getAssessmentContext();
    DocumentFactory df = DocumentFactory.getInstance();
    Document res_doc = df.createDocument();
    Element root = df.createElement("qti_result_report");
    res_doc.setRootElement(root);
    Element result = root.addElement("result");
    Element extension_result = result.addElement("extension_result");

    // add items (not qti standard, but nice to display original questions ->
    // put it into extensions)
    //extension_result.
    int sectioncnt = ac.getSectionContextCount();
    for (int i = 0; i < sectioncnt; i++) {
      SectionContext sc = ac.getSectionContext(i);
      int itemcnt = sc.getItemContextCount();
      for (int j = 0; j < itemcnt; j++) {
        ItemContext it = sc.getItemContext(j);
        Element el_item = it.getEl_item();
        extension_result.add(el_item);
      }
    }

    // add ims cp id for any media references
    addStaticsPath(extension_result, ai);

    // add assessment_result

    // Add User information
    Element context = result.addElement("context");
    User user = identity.getUser();
    String name = user.getProperty(UserConstants.LASTNAME, locale) + " " + user.getProperty(UserConstants.FIRSTNAME, locale) + " (" + identity.getName() + ")";
    String instId = user.getProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, locale);
    String instName = user.getProperty(UserConstants.INSTITUTIONALNAME, locale);

    if (instId == null) instId = "N/A";
    context.addElement("name").addText(name);

    String institution;
    if (instName == null) institution = "N/A";
    else institution = instName;
    if (institution == null) institution = "N/A";

    // Add institutional identifier (e.g. Matrikelnummer)
    Element generic_identifier = context.addElement("generic_identifier");
    generic_identifier.addElement("type_label").addText(institution);
    generic_identifier.addElement("identifier_string").addText(instId);

    // Add start and stop date formatted as datetime
    Element beginDate = context.addElement("date");
    beginDate.addElement("type_label").addText("Start");
    beginDate.addElement("datetime").addText(Formatter.formatDatetime(new Date(ac.getTimeOfStart())));
    Element stopDate = context.addElement("date");
    stopDate.addElement("type_label").addText("Stop");
    stopDate.addElement("datetime").addText(Formatter.formatDatetime(new Date(ac.getTimeOfStop())));

    Element ares = result.addElement("assessment_result");
    ares.addAttribute("ident_ref", ac.getIdent());
    if (ac.getTitle() != null) {
      ares.addAttribute("asi_title", ac.getTitle());
    }

    // process assessment score
    Element a_score = ares.addElement("outcomes").addElement("score");
    a_score.addAttribute("varname", "SCORE");
    String strVal = StringHelper.formatFloat(ac.getScore(), 2);
    a_score.addElement("score_value").addText(strVal);

    strVal = ac.getMaxScore() == -1.0f ? "N/A" : StringHelper.formatFloat(ac.getMaxScore(), 2);
    a_score.addElement("score_max").addText(strVal);

    strVal = ac.getCutvalue() == -1.0f ? "N/A" : StringHelper.formatFloat(ac.getCutvalue(), 2);
    a_score.addElement("score_cut").addText(strVal);

    addElementText(ares, "duration", QTIHelper.getISODuration(ac.getDuration()));
    addElementText(ares, "num_sections", "" + ac.getSectionContextCount());
    addElementText(ares, "num_sections_presented", "0");
    addElementText(ares, "num_items", "" + ac.getItemContextCount());
    addElementText(ares, "num_items_presented", "" + ac.getItemsPresentedCount());
    addElementText(ares, "num_items_attempted", "" + ac.getItemsAttemptedCount());

    // add section_result
    int secnt = ac.getSectionContextCount();
    for (int i = 0; i < secnt; i++) {
      SectionContext secc = ac.getSectionContext(i);
      Element secres = ares.addElement("section_result");
      secres.addAttribute("ident_ref", secc.getIdent());
      if (secc.getTitle() != null) {
        secres.addAttribute("asi_title", secc.getTitle());
      }
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.container.AssessmentContext

Copyright © 2018 www.massapicom. 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.