Ejemplo n.º 1
0
    protected function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);

        if (empty($question->options)) {
            return $question;
        }

        $question->responseformat = $question->options->responseformat;
        $question->responsefieldlines = $question->options->responsefieldlines;
        $question->attachments = $question->options->attachments;

        $draftid = file_get_submitted_draft_itemid('graderinfo');
        $question->graderinfo = array();
        $question->graderinfo['text'] = file_prepare_draft_area(
            $draftid,           // draftid
            $this->context->id, // context
            'qtype_essay',      // component
            'graderinfo',       // filarea
            !empty($question->id) ? (int) $question->id : null, // itemid
            $this->fileoptions, // options
            $question->options->graderinfo // text
        );
        $question->graderinfo['format'] = $question->options->graderinfoformat;
        $question->graderinfo['itemid'] = $draftid;
        $question->responselimitpolicy = $question->options->responselimitpolicy;
        $question->wordlimit = $question->options->wordlimit;
        $question->charlimit = $question->options->charlimit;

        return $question;
    }
Ejemplo n.º 2
0
    protected function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);
        $question = $this->data_preprocessing_answers($question);
        $question = $this->data_preprocessing_hints($question);

        return $question;
    }
Ejemplo n.º 3
0
    protected function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);
        $question = $this->data_preprocessing_combined_feedback($question, true);
        $question = $this->data_preprocessing_hints($question, true, true);

        if (empty($question->options)) {
            return $question;
        }

        $question->shuffleanswers = $question->options->shuffleanswers;

        $key = 0;
        foreach ($question->options->subquestions as $subquestion) {
            $question->subanswers[$key] = $subquestion->answertext;

            $draftid = file_get_submitted_draft_itemid('subquestions[' . $key . ']');
            $question->subquestions[$key] = array();
            $question->subquestions[$key]['text'] = file_prepare_draft_area(
                $draftid,           // draftid
                $this->context->id, // context
                'qtype_match',      // component
                'subquestion',      // filarea
                !empty($subquestion->id) ? (int) $subquestion->id : null, // itemid
                $this->fileoptions, // options
                $subquestion->questiontext // text
            );
            $question->subquestions[$key]['format'] = $subquestion->questiontextformat;
            $question->subquestions[$key]['itemid'] = $draftid;
            $key++;
        }

        return $question;
    }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     if (empty($question->options)) {
         return $question;
     }
     $question->responseformat = $question->options->responseformat;
     $question->responsefieldlines = $question->options->responsefieldlines;
     $question->attachments = $question->options->attachments;
     $question->boardsize = $question->options->boardsize;
     //Set backimage details, and configure a draft area to accept any uploaded pictures
     //all this and this whole method does, is to load existing files into a filearea
     //so it is not called when creating a new question, only when editing an existing one
     //best to use file_get_submitted_draft_itemid - because copying questions gets weird otherwise
     //$draftitemid =$question->options->backimage;
     $draftitemid = file_get_submitted_draft_itemid('backimage');
     file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_poodllrecording', 'backimage', !empty($question->id) ? (int) $question->id : null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
     $question->backimage = $draftitemid;
     $draftid = file_get_submitted_draft_itemid('graderinfo');
     $question->graderinfo = array();
     $question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
     $question->graderinfo['format'] = $question->options->graderinfoformat;
     $question->graderinfo['itemid'] = $draftid;
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     // set the default text for question
     if ('' == $question->questiontext['text']) {
         $question->questiontext['text'] = get_string('default_question_text', 'qtype_' . $this->qtype());
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question);
     $question = $this->data_preprocessing_hints($question);
     if (!empty($question->options)) {
         $question->usecase = $question->options->usecase;
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question, true);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (!empty($question->options)) {
         $question->single = $question->options->single;
         $question->shuffleanswers = $question->options->shuffleanswers;
         $question->qdifficulty = $question->options->qdifficulty;
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     global $PAGE;
     $path = '/question/type/' . $this->question->qtype;
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question);
     $question = $this->data_preprocessing_hints($question);
     $PAGE->requires->jquery();
     $PAGE->requires->js($path . '/js/IPAcontrols.js', true);
     $PAGE->requires->js($path . '/js/IPAcontrols_buttons.js', true);
     $PAGE->requires->css($path . '/css/IPA_buttons.css', true);
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     if (empty($question->options)) {
         return $question;
     }
     $question->responseformat = $question->options->responseformat;
     $question->responsefieldlines = $question->options->responsefieldlines;
     $question->attachments = $question->options->attachments;
     $draftid = file_get_submitted_draft_itemid('graderinfo');
     $question->graderinfo = array();
     $question->graderinfo['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_poodllrecording', 'graderinfo', !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $question->options->graderinfo);
     $question->graderinfo['format'] = $question->options->graderinfoformat;
     $question->graderinfo['itemid'] = $draftid;
     return $question;
 }
