mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-76898' of https://github.com/timhunt/moodle
This commit is contained in:
commit
f9a3ec96b6
9 changed files with 126 additions and 273 deletions
|
@ -364,21 +364,4 @@ abstract class attempts_report extends report_base {
|
|||
quiz_delete_attempt($attempt, $quiz);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about which students to show in the report.
|
||||
* @param object $cm the coures module.
|
||||
* @param object $course the course settings.
|
||||
* @return array with four elements:
|
||||
* 0 => integer the current group id (0 for none).
|
||||
* 1 => array ids of all the students in this course.
|
||||
* 2 => array ids of all the students in the current group.
|
||||
* 3 => array ids of all the students to show in the report. Will be the
|
||||
* same as either element 1 or 2.
|
||||
* @deprecated since Moodle 3.2 Please use get_students_joins() instead.
|
||||
*/
|
||||
protected function load_relevant_students($cm, $course = null) {
|
||||
$msg = 'The function load_relevant_students() is deprecated. Please use get_students_joins() instead.';
|
||||
throw new coding_exception($msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,116 @@ function quiz_get_completion_state($course, $cm, $userid, $type) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves tag information for the given list of quiz slot ids.
|
||||
* Currently the only slots that have tags are random question slots.
|
||||
*
|
||||
* Example:
|
||||
* If we have 3 slots with id 1, 2, and 3. The first slot has two tags, the second
|
||||
* has one tag, and the third has zero tags. The return structure will look like:
|
||||
* [
|
||||
* 1 => [
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* ],
|
||||
* 2 => [
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* ],
|
||||
* 3 => [],
|
||||
* ]
|
||||
*
|
||||
* @param int[] $slotids The list of id for the quiz slots.
|
||||
* @return array[] List of quiz_slot_tags records indexed by slot id.
|
||||
* @deprecated since Moodle 4.0
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
*/
|
||||
function quiz_retrieve_tags_for_slot_ids($slotids) {
|
||||
debugging('Method quiz_retrieve_tags_for_slot_ids() is deprecated, ' .
|
||||
'see filtercondition->tags from the question_set_reference table.', DEBUG_DEVELOPER);
|
||||
global $DB;
|
||||
if (empty($slotids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$slottags = $DB->get_records_list('quiz_slot_tags', 'slotid', $slotids);
|
||||
$tagsbyid = core_tag_tag::get_bulk(array_filter(array_column($slottags, 'tagid')), 'id, name');
|
||||
$tagsbyname = false; // It will be loaded later if required.
|
||||
$emptytagids = array_reduce($slotids, function($carry, $slotid) {
|
||||
$carry[$slotid] = [];
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
return array_reduce(
|
||||
$slottags,
|
||||
function($carry, $slottag) use ($slottags, $tagsbyid, $tagsbyname) {
|
||||
if (isset($tagsbyid[$slottag->tagid])) {
|
||||
// Make sure that we're returning the most updated tag name.
|
||||
$slottag->tagname = $tagsbyid[$slottag->tagid]->name;
|
||||
} else {
|
||||
if ($tagsbyname === false) {
|
||||
// We were hoping that this query could be avoided, but life
|
||||
// showed its other side to us!
|
||||
$tagcollid = core_tag_area::get_collection('core', 'question');
|
||||
$tagsbyname = core_tag_tag::get_by_name_bulk(
|
||||
$tagcollid,
|
||||
array_column($slottags, 'tagname'),
|
||||
'id, name'
|
||||
);
|
||||
}
|
||||
if (isset($tagsbyname[$slottag->tagname])) {
|
||||
// Make sure that we're returning the current tag id that matches
|
||||
// the given tag name.
|
||||
$slottag->tagid = $tagsbyname[$slottag->tagname]->id;
|
||||
} else {
|
||||
// The tag does not exist anymore (neither the tag id nor the tag name
|
||||
// matches an existing tag).
|
||||
// We still need to include this row in the result as some callers might
|
||||
// be interested in these rows. An example is the editing forms that still
|
||||
// need to display tag names even if they don't exist anymore.
|
||||
$slottag->tagid = null;
|
||||
}
|
||||
}
|
||||
|
||||
$carry[$slottag->slotid][$slottag->id] = $slottag;
|
||||
return $carry;
|
||||
},
|
||||
$emptytagids
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object $quiz the quiz settings.
|
||||
* @param int $slot which question in the quiz to test.
|
||||
* @return bool whether the user can use this question.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copyright 2012 the Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
|
|
|
@ -1639,13 +1639,6 @@ function quiz_reset_userdata($data) {
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function quiz_print_overview() {
|
||||
throw new coding_exception('quiz_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a textual summary of the number of attempts that have been made at a particular quiz,
|
||||
* returns '' if no attempts have been made yet, unless $returnzero is passed as true.
|
||||
|
|
|
@ -1957,42 +1957,6 @@ function quiz_send_notify_manual_graded_message(quiz_attempt $attemptobj, object
|
|||
return message_send($eventdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle groups_member_added event
|
||||
*
|
||||
* @param object $event the event object.
|
||||
* @deprecated since 2.6, see {@link \mod_quiz\group_observers::group_member_added()}.
|
||||
*/
|
||||
function quiz_groups_member_added_handler($event) {
|
||||
debugging('quiz_groups_member_added_handler() is deprecated, please use ' .
|
||||
'\mod_quiz\group_observers::group_member_added() instead.', DEBUG_DEVELOPER);
|
||||
quiz_update_open_attempts(array('userid'=>$event->userid, 'groupid'=>$event->groupid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle groups_member_removed event
|
||||
*
|
||||
* @param object $event the event object.
|
||||
* @deprecated since 2.6, see {@link \mod_quiz\group_observers::group_member_removed()}.
|
||||
*/
|
||||
function quiz_groups_member_removed_handler($event) {
|
||||
debugging('quiz_groups_member_removed_handler() is deprecated, please use ' .
|
||||
'\mod_quiz\group_observers::group_member_removed() instead.', DEBUG_DEVELOPER);
|
||||
quiz_update_open_attempts(array('userid'=>$event->userid, 'groupid'=>$event->groupid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle groups_group_deleted event
|
||||
*
|
||||
* @param object $event the event object.
|
||||
* @deprecated since 2.6, see {@link \mod_quiz\group_observers::group_deleted()}.
|
||||
*/
|
||||
function quiz_groups_group_deleted_handler($event) {
|
||||
global $DB;
|
||||
debugging('quiz_groups_group_deleted_handler() is deprecated, please use ' .
|
||||
'\mod_quiz\group_observers::group_deleted() instead.', DEBUG_DEVELOPER);
|
||||
quiz_process_group_deleted_in_course($event->courseid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic to happen when a/some group(s) has/have been deleted in a course.
|
||||
|
@ -2025,22 +1989,6 @@ function quiz_process_group_deleted_in_course($courseid) {
|
|||
quiz_update_open_attempts(['quizid' => array_unique(array_column($records, 'quiz'))]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle groups_members_removed event
|
||||
*
|
||||
* @param object $event the event object.
|
||||
* @deprecated since 2.6, see {@link \mod_quiz\group_observers::group_member_removed()}.
|
||||
*/
|
||||
function quiz_groups_members_removed_handler($event) {
|
||||
debugging('quiz_groups_members_removed_handler() is deprecated, please use ' .
|
||||
'\mod_quiz\group_observers::group_member_removed() instead.', DEBUG_DEVELOPER);
|
||||
if ($event->userid == 0) {
|
||||
quiz_update_open_attempts(array('courseid'=>$event->courseid));
|
||||
} else {
|
||||
quiz_update_open_attempts(array('courseid'=>$event->courseid, 'userid'=>$event->userid));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information about the standard quiz JavaScript module.
|
||||
* @return array a standard jsmodule structure.
|
||||
|
@ -2131,39 +2079,6 @@ function quiz_require_question_use($questionid) {
|
|||
question_require_capability_on($question, 'use');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object $quiz the quiz settings.
|
||||
* @param int $slot which question in the quiz to test.
|
||||
* @return bool whether the user can use this question.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a question to a quiz
|
||||
*
|
||||
|
@ -2610,83 +2525,6 @@ function quiz_is_overriden_calendar_event(\calendar_event $event) {
|
|||
return $DB->record_exists('quiz_overrides', $overrideparams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves tag information for the given list of quiz slot ids.
|
||||
* Currently the only slots that have tags are random question slots.
|
||||
*
|
||||
* Example:
|
||||
* If we have 3 slots with id 1, 2, and 3. The first slot has two tags, the second
|
||||
* has one tag, and the third has zero tags. The return structure will look like:
|
||||
* [
|
||||
* 1 => [
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* ],
|
||||
* 2 => [
|
||||
* quiz_slot_tags.id => { ...tag data... },
|
||||
* ],
|
||||
* 3 => [],
|
||||
* ]
|
||||
*
|
||||
* @param int[] $slotids The list of id for the quiz slots.
|
||||
* @return array[] List of quiz_slot_tags records indexed by slot id.
|
||||
* @deprecated since Moodle 4.0
|
||||
* @todo Final deprecation on Moodle 4.4 MDL-72438
|
||||
*/
|
||||
function quiz_retrieve_tags_for_slot_ids($slotids) {
|
||||
debugging('Method quiz_retrieve_tags_for_slot_ids() is deprecated, ' .
|
||||
'see filtercondition->tags from the question_set_reference table.', DEBUG_DEVELOPER);
|
||||
global $DB;
|
||||
if (empty($slotids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$slottags = $DB->get_records_list('quiz_slot_tags', 'slotid', $slotids);
|
||||
$tagsbyid = core_tag_tag::get_bulk(array_filter(array_column($slottags, 'tagid')), 'id, name');
|
||||
$tagsbyname = false; // It will be loaded later if required.
|
||||
$emptytagids = array_reduce($slotids, function($carry, $slotid) {
|
||||
$carry[$slotid] = [];
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
return array_reduce(
|
||||
$slottags,
|
||||
function($carry, $slottag) use ($slottags, $tagsbyid, $tagsbyname) {
|
||||
if (isset($tagsbyid[$slottag->tagid])) {
|
||||
// Make sure that we're returning the most updated tag name.
|
||||
$slottag->tagname = $tagsbyid[$slottag->tagid]->name;
|
||||
} else {
|
||||
if ($tagsbyname === false) {
|
||||
// We were hoping that this query could be avoided, but life
|
||||
// showed its other side to us!
|
||||
$tagcollid = core_tag_area::get_collection('core', 'question');
|
||||
$tagsbyname = core_tag_tag::get_by_name_bulk(
|
||||
$tagcollid,
|
||||
array_column($slottags, 'tagname'),
|
||||
'id, name'
|
||||
);
|
||||
}
|
||||
if (isset($tagsbyname[$slottag->tagname])) {
|
||||
// Make sure that we're returning the current tag id that matches
|
||||
// the given tag name.
|
||||
$slottag->tagid = $tagsbyname[$slottag->tagname]->id;
|
||||
} else {
|
||||
// The tag does not exist anymore (neither the tag id nor the tag name
|
||||
// matches an existing tag).
|
||||
// We still need to include this row in the result as some callers might
|
||||
// be interested in these rows. An example is the editing forms that still
|
||||
// need to display tag names even if they don't exist anymore.
|
||||
$slottag->tagid = null;
|
||||
}
|
||||
}
|
||||
|
||||
$carry[$slottag->slotid][$slottag->id] = $slottag;
|
||||
return $carry;
|
||||
},
|
||||
$emptytagids
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quiz attempt and handling error.
|
||||
*
|
||||
|
|
|
@ -1,31 +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/>.
|
||||
|
||||
/**
|
||||
* This file renders the quiz overview graph.
|
||||
*
|
||||
* @package quiz_overview
|
||||
* @copyright 2008 Jamie Pratt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated since Moodle 3.2
|
||||
*/
|
||||
|
||||
|
||||
require_once(__DIR__ . '/../../../../config.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
debugging('This way of generating the chart is deprecated, refer to quiz_overview_report::display().', DEBUG_DEVELOPER);
|
||||
send_file_not_found();
|
|
@ -1,36 +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/>.
|
||||
|
||||
/**
|
||||
* This script renders the quiz statistics graph.
|
||||
*
|
||||
* It takes one parameter, the quiz_statistics.id. This is enough to identify the
|
||||
* quiz etc.
|
||||
*
|
||||
* It plots a bar graph showing certain question statistics plotted against
|
||||
* question number.
|
||||
*
|
||||
* @package quiz_statistics
|
||||
* @copyright 2008 Jamie Pratt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated since Moodle 3.2
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../../config.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
debugging('This way of generating the chart is deprecated, refer to quiz_statistics_report::display().', DEBUG_DEVELOPER);
|
||||
send_file_not_found();
|
|
@ -82,23 +82,3 @@ function quiz_statistics_qubaids_condition($quizid, \core\dml\sql_join $groupstu
|
|||
$quizid, $groupstudentsjoins, $whichattempts, $includeungraded);
|
||||
return new qubaid_join($fromqa, 'quiza.uniqueid', $whereqa, $qaparams);
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper function returns a sequence of colours each time it is called.
|
||||
* Used for choosing colours for graph data series.
|
||||
* @return string colour name.
|
||||
* @deprecated since Moodle 3.2
|
||||
*/
|
||||
function quiz_statistics_graph_get_new_colour() {
|
||||
debugging('The function quiz_statistics_graph_get_new_colour() is deprecated, please do not use it any more. '
|
||||
. 'Colours will be handled by the charting library directly.', DEBUG_DEVELOPER);
|
||||
|
||||
static $colourindex = -1;
|
||||
$colours = array('red', 'green', 'yellow', 'orange', 'purple', 'black',
|
||||
'maroon', 'blue', 'ltgreen', 'navy', 'ltred', 'ltltgreen', 'ltltorange',
|
||||
'olive', 'gray', 'ltltred', 'ltorange', 'lime', 'ltblue', 'ltltblue');
|
||||
|
||||
$colourindex = ($colourindex + 1) % count($colours);
|
||||
|
||||
return $colours[$colourindex];
|
||||
}
|
||||
|
|
|
@ -27,6 +27,12 @@ Overview of this plugin type at http://docs.moodle.org/dev/Quiz_reports
|
|||
- mod/quiz/report/attemptsreport_table.php
|
||||
- mod/quiz/report/default.php
|
||||
|
||||
* Final deprecation (complete removal) of the following functions which were deprecated long ago:
|
||||
- attempts_report::load_relevant_students - deprecated in 3.2
|
||||
- quiz_statistics_graph_get_new_colour - deprecated since 3.2
|
||||
- The file mod/quiz/report/overview/overviewgraph.php - deprecated since 3.2
|
||||
- The file mod/quiz/report/statistics/statistics_graph.php - deprecated since 3.2
|
||||
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
|
|
|
@ -76,6 +76,16 @@ This files describes API changes in the quiz code.
|
|||
- mod/quiz/renderer.php - actually, no debugging ouput for this one because of how renderer factories work.
|
||||
- mod/quiz/attemptlib.php
|
||||
|
||||
* Final deprecation (complete removal) of the following functions which were deprecated long ago:
|
||||
- quiz_groups_member_added_handler - deprecated since 2.6
|
||||
- quiz_groups_member_removed_handler - deprecated since 2.6
|
||||
- quiz_groups_group_deleted_handler - deprecated since 2.6
|
||||
- quiz_groups_members_removed_handler - deprecated since 2.6
|
||||
- attempts_report::load_relevant_students - deprecated since 3.2
|
||||
- quiz_statistics_graph_get_new_colour - deprecated since 3.2
|
||||
- The file mod/quiz/report/overview/overviewgraph.php - deprecated since 3.2
|
||||
- The file mod/quiz/report/statistics/statistics_graph.php - deprecated since 3.2
|
||||
- quiz_print_overview - deprecated since 3.3
|
||||
|
||||
=== 4.1 ===
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue