Package org.olat.ims.qti.editor.beecom.objects

Examples of org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion


        editResponse = ((Response) item.getQuestion().getResponses().get(posid));
        Material responseMat = editResponse.getContent();
        displayMaterialFormController(ureq, responseMat, restrictedEdit);

      } else if (cmd.equals("addchoice")) {
        ChoiceQuestion question = (ChoiceQuestion) item.getQuestion();
        List choices = question.getResponses();
        ChoiceResponse newChoice = new ChoiceResponse();
        newChoice.getContent().add(new Mattext(trnsltr.translate("newresponsetext")));
        newChoice.setCorrect(false);
        newChoice.setPoints(-1f); // default value is negative to make sure
        // people understand the meaning of this value
        choices.add(newChoice);
      } else if (cmd.equals("del")) {
        delYesNoCtrl = DialogController.createYesNoDialogController(ureq.getLocale(), trnsltr.translate("confirm.delete.element"), this,
            new Integer(posid));
        getWindowControl().pushAsModalDialog( delYesNoCtrl.getInitialComponent());
      } else if (cmd.equals("ssc")) { // submit sc
        ChoiceQuestion question = (ChoiceQuestion) item.getQuestion();
        List q_choices = question.getResponses();
        String correctChoice = ureq.getParameter("correctChoice");
        for (int i = 0; i < q_choices.size(); i++) {
          ChoiceResponse choice = (ChoiceResponse) q_choices.get(i);
          if (correctChoice != null && correctChoice.equals("value_q" + i)) {
            choice.setCorrect(true);
          } else {
            choice.setCorrect(false);
          }
          choice.setPoints(ureq.getParameter("points_q" + i));
        }
        question.setSingleCorrectScore(ureq.getParameter("single_score"));
      } else if (cmd.equals("smc")) { // submit mc
        ChoiceQuestion question = (ChoiceQuestion) item.getQuestion();
        List choices = question.getResponses();
        boolean hasZeroPointChoice = false;
        for (int i = 0; i < choices.size(); i++) {
          ChoiceResponse choice = (ChoiceResponse) choices.get(i);
          if (ureq.getParameter("value_q" + i) != null && ureq.getParameter("value_q" + i).equalsIgnoreCase("true")) {
            choice.setCorrect(true);
          } else {
            choice.setCorrect(false);
          }
          choice.setPoints(ureq.getParameter("points_q" + i));
          if (choice.getPoints() == 0) hasZeroPointChoice = true;
        }
        if (hasZeroPointChoice && !question.isSingleCorrect()) getWindowControl().setInfo(trnsltr.translate("editor.info.mc.zero.points"));

        // set min/max before single_correct score
        // will be corrected by single_correct score afterwards
        question.setMinValue(ureq.getParameter("min_value"));
        question.setMaxValue(ureq.getParameter("max_value"));
        question.setSingleCorrect(ureq.getParameter("valuation_method").equals("single"));
        if (question.isSingleCorrect()) question.setSingleCorrectScore(ureq.getParameter("single_score"));
        else question.setSingleCorrectScore(0);

      } else if (cmd.equals("skprim")) { // submit kprim
        float maxValue = 0;
        try {
          maxValue = Float.parseFloat(ureq.getParameter("max_value"));
        } catch (NumberFormatException e) {
          // invalid input, set maxValue 0
        }
        ChoiceQuestion question = (ChoiceQuestion) item.getQuestion();
        List q_choices = question.getResponses();
        for (int i = 0; i < q_choices.size(); i++) {
          String correctChoice = ureq.getParameter("correctChoice_q" + i);
          ChoiceResponse choice = (ChoiceResponse) q_choices.get(i);
          choice.setPoints(maxValue / 4);
          if ("correct".equals(correctChoice)) {
            choice.setCorrect(true);
          } else {
            choice.setCorrect(false);
          }
        }
        question.setMaxValue(maxValue);
      }
      qtiPackage.serializeQTIDocument();
    }
  }
View Full Code Here


    ArrayList controls = new ArrayList();
    controls.add(control);
    newItem.setItemcontrols(controls);

    // pepare question
    ChoiceQuestion question = new ChoiceQuestion();
    question.setLable(trans.translate("editor.newquestion"));
    question.getQuestion().getElements().add(new Mattext(
        trans.translate("editor.newquestiontext")));
    question.setType(Question.TYPE_SC);
    question.setSingleCorrect(true);
    question.setSingleCorrectScore(1);

    ChoiceResponse newChoice = new ChoiceResponse();
    newChoice.setCorrect(true);
    newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    question.getResponses().add(newChoice);

    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");

    newItem.setQuestion(question);
View Full Code Here

    ArrayList controls = new ArrayList();
    controls.add(control);
    newItem.setItemcontrols(controls);
   
    // pepare question
    ChoiceQuestion question = new ChoiceQuestion();
    question.setLable(trans.translate("editor.newquestion"));
    question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    question.setType(Question.TYPE_MC);
    question.setSingleCorrect(true);
    question.setSingleCorrectScore(1);
   
    ChoiceResponse newChoice = new ChoiceResponse();
    newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice.setCorrect(true);
    newChoice.setPoints(1);
    question.getResponses().add(newChoice);
    newItem.setQuestion(question);
   
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "")
View Full Code Here

    controls.add(control);
    newItem.setItemcontrols(controls);
   
    // prepare question
    float maxValue = 1;
    ChoiceQuestion question = new ChoiceQuestion();
    question.setLable(trans.translate("editor.newquestion"));
    question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    question.setType(Question.TYPE_KPRIM);
    question.setSingleCorrect(false);
   
    // Kprim has always 4 answers, each of them score 1/4 of the maximum value
    ChoiceResponse newChoice = new ChoiceResponse();
    newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice.setCorrect(false);
    newChoice.setPoints(maxValue/4);
    question.getResponses().add(newChoice);
    ChoiceResponse newChoice2 = new ChoiceResponse();
    newChoice2.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice2.setCorrect(false);
    newChoice2.setPoints(maxValue/4);
    question.getResponses().add(newChoice2);
    ChoiceResponse newChoice3 = new ChoiceResponse();
    newChoice3.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice3.setCorrect(false);
    newChoice3.setPoints(maxValue/4);
    question.getResponses().add(newChoice3);
    ChoiceResponse newChoice4 = new ChoiceResponse();
    newChoice4.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice4.setCorrect(false);
    newChoice4.setPoints(maxValue/4);
    question.getResponses().add(newChoice4);
    question.setMaxValue(maxValue);
    newItem.setQuestion(question);
   
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "")
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion

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.