Package org.olat.ims.qti.container

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


      maxScore = ai.getAssessmentContext().getMaxScore();
    }

    assessStart = ai.getAssessmentContext().getTimeOfStart();
    assessMaxdur = ai.getAssessmentContext().getDurationLimit();
    SectionContext sc = ai.getAssessmentContext().getCurrentSectionContext();
    if (sc != null && sc.getCurrentItemContextPos() != -1) {
      ItemContext itc = sc.getCurrentItemContext();
      itemStart = itc.getTimeOfStart();
      itemMaxdur = itc.getDurationLimit();
      itemAttemptsLeft = (itc.getMaxAttempts() == -1) ? -1 : (itc.getMaxAttempts() - itc.getTimesAnswered());
    } else {
      itemMaxdur = -1;
View Full Code Here


   
    // 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();
        qtiResult.setResultSet(qtiResultSet);
        qtiResult.setItemIdent(ic.getIdent());
        qtiResult.setDuration(new Long(ic.getTimeSpent()));
View Full Code Here

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

    // 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

    if (cnt == 0) throw new RuntimeException("program bug: not even one iteminput in the answer");
    if (cnt > 1) throw new RuntimeException("may only submit 1 item");
    ItemInput itemInput = (ItemInput) curitsinp.getItemInputIterator().next();
    String ident = itemInput.getIdent();
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getCurrentSectionContext();
    ItemContext it = sc.getCurrentItemContext();
    ItemContext ict = sc.getItemContext(ident);
    if (ict == null) throw new RuntimeException("submitted item id ("+ident+")not found in xml");
    if (ict != it) throw new RuntimeException("answering to a non-current item");
    if (!ac.isOpen()) {
      // assessment must also be open (=on time)
      return QTIConstants.ERROR_ASSESSMENT_OUTOFTIME;
    }
    if (!sc.onTime()) {
      // section of the current item must also be open (=on time)
      return QTIConstants.ERROR_SUBMITTEDSECTION_OUTOFTIME;
    }
    if (!ict.isOnTime()) {
      // current item must be on time
View Full Code Here

    // = submit a whole section at once
    if (info.getStatus() != QTIConstants.ASSESSMENT_RUNNING) throw new RuntimeException("assessment is NOT running yet or anymore");
    int cnt = curitsinp.getItemCount();
    if (cnt == 0) throw new RuntimeException("bug: not even one iteminput in the answer");
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getCurrentSectionContext();

    if (!ac.isOpen())
      return QTIConstants.ERROR_ASSESSMENT_OUTOFTIME;
    if (!sc.isOpen())
      return QTIConstants.ERROR_SUBMITTEDSECTION_OUTOFTIME;

    int sectionResult = QTIConstants.SECTION_SUBMITTED;
    for (Iterator it_inp = curitsinp.getItemInputIterator(); it_inp.hasNext();) {
      ItemInput itemInput = (ItemInput) it_inp.next();
      String ident = itemInput.getIdent();
      ItemContext ict = sc.getItemContext(ident);
      if (ict == null) throw new RuntimeException("submitted item id ("+ident+") not found in section sectioncontext "+sc.getIdent());
      int subres = ict.addItemInput(itemInput);
      ict.eval(); // to be up-to-date with the scores
      if (subres != QTIConstants.ITEM_SUBMITTED) {
        // item had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage
        // throw new RuntimeException("section "+sc.getIdent()+" was submitted, but item "+ict.getIdent()+"  could not be submitted, because it had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage");
View Full Code Here

   * Method close.
   */
  public void close() {
    closed = true;
    assessmentContext.stop();
    SectionContext sc = assessmentContext.getCurrentSectionContext();
    if (sc != null) sc.setCurrentItemContextPos(-1);
    assessmentContext.setCurrentSectionContextPos(-1);
    if (persister != null) persister.cleanUp();
  }
View Full Code Here

   * @see org.olat.qti.process.Navigator#submitItem(org.olat.qti.process.ItemsInput)
   */
  public void submitItems(ItemsInput curitsinp) {
    clearInfo();
    int st = submitMultipleItems(curitsinp);
    SectionContext sc = getAssessmentContext().getCurrentSectionContext();
    if (st != QTIConstants.SECTION_SUBMITTED) {
      // we could not submit the section (out of time is the only reason),
      // display a error msg above the next section or assessment-finished-text
      getInfo().setError(st);
      getInfo().setRenderItems(true);
    } else { // section was successfully submitted
      sc.sectionWasSubmitted(); // increase times answered of section
      sc.eval(); // calculate any section feedback
      if (sc.isFeedbackavailable()) {
        Output outp = sc.getOutput();
        getInfo().setCurrentOutput(outp);
        getInfo().setFeedback(true);
      }
      getInfo().setMessage(QTIConstants.MESSAGE_SECTION_SUBMITTED);
      getInfo().setRenderItems(true);
View Full Code Here

   * @see org.olat.qti.process.Navigator#goToSection(int)
   */
  public void goToSection(int sectionPos) {
    clearInfo();
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getSectionContext(sectionPos);
    // check if section still open
    if (!ac.isOpen()) {
      getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
      getInfo().setRenderItems(false);
    } else if (!sc.isOpen()) {
      getInfo().setError(QTIConstants.ERROR_SECTION_OUTOFTIME);
      getInfo().setRenderItems(false);
    } else {
      getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
      getInfo().setMessage(QTIConstants.MESSAGE_SECTION_INFODEMANDED); //show section info (title and description)
View Full Code Here

    // 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());
      }
      addElementText(secres, "duration", QTIHelper.getISODuration(secc.getDuration()));
      addElementText(secres, "num_items", "" + secc.getItemContextCount());
      addElementText(secres, "num_items_presented", "" + secc.getItemsPresentedCount());
      addElementText(secres, "num_items_attempted", "" + secc.getItemsAttemptedCount());

      // process section score
      Element sec_score = secres.addElement("outcomes").addElement("score");
      sec_score.addAttribute("varname", "SCORE");
      strVal = secc.getScore() == -1.0f ? "N/A" : "" + StringHelper.formatFloat(secc.getScore(), 2);
      sec_score.addElement("score_value").addText(strVal);
      strVal = secc.getMaxScore() == -1.0f ? "N/A" : "" + StringHelper.formatFloat(secc.getMaxScore(), 2);
      sec_score.addElement("score_max").addText(strVal);
      strVal = secc.getCutValue() == -1 ? "N/A" : "" + secc.getCutValue();
      sec_score.addElement("score_cut").addText(strVal);

      // iterate over all items in this section context
      List itemsc = secc.getSectionItemContexts();
      for (Iterator it_it = itemsc.iterator(); it_it.hasNext();) {
        ItemContext itemc = (ItemContext) it_it.next();
        Element itres = secres.addElement("item_result");
        itres.addAttribute("ident_ref", itemc.getIdent());
        itres.addAttribute("asi_title", itemc.getEl_item().attributeValue("title"));
View Full Code Here

TOP

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

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.