Fixing SCORM export when using the Exact question

skala
Julio Montoya 16 years ago
parent fd9bed7680
commit 72ee6c4010
  1. 5
      main/exercice/exercise_show.php
  2. 42
      main/exercice/export/scorm/scorm_classes.php
  3. 3
      main/exercice/export/scorm/scorm_export.php
  4. 46
      main/newscorm/js/api_wrapper.js

@ -119,10 +119,7 @@ if (isset($_SESSION['gradebook'])){
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook')
);
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('Gradebook'));
}
$fromlink = '';
if($origin=='user_course') {

@ -82,6 +82,10 @@ class ScormQuestion extends Question
break;
case HOTSPOT:
$this->answer = new ScormAnswerHotspot($this->id);
$this->answer->questionJSId = $this->js_id;
break;
case MULTIPLE_ANSWER_COMBINATION:
$this->answer = new ScormAnswerMultipleChoice($this->id, false);
$this->answer->questionJSId = $this->js_id;
break;
default :
@ -170,8 +174,10 @@ class ScormAnswerMultipleChoice extends Answer
$type = $this->getQuestionType();
$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
if ($type == MCMA)
{
//not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM
//if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) {
if ($type == MCMA ) {
//$questionTypeLang = get_lang('MultipleChoiceMultipleAnswers');
$id = 1;
$jstmp = '';
@ -198,11 +204,35 @@ class ScormAnswerMultipleChoice extends Answer
}
$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
$js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
if ($type == MCMA) {
$js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n";
} else {
$js .= 'questions_types['.$this->questionJSId.'] = \'exact\';'."\n";
}
$js .= $jstmpw;
}
else
{
} elseif ($type == MULTIPLE_ANSWER_COMBINATION) {
//To this items we show the ThisItemIsNotExportable
$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>' . "\n"
. '<td>' . "\n"
. '<textarea name="question_'.$qId.'_free" id="question_'.$qId.'_free" rows="20" cols="100"></textarea>' . "\n"
. '</td>' . "\n"
. '</tr>' . "\n";
$html .= '</table></td></tr>' . "\n";
// 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_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.'][1] = 0;'.";\n";
$js .= $jstmpw;
return array($js,$html);
} else {
//$questionTypeLang = get_lang('MultipleChoiceUniqueAnswer');
$id = 1;
$jstmp = '';

@ -612,8 +612,7 @@ class ScormSection
function export_exercise($exerciseId, $standalone=true)
{
$exercise = new Exercise();
if (! $exercise->read($exerciseId))
{
if (! $exercise->read($exerciseId)) {
return '';
}
$ims = new ScormSection($exercise);

@ -629,6 +629,52 @@ function checkAnswers(interrupted)
//{
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
//}
} else if(type == 'exact') {
// not yet implemented see scorm_classes.php ScormAnswerMultipleChoice::export() function
/*
var interactionType = 'exact';
var myScore = 0;
var real_answers = new Array();
for(var j=0; j<questions_answers[idQuestion].length;j++) {
var idAnswer = questions_answers[idQuestion][j];
var answer = document.getElementById('question_'+(idQuestion)+'_multiple_'+(idAnswer));
if (answer.checked == true) {
if(questions_answers_ponderation[idQuestion][idAnswer] != 0 ) {
real_answers[j] = true;
} else {
real_answers[j] = false;
}
} else {
if(questions_answers_ponderation[idQuestion][idAnswer] != 0) {
real_answers[j] = false;
} else {
real_answers[j] = true;
}
}
//alert(real_answers[j] +' ' + answer.checked + ' ' + questions_answers_ponderation[idQuestion][idAnswer]);
}
var final_answer = true;
for(var z=0; z<real_answers.length ;z++) {
if (real_answers[z] == false) {
final_answer = false;
}
}
if (final_answer == true) {
//getting only the first score where we save the weight of all the question
myScore += questions_answers_ponderation[idQuestion][1];
}
interactionScore = myScore;
//correct responses work by pattern, see SCORM Runtime Env Doc
//for(k=0;k<questions_answers_correct[idQuestion].length;k++)
//{
// interactionCorrectResponses += questions_answers_correct[idQuestion][k].toString()+',';
//}
scoreMax += questions_score_max[idQuestion];
*/
}
else
{

Loading…
Cancel
Save