diff --git a/main/exercise/Annotation.php b/main/exercise/Annotation.php
index 49c91690a3..810bd80724 100644
--- a/main/exercise/Annotation.php
+++ b/main/exercise/Annotation.php
@@ -27,12 +27,11 @@ class Annotation extends Question
}
/**
- * @param FormValidator $form
- * @param int $fck_config
+ * @inheritdoc
*/
- public function createForm(&$form, $fck_config = 0)
+ public function createForm(&$form, $exercise)
{
- parent::createForm($form, $fck_config);
+ parent::createForm($form, $exercise);
$form->addElement(
'number',
@@ -115,11 +114,11 @@ class Annotation extends Question
}
/**
- * @param FormValidator $form
+ * @inheritdoc
*/
- public function processAnswersCreation($form)
+ public function processAnswersCreation($form, $exercise)
{
$this->weighting = $form->getSubmitValue('weighting');
- $this->save();
+ $this->save($exercise);
}
}
diff --git a/main/exercise/Draggable.php b/main/exercise/Draggable.php
index fa6d63829d..7ae71034b0 100644
--- a/main/exercise/Draggable.php
+++ b/main/exercise/Draggable.php
@@ -29,9 +29,7 @@ class Draggable extends Question
$defaults = array();
$nb_matches = $nb_options = 2;
$matches = array();
-
$answer = null;
-
if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
@@ -174,29 +172,24 @@ class Draggable extends Question
}
/**
- * Abstract function which creates the form to create / edit the answers of the question
- * @param FormValidator $form
+ * @inheritdoc
*/
- public function processAnswersCreation($form)
+ public function processAnswersCreation($form, $exercise)
{
$this->extra = $form->exportValue('orientation');
$nb_matches = $form->getSubmitValue('nb_matches');
$this->weighting = 0;
$position = 0;
-
$objAnswer = new Answer($this->id);
-
// Insert the options
for ($i = 1; $i <= $nb_matches; ++$i) {
$position++;
-
$objAnswer->createAnswer($position, 0, '', 0, $position);
}
// Insert the answers
for ($i = 1; $i <= $nb_matches; ++$i) {
$position++;
-
$answer = $form->getSubmitValue('answer['.$i.']');
$matches = $form->getSubmitValue('matches['.$i.']');
$weighting = $form->getSubmitValue('weighting['.$i.']');
@@ -211,19 +204,15 @@ class Draggable extends Question
}
$objAnswer->save();
- $this->save();
+ $this->save($exercise);
}
/**
- * Shows question title an description
- * @param string $feedback_type
- * @param int $counter
- * @param float $score
- * @return string
+ * @inheritdoc
*/
- public function return_header($feedback_type = null, $counter = null, $score = null)
+ public function return_header($exercise, $counter = null, $score = null)
{
- $header = parent::return_header($feedback_type, $counter, $score);
+ $header = parent::return_header($exercise, $counter, $score);
$header .= '
| ' . get_lang('ElementList').' |
diff --git a/main/exercise/MatchingDraggable.php b/main/exercise/MatchingDraggable.php
index ce51c4c9c3..98495cd6ce 100644
--- a/main/exercise/MatchingDraggable.php
+++ b/main/exercise/MatchingDraggable.php
@@ -17,7 +17,6 @@ class MatchingDraggable extends Question
public function __construct()
{
parent::__construct();
-
$this->type = MATCHING_DRAGGABLE;
$this->isContent = $this->getIsContent();
}
@@ -30,10 +29,8 @@ class MatchingDraggable extends Question
$defaults = array();
$nb_matches = $nb_options = 2;
$matches = array();
-
$answer = null;
$counter = 1;
-
if (isset($this->id)) {
$answer = new Answer($this->id);
$answer->read();
@@ -60,7 +57,7 @@ class MatchingDraggable extends Question
$nb_matches++;
$nb_options++;
}
- } else if (!empty($this->id)) {
+ } elseif (!empty($this->id)) {
if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
@@ -224,16 +221,14 @@ class MatchingDraggable extends Question
}
/**
- * Process the creation of answers
- * @param FormValidator $form
+ * @inheritdoc
*/
- public function processAnswersCreation($form)
+ public function processAnswersCreation($form, $exercise)
{
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
$this->weighting = 0;
$position = 0;
-
$objAnswer = new Answer($this->id);
// Insert the options
@@ -260,19 +255,15 @@ class MatchingDraggable extends Question
);
}
$objAnswer->save();
- $this->save();
+ $this->save($exercise);
}
/**
- * Shows question title an description
- * @param string $feedback_type
- * @param int $counter
- * @param float $score
- * @return string The header HTML code
+ * @inheritdoc
*/
- public function return_header($feedback_type = null, $counter = null, $score = null)
+ public function return_header($exercise, $counter = null, $score = null)
{
- $header = parent::return_header($feedback_type, $counter, $score);
+ $header = parent::return_header($exercise, $counter, $score);
$header .= '
| ' . get_lang('ElementList').' |
diff --git a/main/exercise/ReadingComprehension.php b/main/exercise/ReadingComprehension.php
index ea45eb5c4e..389cf30148 100755
--- a/main/exercise/ReadingComprehension.php
+++ b/main/exercise/ReadingComprehension.php
@@ -136,7 +136,7 @@ class ReadingComprehension extends UniqueAnswer
/**
* @inheritdoc
*/
- public function createForm(&$form)
+ public function createForm(&$form, $exercise)
{
// Categories
$tabCat = TestCategory::getCategoriesIdAndName();
diff --git a/main/exercise/UniqueAnswerImage.php b/main/exercise/UniqueAnswerImage.php
index 14c19f3892..b6f4d1ebec 100644
--- a/main/exercise/UniqueAnswerImage.php
+++ b/main/exercise/UniqueAnswerImage.php
@@ -274,7 +274,10 @@ class UniqueAnswerImage extends UniqueAnswer
$form->setConstants(array('nb_answers' => $numberAnswers));
}
- public function processAnswersCreation($form)
+ /**
+ * @inheritdoc
+ */
+ public function processAnswersCreation($form, $exercise)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form->getSubmitValue('correct');
@@ -361,12 +364,6 @@ class UniqueAnswerImage extends UniqueAnswer
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
- $this->save();
+ $this->save($exercise);
}
-
- public function return_header($feedback_type = null, $counter = null, $score = null)
- {
- return parent::return_header($feedback_type, $counter, $score);
- }
-
}
diff --git a/main/exercise/admin.php b/main/exercise/admin.php
index 514f56207b..9d830ae8c8 100755
--- a/main/exercise/admin.php
+++ b/main/exercise/admin.php
@@ -292,9 +292,15 @@ if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) {
- $interbreadcrumb[] = ["url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->selectTitle(true)];
+ $interbreadcrumb[] = [
+ "url" => "admin.php?exerciseId=".$objExercise->id,
+ "name" => $objExercise->selectTitle(true),
+ ];
} else {
- $interbreadcrumb[] = ["url" => "#", "name" => $objExercise->selectTitle(true)];
+ $interbreadcrumb[] = [
+ "url" => "#",
+ "name" => $objExercise->selectTitle(true),
+ ];
}
// shows a link to go back to the question pool
@@ -314,7 +320,6 @@ if ($modifyIn == 'thisExercise') {
}
}
$htmlHeadXtra[] = '';
} else {
diff --git a/main/exercise/result.php b/main/exercise/result.php
index 9ee352c0c3..ba56e84324 100755
--- a/main/exercise/result.php
+++ b/main/exercise/result.php
@@ -74,7 +74,7 @@ if ($show_headers) {
$message = Session::read('attempt_remaining');
Session::erase('attempt_remaining');
-ExerciseLib::display_question_list_by_attempt(
+ExerciseLib::displayQuestionListByAttempt(
$objExercise,
$id,
false,
diff --git a/main/exercise/unique_answer.class.php b/main/exercise/unique_answer.class.php
index d869637a75..5d0391072d 100755
--- a/main/exercise/unique_answer.class.php
+++ b/main/exercise/unique_answer.class.php
@@ -316,11 +316,9 @@ class UniqueAnswer extends Question
}
/**
- * Receives the unique answer question type creation form data and creates
- * or updates the answers from that question
- * @param FormValidator $form
+ * @inheritdoc
*/
- public function processAnswersCreation($form)
+ public function processAnswersCreation($form, $exercise)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form->getSubmitValue('correct');
@@ -405,27 +403,23 @@ class UniqueAnswer extends Question
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
- $this->save();
+ $this->save($exercise);
}
/**
- * Helper function to print the column titles in the answers edition form
- * @param null $feedback_type The type of feedback influences what columns are shown to the editor
- * @param null $counter The number of answers to show, in case there should be pagination
- * @param null $score The maximum score for the question
- * @return string HTML string for a table header + a wrapper before it
+ * @inheritdoc
*/
public function return_header(
- $feedback_type = null,
+ $exercise,
$counter = null,
$score = null
) {
- $header = parent::return_header($feedback_type, $counter, $score);
+ $header = parent::return_header($exercise, $counter, $score);
$header .= '
- | ' . get_lang("Choice").' |
- ' . get_lang("ExpectedChoice").' |
- ' . get_lang("Answer").' | ';
+ '.get_lang("Choice").' |
+ '.get_lang("ExpectedChoice").' |
+ '.get_lang("Answer").' | ';
$header .= ''.get_lang("Comment").' | ';
$header .= '
';
diff --git a/main/exercise/unique_answer_no_option.class.php b/main/exercise/unique_answer_no_option.class.php
index 974f2565a5..754b24d4dd 100755
--- a/main/exercise/unique_answer_no_option.class.php
+++ b/main/exercise/unique_answer_no_option.class.php
@@ -284,11 +284,9 @@ class UniqueAnswerNoOption extends Question
}
/**
- * Function which creates the form to create / edit the answers of the question
- * @param the formvalidator instance
- * @param the answers number to display
- */
- function processAnswersCreation($form)
+ * @inheritdoc
+ */
+ public function processAnswersCreation($form, $exercise)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form->getSubmitValue('correct');
@@ -398,17 +396,20 @@ class UniqueAnswerNoOption extends Question
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
- $this->save();
+ $this->save($exercise);
}
- function return_header($feedback_type = null, $counter = null, $score = null)
+ /**
+ * @inheritdoc
+ */
+ public function return_header($exercise, $counter = null, $score = null)
{
- $header = parent::return_header($feedback_type, $counter, $score);
+ $header = parent::return_header($exercise, $counter, $score);
$header .= '
| '.get_lang("Choice").' |
- '. get_lang("ExpectedChoice").' |
- '. get_lang("Answer").' | ';
+ '.get_lang("ExpectedChoice").' |
+ '.get_lang("Answer").' | ';
$header .= ''.get_lang("Comment").' | ';
$header .= '
';
diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php
index bebe65c607..45b8c0e6b2 100644
--- a/main/inc/lib/exercise.lib.php
+++ b/main/inc/lib/exercise.lib.php
@@ -3630,7 +3630,7 @@ HOTSPOT;
* @param bool $save_user_result save users results (true) or just show the results (false)
* @param string $remainingMessage
*/
- public static function display_question_list_by_attempt(
+ public static function displayQuestionListByAttempt(
$objExercise,
$exe_id,
$save_user_result = false,
@@ -3817,7 +3817,6 @@ HOTSPOT;
// Category report
$category_was_added_for_this_test = false;
-
if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
if (!isset($category_list[$objQuestionTmp->category]['score'])) {
$category_list[$objQuestionTmp->category]['score'] = 0;
@@ -3851,7 +3850,8 @@ HOTSPOT;
$category_list['none']['total'] += $my_total_weight;
}
- if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0
+ if ($objExercise->selectPropagateNeg() == 0 &&
+ $my_total_score < 0
) {
$my_total_score = 0;
}
@@ -3866,7 +3866,7 @@ HOTSPOT;
}
if ($show_results) {
- $score = array(
+ $score = [
'result' => self::show_score(
$my_total_score,
$my_total_weight,
@@ -3877,9 +3877,9 @@ HOTSPOT;
'score' => $my_total_score,
'weight' => $my_total_weight,
'comments' => $comnt,
- );
+ ];
} else {
- $score = array();
+ $score = [];
}
if (in_array($objQuestionTmp->type, [FREE_ANSWER, ORAL_EXPRESSION])) {
@@ -3895,7 +3895,7 @@ HOTSPOT;
$question_content = '';
// Shows question title an description
$question_content .= $objQuestionTmp->return_header(
- null,
+ $objExercise,
$counter,
$score
);
@@ -3940,6 +3940,7 @@ HOTSPOT;
"ExerciseWithFeedbackWithoutCorrectionComment"
)."
";
}
+
// Remove audio auto play from questions on results page - refs BT#7939
$exercise_content = preg_replace(
['/autoplay[\=\".+\"]+/', '/autostart[\=\".+\"]+/'],
diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php
index b97af6abd2..81dacb384a 100755
--- a/main/install/configuration.dist.php
+++ b/main/install/configuration.dist.php
@@ -386,3 +386,5 @@ $_configuration['agenda_legend'] = [
// If the MySpace page takes too long to load, you might want to remove the
// processing of generic statistics for the user. In this case set the following to true.
//$_configuration['tracking_skip_generic_data'] = false;
+// Show question feedback (requires DB change)
+//$_configuration['allow_quiz_question_feedback'] = false;