containing several . * * Some properties cannot be exported, as SCORM does not support them : * - type (one page or multiple pages) * - start_date and end_date * - max_attempts * - show_answer * - anonymous_attempts * * @author Julio Montoya * @author Amand Tihon * * @package chamilo.exercise.scorm */ class ScormExercise { public $exercise; public $standalone; /** * ScormExercise constructor. * * @param Exercise $exe * @param bool $standalone */ public function __construct($exe, $standalone) { $this->exercise = $exe; $this->standalone = $standalone; } /** * Start the XML flow. * * This opens the block, with correct attributes. */ public function startPage() { $charset = 'UTF-8'; $head = ''; return $head; } /** * End the XML flow, closing the tag. */ public function end_page() { return ''; } /** * Start document header. */ public function start_header() { return ''; } /** * Common JS functions. */ public function common_js() { $js = file_get_contents(api_get_path(SYS_CODE_PATH).'exercise/export/scorm/common.js'); return $js."\n"; } /** * End the itemBody part. */ public function end_js() { return ''; } /** * Start the itemBody. */ public function start_body() { return ''. '

'.$this->exercise->selectTitle().'

'.$this->exercise->selectDescription()."

". '
'. ''; } /** * End the itemBody part. */ public function end_body() { $button = ''; return '

'.$button.'
'; } /** * Export the question as a SCORM Item. * * This is a default behaviour, some classes may want to override this. * * @param $standalone: Boolean stating if it should be exported as a stand-alone question * * @return string string, the XML flow for an Item */ public function export() { global $charset; /*$head = ''; if ($this->standalone) { $head = ''."\n" .''."\n"; }*/ list($js, $html) = $this->exportQuestions(); $res = $this->startPage() .$this->start_header() .$this->css() .$this->globalAssets() .$this->start_js() .$this->common_js() .$js .$this->end_js() .$this->end_header() .$this->start_body() .$html .$this->end_body() .$this->end_page(); return $res; } /** * Export the questions, as a succession of . * * @author Amand Tihon */ public function exportQuestions() { $js = $html = ''; $encoders = [new JsonEncoder()]; $normalizers = [new ObjectNormalizer()]; $em = Database::getManager(); // Export cquiz data /** @var CQuiz $exercise */ $exercise = $em->find('ChamiloCourseBundle:CQuiz', $this->exercise->iId); $exercise->setDescription(''); $exercise->setTextWhenFinished(''); $serializer = new Serializer($normalizers, $encoders); $jsonContent = $serializer->serialize($exercise, 'json'); $js .= "var exerciseInfo = JSON.parse('".$jsonContent."');\n"; $counter = 0; $scormQuestion = new ScormQuestion(); foreach ($this->exercise->selectQuestionList() as $q) { list($jstmp, $htmltmp) = $scormQuestion->exportQuestionToScorm($q, $counter); $js .= $jstmp."\n"; $html .= $htmltmp."\n"; $counter++; } return [$js, $html]; } /** * Print CSS inclusion. */ private function css() { return ''; } /** * End document header. */ private function end_header() { return ''; } /** * Start the itemBody. */ private function start_js() { return ''."\n"; $assets .= ''."\n"; $assets .= ''; return $assets; } }