mirror of
https://github.com/moodle/moodle.git
synced 2025-04-18 23:15:38 +02:00
Merge branch 'MDL-74470' of https://github.com/timhunt/moodle
This commit is contained in:
commit
65224aa30d
@ -1039,6 +1039,7 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
|
||||
$temp = clone($question);
|
||||
$temp->questiontext = '';
|
||||
$temp->name = qbank_helper::describe_random_question($slot);
|
||||
$instancename = quiz_question_tostring($temp);
|
||||
|
||||
$configuretitle = get_string('configurerandomquestion', 'quiz');
|
||||
|
@ -19,7 +19,6 @@ namespace mod_quiz\question\bank;
|
||||
use core_question\local\bank\question_version_status;
|
||||
use core_question\local\bank\random_question_loader;
|
||||
use qubaid_condition;
|
||||
use quiz_attempt;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@ -130,7 +129,7 @@ class qbank_helper {
|
||||
|
||||
-- This way of getting the latest version for each slot is a bit more complicated
|
||||
-- than we would like, but the simpler SQL did not work in Oracle 11.2.
|
||||
-- (It did work find in Oracle 19.x, so once we have updated our min supported
|
||||
-- (It did work fine in Oracle 19.x, so once we have updated our min supported
|
||||
-- version we could consider digging the old code out of git history from
|
||||
-- just before the commit that added this comment.
|
||||
-- For relevant question_bank_entries, this gets the latest non-draft slot number.
|
||||
@ -202,21 +201,31 @@ class qbank_helper {
|
||||
/**
|
||||
* Get this list of random selection tag ids from one of the slots returned by get_question_structure.
|
||||
*
|
||||
* @param \stdClass $slotdata one of the array elements returend by get_question_structure.
|
||||
* @param \stdClass $slotdata one of the array elements returned by get_question_structure.
|
||||
* @return array list of tag ids.
|
||||
*/
|
||||
public static function get_tag_ids_for_slot(\stdClass $slotdata): array {
|
||||
if (empty($slot->randomtags)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$tagids = [];
|
||||
foreach ($slotdata->randomtags as $tag) {
|
||||
$tagids[] = $tag->id;
|
||||
foreach ($slotdata->randomtags as $taginfo) {
|
||||
[$id] = explode(',', $taginfo, 2);
|
||||
$tagids[] = $id;
|
||||
}
|
||||
return $tagids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a slot from the array returned by get_question_structure, describe the random question it represents.
|
||||
*
|
||||
* @param \stdClass $slotdata one of the array elements returned by get_question_structure.
|
||||
* @return string that can be used to display the random slot.
|
||||
*/
|
||||
public static function describe_random_question(\stdClass $slotdata): string {
|
||||
global $DB;
|
||||
$category = $DB->get_record('question_categories', ['id' => $slotdata->category]);
|
||||
return \question_bank::get_qtype('random')->question_name(
|
||||
$category, $slotdata->randomrecurse, $slotdata->randomtags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose question for redo in a particular slot.
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ Feature: Adding random questions to a quiz based on category and tags
|
||||
And I follow "a random question"
|
||||
And I set the field "Tags" to "foo"
|
||||
And I press "Add random question"
|
||||
And I should see "Random question"
|
||||
And I should see "Random (Questions Category 1, tags: foo)" on quiz page "1"
|
||||
And I click on "(See questions)" "link"
|
||||
Then I should see "Questions Category 1"
|
||||
And I should see "foo"
|
||||
@ -99,6 +99,6 @@ Feature: Adding random questions to a quiz based on category and tags
|
||||
| Name | New Random category |
|
||||
| Parent category | Top for Quiz 1 |
|
||||
And I press "Create category and add random question"
|
||||
And I should see "Random question"
|
||||
And I should see "Random (New Random category)" on quiz page "1"
|
||||
And I click on "(See questions)" "link"
|
||||
Then I should see "Top for Quiz 1"
|
||||
|
@ -45,11 +45,11 @@ Feature: Editing random questions already in a quiz based on category and tags
|
||||
And I set the field "Tags" to "hard"
|
||||
And I press "Add random question"
|
||||
And I follow "Add page break"
|
||||
When I click on "Configure question" "link" in the "Random question" "list_item"
|
||||
When I click on "Configure question" "link" in the "Random (Questions Category 1, tags: easy)" "list_item"
|
||||
And I click on "easy" "autocomplete_selection"
|
||||
And I set the field "Tags" to "essay"
|
||||
And I press "Save changes"
|
||||
Then I should see "Random question" on quiz page "1"
|
||||
And I should see "Random question" on quiz page "2"
|
||||
And I click on "Configure question" "link" in the "2" "mod_quiz > Edit slot"
|
||||
Then I should see "Random (Questions Category 1, tags: essay)" on quiz page "1"
|
||||
And I should see "Random (Questions Category 1, tags: hard)" on quiz page "2"
|
||||
And I click on "Configure question" "link" in the "Questions Category 1, tags: hard" "list_item"
|
||||
And "hard" "autocomplete_selection" should be visible
|
||||
|
@ -130,7 +130,7 @@ class qtype_random extends question_type {
|
||||
/**
|
||||
* Random questions always get a question name that is Random (cateogryname).
|
||||
* This function is a centralised place to calculate that, given the category.
|
||||
* @param stdClass $category the category this question picks from. (Only ->name is used.)
|
||||
* @param stdClass $category the category this question picks from. (->parent, ->name & ->contextid are used.)
|
||||
* @param bool $includesubcategories whether this question also picks from subcategories.
|
||||
* @param string[] $tagnames Name of tags this question picks from.
|
||||
* @return string the name this question should have.
|
||||
|
Loading…
x
Reference in New Issue
Block a user