Beispiel #1
0
 /** Method calcFeedBack. */
 private void calcFeedBack() {
   if (feedbacktesting) {
     List<?> el_ofts = el_assessment.selectNodes("outcomes_processing/outcomes_feedback_test");
     feedbackavailable = false;
     for (Iterator<?> it_oft = el_ofts.iterator(); it_oft.hasNext(); ) {
       Element el_oft = (Element) it_oft.next();
       // <!ELEMENT outcomes_feedback_test (test_variable , displayfeedback+)>
       Element el_testvar = (Element) el_oft.selectSingleNode("test_variable");
       // must exist: dtd
       // <!ELEMENT test_variable (variable_test | and_test | or_test |
       // not_test)>
       Element el_varandornot =
           (Element) el_testvar.selectSingleNode("variable_test|and_test|or_test|not_test");
       String elname = el_varandornot.getName();
       ScoreBooleanEvaluable sbe = QTIHelper.getSectionBooleanEvaluableInstance(elname);
       float totalscore = getScore();
       boolean fulfilled = sbe.eval(el_varandornot, totalscore);
       if (fulfilled) {
         // get feedback
         Element el_displayfeedback = (Element) el_oft.selectSingleNode("displayfeedback");
         String linkRefId = el_displayfeedback.attributeValue("linkrefid");
         // must exist (dtd)
         // ignore feedbacktype, since we section or assess feedback only
         // accepts material, no hints or solutions
         Element el_resolved =
             (Element)
                 el_assessment.selectSingleNode(".//assessfeedback[@ident='" + linkRefId + "']");
         getOutput().setEl_response(new AssessFeedback(el_resolved));
         // give the whole assessmentfeedback to render
         feedbackavailable = true;
       }
     }
   }
 }
 public void buildDocument() {
   final File unzippedRoot = fileresourceManager.unzipFileResource(resourceable);
   // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
   final VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
   final VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
   // getDocument(..) ensures that InputStream is closed in every case.
   document = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
 }
 public String extractTimeLimitFromDocument() {
   if (isNullDocument()) {
     return "";
   }
   String timeLimit = "-";
   final Element el_assess = (Element) document.selectSingleNode("questestinterop/assessment");
   final Element el_duration = (Element) el_assess.selectSingleNode("duration");
   if (el_duration != null) {
     final long dur = QTIHelper.parseISODuration(el_duration.getTextTrim());
     final long min = dur / 1024 / 60;
     final long sec = (dur - (min * 60 * 1024)) / 1024;
     timeLimit = "" + min + "' " + sec + "''";
   }
   return timeLimit;
 }
Beispiel #4
0
 /**
  * <!ELEMENT and_selection (selection_metadata | and_selection | or_selection | not_selection)+>
  */
 @Override
 public void buildXPathExpression(
     final Element selectionElement,
     final StringBuilder expr,
     final boolean not_switch,
     final boolean use_switch) {
   // assert: use_switch always true
   if (!use_switch) {
     throw new RuntimeException("error in not_selection; use_switch was switched off");
   }
   final List elems = selectionElement.elements();
   final Element child = (Element) elems.get(0);
   final String name = child.getName();
   final ExpressionBuilder eb = QTIHelper.getExpressionBuilder(name);
   eb.buildXPathExpression(child, expr, !not_switch, true);
 }
Beispiel #5
0
  /**
   * Method setUp.
   *
   * @param assessInstance
   */
  public void setUp(AssessmentInstance assessInstance) {
    this.assessInstance = assessInstance;
    init();

    Document el_questestinterop = assessInstance.getResolver().getQTIDocument();
    el_assessment = (Element) el_questestinterop.selectSingleNode("questestinterop/assessment");

    ident = el_assessment.attributeValue("ident");
    title = el_assessment.attributeValue("title");
    Element dur = (Element) el_assessment.selectSingleNode("duration");

    if (dur == null) {
      durationLimit = -1; // no limit
    } else {
      String sdur = dur.getText();
      durationLimit = QTIHelper.parseISODuration(sdur);
      if (durationLimit == 0) durationLimit = -1; // Assesst Designer fix
    }

    // get objectives
    Element el_objectives = (Element) el_assessment.selectSingleNode("objectives");
    if (el_objectives != null) objectives = new Objectives(el_objectives);

    // set feedback, hint, and solutions switches
    // <!ENTITY % I_FeedbackSwitch " feedbackswitch (Yes | No ) 'Yes'">
    // <!ENTITY % I_HintSwitch " hintswitch (Yes | No ) 'Yes'">
    // <!ENTITY % I_SolutionSwitch " solutionswitch (Yes | No ) 'Yes'">

    // <!ELEMENT assessment (qticomment? , duration? , qtimetadata* ,
    // objectives* , assessmentcontrol* , rubric* , presentation_material? ,
    // outcomes_processing* , assessproc_extension? , assessfeedback* ,
    // selection_ordering? , reference? , (sectionref | section)+)>
    // <!ELEMENT assessmentcontrol (qticomment?)>
    Element el_control = (Element) el_assessment.selectSingleNode("assessmentcontrol");
    if (el_control != null) {
      String feedbackswitch = el_control.attributeValue("feedbackswitch");
      String hintswitch = el_control.attributeValue("hintswitch");
      String solutionswitch = el_control.attributeValue("solutionswitch");
      boolean feedback = (feedbackswitch == null) ? true : feedbackswitch.equals("Yes");
      boolean hints = (hintswitch == null) ? true : hintswitch.equals("Yes");
      boolean solutions = (solutionswitch == null) ? true : solutionswitch.equals("Yes");
      switches = new Switches(feedback, hints, solutions);
    }

    // scoring model and outcomes processing
    Element el_outpro = (Element) el_assessment.selectSingleNode("outcomes_processing");
    if (el_outpro != null) {
      // get the scoring model: we need it later for calculating the score
      // <!ENTITY % I_ScoreModel " scoremodel CDATA #IMPLIED">
      scoremodel = el_outpro.attributeValue("scoremodel");
      // may be null -> then assume SumOfScores

      // set the cutvalue if given (only variable score)
      cutvalue =
          QTIHelper.getFloatAttribute(el_outpro, "outcomes/decvar[@varname='SCORE']", "cutvalue");
      List<?> el_oft = el_outpro.selectNodes("outcomes_feedback_test");
      if (el_oft.size() != 0) {
        feedbacktesting = true;
      }
    }

    initSections(el_assessment, switches);
    init();
  }