diff --git a/main/exercice/answer_admin.inc.php b/main/exercice/answer_admin.inc.php
index dd7be4be23..3bbfaa861a 100755
--- a/main/exercice/answer_admin.inc.php
+++ b/main/exercice/answer_admin.inc.php
@@ -77,7 +77,7 @@ if($modifyIn)
$objAnswer=new Answer($questionId);
}
- if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
+ if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION)
{
$correct=unserialize($correct);
$reponse=unserialize($reponse);
@@ -128,13 +128,11 @@ if($modifyIn)
if($submitAnswers || $buttonBack)
{
if($debug>0){echo '$submitAnswers or $buttonBack was set'."
\n";}
- if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
- {
+ if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION) {
if($debug>0){echo ' $answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."
\n";}
$questionWeighting=$nbrGoodAnswers=0;
- for($i=1;$i <= $nbrAnswers;$i++)
- {
+ for($i=1;$i <= $nbrAnswers;$i++) {
$reponse[$i]=trim($reponse[$i]);
$comment[$i]=trim($comment[$i]);
$weighting[$i]=intval($weighting[$i]);
@@ -161,14 +159,11 @@ if($submitAnswers || $buttonBack)
{
$questionWeighting+=$weighting[$i];
}
- }
- elseif($answerType == MULTIPLE_ANSWER)
- {
+ } elseif($answerType == MULTIPLE_ANSWER) {
if($debug>0){echo str_repeat(' ',4).'$answerType is MULTIPLE_ANSWER'."
\n";}
// a bad answer can't have a positive weighting
$weighting[$i]=0-abs($weighting[$i]);
}
-
// checks if field is empty
if(empty($reponse[$i]) && $reponse[$i] != '0')
{
@@ -178,9 +173,7 @@ if($submitAnswers || $buttonBack)
$objAnswer->cancel();
break;
- }
- else
- {
+ } else {
// adds the answer into the object
$objAnswer->createAnswer($reponse[$i],$goodAnswer,$comment[$i],$weighting[$i],$i);
//added
@@ -883,19 +876,11 @@ if($modifyAnswers)
{
if($debug>0){echo str_repeat(' ',2).'$usedInSeveralExercises is untrue'."
\n";}
- if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
+ if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION)
{
if($debug>0){echo str_repeat(' ',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."
\n";}
-
-
-
?>
-
-
-
-
-
@@ -618,7 +618,8 @@ foreach ($questionList as $questionId) {
while ($real_answer = Database::fetch_array($res_answer)) {
$answer_matching[$real_answer['id']]= $real_answer['answer'];
}
-
+ $real_answers = array();
+
// We're inside *one* question. Go through each possible answer for this question
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
@@ -644,12 +645,29 @@ foreach ($questionList as $questionId) {
break;
// for multiple answers
case MULTIPLE_ANSWER :
- $studentChoice=$choice[$numAnswer];
- if($studentChoice) {
- $questionScore+=$answerWeighting;
- $totalScore+=$answerWeighting;
+ $studentChoice=$choice[$numAnswer];
+ if($studentChoice) {
+ $questionScore+=$answerWeighting;
+ $totalScore+=$answerWeighting;
+ }
+ break;
+ case MULTIPLE_ANSWER_COMBINATION :
+ $studentChoice=$choice[$numAnswer];
+
+ if ($answerCorrect == 1) {
+ if ($studentChoice) {
+ $real_answers[$answerId] = true;
+ } else {
+ $real_answers[$answerId] = false;
}
- break;
+ } else {
+ if ($studentChoice) {
+ $real_answers[$answerId] = false;
+ } else {
+ $real_answers[$answerId] = true;
+ }
+ }
+ break;
// for fill in the blanks
case FILL_IN_BLANKS :
// the question is encoded like this
@@ -810,8 +828,6 @@ foreach ($questionList as $questionId) {
$questionScore=-1;
$totalScore+=0;
}
-
-
break;
// for matching
case MATCHING :
@@ -854,7 +870,7 @@ foreach ($questionList as $questionId) {
//display answers (if not matching type, or if the answer is correct)
if ($answerType != MATCHING || $answerCorrect) {
- if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
+ if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_COMBINATION) {
if ($origin!='learnpath') {
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect);
}
@@ -894,6 +910,22 @@ foreach ($questionList as $questionId) {
}
}
} // end for that loops over all answers of the current question
+
+ //
+ if ($answerType == MULTIPLE_ANSWER_COMBINATION) {
+ $final_answer = true;
+ foreach($real_answers as $my_answer) {
+ if (!$my_answer) {
+ $final_answer = false;
+ }
+ }
+ if ($final_answer) {
+ //getting only the first score where we save the weight of all the question
+ $answerWeighting=$objAnswerTmp->selectWeighting(1);
+ $questionScore+=$answerWeighting;
+ $totalScore+=$answerWeighting;
+ }
+ }
// if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0)
// TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet
@@ -952,6 +984,16 @@ foreach ($questionList as $questionId) {
} else {
exercise_attempt($questionScore, 0 ,$quesId,$exeId,0);
}
+ } elseif ($answerType==MULTIPLE_ANSWER_COMBINATION ) {
+ if ($choice != 0) {
+ $reply = array_keys($choice);
+ for ($i=0;$i $val) {
exercise_attempt($questionScore, $val, $quesId, $exeId, $j);
diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php
index 7250e05fe5..15f60f6b2f 100755
--- a/main/exercice/exercise_show.php
+++ b/main/exercice/exercise_show.php
@@ -673,7 +673,7 @@ if ($show_results) {
$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
$questionScore=0;
- $real_answer = true;
+ $real_answers = array();
for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
$answer=$objAnswerTmp->selectAnswer($answerId);
@@ -686,17 +686,23 @@ if ($show_results) {
$ind = $row['answer'];
$choice[$ind] = 1;
}
-
- $numAnswer=$objAnswerTmp->selectAutoId($answerId);
-
- $studentChoice=$choice[$numAnswer];
- var_dump($studentChoice);
-
- if (!$studentChoice) {
- $real_answer = false;
- /*$questionScore+=$answerWeighting;
- $totalScore+=$answerWeighting;*/
+ $numAnswer=$objAnswerTmp->selectAutoId($answerId);
+ $studentChoice=$choice[$numAnswer];
+
+ if ($answerCorrect == 1) {
+ if ($studentChoice) {
+ $real_answers[$answerId] = true;
+ } else {
+ $real_answers[$answerId] = false;
+ }
+ } else {
+ if ($studentChoice) {
+ $real_answers[$answerId] = false;
+ } else {
+ $real_answers[$answerId] = true;
+ }
}
+
echo '| ';
if ($answerId==1) {
display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
@@ -706,12 +712,19 @@ if ($show_results) {
echo ' | ';
$i++;
}
- var_dump($real_answer);
- if ($real_answer) {
+
+ $final_answer = true;
+ foreach($real_answers as $my_answer) {
+ if (!$my_answer) {
+ $final_answer = false;
+ }
+ }
+ if ($final_answer) {
+ //getting only the first score where we save the weight of all the question
+ $answerWeighting=$objAnswerTmp->selectWeighting(1);
$questionScore+=$answerWeighting;
$totalScore+=$answerWeighting;
- }
-
+ }
echo '';
diff --git a/main/exercice/export/qti2/qti2_classes.php b/main/exercice/export/qti2/qti2_classes.php
index 0059601096..1b374e9429 100755
--- a/main/exercice/export/qti2/qti2_classes.php
+++ b/main/exercice/export/qti2/qti2_classes.php
@@ -25,6 +25,7 @@ require_once(api_get_path(SYS_CODE_PATH).'/exercice/answer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotspot.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/unique_answer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer.class.php');
+//require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer_combination.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/matching.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/freeanswer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'/exercice/fill_blanks.class.php');
diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php
index b05491040a..8c134ad134 100755
--- a/main/exercice/export/scorm/scorm_classes.php
+++ b/main/exercice/export/scorm/scorm_classes.php
@@ -14,6 +14,7 @@ require_once(api_get_path(SYS_CODE_PATH).'exercice/question.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/answer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/unique_answer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/multiple_answer.class.php');
+require_once(api_get_path(SYS_CODE_PATH).'exercice/multiple_answer_combination.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/fill_blanks.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/freeanswer.class.php');
require_once(api_get_path(SYS_CODE_PATH).'exercice/hotspot.class.php');
@@ -32,6 +33,11 @@ define('MATCHING', 4);
define('FREE_ANSWER', 5);
define('HOTSPOT', 6);
+define('HOT_SPOT_ORDER', 7);
+define('HOT_SPOT_DELINEATION', 8);
+define('MULTIPLE_ANSWER_COMBINATION', 9);
+
+
/**
* The ScormQuestion class is a gateway to getting the answers exported
* (the question is just an HTML text, while the answers are the most important).
|