Ejemplo n.º 10
0
    public function data_preprocessing($question) {
        $question = parent::data_preprocessing($question);

        if (!empty($question->options->trueanswer)) {
            $trueanswer = $question->options->answers[$question->options->trueanswer];
            $question->correctanswer = ($trueanswer->fraction != 0);

            $draftid = file_get_submitted_draft_itemid('trueanswer');
            $answerid = $question->options->trueanswer;

            $question->feedbacktrue = array();
            $question->feedbacktrue['format'] = $trueanswer->feedbackformat;
            $question->feedbacktrue['text'] = file_prepare_draft_area(
                $draftid,             // draftid
                $this->context->id,   // context
                'question',           // component
                'answerfeedback',     // filarea
                !empty($answerid) ? (int) $answerid : null, // itemid
                $this->fileoptions,   // options
                $trueanswer->feedback // text
            );
            $question->feedbacktrue['itemid'] = $draftid;
        }

        if (!empty($question->options->falseanswer)) {
            $falseanswer = $question->options->answers[$question->options->falseanswer];

            $draftid = file_get_submitted_draft_itemid('falseanswer');
            $answerid = $question->options->falseanswer;

            $question->feedbackfalse = array();
            $question->feedbackfalse['format'] = $falseanswer->feedbackformat;
            $question->feedbackfalse['text'] = file_prepare_draft_area(
                $draftid,              // draftid
                $this->context->id,    // context
                'question',            // component
                'answerfeedback',      // filarea
                !empty($answerid) ? (int) $answerid : null, // itemid
                $this->fileoptions,    // options
                $falseanswer->feedback // text
            );
            $question->feedbackfalse['itemid'] = $draftid;
        }

        return $question;
    }
Ejemplo n.º 11
0
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (!empty($question->options)) {
         $question->choose = $question->options->choose;
         $question->subcats = $question->options->subcats;
     }
     if (empty($question->name)) {
         $question->name = get_string('randomsamatch', 'qtype_randomsamatch');
     }
     if (empty($question->questiontext)) {
         $question->questiontext = get_string('randomsamatchintro', 'qtype_randomsamatch');
     }
     return $question;
 }
 function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (empty($question->options)) {
         return $question;
     }
     $question->horizontal = $question->options->horizontal;
     $key = 0;
     foreach ($question->options->subquestions as $subquestion) {
         $question->subanswers[$key] = $subquestion->answertext;
         $draftid = file_get_submitted_draft_itemid('subquestions[' . $key . ']');
         $question->subquestions[$key] = array();
         $question->subquestions[$key]['text'] = file_prepare_draft_area($draftid, $this->context->id, 'qtype_order', 'subquestion', !empty($subquestion->id) ? (int) $subquestion->id : null, $this->fileoptions, $subquestion->questiontext);
         $question->subquestions[$key]['format'] = $subquestion->questiontextformat;
         $question->subquestions[$key]['itemid'] = $draftid;
         $key++;
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (!empty($question->options->answers)) {
         $key = 0;
         foreach ($question->options->answers as $answer) {
             $question->correctanswer[$key] = $answer->fraction > 0;
             $key++;
         }
     }
     if (!empty($question->hints)) {
         $key = 0;
         foreach ($question->hints as $hint) {
             $question->hintshowchoicefeedback[$key] = !empty($hint->options);
             $key += 1;
         }
     }
     if (!empty($question->options)) {
         $question->shuffleanswers = $question->options->shuffleanswers;
         $question->answernumbering = $question->options->answernumbering;
         $question->shownumcorrect = $question->options->shownumcorrect;
         // Prepare feedback editor to display files in draft area.
         foreach (array('correctfeedback', 'incorrectfeedback') as $feedbackname) {
             $draftid = file_get_submitted_draft_itemid($feedbackname);
             $text = $question->options->{$feedbackname};
             $feedbackformat = $feedbackname . 'format';
             $format = $question->options->{$feedbackformat};
             $defaultvalues[$feedbackname] = array();
             $defaultvalues[$feedbackname]['text'] = file_prepare_draft_area($draftid, $this->context->id, 'question', $feedbackname, !empty($question->id) ? (int) $question->id : null, $this->fileoptions, $text);
             $defaultvalues[$feedbackname]['format'] = $format;
             $defaultvalues[$feedbackname]['itemid'] = $draftid;
         }
         // Prepare files code block ends.
         $question = (object) ((array) $question + $defaultvalues);
     }
     return $question;
 }
