|
@@ -21,9 +21,9 @@ class ScormQuestion extends Question
|
|
|
/**
|
|
|
* Returns the HTML + JS flow corresponding to one question
|
|
|
*
|
|
|
- * @param int The question ID
|
|
|
- * @param bool standalone (ie including XML tag, DTD declaration, etc)
|
|
|
- * @param int The JavaScript ID for this question.
|
|
|
+ * @param int $questionId The question ID
|
|
|
+ * @param bool $standalone (ie including XML tag, DTD declaration, etc)
|
|
|
+ * @param int $js_id The JavaScript ID for this question.
|
|
|
* Due to the nature of interactions, we must have a natural sequence for
|
|
|
* questions in the generated JavaScript.
|
|
|
* @param integer $js_id
|
|
@@ -44,7 +44,7 @@ class ScormQuestion extends Question
|
|
|
$question->position=$qst->position;
|
|
|
$question->picture=$qst->picture;
|
|
|
$assessmentItem = new ScormAssessmentItem($question, $standalone);
|
|
|
- //echo "<pre>".print_r($scorm,1)."</pre>";exit;
|
|
|
+
|
|
|
return $assessmentItem->export();
|
|
|
}
|
|
|
|
|
@@ -147,19 +147,19 @@ class ScormQuestion extends Question
|
|
|
*/
|
|
|
function getQuestionHTML()
|
|
|
{
|
|
|
- $title = $this->selectTitle();
|
|
|
- $description = $this->selectDescription();
|
|
|
+ $title = $this->selectTitle();
|
|
|
+ $description = $this->selectDescription();
|
|
|
$cols = 2;
|
|
|
- $s='<tr>' .
|
|
|
- '<td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">' . "\n" .
|
|
|
- $title.
|
|
|
- '</td>' . "\n" .
|
|
|
- '</tr>' . "\n" .
|
|
|
- '<tr>' . "\n" .
|
|
|
- '<td valign="top" colspan="'.$cols.'">' . "\n" .
|
|
|
- '<i>'.$description.'</i>' . "\n" .
|
|
|
- '</td>' . "\n" .
|
|
|
- '</tr>' . "\n";
|
|
|
+ $s = '<tr>
|
|
|
+ <td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;">
|
|
|
+ '.$title.'
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td valign="top" colspan="'.$cols.'">
|
|
|
+ <i>'.$description.'</i>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
return $s;
|
|
|
}
|
|
|
|
|
@@ -168,15 +168,15 @@ class ScormQuestion extends Question
|
|
|
*/
|
|
|
function getQuestionJS()
|
|
|
{
|
|
|
- //$id = $this->id;
|
|
|
$w = $this->selectWeighting();
|
|
|
$s = 'questions.push('.$this->js_id.');'."\n";
|
|
|
- if($this->type == FREE_ANSWER or $this->type == HOT_SPOT)
|
|
|
- { //put the max score to 0 to avoid discounting the points of
|
|
|
- //non-exported quiz types in the SCORM
|
|
|
- $w=0;
|
|
|
- }
|
|
|
- $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";\n";
|
|
|
+ if ($this->type == FREE_ANSWER || $this->type == HOT_SPOT) {
|
|
|
+ //put the max score to 0 to avoid discounting the points of
|
|
|
+ //non-exported quiz types in the SCORM
|
|
|
+ $w = 0;
|
|
|
+ }
|
|
|
+ $s .= 'questions_score_max['.$this->js_id.'] = '.$w.";";
|
|
|
+
|
|
|
return $s;
|
|
|
}
|
|
|
}
|
|
@@ -193,12 +193,11 @@ class ScormAnswerMultipleChoice extends Answer
|
|
|
*/
|
|
|
function export()
|
|
|
{
|
|
|
- $html = '';
|
|
|
- $js = '';
|
|
|
- $html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
+ $js = '';
|
|
|
+ $html = '<tr><td colspan="2"><table width="100%">';
|
|
|
$type = $this->getQuestionType();
|
|
|
- $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
- $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
|
|
|
+ $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
|
|
|
+ $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
|
|
|
|
|
|
//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
|
|
|
//if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) {
|
|
@@ -207,23 +206,22 @@ class ScormAnswerMultipleChoice extends Answer
|
|
|
$id = 1;
|
|
|
$jstmp = '';
|
|
|
$jstmpc = '';
|
|
|
- foreach( $this->answer as $i => $answer )
|
|
|
- {
|
|
|
+ foreach ($this->answer as $i => $answer) {
|
|
|
$identifier = 'question_'.$this->questionJSId.'_multiple_'.$i;
|
|
|
$html .=
|
|
|
- '<tr>' . "\n"
|
|
|
- . '<td align="center" width="5%">' . "\n"
|
|
|
- . '<input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '<td width="95%">' . "\n"
|
|
|
- . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n\n";
|
|
|
+ '<tr>
|
|
|
+ <td align="center" width="5%">
|
|
|
+ <input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" />
|
|
|
+ </td>
|
|
|
+ <td width="95%">
|
|
|
+ <label for="'.$identifier.'">' . $this->answer[$i] . '</label>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
+
|
|
|
$jstmp .= $i.',';
|
|
|
- if($this->correct[$i])
|
|
|
- {
|
|
|
- $jstmpc .= $i.',';
|
|
|
- }
|
|
|
+ if ($this->correct[$i]) {
|
|
|
+ $jstmpc .= $i.',';
|
|
|
+ }
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
|
|
|
$id++;
|
|
|
}
|
|
@@ -239,14 +237,14 @@ class ScormAnswerMultipleChoice extends Answer
|
|
|
//To this items we show the ThisItemIsNotExportable
|
|
|
$qId = $this->questionJSId;
|
|
|
$js = '';
|
|
|
- $html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
+ $html = '<tr><td colspan="2"><table width="100%">';
|
|
|
// some javascript must be added for that kind of questions
|
|
|
- $html .= '<tr>' . "\n"
|
|
|
- . '<td>' . "\n"
|
|
|
- . '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n";
|
|
|
- $html .= '</table></td></tr>' . "\n";
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>
|
|
|
+ <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_exact" rows="20" cols="100"></textarea>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
+ $html .= '</table></td></tr>';
|
|
|
// currently the exact answers cannot be displayed, so ignore the textarea
|
|
|
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
|
|
|
$js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
|
|
@@ -256,41 +254,39 @@ class ScormAnswerMultipleChoice extends Answer
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
|
|
|
$js .= $jstmpw;
|
|
|
- return array($js,$html);
|
|
|
+ return array($js, $html);
|
|
|
} else {
|
|
|
//$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer');
|
|
|
$id = 1;
|
|
|
$jstmp = '';
|
|
|
$jstmpc = '';
|
|
|
- foreach( $this->answer as $i => $answer )
|
|
|
- {
|
|
|
- $identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
|
|
|
+ foreach ($this->answer as $i => $answer) {
|
|
|
+ $identifier = 'question_'.$this->questionJSId.'_unique_'.$i;
|
|
|
$identifier_name = 'question_'.$this->questionJSId.'_unique_answer';
|
|
|
$html .=
|
|
|
- '<tr>' . "\n"
|
|
|
- . '<td align="center" width="5%">' . "\n"
|
|
|
- . '<input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '<td width="95%">' . "\n"
|
|
|
- . '<label for="'.$identifier.'">' . $this->answer[$i] . '</label>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n\n";
|
|
|
+ '<tr>
|
|
|
+ <td align="center" width="5%">
|
|
|
+ <input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="radio"/>
|
|
|
+ </td>
|
|
|
+ <td width="95%">
|
|
|
+ <label for="'.$identifier.'">' . $this->answer[$i] . '</label>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
$jstmp .= $i.',';
|
|
|
- if($this->correct[$i])
|
|
|
- {
|
|
|
- $jstmpc .= $i;
|
|
|
- }
|
|
|
- $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";\n";
|
|
|
+ if ($this->correct[$i]) {
|
|
|
+ $jstmpc .= $i;
|
|
|
+ }
|
|
|
+ $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";";
|
|
|
$id++;
|
|
|
}
|
|
|
- $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
|
|
|
- $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';'."\n";
|
|
|
- $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'."\n";
|
|
|
+ $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');';
|
|
|
+ $js .= 'questions_answers_correct['.$this->questionJSId.'] = '.$jstmpc.';';
|
|
|
+ $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';';
|
|
|
$js .= $jstmpw;
|
|
|
}
|
|
|
- $html .= '</table></td></tr>' . "\n";
|
|
|
+ $html .= '</table></td></tr>';
|
|
|
|
|
|
- return array($js,$html);
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -314,29 +310,26 @@ class ScormAnswerTrueFalse extends Answer
|
|
|
$identifier_true = $identifier.'_true';
|
|
|
$identifier_false = $identifier.'_false';
|
|
|
$html .=
|
|
|
- '<tr>' . "\n"
|
|
|
- . '<td align="center" width="5%">' . "\n"
|
|
|
- . '<input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" '
|
|
|
- . '/>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '<td width="95%">' . "\n"
|
|
|
- . '<label for="'.$identifier_true.'">' . get_lang('True') . '</label>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n\n";
|
|
|
+ '<tr>
|
|
|
+ <td align="center" width="5%">
|
|
|
+ <input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" />
|
|
|
+ </td>
|
|
|
+ <td width="95%">
|
|
|
+ <label for="'.$identifier_true.'">' . get_lang('True') . '</label>
|
|
|
+ </td>
|
|
|
+ </tr>';
|
|
|
$html .=
|
|
|
- '<tr>' . "\n"
|
|
|
- . '<td align="center" width="5%">' . "\n"
|
|
|
- . '<input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" '
|
|
|
- . '/>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '<td width="95%">' . "\n"
|
|
|
- . '<label for="'.$identifier_false.'">' . get_lang('False') . '</label>' . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n\n";
|
|
|
- $html .= '</table></td></tr>' . "\n";
|
|
|
+ '<tr>
|
|
|
+ <td align="center" width="5%">
|
|
|
+ <input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" />
|
|
|
+ </td>
|
|
|
+ <td width="95%">
|
|
|
+ <label for="'.$identifier_false.'">' . get_lang('False') . '</label>
|
|
|
+ </td>
|
|
|
+ </tr></table></td></tr>';
|
|
|
$js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
|
|
|
$js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
|
|
|
- if ($this->response == 'TRUE') {
|
|
|
+ if ($this->response === 'TRUE') {
|
|
|
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
|
|
|
} else {
|
|
|
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
|
|
@@ -346,7 +339,7 @@ class ScormAnswerTrueFalse extends Answer
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
|
|
|
$js .= $jstmpw;
|
|
|
|
|
|
- return array($js,$html);
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -366,7 +359,7 @@ class ScormAnswerFillInBlanks extends Answer
|
|
|
{
|
|
|
global $charset;
|
|
|
$js = '';
|
|
|
- $html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
+ $html = '<tr><td colspan="2"><table width="100%">';
|
|
|
// get all enclosed answers
|
|
|
$blankList = array();
|
|
|
// build replacement
|
|
@@ -388,29 +381,33 @@ class ScormAnswerFillInBlanks extends Answer
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
|
|
|
$startlocations=api_strpos($answer,'[');
|
|
|
$endlocations=api_strpos($answer,']');
|
|
|
- while($startlocations !== false && $endlocations !== false) {
|
|
|
+ while ($startlocations !== false && $endlocations !== false) {
|
|
|
$texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
|
|
|
- $answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1);
|
|
|
- $jstmp .= $i.',';
|
|
|
- $jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',";
|
|
|
- $my_weight=explode('@',$weights[$i-1]);
|
|
|
- if (count($my_weight)==2) {
|
|
|
- $weight_db=$my_weight[0];
|
|
|
- } else {
|
|
|
- $weight_db=$my_weight[0];
|
|
|
- }
|
|
|
+ $answer = api_substr_replace(
|
|
|
+ $answer,
|
|
|
+ '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',
|
|
|
+ $startlocations,
|
|
|
+ ($endlocations-$startlocations)+1
|
|
|
+ );
|
|
|
+ $jstmp .= $i.',';
|
|
|
+ $jstmpc .= "'".api_htmlentities(api_substr($texstring, 1, -1), ENT_QUOTES, $charset)."',";
|
|
|
+ $my_weight = explode('@', $weights[$i - 1]);
|
|
|
+ if (count($my_weight) == 2) {
|
|
|
+ $weight_db = $my_weight[0];
|
|
|
+ } else {
|
|
|
+ $weight_db = $my_weight[0];
|
|
|
+ }
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n";
|
|
|
$i++;
|
|
|
$startlocations = api_strpos($answer, '[');
|
|
|
$endlocations = api_strpos($answer, ']');
|
|
|
}
|
|
|
|
|
|
- $html .= '<tr>' . "\n"
|
|
|
- . '<td>' . "\n"
|
|
|
- . $answer . "\n"
|
|
|
- . '</td>' . "\n"
|
|
|
- . '</tr>' . "\n";
|
|
|
- $html .= '</table></td></tr>' . "\n";
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>
|
|
|
+ '.$answer.'
|
|
|
+ </td>
|
|
|
+ </tr></table></td></tr>';
|
|
|
$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
|
|
|
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
|
|
|
$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
|
|
@@ -433,7 +430,7 @@ class ScormAnswerMatching extends Answer
|
|
|
function export()
|
|
|
{
|
|
|
$js = '';
|
|
|
- $html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
+ $html = '<tr><td colspan="2"><table width="100%">';
|
|
|
// prepare list of right proposition to allow
|
|
|
// - easiest display
|
|
|
// - easiest randomisation if needed one day
|
|
@@ -466,30 +463,32 @@ class ScormAnswerMatching extends Answer
|
|
|
$Select[$answerId]['Reponse'] = $answer;
|
|
|
$cpt1++;
|
|
|
} else {
|
|
|
- $s.='<tr>'."\n";
|
|
|
- $s.='<td width="40%" valign="top">'."\n".'<b>'.$cpt2.'</b>. '.$answer."\n</td>\n";
|
|
|
+ $s.='<tr>';
|
|
|
+ $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>. '.$answer."</td>";
|
|
|
$s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">';
|
|
|
$s.=' <option value="0">--</option>';
|
|
|
// fills the list-box
|
|
|
- foreach($Select as $key=>$val)
|
|
|
- {
|
|
|
- $s.='<option value="'.$key.'">'.$val['Lettre'].'</option>';
|
|
|
- } // end foreach()
|
|
|
+ foreach ($Select as $key => $val) {
|
|
|
+ $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>';
|
|
|
+ } // end foreach()
|
|
|
|
|
|
- $s.='</select> </td>'."\n";
|
|
|
+ $s.='</select> </td>';
|
|
|
$s.='<td width="40%" valign="top">';
|
|
|
- if(isset($Select[$cpt2])) $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
|
|
|
- else $s.=' ';
|
|
|
- $s.="</td>\n</tr>\n";
|
|
|
+ if (isset($Select[$cpt2])) {
|
|
|
+ $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
|
|
|
+ } else {
|
|
|
+ $s .= ' ';
|
|
|
+ }
|
|
|
+ $s.="</td></tr>";
|
|
|
|
|
|
$jstmpc .= '['.$answerCorrect.','.$cpt2.'],';
|
|
|
|
|
|
- $my_weight=explode('@',$weight);
|
|
|
- if (count($my_weight)==2) {
|
|
|
- $weight=$my_weight[0];
|
|
|
- } else {
|
|
|
- $weight=$my_weight[0];
|
|
|
- }
|
|
|
+ $my_weight = explode('@', $weight);
|
|
|
+ if (count($my_weight) == 2) {
|
|
|
+ $weight = $my_weight[0];
|
|
|
+ } else {
|
|
|
+ $weight = $my_weight[0];
|
|
|
+ }
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n";
|
|
|
$cpt2++;
|
|
|
|
|
@@ -497,14 +496,11 @@ class ScormAnswerMatching extends Answer
|
|
|
if ($answerId == $nbrAnswers) {
|
|
|
// if there remain answers to be shown on the right side
|
|
|
while (isset($Select[$cpt2])) {
|
|
|
- //$s.='<tr>'."\n";
|
|
|
- //$s.='<td colspan="2">'."\n";
|
|
|
- //$s.='<table border="0" cellpadding="0" cellspacing="0" width="100%">'."\n";
|
|
|
- $s.='<tr>'."\n";
|
|
|
- $s.='<td width="60%" colspan="2"> </td>'."\n";
|
|
|
- $s.='<td width="40%" valign="top">';
|
|
|
- $s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
|
|
|
- $s.="</td>\n</tr>\n";
|
|
|
+ $s.= '<tr>';
|
|
|
+ $s.= '<td width="60%" colspan="2"> </td>';
|
|
|
+ $s.= '<td width="40%" valign="top">';
|
|
|
+ $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
|
|
|
+ $s.= "</td></tr>";
|
|
|
$cpt2++;
|
|
|
} // end while()
|
|
|
} // end if()
|
|
@@ -517,7 +513,7 @@ class ScormAnswerMatching extends Answer
|
|
|
$html .= $s;
|
|
|
$html .= '</table></td></tr>' . "\n";
|
|
|
|
|
|
- return array($js,$html);
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -536,22 +532,14 @@ class ScormAnswerFree extends Answer
|
|
|
*/
|
|
|
function export()
|
|
|
{
|
|
|
- //$qId = $this->questionJSId;
|
|
|
$js = '';
|
|
|
- /*$html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
- // some javascript must be added for that kind of questions
|
|
|
- $html .= '<tr><td>
|
|
|
- <textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea>
|
|
|
- </td>
|
|
|
- </tr>';
|
|
|
- $html .= '</table></td></tr>';*/
|
|
|
// currently the free answers cannot be displayed, so ignore the textarea
|
|
|
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
|
|
|
- $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
- $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
+ $js .= 'questions_answers['.$this->questionJSId.'] = new Array();';
|
|
|
+ $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();';
|
|
|
$js .= 'questions_types['.$this->questionJSId.'] = \'free\';'."\n";
|
|
|
- $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
- $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
|
|
|
+ $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();';
|
|
|
+ $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;';
|
|
|
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n";
|
|
|
$js .= $jstmpw;
|
|
|
|
|
@@ -571,11 +559,11 @@ class ScormAnswerHotspot extends Answer
|
|
|
function get_js_header()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- $header = '<script type="text/javascript" language="javascript">';
|
|
|
+ $header = '<script>';
|
|
|
$header .= file_get_contents('../inc/lib/javascript/hotspot/js/hotspot.js');
|
|
|
$header .= '</script>';
|
|
|
//because this header closes so many times the <script> tag, we have to reopen our own
|
|
|
- $header .= '<script type="text/javascript" language="javascript">'."\n";
|
|
|
+ $header .= '<script>';
|
|
|
$header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
$header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n";
|
|
|
$header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n";
|
|
@@ -606,7 +594,7 @@ class ScormAnswerHotspot extends Answer
|
|
|
function export()
|
|
|
{
|
|
|
$js = $this->get_js_header();
|
|
|
- $html = '<tr><td colspan="2"><table width="100%">' . "\n";
|
|
|
+ $html = '<tr><td colspan="2"><table width="100%">';
|
|
|
// some javascript must be added for that kind of questions
|
|
|
$html .= '';
|
|
|
|
|
@@ -614,11 +602,10 @@ class ScormAnswerHotspot extends Answer
|
|
|
$nbrAnswers=$this->selectNbrAnswers();
|
|
|
|
|
|
$answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>';
|
|
|
- for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
|
|
|
- {
|
|
|
- $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
|
|
|
- }
|
|
|
- $answer_list .= '</ol></div>';
|
|
|
+ for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
|
|
|
+ $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>';
|
|
|
+ }
|
|
|
+ $answer_list .= '</ol></div>';
|
|
|
$canClick = true;
|
|
|
$relPath = api_get_path(REL_PATH);
|
|
|
$html .= <<<HTML
|
|
@@ -641,15 +628,15 @@ class ScormAnswerHotspot extends Answer
|
|
|
</td>
|
|
|
<tr>
|
|
|
HTML;
|
|
|
- $html .= '</table></td></tr>' . "\n";
|
|
|
+ $html .= '</table></td></tr>';
|
|
|
|
|
|
// currently the free answers cannot be displayed, so ignore the textarea
|
|
|
$html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>';
|
|
|
- return array($js,$html);
|
|
|
+
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* A SCORM item. It corresponds to a single question.
|
|
|
* This class allows export from Dokeos SCORM 1.2 format of a single question.
|
|
@@ -689,12 +676,11 @@ class ScormAssessmentItem
|
|
|
function start_page()
|
|
|
{
|
|
|
global $charset;
|
|
|
- $head = "";
|
|
|
- if( $this->standalone)
|
|
|
- {
|
|
|
- $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n";
|
|
|
- $head .= '<html>'."\n";
|
|
|
- }
|
|
|
+ $head = '';
|
|
|
+ if ($this->standalone) {
|
|
|
+ $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>';
|
|
|
+ $head .= '<html>';
|
|
|
+ }
|
|
|
return $head;
|
|
|
}
|
|
|
|
|
@@ -702,7 +688,8 @@ class ScormAssessmentItem
|
|
|
* End the XML flow, closing the </item> tag.
|
|
|
*
|
|
|
*/
|
|
|
- function end_page() {
|
|
|
+ function end_page()
|
|
|
+ {
|
|
|
if ($this->standalone) {
|
|
|
return '</html>';
|
|
|
}
|
|
@@ -716,7 +703,7 @@ class ScormAssessmentItem
|
|
|
function start_header()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- return '<head>'."\n";
|
|
|
+ return '<head>';
|
|
|
}
|
|
|
|
|
|
return '';
|
|
@@ -729,14 +716,14 @@ class ScormAssessmentItem
|
|
|
{
|
|
|
$css = '';
|
|
|
if ($this->standalone) {
|
|
|
- $css = '<style type="text/css" media="screen, projection">'."\n";
|
|
|
+ $css = '<style type="text/css" media="screen, projection">';
|
|
|
$css .= '/*<![CDATA[*/'."\n";
|
|
|
$css .= '/*]]>*/'."\n";
|
|
|
$css .= '</style>'."\n";
|
|
|
- $css .= '<style type="text/css" media="print">'."\n";
|
|
|
+ $css .= '<style type="text/css" media="print">';
|
|
|
$css .= '/*<![CDATA[*/'."\n";
|
|
|
$css .= '/*]]>*/'."\n";
|
|
|
- $css .= '</style>'."\n";
|
|
|
+ $css .= '</style>';
|
|
|
}
|
|
|
return $css;
|
|
|
}
|
|
@@ -747,7 +734,7 @@ class ScormAssessmentItem
|
|
|
function end_header()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- return '</head>'."\n";
|
|
|
+ return '</head>';
|
|
|
}
|
|
|
|
|
|
return '';
|
|
@@ -759,20 +746,21 @@ class ScormAssessmentItem
|
|
|
function start_js()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- return '<script type="text/javascript" language="javascript">'."\n";
|
|
|
+ return '<script>';
|
|
|
}
|
|
|
return '';
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Common JS functions
|
|
|
*/
|
|
|
function common_js()
|
|
|
{
|
|
|
$js = file_get_contents('../lp/js/api_wrapper.js');
|
|
|
- $js .= 'var questions = new Array();' . "\n";
|
|
|
- $js .= 'var questions_answers = new Array();' . "\n";
|
|
|
- $js .= 'var questions_answers_correct = new Array();' . "\n";
|
|
|
- $js .= 'var questions_types = new Array();' . "\n";
|
|
|
+ $js .= 'var questions = new Array();';
|
|
|
+ $js .= 'var questions_answers = new Array();';
|
|
|
+ $js .= 'var questions_answers_correct = new Array();';
|
|
|
+ $js .= 'var questions_types = new Array();';
|
|
|
$js .= "\n" .
|
|
|
'/**
|
|
|
* Assigns any event handler to any element
|
|
@@ -810,10 +798,10 @@ class ScormAssessmentItem
|
|
|
}'."\n\n";
|
|
|
|
|
|
$js .= '';
|
|
|
- //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n";
|
|
|
- //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n";
|
|
|
$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
|
|
|
- if($this->standalone){return $js. "\n";}
|
|
|
+ if ($this->standalone) {
|
|
|
+ return $js."\n";
|
|
|
+ }
|
|
|
return '';
|
|
|
}
|
|
|
|
|
@@ -823,8 +811,11 @@ class ScormAssessmentItem
|
|
|
*/
|
|
|
function end_js()
|
|
|
{
|
|
|
- if($this->standalone){return '</script>'. "\n";}
|
|
|
- return '';
|
|
|
+ if ($this->standalone) {
|
|
|
+ return '</script>';
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -834,7 +825,7 @@ class ScormAssessmentItem
|
|
|
function start_body()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- return '<body>'."\n".'<form id="dokeos_scorm_form" method="post" action="">'."\n";
|
|
|
+ return '<body><form id="dokeos_scorm_form" method="post" action="">';
|
|
|
}
|
|
|
|
|
|
return '';
|
|
@@ -847,7 +838,7 @@ class ScormAssessmentItem
|
|
|
function end_body()
|
|
|
{
|
|
|
if ($this->standalone) {
|
|
|
- return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'."\n";
|
|
|
+ return '<br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
|
|
|
}
|
|
|
|
|
|
return '';
|
|
@@ -865,7 +856,6 @@ class ScormAssessmentItem
|
|
|
{
|
|
|
$js = $html = '';
|
|
|
list($js,$html) = $this->question->export();
|
|
|
- //list($js,$html) = $this->question->answer->export();
|
|
|
if ($this->standalone) {
|
|
|
$res = $this->start_page()
|
|
|
. $this->start_header()
|
|
@@ -876,16 +866,12 @@ class ScormAssessmentItem
|
|
|
. $this->end_js()
|
|
|
. $this->end_header()
|
|
|
. $this->start_body()
|
|
|
- // .$this->answer->imsExportResponsesDeclaration($this->questionIdent)
|
|
|
- // . $this->start_item_body()
|
|
|
- // . $this->answer->scormExportResponses($this->questionIdent, $this->question->question, $this->question->description, $this->question->picture)
|
|
|
- // .$question
|
|
|
- . $html
|
|
|
+ . $html
|
|
|
. $this->end_body()
|
|
|
. $this->end_page();
|
|
|
return $res;
|
|
|
} else {
|
|
|
- return array($js,$html);
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -926,13 +912,12 @@ class ScormSection
|
|
|
return $xml;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Constructor.
|
|
|
* @param Exercise $exe The Exercise instance to export
|
|
|
* @author Amand Tihon <amand@alrj.org>
|
|
|
*/
|
|
|
- function ScormSection($exe)
|
|
|
+ public function __construct($exe)
|
|
|
{
|
|
|
$this->exercise = $exe;
|
|
|
}
|
|
@@ -946,8 +931,8 @@ class ScormSection
|
|
|
function start_page()
|
|
|
{
|
|
|
global $charset;
|
|
|
- $head = $foot = "";
|
|
|
- $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?>' . "\n".'<html>'."\n";
|
|
|
+ $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>';
|
|
|
+
|
|
|
return $head;
|
|
|
}
|
|
|
|
|
@@ -965,7 +950,7 @@ class ScormSection
|
|
|
*/
|
|
|
function start_header()
|
|
|
{
|
|
|
- return '<head>'. "\n";
|
|
|
+ return '<head>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -973,14 +958,14 @@ class ScormSection
|
|
|
*/
|
|
|
function css()
|
|
|
{
|
|
|
- $css = '<style type="text/css" media="screen, projection">'."\n";
|
|
|
+ $css = '<style type="text/css" media="screen, projection">';
|
|
|
$css .= '/*<![CDATA[*/'."\n";
|
|
|
$css .= '/*]]>*/'."\n";
|
|
|
$css .= '</style>'."\n";
|
|
|
- $css .= '<style type="text/css" media="print">'."\n";
|
|
|
+ $css .= '<style type="text/css" media="print">';
|
|
|
$css .= '/*<![CDATA[*/'."\n";
|
|
|
$css .= '/*]]>*/'."\n";
|
|
|
- $css .= '</style>'."\n";
|
|
|
+ $css .= '</style>';
|
|
|
|
|
|
return $css;
|
|
|
}
|
|
@@ -990,7 +975,7 @@ class ScormSection
|
|
|
*/
|
|
|
function end_header()
|
|
|
{
|
|
|
- return '</head>'. "\n";
|
|
|
+ return '</head>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -999,7 +984,7 @@ class ScormSection
|
|
|
*/
|
|
|
function start_js()
|
|
|
{
|
|
|
- return '<script type="text/javascript" language="javascript">'. "\n";
|
|
|
+ return '<script>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1058,8 +1043,6 @@ class ScormSection
|
|
|
'."\n";
|
|
|
|
|
|
$js .= '';
|
|
|
- //$js .= 'addEvent(window,\'load\',loadPage,false);'."\n";
|
|
|
- //$js .= 'addEvent(window,\'unload\',unloadPage,false);'."\n";
|
|
|
$js .= 'addEvent(window,\'load\',addListeners,false);'."\n";
|
|
|
return $js. "\n";
|
|
|
}
|
|
@@ -1068,8 +1051,9 @@ class ScormSection
|
|
|
* End the itemBody part.
|
|
|
*
|
|
|
*/
|
|
|
- function end_js() {
|
|
|
- return '</script>'. "\n";
|
|
|
+ function end_js()
|
|
|
+ {
|
|
|
+ return '</script>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1078,10 +1062,10 @@ class ScormSection
|
|
|
*/
|
|
|
function start_body()
|
|
|
{
|
|
|
- return '<body>'. "\n".
|
|
|
- '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>\n".
|
|
|
- '<form id="dokeos_scorm_form" method="post" action="">'."\n".
|
|
|
- '<table width="100%">'."\n";
|
|
|
+ return '<body>'.
|
|
|
+ '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>".
|
|
|
+ '<form id="dokeos_scorm_form" method="post" action="">'.
|
|
|
+ '<table width="100%">';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1090,7 +1074,7 @@ class ScormSection
|
|
|
*/
|
|
|
function end_body()
|
|
|
{
|
|
|
- return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form>'."\n".'</body>'. "\n";
|
|
|
+ return '</table><br /><input type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1111,8 +1095,7 @@ class ScormSection
|
|
|
. '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n";
|
|
|
}
|
|
|
|
|
|
- list($js,$html) = $this->export_questions();
|
|
|
- //list($js,$html) = $this->question->answer->export();
|
|
|
+ list($js, $html) = $this->export_questions();
|
|
|
$res = $this->start_page()
|
|
|
. $this->start_header()
|
|
|
. $this->css()
|
|
@@ -1122,11 +1105,7 @@ class ScormSection
|
|
|
. $this->end_js()
|
|
|
. $this->end_header()
|
|
|
. $this->start_body()
|
|
|
- // .$this->answer->imsExportResponsesDeclaration($this->questionIdent)
|
|
|
- // . $this->start_item_body()
|
|
|
- // . $this->answer->scormExportResponses($this->questionIdent, $this->question->question, $this->question->description, $this->question->picture)
|
|
|
- // .$question
|
|
|
- .$html
|
|
|
+ . $html
|
|
|
. $this->end_body()
|
|
|
. $this->end_page();
|
|
|
|
|
@@ -1147,6 +1126,7 @@ class ScormSection
|
|
|
$html .= $htmltmp."\n";
|
|
|
++$js_id;
|
|
|
}
|
|
|
- return array($js,$html);
|
|
|
+
|
|
|
+ return array($js, $html);
|
|
|
}
|
|
|
}
|