Package org.olat.ims.qti.container

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


    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;
      itemAttemptsLeft = -1;
    }
   
View Full Code Here


    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()));
        if (ai.isSurvey()) qtiResult.setScore(0);
        else qtiResult.setScore(ic.getScore());
        qtiResult.setTstamp(new Date(ic.getLatestAnswerTime()));
        qtiResult.setLastModified(new Date(System.currentTimeMillis()));
        qtiResult.setIp(ureq.getHttpReq().getRemoteAddr());
       
        // Get user answers for this item
        StringBuilder sb = new StringBuilder();
        if (ic.getItemInput() == null) {} else {
          ItemInput inp = ic.getItemInput();
          if (inp.isEmpty()) {
            sb.append("[]");
          } else {
            Map im = inp.getInputMap();
            // Create answer block
View Full Code Here

          //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=\"");
View Full Code Here

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

  private void displayItems(StringOutput sb, Renderer renderer, URLBuilder ubu, SectionContext sc, AssessmentInstance ai) {
    // display the whole current section on one page
    List items = sc.getItemContextsToRender();
    for (Iterator iter= items.iterator(); iter.hasNext();) {
      ItemContext itc  = (ItemContext) iter.next();
      if (itc.isOpen()) {
        displayItem(sb, renderer, ubu, itc, ai);
      } else {
        displayItemClosed(sb,renderer,itc);
      }
    }
View Full Code Here

    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
      return QTIConstants.ERROR_SUBMITTEDITEM_OUTOFTIME;
    }
    if (!ict.isUnderMaxAttempts()) {
      // current item must be below maxattempts
      return QTIConstants.ERROR_SUBMITTEDITEM_TOOMANYATTEMPTS;
    }
    int subres = ict.addItemInput(itemInput);
    ict.eval(); // to have an up-to-date score
    return subres;
  }
View Full Code Here

    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");
        sectionResult = QTIConstants.ERROR_SECTION_PART_OUTOFTIME;
      }
View Full Code Here

  }

  private void startSection(SectionContext sc) {
    sc.start();
    for (int i = 0; i < sc.getItemContextCount(); i++) {
      ItemContext itc = sc.getItemContext(i);
      itc.start();
    }
  }
View Full Code Here

 
  private void startSection(SectionContext sc) {
    sc.start();
    for (int i = 0; i < sc.getItemContextCount(); i++) {
      ItemContext itc = sc.getItemContext(i);
      itc.start();   
    }
  }
View Full Code Here

    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"));
        Element it_duration = itres.addElement("duration");
        it_duration.addText(QTIHelper.getISODuration(itemc.getTimeSpent()));

        // process item score
        DecimalVariable scoreVar = (DecimalVariable) (itemc.getVariables().getSCOREVariable());
        Element it_score = itres.addElement("outcomes").addElement("score");
        it_score.addAttribute("varname", "SCORE");
        it_score.addElement("score_value").addText(StringHelper.formatFloat(scoreVar.getTruncatedValue(), 2));
        strVal = scoreVar.hasMinValue() ? "" + scoreVar.getMinValue() : "0.0";
        it_score.addElement("score_min").addText(strVal);
        strVal = scoreVar.hasMaxValue() ? "" + scoreVar.getMaxValue() : "N/A";
        it_score.addElement("score_max").addText(strVal);
        strVal = scoreVar.hasCutValue() ? "" + scoreVar.getCutValue() : "N/A";
        it_score.addElement("score_cut").addText(strVal);

        Element el_item = itemc.getEl_item();
        Map res_responsehash = new HashMap(3);

        // iterate over all responses of this item
        List resps = el_item.selectNodes(".//response_lid|.//response_xy|.//response_str|.//response_num|.//response_grp");
        for (Iterator it_resp = resps.iterator(); it_resp.hasNext();) {
          Element resp = (Element) it_resp.next();
          String ident = resp.attributeValue("ident");
          String rcardinality = resp.attributeValue("rcardinality");
          String rtiming = resp.attributeValue("rtiming");

          // add new response
          Element res_response = itres.addElement("response");
          res_response.addAttribute("ident_ref", ident);
          res_responsehash.put(ident, res_response); // enable lookup of
                                                     // @identref of <response>
                                                     // (needed with <varequal>
                                                     // elements

          // add new response_form
          //<response_lid ident="MR01" rcardinality="Multiple" rtiming="No">
          Element res_responseform = res_response.addElement("response_form");
          res_responseform.addAttribute("cardinality", rcardinality);
          res_responseform.addAttribute("timing", rtiming);
          String respName = resp.getName();
          String type = respName.substring(respName.indexOf("_") + 1);
          res_responseform.addAttribute("response_type", type);

          // add user answer
          ItemInput itemInp = itemc.getItemInput();
          Translator trans = Util.createPackageTranslator(QTIModule.class, locale);
          if (itemInp == null) { // user did not answer this question at all
            res_response.addElement("response_value").addText(trans.translate("ResBuilder.NoAnswer"));
          } else {
            List userAnswer = itemInp.getAsList(ident);
View Full Code Here

TOP

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

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.