/**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $a = reset($data->options->answers);
     $result->feedback = $this->format_text($a->feedback);
     return $result;
 }
 static function factory(QtiImportSettings $settings)
 {
     $item = $settings->get_reader();
     $category = $settings->get_category();
     //if it is a reimport
     if ($data = $settings->get_data()) {
         if ($data->qtype == 'calculatedsimple') {
             return new self($category);
         } else {
             return null;
         }
     }
     $accept = !is_null(CalculatedBuilder::factory($item, $source_root, $target_root)) && $item->toolName == self::get_tool_name() && $item->toolVersion >= Qti::get_tool_version() && $item->label == 'calculatedsimple';
     if ($accept) {
         return new self($category);
     } else {
         return null;
     }
 }
 static function factory(QtiImportSettings $settings)
 {
     $item = $settings->get_reader();
     $category = $settings->get_category();
     //if it is a reimport
     if ($data = $settings->get_data()) {
         if ($data->qtype == 'multianswer') {
             return new self($category);
         } else {
             return null;
         }
     }
     if ($item->has_templateDeclaration() || !self::has_score($item)) {
         return null;
     } else {
         $interactions = $item->list_interactions();
         foreach ($interactions as $interaction) {
             if (!($interaction->is_inlineChoiceInteraction() || $interaction->is_choiceInteraction() || $interaction->is_textEntryInteraction() || $interaction->is_gapMatchInteraction())) {
                 return null;
             }
         }
         return new self($category);
     }
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $result->dataset = $data->options->datasets;
     $result->single = $data->options->single;
     $result->shuffleanswers = $data->options->shuffleanswers;
     $result->answernumbering = $data->options->answernumbering;
     $result->synchronize = $data->options->synchronize;
     $answers = $data->options->answers;
     foreach ($answers as $a) {
         $result->answers[] = $a->answer;
         $result->feedback[] = $this->format_text($a->feedback);
         $result->fraction[] = $a->fraction;
         $result->tolerance[] = $a->tolerance;
         $result->tolerancetype[] = $a->tolerancetype;
         $result->correctanswerformat[] = $a->correctanswerformat;
         $result->correctanswerlength[] = $a->correctanswerlength;
     }
     $datasets = $data->options->datasets;
     foreach ($result->dataset as $ds) {
         $ds->min = $ds->minimum;
         $ds->max = $ds->maximum;
         $ds->length = end(explode(':', $ds->options));
         $ds->datasetitem = $ds->items;
     }
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $true_answer = $data->options->answers[$data->options->trueanswer];
     $false_answer = $data->options->answers[$data->options->falseanswer];
     $result->feedbacktrue = $this->format_text($true_answer->feedback);
     $result->feedbackfalse = $this->format_text($false_answer->feedback);
     $result->correctanswer = intval($true_answer->fraction) == 1;
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $result->single = $data->options->single;
     $result->shuffleanswers = $data->options->shuffleanswers;
     $result->answernumbering = $data->options->layout;
     $answers = $data->options->answers;
     foreach ($answers as $a) {
         $result->answer[] = $a->answer;
         $result->feedback[] = $this->format_text($a->feedback);
         $result->fraction[] = $a->fraction;
     }
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $result->usecase = $data->options->usecase;
     foreach ($data->options->answers as $a) {
         $result->answer[] = $a->answer;
         $result->feedback[] = $this->format_text($a->feedback);
         $result->fraction[] = $a->fraction;
     }
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $result->instructions = $this->format_text($data->options->instructions);
     $result->showunits = $data->options->showunits;
     $result->unitsleft = $data->options->unitsleft;
     $result->unitgradingtype = $data->options->unitgradingtype;
     $result->unitpenalty = $data->options->unitpenalty;
     $result->multiplier = array();
     $result->unit = array();
     $units = $data->options->units;
     foreach ($units as $u) {
         $result->multiplier[] = $u->multiplier;
         $result->unit[] = $u->unit;
     }
     $answers = $data->options->answers;
     foreach ($answers as $a) {
         $result->answer[] = $a->answer;
         $result->fraction[] = $a->fraction;
         $result->tolerance[] = $a->tolerance;
         $result->feedback[] = $this->format_text($a->feedback);
     }
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param QtiImportSettings $data
  * @return object|null
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = parent::build_moodle($settings);
     $result->shuffleanswers = $data->options->shuffleanswers;
     $result->subquestions = array();
     $result->subanswers = array();
     foreach ($data->options->subquestions as $q) {
         $result->subquestions[] = $this->format_text($q->questiontext);
         $result->subanswers[] = $q->answertext;
     }
     return $result;
 }
 /**
  * Build questions using moodle serialized data. Used for reimport, i.e. from Moodle to Moodle.
  * Used to process data not supported by QTI and to improve performances.
  *
  * @param object $data
  */
 public function build_moodle(QtiImportSettings $settings)
 {
     $data = $settings->get_data();
     $result = $this->create_question();
     if (isset($data->name)) {
         $result->name = $data->name;
     }
     if (isset($data->questiontext)) {
         $result->questiontext = $data->questiontext;
     }
     if (isset($data->generalfeedback)) {
         $result->generalfeedback = $data->generalfeedback;
     }
     if (isset($data->penalty)) {
         $result->penalty = $data->penalty;
     }
     if (isset($data->defaultgrade)) {
         $result->defaultgrade = $data->defaultgrade;
     }
     if (isset($data->options)) {
         if (isset($data->options->correctfeedback)) {
             $result->correctfeedback = $this->format_text($data->options->correctfeedback);
         }
         if (isset($data->options->partiallycorrectfeedback)) {
             $result->partiallycorrectfeedback = $this->format_text($data->options->partiallycorrectfeedback);
         }
         if (isset($data->options->incorrectfeedback)) {
             $result->incorrectfeedback = $this->format_text($data->options->incorrectfeedback);
         }
     }
     return $result;
 }