diff --git a/main/exercice/admin.php b/main/exercice/admin.php
index fdc2dcdf33..d6be2de610 100755
--- a/main/exercice/admin.php
+++ b/main/exercice/admin.php
@@ -109,6 +109,7 @@ $cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
$cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
$modifyIn = isset($modifyIn) ? $modifyIn : null;
$cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
+$_course = api_get_course_info();
/* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems
when changing the exercise settings, number of questions, etc */
@@ -186,8 +187,6 @@ if (!is_object($objExercise)) {
// Exercise can be edited in their course.
if ($objExercise->sessionId != $sessionId) {
api_not_allowed(true);
- /*header('Location: '.api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq());
- exit;*/
}
// doesn't select the exercise ID if we come from the question pool
@@ -216,7 +215,7 @@ if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
}
// checks if the object exists
- if(is_object($objQuestion)) {
+ if (is_object($objQuestion)) {
// gets the question ID
$questionId = $objQuestion->selectId();
}
@@ -225,7 +224,7 @@ if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
// if cancelling an exercise
if ($cancelExercise) {
// existing exercise
- if($exerciseId) {
+ if ($exerciseId) {
unset($modifyExercise);
} else {
// new exercise
@@ -238,14 +237,14 @@ if ($cancelExercise) {
// if cancelling question creation/modification
if ($cancelQuestion) {
// if we are creating a new question from the question pool
- if(!$exerciseId && !$questionId) {
+ if (!$exerciseId && !$questionId) {
// goes back to the question pool
header('Location: question_pool.php');
exit();
} else {
// goes back to the question viewing
- $editQuestion=$modifyQuestion;
- unset($newQuestion,$modifyQuestion);
+ $editQuestion = $modifyQuestion;
+ unset($newQuestion, $modifyQuestion);
}
}
@@ -275,6 +274,7 @@ if ($cancelAnswers) {
$editQuestion=$modifyAnswers;
unset($modifyAnswers);
}
+
$nameTools = null;
// modifies the query string that is used in the link of tool name
if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
@@ -292,16 +292,16 @@ if (!empty($gradebook) && $gradebook=='view') {
);
}
-$interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
+$interbreadcrumb[] = array("url" => "exercice.php?".api_get_cidreq(),"name" => get_lang('Exercices'));
if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) {
- $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name);
+ $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id.'&'.api_get_cidreq(), "name" => $objExercise->name);
} else {
$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
}
// shows a link to go back to the question pool
if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){
- $interbreadcrumb[]=array(
+ $interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH)."exercice/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(),
"name" => get_lang('QuestionPool')
);
@@ -309,7 +309,7 @@ if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){
// if the question is duplicated, disable the link of tool name
if ($modifyIn == 'thisExercise') {
- if($buttonBack) {
+ if ($buttonBack) {
$modifyIn='allExercises';
} else {
$noPHP_SELF=true;
@@ -332,8 +332,6 @@ function multiple_answer_true_false_onchange(variable) {
}
document.getElementById(weight_id).value = array_result[result];
}
-
-
';
$htmlHeadXtra[] = "
@@ -523,7 +521,6 @@ if ($newQuestion || $editQuestion) {
if ($newQuestion == 'yes') {
$objExercise->edit_exercise_in_lp = true;
}
-
require 'question_admin.inc.php';
}
diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php
index 379269df7e..e2fa718c29 100755
--- a/main/exercice/hotspot_admin.inc.php
+++ b/main/exercice/hotspot_admin.inc.php
@@ -1,14 +1,13 @@
selectTitle();
$answerType = $objQuestion->selectType();
$pictureName = $objQuestion->selectPicture();
$debug = 0; // debug variable to get where we are
-
$okPicture = empty($pictureName) ? false : true;
-// if we come from the warning box "this question is used in serveral exercises"
+// if we come from the warning box "this question is used in several exercises"
+
if ($modifyIn) {
if ($debug > 0) {
echo '$modifyIn was set' . "
\n";
}
- // if the user has chosed to modify the question only in the current exercise
+ // if the user has chosen to modify the question only in the current exercise
if ($modifyIn == 'thisExercise') {
// duplicates the question
$questionId = $objQuestion->duplicate();
@@ -53,7 +52,6 @@ if ($modifyIn) {
$objAnswer->duplicate($questionId);
// construction of the duplicated Answers
-
$objAnswer = new Answer($questionId);
}
$color = unserialize($color);
@@ -69,17 +67,16 @@ if ($modifyIn) {
$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $exerciseId;
// the answer form has been submitted
+$submitAnswers = isset($_POST['submitAnswers']) ? true : false;
+$buttonBack = isset($_POST['buttonBack']) ? true : false;
+$nbrAnswers = isset($_POST['nbrAnswers']) ? intval($_POST['nbrAnswers']) : 0;
-$submitAnswers = isset($submitAnswers) ? $submitAnswers : false;
-$buttonBack = isset($buttonBack) ? $buttonBack : false;
-$nbrAnswers = isset($nbrAnswers) ? $nbrAnswers : 0;
if ($submitAnswers || $buttonBack) {
-
if ($answerType == HOT_SPOT) {
-
if ($debug > 0) {
echo '$submitAnswers or $buttonBack was set' . "
\n";
}
+
$questionWeighting = $nbrGoodAnswers = 0;
for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) {
@@ -88,6 +85,7 @@ if ($submitAnswers || $buttonBack) {
$reponse[$i] = trim($reponse[$i]);
$comment[$i] = trim($comment[$i]);
$weighting[$i] = $weighting[$i]; // it can be float
+
// checks if field is empty
if (empty($reponse[$i]) && $reponse[$i] != '0') {
$msgErr = get_lang('HotspotGiveAnswers');
@@ -124,7 +122,15 @@ if ($submitAnswers || $buttonBack) {
$questionWeighting+=$weighting[$i];
}
// creates answer
- $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i]);
+ $objAnswer->createAnswer(
+ $reponse[$i],
+ '',
+ $comment[$i],
+ $weighting[$i],
+ $i,
+ $hotspot_coordinates[$i],
+ $hotspot_type[$i]
+ );
} // end for()
// saves the answers into the data base
$objAnswer->save();
@@ -141,7 +147,6 @@ if ($submitAnswers || $buttonBack) {
echo '$modifyIn was set - end' . "
\n";
}
} else {
-
if ($debug > 0) {
echo '$submitAnswers or $buttonBack was set' . "
\n";
}
@@ -164,23 +169,25 @@ if ($submitAnswers || $buttonBack) {
$comment[$i] = trim($comment[$i]);
$weighting[$i] = $weighting[$i];
- if (empty($threadhold1[$i]))
+ if (empty($threadhold1[$i])) {
$threadhold1_str = 0;
- else
+ } else {
$threadhold1_str = intval($threadhold1[$i]);
+ }
- if (empty($threadhold2[$i]))
+ if (empty($threadhold2[$i])) {
$threadhold2_str = 0;
- else
+ } else {
$threadhold2_str = intval($threadhold2[$i]);
+ }
- if (empty($threadhold3[$i]))
+ if (empty($threadhold3[$i])) {
$threadhold3_str = 0;
- else
+ } else {
$threadhold3_str = intval($threadhold3[$i]);
+ }
$threadhold_total = $threadhold1_str . ';' . $threadhold2_str . ';' . $threadhold3_str;
- //echo '
';print_r($_POST);echo ''; if ($try[$i] == 'on') { $try_str = 1; @@ -207,9 +214,6 @@ if ($submitAnswers || $buttonBack) { } $destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; - // the last answer is the IF NO ERROR section witch has not have the reponse, weight and coordinates values - //if ($i!=$nbrAnswers && !($answerType==HOT_SPOT_DELINEATION)) - // { // checks if field is empty if (empty($reponse[$i]) && $reponse[$i] != '0') { $msgErr = get_lang('HotspotGiveAnswers'); @@ -281,11 +285,29 @@ if ($submitAnswers || $buttonBack) { $questionWeighting+=$weighting[$i]; } // creates answer - $objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i], $destination[$i]); + $objAnswer->createAnswer( + $reponse[$i], + '', + $comment[$i], + $weighting[$i], + $i, + $hotspot_coordinates[$i], + $hotspot_type[$i], + $destination[$i] + ); } // end for() // saves the answers into the data base - $objAnswer->createAnswer('noerror', '', $comment_noerror, '0', $nbrAnswers + 1, null, 'noerror', $destination_noerror); + $objAnswer->createAnswer( + 'noerror', + '', + $comment_noerror, + '0', + $nbrAnswers + 1, + null, + 'noerror', + $destination_noerror + ); $objAnswer->save(); // sets the total weighting of the question @@ -301,7 +323,6 @@ if ($submitAnswers || $buttonBack) { } if ($modifyAnswers) { - if ($debug > 0) { echo str_repeat(' ', 0) . '$modifyAnswers is set' . "