public function serialize($quiz, $questions)
 {
     $writer = new ImsQtiWriter();
     $quiz_id = self::get_identifier($quiz);
     $test = $writer->add_assessmentTest($quiz_id, $quiz->name, self::get_tool_name(), Qti::get_tool_version());
     $part = $test->add_testPart(null, Qti::NAVIGATION_MODE_LINEAR, Qti::SUBMISSION_MODE_INDIVIDUAL);
     $part->add_itemSessionControl(0, true, true, true, true, true, false);
     $section = $part->add_assessmentSection(null, $quiz->name, false);
     $instruction = $this->translate_question_text($quiz->intro);
     $section->add_rubricBlock(Qti::VIEW_ALL)->add_flow($instruction);
     $this->add_questions($section, $quiz, $questions);
     return $writer->saveXML();
 }
 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;
     }
 }
 protected function add_assessment_item(ImsQtiWriter $writer, $question)
 {
     $identifier = self::question_identifier($question);
     $lang = MoodleUtil::get_current_language();
     $label = $question->qtype;
     $toolname = self::get_tool_name();
     $toolversion = Qti::get_tool_version();
     $result = $writer->add_assessmentItem($identifier, $question->name, true, false, $label, $lang, $toolname, $toolversion);
     return $result;
 }