diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 87092d5aaa..a5ca24bf9c 100644 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -248,20 +248,20 @@ if ($cancelQuestion) { if (isset($clone_question) && !empty($objExercise->id)) { $old_question_obj = Question::read($clone_question); - $old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy'); - + $old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy'); + $new_id = $old_question_obj->duplicate(); $new_question_obj = Question::read($new_id); $new_question_obj->addToList($exerciseId); - + // This should be moved to the duplicate function $new_answer_obj = new Answer($clone_question); $new_answer_obj->read(); $new_answer_obj->duplicate($new_id); - + //Reloading tne $objExercise obj $objExercise->read($objExercise->id); - + header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id); exit; } @@ -309,8 +309,8 @@ if ($modifyIn == 'thisExercise') { $noPHP_SELF=true; } } -$htmlHeadXtra[] = ''; @@ -443,7 +443,7 @@ function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) Display::display_header($nameTools,'Exercise'); $course_id = api_get_course_int_id(); - + $show_quiz_edition = true; if (isset($exerciseId) && !empty($exerciseId)) { $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); @@ -477,11 +477,15 @@ if ($inATest) { } $maxScoreAllQuestions = 0; - foreach ($objExercise->questionList as $q) { - $oQ = Question::read($q); - $maxScoreAllQuestions += $oQ->selectWeighting(); + if (!empty($objExercise->questionList)) { + foreach ($objExercise->questionList as $q) { + $question = Question::read($q); + if ($question) { + $maxScoreAllQuestions += $question->selectWeighting(); + } + } } - echo ''.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(),$maxScoreAllQuestions).''; + echo ''.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions).''; echo ''; } else if (isset($_GET['newQuestion'])) { // we are in create a new question from question pool not in a test @@ -492,7 +496,7 @@ if ($inATest) { // If we are in question_poolbut not in an test, go back to question create in pool echo '
'; echo ''.Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).''; - echo '
'; + echo ''; } if (isset($_GET['message'])) { @@ -504,18 +508,18 @@ if (isset($_GET['message'])) { if ($newQuestion || $editQuestion) { // statement management $type = Security::remove_XSS($_REQUEST['answerType']); - echo ''; + echo ''; require 'question_admin.inc.php'; } -if (isset($_GET['hotspotadmin'])) { +if (isset($_GET['hotspotadmin'])) { if (!is_object($objQuestion)) { $objQuestion = Question :: read($_GET['hotspotadmin']); } if (!$objQuestion) { api_not_allowed(); - } - require 'hotspot_admin.inc.php'; + } + require 'hotspot_admin.inc.php'; } if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) {