mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-74610 quiz: multiple grades - show grade items
This commit is contained in:
parent
be49319a87
commit
a47705c09e
@ -45,6 +45,19 @@ class edit_grading_page implements renderable, templatable {
|
||||
}
|
||||
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $PAGE;
|
||||
/** @var edit_renderer $editrenderer */
|
||||
$editrenderer = $PAGE->get_renderer('mod_quiz', 'edit');
|
||||
|
||||
// Get the list of grade items, but to be the choices for a slot, and the list to be edited.
|
||||
$gradeitemchoices = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'choice' => get_string('gradeitemnoneselected', 'quiz'),
|
||||
'isselected' => false,
|
||||
],
|
||||
];
|
||||
$selectdgradeitemchoices = [];
|
||||
$gradeitems = [];
|
||||
foreach ($this->structure->get_grade_items() as $gradeitem) {
|
||||
$gradeitem = clone($gradeitem);
|
||||
@ -52,16 +65,50 @@ class edit_grading_page implements renderable, templatable {
|
||||
$gradeitem->displayname = format_string($gradeitem->name);
|
||||
$gradeitem->isused = $this->structure->is_grade_item_used($gradeitem->id);
|
||||
$gradeitems[] = $gradeitem;
|
||||
|
||||
$gradeitemchoices[$gradeitem->id] = (object) [
|
||||
'id' => $gradeitem->id,
|
||||
'choice' => $gradeitem->displayname,
|
||||
'isselected' => false,
|
||||
];
|
||||
$selectdgradeitemchoices[$gradeitem->id] = clone($gradeitemchoices[$gradeitem->id]);
|
||||
$selectdgradeitemchoices[$gradeitem->id]->isselected = true;
|
||||
}
|
||||
|
||||
$slots = $this->structure->get_slots();
|
||||
// Get the list of quiz sections.
|
||||
$sections = [];
|
||||
foreach ($this->structure->get_sections() as $section) {
|
||||
$sections[$section->id] = (object) [
|
||||
'displayname' => $section->heading ? format_string($section->heading) : get_string('sectionnoname', 'quiz'),
|
||||
'slots' => [],
|
||||
];
|
||||
}
|
||||
|
||||
// Add the relevant slots ot each section.
|
||||
foreach ($this->structure->get_slots() as $slot) {
|
||||
// Mark the right choice as selected.
|
||||
$choices = $gradeitemchoices;
|
||||
if ($slot->quizgradeitemid) {
|
||||
$choices[$slot->quizgradeitemid] = $selectdgradeitemchoices[$slot->quizgradeitemid];
|
||||
}
|
||||
|
||||
$sections[$slot->section->id]->slots[] = (object) [
|
||||
'id' => $slot->id,
|
||||
'displaynumber' => $this->structure->get_displayed_number_for_slot($slot->slot),
|
||||
'displayname' => $editrenderer->get_question_name_for_slot(
|
||||
$this->structure, $slot->slot, $PAGE->url),
|
||||
'choices' => array_values($choices),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'quizid' => $this->structure->get_quizid(),
|
||||
'gradeitems' => $gradeitems,
|
||||
'sections' => array_values($sections),
|
||||
'hasgradeitems' => !empty($gradeitems),
|
||||
'nogradeitems' => ['message' => get_string('gradeitemsnoneyet', 'quiz')],
|
||||
'slots' => $slots,
|
||||
'hasslots' => $this->structure->has_questions(),
|
||||
'noslots' => ['message' => get_string('gradeitemnoslots', 'quiz')],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -443,7 +443,10 @@ $string['gradehighest'] = 'Highest grade';
|
||||
$string['gradeitemdefaultname'] = 'New grade item';
|
||||
$string['gradeitemdelete'] = 'Delete grade item {$a}';
|
||||
$string['gradeitemedit'] = 'Edit name of grade item {$a}';
|
||||
$string['gradeitemmarkscheme'] = 'Mark scheme';
|
||||
$string['gradeitemnewname'] = 'New name for grade item {$a}';
|
||||
$string['gradeitemnoneselected'] = '[none]';
|
||||
$string['gradeitemnoslots'] = 'No questions have been added to the quiz yet. Please add the questions to the quiz before setting up grading.';
|
||||
$string['gradeitems'] = 'Grade items';
|
||||
$string['gradeitemsetup'] = 'Quiz grading setup (advanced view)';
|
||||
$string['gradeitemsnoneyet'] = 'This quiz does not yet have any grade items defined, just a simple overall score will be used.';
|
||||
@ -747,8 +750,9 @@ $string['privacy:metadata:quiz_overrides:userid'] = 'The user being overridden';
|
||||
$string['privacy:metadata:quizaccess'] = 'The quiz activity makes use of quiz access rules.';
|
||||
$string['publish'] = 'Publish';
|
||||
$string['publishedit'] = 'You must have permission in the publishing course to add or edit questions in this category';
|
||||
$string['qname'] = 'name';
|
||||
$string['qbrief'] = 'Q. {$a}';
|
||||
$string['qname'] = 'name';
|
||||
$string['qnumberbrief'] = 'No.';
|
||||
$string['qti'] = 'IMS QTI format';
|
||||
$string['qtypename'] = 'type, name';
|
||||
$string['question'] = 'Question';
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
<h2>{{#str}} gradeitemsetup, quiz {{/str}}</h2>
|
||||
|
||||
<h3>{{#str}} gradeitems, quiz {{/str}}</h3>
|
||||
<h3>{{#str}} gradeitems, grades {{/str}}</h3>
|
||||
|
||||
{{^hasgradeitems}}
|
||||
{{#nogradeitems}}
|
||||
@ -96,84 +96,46 @@
|
||||
data-quiz-id="{{quizid}}">{{#str}} additem, grades{{/str}}</button>
|
||||
</div>
|
||||
|
||||
<h3>Mark scheme</h3>
|
||||
<h3>{{#str}} gradeitemmarkscheme, quiz {{/str}}</h3>
|
||||
|
||||
<table class="table table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">No.</th>
|
||||
<th scope="col">Question</th>
|
||||
<th scope="col">Spelling</th>
|
||||
<th scope="col">Grammar</th>
|
||||
<th scope="col">Comprehension</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="mod_quiz-new-section">
|
||||
<td colspan="5">
|
||||
<h4>Section 1: Holidays</h4>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>i</td>
|
||||
<th scope="row">
|
||||
<img class="icon activityicon" title="Description" alt="Description" role="presentation" src="http://localhost/moodle_head/theme/image.php/boost/qtype_description/1677258549/icon">
|
||||
<span class="questionname">Instructions</span>
|
||||
<span class="questiontext">To answer this quiz you need to ...</span>
|
||||
</th>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<th scope="row">
|
||||
<img class="icon activityicon" title="Short answer" alt="" role="presentation" src="http://localhost/moodle_head/theme/image.php/boost/qtype_multichoice/1677258549/icon">
|
||||
<span class="questionname">Beach 1</span>
|
||||
<span class="questiontext">What colour is the sand?</span>
|
||||
</th>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade for this question" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429000" data-value="1" data-editlabel="New maximum grade for this question" data-type="text" data-options="">
|
||||
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit the grade for this question">
|
||||
2.00
|
||||
<span class="quickediticon">
|
||||
<i class="icon fa fa-pencil fa-fw " title="Edit the grade for this question" role="img" aria-label="Edit the grade for this question"></i>
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<th scope="row">
|
||||
<img class="icon activityicon" title="Short answer" alt="" role="presentation" src="http://localhost/moodle_head/theme/image.php/boost/qtype_shortanswer/1677258549/icon">
|
||||
<span class="questionname">Beach 2</span>
|
||||
<span class="questiontext">The sea is blue. How do you write that in French?</span>
|
||||
</th>
|
||||
<td>
|
||||
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade for this question" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429000" data-value="1" data-editlabel="New maximum grade for this question" data-type="text" data-options="">
|
||||
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit the grade for this question">
|
||||
2.00
|
||||
<span class="quickediticon">
|
||||
<i class="icon fa fa-pencil fa-fw " title="Edit the grade for this question" role="img" aria-label="Edit the grade for this question"></i>
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr class="mod_quiz-new-section">
|
||||
<td colspan="5">
|
||||
<h4>Section 2: Food</h4>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="mod_quiz-new-section">
|
||||
<td colspan="5">
|
||||
<h4>Section 3: Pets</h4>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{^hasslots}}
|
||||
{{#noslots}}
|
||||
{{> core/notification_info}}
|
||||
{{/noslots}}
|
||||
{{/hasslots}}
|
||||
|
||||
{{#hasslots}}
|
||||
<table class="table table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}} qnumberbrief, quiz {{/str}}</th>
|
||||
<th scope="col">{{#str}} question, quiz {{/str}}</th>
|
||||
<th scope="col">{{#str}} gradeitem, grades {{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#sections}}
|
||||
<tr class="mod_quiz-new-section">
|
||||
<td colspan="3">
|
||||
<h4>{{{displayname}}}</h4>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{#slots}}
|
||||
<tr>
|
||||
<td>{{displaynumber}}</td>
|
||||
<th scope="row"><label for="grade-item-choice-{{id}}">{{{displayname}}}</label></th>
|
||||
<td>
|
||||
<select id="grade-item-choice-{{id}}">
|
||||
{{#choices}}
|
||||
<option value="{{id}}"{{#isselected}} selected="selected"{{/isselected}}>{{choice}}</option>
|
||||
{{/choices}}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
{{/slots}}
|
||||
{{/sections}}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{{/hasslots}}
|
||||
|
@ -26,6 +26,7 @@ Feature: Setup multiple grades for a quiz
|
||||
| activity | name | course |
|
||||
| quiz | Quiz 1 | C1 |
|
||||
|
||||
@javascript
|
||||
Scenario: Navigation to, and display of, grading setup
|
||||
Given the following "mod_quiz > grade items" exist:
|
||||
| quiz | name |
|
||||
@ -42,6 +43,9 @@ Feature: Setup multiple grades for a quiz
|
||||
And "Delete" "icon" should not exist in the "Intuition" "table_row"
|
||||
And "Delete" "icon" should not exist in the "Intelligence" "table_row"
|
||||
And "Delete" "icon" should exist in the "Unused grade item" "table_row"
|
||||
And the field "Question A" matches value "Intuition"
|
||||
And the field "Question B" matches value "Intelligence"
|
||||
And the field "Question C" matches value "Intuition"
|
||||
|
||||
@javascript
|
||||
Scenario: A grade item can be created and renamed
|
||||
|
Loading…
x
Reference in New Issue
Block a user