Ejemplo n.º 14
0
 protected function data_preprocessing($question)
 {
     global $CFG, $PAGE, $SESSION;
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question);
     $question = $this->data_preprocessing_hints($question);
     if (!empty($question->options)) {
         $question->usecase = $question->options->usecase;
         $question->usehint = $question->options->usehint;
         $question->studentshowalternate = $question->options->studentshowalternate;
     } else {
         $key = 0;
         $default_values['fraction[' . $key . ']'] = 1;
         $question = (object) ((array) $question + $default_values);
     }
     // disable the score dropdown list for Answer 1 to make sure it remains at 100%
     // grade for Answer 1 will need to be automatically set to 1 in questiontype.php,  save_question_options($question)
     $i = 1;
     foreach ($this->_form->_elements as $element) {
         if ($element->_attributes['name'] == 'fraction[0]') {
             break;
         }
         $i++;
     }
     $this->_form->_elements[$i]->_attributes['disabled'] = 'disabled';
     return $question;
 }
 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question, false);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (isset($question->options)) {
         $question->synchronize = $question->options->synchronize;
         $question->single = $question->options->single;
         $question->answernumbering = $question->options->answernumbering;
         $question->shuffleanswers = $question->options->shuffleanswers;
     }
     return $question;
 }
 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_options($question);
     $question = $this->data_preprocessing_inputs($question);
     $question = $this->data_preprocessing_prts($question);
     $question = $this->data_preprocessing_hints($question);
     if (empty($question->questiontext['text'])) {
         // Nasty hack to override what the base class does. The way it
         // prepares the questiontext field overwrites the default.
         $question->questiontext['text'] = self::DEFAULT_QUESTION_TEXT;
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question);
     /* populates the hints and adds clearincorrect and and shownumcorrect (true,true) */
     $question = $this->data_preprocessing_hints($question, true, true);
     if (!empty($question->options)) {
         $question->answerdisplay = $question->options->answerdisplay;
     }
     return $question;
 }
 protected function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_answers($question, true);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     if (!empty($question->options)) {
         $question->single = $question->options->single;
         $question->shuffleanswers = $question->options->shuffleanswers;
         $question->qdifficulty = $question->options->qdifficulty;
     }
     if (isset($question->id)) {
         // Prepare the questionimage filemanager to display files in draft area.
         $draftitemid = file_get_submitted_draft_itemid('questionimage');
         file_prepare_draft_area($draftitemid, 1, 'question', 'questionimage', $question->id);
         $question->questionimage = $draftitemid;
         // Prepare the questionsound filemanager to display files in draft area.
         $draftitemid = file_get_submitted_draft_itemid('questionsound');
         file_prepare_draft_area($draftitemid, 1, 'question', 'questionsound', $question->id);
         $question->questionsound = $draftitemid;
     }
     return $question;
 }
 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     //$question = $this->data_preprocessing_answers($question, true);
     // feedback
     $question = $this->data_preprocessing_ordering_feedback($question);
     // answers and fractions
     $question->answer = array();
     $question->fraction = array();
     if (isset($question->options->answers)) {
         $i = 0;
         foreach ($question->options->answers as $answer) {
             if (trim($answer->answer) == '') {
                 continue;
                 // skip empty answers
             }
             $question->answer[$i] = $answer->answer;
             $question->fraction[$i] = $i + 1;
             $i++;
         }
     }
     // selecttype
     if (isset($question->options->selecttype)) {
         $question->selecttype = $question->options->selecttype;
     } else {
         $question->selecttype = 0;
     }
     // selectcount
     if (isset($question->options->selectcount)) {
         $question->selectcount = $question->options->selectcount;
     } else {
         $question->selectcount = max(3, count($question->answer));
     }
     return $question;
 }
 public function data_preprocessing($question)
 {
     $question = parent::data_preprocessing($question);
     $question = $this->data_preprocessing_combined_feedback($question, true);
     $question = $this->data_preprocessing_hints($question, true, true);
     $question = $this->data_preprocessing_answers($question, true);
     if (!empty($question->options->answers)) {
         $key = 0;
         foreach ($question->options->answers as $answer) {
             $question = $this->data_preprocessing_choice($question, $answer, $key);
             $key++;
         }
     }
     if (!empty($question->options)) {
         $question->shuffleanswers = $question->options->shuffleanswers;
     }
     return $question;
 }