MDL-76612 mod_quiz: Final deprecations
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
issueNumber: MDL-76612
|
||||
notes:
|
||||
mod_quiz:
|
||||
- message: >
|
||||
Final deprecations for the quiz. The following files have been removed:
|
||||
- mod/quiz/accessmanager_form.php
|
||||
- mod/quiz/accessmanager.php
|
||||
- mod/quiz/accessrule/accessrulebase.php
|
||||
- mod/quiz/attemptlib.php
|
||||
- mod/quiz/cronlib.php
|
||||
- mod/quiz/override_form.php
|
||||
- mod/quiz/renderer.php
|
||||
- mod/quiz/report/attemptsreport_form.php
|
||||
- mod/quiz/report/attemptsreport_options.php
|
||||
- mod/quiz/report/attemptsreport_table.php
|
||||
- mod/quiz/report/attemptsreport.php
|
||||
- mod/quiz/report/default.php
|
||||
type: removed
|
||||
- message: >
|
||||
Final deprecations for the quiz. The following methods have been removed:
|
||||
- mod_quiz\output\renderer::no_questions_message
|
||||
- mod_quiz\output\renderer::render_mod_quiz_links_to_other_attempts
|
||||
- mod_quiz\output\renderer::render_quiz_nav_question_button
|
||||
- mod_quiz\output\renderer::render_quiz_nav_section_heading
|
||||
- mod_quiz\structure::get_slot_tags_for_slot_id
|
||||
- mod_quiz\structure::is_display_number_customised
|
||||
type: removed
|
||||
- message: >
|
||||
Final deprecations for the quiz. The following functions have been removed:
|
||||
- quiz_has_question_use
|
||||
- quiz_update_sumgrades
|
||||
- quiz_update_all_attempt_sumgrades
|
||||
- quiz_update_all_final_grades
|
||||
- quiz_set_grade
|
||||
- quiz_save_best_grade
|
||||
- quiz_calculate_best_grade
|
||||
- quiz_calculate_best_attempt
|
||||
type: deprecated
|
||||
- message: >
|
||||
Final deprecations for the quiz. The following classes have been removed:
|
||||
- mod_quiz_overdue_attempt_updater
|
||||
- moodle_quiz_exception
|
||||
type: removed
|
||||
- message: >-
|
||||
The const quiz_statistics\calculator::TIME_TO_CACHE has been removed.
|
||||
type: removed
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -999,29 +999,11 @@ class renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a message saying that this quiz has no questions, with a button to
|
||||
* go to the edit page, if the user has the right capability.
|
||||
*
|
||||
* @param bool $canedit can the current user edit the quiz?
|
||||
* @param moodle_url $editurl URL of the edit quiz page.
|
||||
* @return string HTML to output.
|
||||
*
|
||||
* @deprecated since Moodle 4.0 MDL-71915 - please do not use this function any more.
|
||||
*/
|
||||
#[\core\attribute\deprecated('generate_no_questions_message()', since: '4.0', mdl: 'MDL-71915', final: true)]
|
||||
public function no_questions_message($canedit, $editurl) {
|
||||
debugging('no_questions_message() is deprecated, please use generate_no_questions_message() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$output = html_writer::start_tag('div', ['class' => 'card text-center mb-3']);
|
||||
$output .= html_writer::start_tag('div', ['class' => 'card-body']);
|
||||
|
||||
$output .= $this->notification(get_string('noquestions', 'quiz'), 'warning', false);
|
||||
if ($canedit) {
|
||||
$output .= $this->single_button($editurl, get_string('editquiz', 'quiz'), 'get');
|
||||
}
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('div');
|
||||
|
||||
return $output;
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1479,38 +1461,26 @@ class renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated version of render_links_to_other_attempts.
|
||||
*
|
||||
* @param links_to_other_attempts $links
|
||||
* @return string HTML fragment.
|
||||
* @deprecated since Moodle 4.2. Please use render_links_to_other_attempts instead.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated('render_links_to_other_attempts()', since: '4.2', mdl: 'MDL-76614', final: true)]
|
||||
protected function render_mod_quiz_links_to_other_attempts(links_to_other_attempts $links) {
|
||||
return $this->render_links_to_other_attempts($links);
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated version of render_navigation_question_button.
|
||||
*
|
||||
* @param navigation_question_button $button
|
||||
* @return string HTML fragment.
|
||||
* @deprecated since Moodle 4.2. Please use render_links_to_other_attempts instead.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
* @deprecated since Moodle 4.2. Please use render_navigation_question_button instead.
|
||||
*/
|
||||
#[\core\attribute\deprecated('render_navigation_question_button()', since: '4.2', mdl: 'MDL-76614', final: true)]
|
||||
protected function render_quiz_nav_question_button(navigation_question_button $button) {
|
||||
return $this->render_navigation_question_button($button);
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated version of render_navigation_section_heading.
|
||||
*
|
||||
* @param navigation_section_heading $heading the heading.
|
||||
* @return string HTML fragment.
|
||||
* @deprecated since Moodle 4.2. Please use render_links_to_other_attempts instead.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
* @deprecated since Moodle 4.2. Please use render_navigation_section_heading instead.
|
||||
*/
|
||||
#[\core\attribute\deprecated('render_navigation_section_heading()', since: '4.2', mdl: 'MDL-76614', final: true)]
|
||||
protected function render_quiz_nav_section_heading(navigation_section_heading $heading) {
|
||||
return $this->render_navigation_section_heading($heading);
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,17 +179,12 @@ class structure {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the question number is customised.
|
||||
*
|
||||
* @param int $slotid
|
||||
* @return bool
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
* @deprecated since 4.2. $slot->displayednumber is no longer used. If you need this,
|
||||
* use isset(...->displaynumber), but this method was not used.
|
||||
*/
|
||||
#[\core\attribute\deprecated('isset(...->displaynumber)()', since: '4.2', mdl: 'MDL-77656', final: true)]
|
||||
public function is_display_number_customised(int $slotid): bool {
|
||||
$slotobj = $this->get_slot_by_id($slotid);
|
||||
return isset($slotobj->displaynumber);
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1659,13 +1654,6 @@ class structure {
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 4.0 MDL-71573
|
||||
*/
|
||||
public function get_slot_tags_for_slot_id() {
|
||||
throw new \coding_exception(__FUNCTION__ . '() has been removed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a random question to the quiz at a given point.
|
||||
*
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Library code used by quiz cron.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2012 the Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/quiz/deprecatedlib.php');
|
||||
+20
-227
@@ -22,279 +22,72 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use mod_quiz\access_manager;
|
||||
use mod_quiz\quiz_settings;
|
||||
use mod_quiz\task\update_overdue_attempts;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Verify that the question exists, and the user has permission to use it.
|
||||
*
|
||||
* @deprecated in 4.1 use mod_quiz\structure::has_use_capability(...) instead.
|
||||
*
|
||||
* @param stdClass $quiz the quiz settings.
|
||||
* @param int $slot which question in the quiz to test.
|
||||
* @return bool whether the user can use this question.
|
||||
* @deprecated in 4.1 use mod_quiz\structure::has_use_capability(...) instead. MDL-76898
|
||||
*/
|
||||
#[\core\attribute\deprecated('mod_quiz\structure::has_use_capability()', since: '4.1', mdl: 'MDL-76898', final: true)]
|
||||
function quiz_has_question_use($quiz, $slot) {
|
||||
global $DB;
|
||||
|
||||
debugging('Deprecated. Please use mod_quiz\structure::has_use_capability instead.');
|
||||
|
||||
$sql = 'SELECT q.*
|
||||
FROM {quiz_slots} slot
|
||||
JOIN {question_references} qre ON qre.itemid = slot.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qre.questionbankentryid
|
||||
JOIN {question_versions} qve ON qve.questionbankentryid = qbe.id
|
||||
JOIN {question} q ON q.id = qve.questionid
|
||||
WHERE slot.quizid = ?
|
||||
AND slot.slot = ?
|
||||
AND qre.component = ?
|
||||
AND qre.questionarea = ?';
|
||||
|
||||
$question = $DB->get_record_sql($sql, [$quiz->id, $slot, 'mod_quiz', 'slot']);
|
||||
|
||||
if (!$question) {
|
||||
return false;
|
||||
}
|
||||
return question_has_capability_on($question, 'use');
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copyright 2012 the Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated since Moodle 4.2. Code moved to mod_quiz\task\update_overdue_attempts.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
class mod_quiz_overdue_attempt_updater {
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 4.2. Code moved to mod_quiz\task\update_overdue_attempts. that was.
|
||||
*/
|
||||
public function update_overdue_attempts($timenow, $processto) {
|
||||
debugging('mod_quiz_overdue_attempt_updater has been deprecated. The code wsa moved to ' .
|
||||
'mod_quiz\task\update_overdue_attempts.');
|
||||
return (new update_overdue_attempts())->update_all_overdue_attempts((int) $timenow, (int) $processto);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 4.2. Code moved to mod_quiz\task\update_overdue_attempts.
|
||||
*/
|
||||
public function get_list_of_overdue_attempts($processto) {
|
||||
debugging('mod_quiz_overdue_attempt_updater has been deprecated. The code wsa moved to ' .
|
||||
'mod_quiz\task\update_overdue_attempts.');
|
||||
return (new update_overdue_attempts())->get_list_of_overdue_attempts((int) $processto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for quiz exceptions. Just saves a couple of arguments on the
|
||||
* constructor for a moodle_exception.
|
||||
*
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 2.0
|
||||
* @deprecated since Moodle 4.2. Please just use moodle_exception.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
class moodle_quiz_exception extends moodle_exception {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param quiz_settings $quizobj the quiz the error relates to.
|
||||
* @param string $errorcode The name of the string from error.php to print.
|
||||
* @param mixed $a Extra words and phrases that might be required in the error string.
|
||||
* @param string $link The url where the user will be prompted to continue.
|
||||
* If no url is provided the user will be directed to the site index page.
|
||||
* @param string|null $debuginfo optional debugging information.
|
||||
* @deprecated since Moodle 4.2. Please just use moodle_exception.
|
||||
*/
|
||||
public function __construct($quizobj, $errorcode, $a = null, $link = '', $debuginfo = null) {
|
||||
debugging('Class moodle_quiz_exception is deprecated. ' .
|
||||
'Please use a standard moodle_exception instead.', DEBUG_DEVELOPER);
|
||||
if (!$link) {
|
||||
$link = $quizobj->view_url();
|
||||
}
|
||||
parent::__construct($errorcode, 'quiz', $link, $a, $debuginfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the sumgrades field of the quiz. This needs to be called whenever
|
||||
* the grading structure of the quiz is changed. For example if a question is
|
||||
* added or removed, or a question weight is changed.
|
||||
*
|
||||
* You should call {@see quiz_delete_previews()} before you call this function.
|
||||
*
|
||||
* @param stdClass $quiz a quiz.
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::recompute_quiz_sumgrades.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated('grade_calculator::recompute_quiz_sumgrades()', since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_update_sumgrades($quiz) {
|
||||
debugging('quiz_update_sumgrades is deprecated. ' .
|
||||
'Please use a standard grade_calculator::recompute_quiz_sumgrades instead.', DEBUG_DEVELOPER);
|
||||
quiz_settings::create($quiz->id)->get_grade_calculator()->recompute_quiz_sumgrades();
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the sumgrades field of the attempts at a quiz.
|
||||
*
|
||||
* @param stdClass $quiz a quiz.
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::recompute_all_attempt_sumgrades.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated('grade_calculator::recompute_all_attempt_sumgrades()', since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_update_all_attempt_sumgrades($quiz) {
|
||||
debugging('quiz_update_all_attempt_sumgrades is deprecated. ' .
|
||||
'Please use a standard grade_calculator::recompute_all_attempt_sumgrades instead.', DEBUG_DEVELOPER);
|
||||
quiz_settings::create($quiz->id)->get_grade_calculator()->recompute_all_attempt_sumgrades();
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the final grade at this quiz for all students.
|
||||
*
|
||||
* This function is equivalent to calling quiz_save_best_grade for all
|
||||
* users, but much more efficient.
|
||||
*
|
||||
* @param stdClass $quiz the quiz settings.
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::recompute_all_final_grades.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated('grade_calculator::recompute_all_final_grades()', since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_update_all_final_grades($quiz) {
|
||||
debugging('quiz_update_all_final_grades is deprecated. ' .
|
||||
'Please use a standard grade_calculator::recompute_all_final_grades instead.', DEBUG_DEVELOPER);
|
||||
quiz_settings::create($quiz->id)->get_grade_calculator()->recompute_all_final_grades();
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* The quiz grade is the maximum that student's results are marked out of. When it
|
||||
* changes, the corresponding data in quiz_grades and quiz_feedback needs to be
|
||||
* rescaled. After calling this function, you probably need to call
|
||||
* quiz_update_all_attempt_sumgrades, grade_calculator::recompute_all_final_grades();
|
||||
* quiz_update_grades. (At least, that is what this comment has said for years, but
|
||||
* it seems to call recompute_all_final_grades itself.)
|
||||
*
|
||||
* @param float $newgrade the new maximum grade for the quiz.
|
||||
* @param stdClass $quiz the quiz we are updating. Passed by reference so its
|
||||
* grade field can be updated too.
|
||||
* @return bool indicating success or failure.
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::update_quiz_maximum_grade.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated('grade_calculator::update_quiz_maximum_grade()', since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_set_grade($newgrade, $quiz) {
|
||||
debugging('quiz_set_grade is deprecated. ' .
|
||||
'Please use a standard grade_calculator::update_quiz_maximum_grade instead.', DEBUG_DEVELOPER);
|
||||
quiz_settings::create($quiz->id)->get_grade_calculator()->update_quiz_maximum_grade($newgrade);
|
||||
return true;
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the overall grade for a user at a quiz in the quiz_grades table
|
||||
*
|
||||
* @param stdClass $quiz The quiz for which the best grade is to be calculated and then saved.
|
||||
* @param int $userid The userid to calculate the grade for. Defaults to the current user.
|
||||
* @param array $attempts The attempts of this user. Useful if you are
|
||||
* looping through many users. Attempts can be fetched in one master query to
|
||||
* avoid repeated querying.
|
||||
* @return bool Indicates success or failure.
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::update_quiz_maximum_grade.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
* @deprecated since Moodle 4.2. Please use grade_calculator::recompute_final_grade.
|
||||
*/
|
||||
#[\core\attribute\deprecated('grade_calculator::recompute_final_grade()', since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_save_best_grade($quiz, $userid = null, $attempts = []) {
|
||||
debugging('quiz_save_best_grade is deprecated. ' .
|
||||
'Please use a standard grade_calculator::recompute_final_grade instead.', DEBUG_DEVELOPER);
|
||||
quiz_settings::create($quiz->id)->get_grade_calculator()->recompute_final_grade($userid, $attempts);
|
||||
return true;
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the overall grade for a quiz given a number of attempts by a particular user.
|
||||
*
|
||||
* @param stdClass $quiz the quiz settings object.
|
||||
* @param array $attempts an array of all the user's attempts at this quiz in order.
|
||||
* @return float the overall grade
|
||||
* @deprecated since Moodle 4.2. No direct replacement.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated(null, since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_calculate_best_grade($quiz, $attempts) {
|
||||
debugging('quiz_calculate_best_grade is deprecated with no direct replacement. It was only used ' .
|
||||
'in one place in the quiz code so this logic is now private to grade_calculator.', DEBUG_DEVELOPER);
|
||||
|
||||
switch ($quiz->grademethod) {
|
||||
|
||||
case QUIZ_ATTEMPTFIRST:
|
||||
$firstattempt = reset($attempts);
|
||||
return $firstattempt->sumgrades;
|
||||
|
||||
case QUIZ_ATTEMPTLAST:
|
||||
$lastattempt = end($attempts);
|
||||
return $lastattempt->sumgrades;
|
||||
|
||||
case QUIZ_GRADEAVERAGE:
|
||||
$sum = 0;
|
||||
$count = 0;
|
||||
foreach ($attempts as $attempt) {
|
||||
if (!is_null($attempt->sumgrades)) {
|
||||
$sum += $attempt->sumgrades;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if ($count == 0) {
|
||||
return null;
|
||||
}
|
||||
return $sum / $count;
|
||||
|
||||
case QUIZ_GRADEHIGHEST:
|
||||
default:
|
||||
$max = null;
|
||||
foreach ($attempts as $attempt) {
|
||||
if ($attempt->sumgrades > $max) {
|
||||
$max = $attempt->sumgrades;
|
||||
}
|
||||
}
|
||||
return $max;
|
||||
}
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the attempt with the best grade for a quiz
|
||||
*
|
||||
* Which attempt is the best depends on $quiz->grademethod. If the grade
|
||||
* method is GRADEAVERAGE then this function simply returns the last attempt.
|
||||
* @return stdClass The attempt with the best grade
|
||||
* @param stdClass $quiz The quiz for which the best grade is to be calculated
|
||||
* @param array $attempts An array of all the attempts of the user at the quiz
|
||||
* @deprecated since Moodle 4.2. No direct replacement.
|
||||
* @todo MDL-76612 Final deprecation in Moodle 4.6
|
||||
*/
|
||||
#[\core\attribute\deprecated(null, since: '4.2', mdl: 'MDL-76897', final: true)]
|
||||
function quiz_calculate_best_attempt($quiz, $attempts) {
|
||||
debugging('quiz_calculate_best_attempt is deprecated with no direct replacement. ' .
|
||||
'It was not used anywhere!', DEBUG_DEVELOPER);
|
||||
|
||||
switch ($quiz->grademethod) {
|
||||
|
||||
case QUIZ_ATTEMPTFIRST:
|
||||
foreach ($attempts as $attempt) {
|
||||
return $attempt;
|
||||
}
|
||||
break;
|
||||
|
||||
case QUIZ_GRADEAVERAGE: // We need to do something with it.
|
||||
case QUIZ_ATTEMPTLAST:
|
||||
foreach ($attempts as $attempt) {
|
||||
$final = $attempt;
|
||||
}
|
||||
return $final;
|
||||
|
||||
default:
|
||||
case QUIZ_GRADEHIGHEST:
|
||||
$max = -1;
|
||||
foreach ($attempts as $attempt) {
|
||||
if ($attempt->sumgrades > $max) {
|
||||
$max = $attempt->sumgrades;
|
||||
$maxattempt = $attempt;
|
||||
}
|
||||
}
|
||||
return $maxattempt;
|
||||
}
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Settings form for overrides in the quiz module.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @copyright 2010 Matt Petro
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
|
||||
// Normally I would debug-output
|
||||
// 'This file is no longer required in Moodle 4.2+. Please do not include/require it.'
|
||||
// but this file gets automatically included by the renderer factories in a way that
|
||||
// is hard to prevent, so not doing that here.
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* File only retained to prevent fatal errors in code that tries to require/include this.
|
||||
*
|
||||
* @todo MDL-76612 delete this file as part of Moodle 4.6 development.
|
||||
* @deprecated This file is no longer required in Moodle 4.2+.
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('This file is no longer required in Moodle 4.2+. Please do not include/require it.', DEBUG_DEVELOPER);
|
||||
@@ -121,13 +121,6 @@ class calculator {
|
||||
return $quizstats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int previously, the time after which statistics are automatically recomputed.
|
||||
* @deprecated since Moodle 4.3. Use of pre-computed stats is no longer time-limited.
|
||||
* @todo MDL-78091 Final deprecation in Moodle 4.7
|
||||
*/
|
||||
const TIME_TO_CACHE = 900; // 15 minutes.
|
||||
|
||||
/**
|
||||
* Load cached statistics from the database.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user