$smarty->assign("T_SCORM", true); $smarty->assign("T_SCORM_VERSION", $scormVersion); } $userObj = new stdClass(); $userObj->name = array($currentUser->user['name'] . ' ' . $currentUser->user['surname']); $userObj->account = new stdClass(); $userObj->account->accountServiceHomePage = array($_SERVER['HTTP_HOST']); //These 2 for 0.9 $userObj->account->accountName = array($currentUser->user['login']); $userObj->account->homePage = $_SERVER['HTTP_HOST']; //These 2 for 0.95 $userObj->account->name = $currentUser->user['login']; $currentUnit['data'] = str_replace(array(urlencode('###LRS###'), urlencode('###actor###'), urlencode('###auth###'), urlencode('###unit_id###')), array(urlencode(G_SERVERNAME . 'XAPI/'), urlencode(json_encode($userObj)), urlencode(base64_encode('auth')), urlencode($currentUnit['id'])), $currentUnit['data']); //If glossary is activated, transform content data accordingly if (EfrontUser::isOptionVisible('glossary') && !isset($_GET['print'])) { $currentUnit['data'] = glossary::applyGlossary($currentUnit['data'], $currentLesson->lesson['id']); } //Replace inner links. Inner links are created when linking from one unit to another, so they must point either to professor.php or student.php, depending on the user viewing the content $currentUnit['data'] = str_replace("##EFRONTINNERLINK##", $_SESSION['s_lesson_user_type'], $currentUnit['data']); $currentUnit['data'] = str_replace(array("##USER_NAME##", "##USER_LAST_NAME##"), array($currentUser->user['name'], $currentUser->user['surname']), $currentUnit['data']); if ($currentUnit['ctg_type'] == 'tests' || $currentUnit['ctg_type'] == 'feedback') { $loadScripts[] = 'scriptaculous/dragdrop'; $loadScripts[] = 'includes/tests'; include "tests/show_unsolved_test.php"; } if (isset($_GET['print'])) { $currentUnit['data'] = preg_replace("#<script.*?>.*?</script>#", "<script removed>", $currentUnit['data']); $currentUnit['data'] = strip_tags($currentUnit['data'], '<img><applet><iframe><div><br><p><ul><li><ol><span><sub><sup><hr><h1><h2><h3><h4><h5><h6><table><tbody><tr><th><td><font><em><i><strong><u><b><blockquote><big><center><code>'); } //in case unit is simply an iframe,do not load the print it button $contentStripped = strip_tags($currentUnit['data'], '<img><applet><iframe><div><br><p><ul><li><ol><span><sub><sup><hr><h1><h2><h3><h4><h5><h6><table><tbody><tr><th><td><font><em><i><strong><u><b><blockquote><big><center><code>');
/** * Create HTML version of unsolved question * * This function is used to create the HTML code corresponding * to the question. The HTML is created using the question form * fields, so the proper form must be specified. A form renderer * is used to output the fields. The function calls internally * toHTMLQuickForm() * <br/>Example: * <code> * $question = new DragDropQuestion(3); //Instantiate question * $form = new HTML_QuickForm("questionForm", "post", "", "", null, true); //Create a form * echo $question -> toHTML($form); //Output question HTML code * </code> * * @param HTML_QuickForm $form The form to add fields to and display * @return string The HTML code for the question * @since 3.5.0 * @access public */ public function toHTML(&$form) { $this->toHTMLQuickForm($form); //Assign proper elements to the form $renderer = new HTML_QuickForm_Renderer_ArraySmarty($foo); //Get a smarty renderer, only because it reforms the form in a very convenient way for printing html $form->accept($renderer); //Render the form $formArray = $renderer->toArray(); //Get the rendered form fields $random = range(0, sizeof($this->answer) - 1); //$random is a temporary array used only for creating a random ordering shuffle($random); $questionString = "\r\n <script>\r\n \tif (typeof(dragDropQuestions) == 'undefined') {\r\n \t\tdragDropQuestions = new Array();\r\n \t}\r\n \tif (typeof(dragDropQuestionKeys) == 'undefined') {\r\n \t\tdragDropQuestionKeys = new Array();\r\n \t}\r\n \tdragDropQuestionKeys[" . $this->question['id'] . "] = new Array();\r\n \tdragDropQuestions.push(" . $this->question['id'] . ");\r\n \t//var questionId = '" . $this->question['id'] . "';\r\n </script>"; $questionString .= ' <table class = "unsolvedQuestion dragDropQuestion" style = "width:auto;min-width:300px"> <tr><td colspan = "3">' . (EfrontUser::isOptionVisible('test_glossary') ? glossary::applyGlossary($this->question['text'], $this->question['lessons_ID']) : $this->question['text']) . ' ' . $this->getCounter() . '</td></tr>'; foreach ($formArray['question'][$this->question['id']] as $key => $value) { if ($this->preview_correct) { $label = $formArray['question'][$this->question['id']][$key]['label']; } else { $label = $formArray['question'][$this->question['id']][$random[$key]]['label']; } $questionString .= "\r\n \t\t\t\t<tr><td style = 'min-width:100px;' class = 'droppable' id = 'secondlist_" . $this->question['id'] . "_{$key}'>\r\n \t\t\t\t\t\t<input type = 'hidden' value = '" . $random[$key] . "'>\r\n \t\t\t\t\t\t" . $label . "\r\n \t\t\t\t\t\t<script>dragDropQuestionKeys[" . $this->question['id'] . "].push({$key});\r\n \t\t\t\t\t\t\t//Droppables.add('secondlist_" . $this->question['id'] . "_{$key}', {accept:'draggable', onDrop:handleDrop});\r\n \t\t\t\t\t\t</script>\r\n \t\t\t\t\t</td>\r\n \t\t\t\t\t<td style = 'min-width:50px;' class = 'dragDropTarget'></td>\r\n \t\t\t\t\t<td style = 'min-width:100px;height:100%;border:1px dotted gray' id = 'source_" . $this->question['id'] . "_{$key}'>\r\n \t\t\t\t\t\t<div class = 'draggable' id = 'firstlist_" . $this->question['id'] . "_{$key}'>" . $this->answer[$key] . $value['html'] . "</div>\r\n \t\t\t\t\t<script>\r\n \t\t\t\t\t\t//new Draggable('firstlist_" . $this->question['id'] . "_{$key}', {revert:'failure', onStart:handleDrag});\r\n \t\t\t\t\t</script>\r\n \t\t\t\t\t</td>\r\n \t\t\t\t</tr>\r\n \t\t\t\t<tr><td colspan = '3' style = 'height:25px'></td></tr>"; } $questionString .= '</table>'; return bypassCommonPoolCheck($questionString); }