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) {
|
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 = [];
|
$gradeitems = [];
|
||||||
foreach ($this->structure->get_grade_items() as $gradeitem) {
|
foreach ($this->structure->get_grade_items() as $gradeitem) {
|
||||||
$gradeitem = clone($gradeitem);
|
$gradeitem = clone($gradeitem);
|
||||||
@ -52,16 +65,50 @@ class edit_grading_page implements renderable, templatable {
|
|||||||
$gradeitem->displayname = format_string($gradeitem->name);
|
$gradeitem->displayname = format_string($gradeitem->name);
|
||||||
$gradeitem->isused = $this->structure->is_grade_item_used($gradeitem->id);
|
$gradeitem->isused = $this->structure->is_grade_item_used($gradeitem->id);
|
||||||
$gradeitems[] = $gradeitem;
|
$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 [
|
return [
|
||||||
'quizid' => $this->structure->get_quizid(),
|
'quizid' => $this->structure->get_quizid(),
|
||||||
'gradeitems' => $gradeitems,
|
'gradeitems' => $gradeitems,
|
||||||
|
'sections' => array_values($sections),
|
||||||
'hasgradeitems' => !empty($gradeitems),
|
'hasgradeitems' => !empty($gradeitems),
|
||||||
'nogradeitems' => ['message' => get_string('gradeitemsnoneyet', 'quiz')],
|
'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['gradeitemdefaultname'] = 'New grade item';
|
||||||
$string['gradeitemdelete'] = 'Delete grade item {$a}';
|
$string['gradeitemdelete'] = 'Delete grade item {$a}';
|
||||||
$string['gradeitemedit'] = 'Edit name of grade item {$a}';
|
$string['gradeitemedit'] = 'Edit name of grade item {$a}';
|
||||||
|
$string['gradeitemmarkscheme'] = 'Mark scheme';
|
||||||
$string['gradeitemnewname'] = 'New name for grade item {$a}';
|
$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['gradeitems'] = 'Grade items';
|
||||||
$string['gradeitemsetup'] = 'Quiz grading setup (advanced view)';
|
$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.';
|
$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['privacy:metadata:quizaccess'] = 'The quiz activity makes use of quiz access rules.';
|
||||||
$string['publish'] = 'Publish';
|
$string['publish'] = 'Publish';
|
||||||
$string['publishedit'] = 'You must have permission in the publishing course to add or edit questions in this category';
|
$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['qbrief'] = 'Q. {$a}';
|
||||||
|
$string['qname'] = 'name';
|
||||||
|
$string['qnumberbrief'] = 'No.';
|
||||||
$string['qti'] = 'IMS QTI format';
|
$string['qti'] = 'IMS QTI format';
|
||||||
$string['qtypename'] = 'type, name';
|
$string['qtypename'] = 'type, name';
|
||||||
$string['question'] = 'Question';
|
$string['question'] = 'Question';
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
<h2>{{#str}} gradeitemsetup, quiz {{/str}}</h2>
|
<h2>{{#str}} gradeitemsetup, quiz {{/str}}</h2>
|
||||||
|
|
||||||
<h3>{{#str}} gradeitems, quiz {{/str}}</h3>
|
<h3>{{#str}} gradeitems, grades {{/str}}</h3>
|
||||||
|
|
||||||
{{^hasgradeitems}}
|
{{^hasgradeitems}}
|
||||||
{{#nogradeitems}}
|
{{#nogradeitems}}
|
||||||
@ -96,84 +96,46 @@
|
|||||||
data-quiz-id="{{quizid}}">{{#str}} additem, grades{{/str}}</button>
|
data-quiz-id="{{quizid}}">{{#str}} additem, grades{{/str}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Mark scheme</h3>
|
<h3>{{#str}} gradeitemmarkscheme, quiz {{/str}}</h3>
|
||||||
|
|
||||||
<table class="table table-striped table-responsive">
|
{{^hasslots}}
|
||||||
<thead>
|
{{#noslots}}
|
||||||
<tr>
|
{{> core/notification_info}}
|
||||||
<th scope="col">No.</th>
|
{{/noslots}}
|
||||||
<th scope="col">Question</th>
|
{{/hasslots}}
|
||||||
<th scope="col">Spelling</th>
|
|
||||||
<th scope="col">Grammar</th>
|
{{#hasslots}}
|
||||||
<th scope="col">Comprehension</th>
|
<table class="table table-striped table-responsive">
|
||||||
</tr>
|
<thead>
|
||||||
</thead>
|
<tr>
|
||||||
<tbody>
|
<th scope="col">{{#str}} qnumberbrief, quiz {{/str}}</th>
|
||||||
<tr class="mod_quiz-new-section">
|
<th scope="col">{{#str}} question, quiz {{/str}}</th>
|
||||||
<td colspan="5">
|
<th scope="col">{{#str}} gradeitem, grades {{/str}}</th>
|
||||||
<h4>Section 1: Holidays</h4>
|
</tr>
|
||||||
</td>
|
</thead>
|
||||||
</tr>
|
<tbody>
|
||||||
<tr>
|
{{#sections}}
|
||||||
<td>i</td>
|
<tr class="mod_quiz-new-section">
|
||||||
<th scope="row">
|
<td colspan="3">
|
||||||
<img class="icon activityicon" title="Description" alt="Description" role="presentation" src="http://localhost/moodle_head/theme/image.php/boost/qtype_description/1677258549/icon">
|
<h4>{{{displayname}}}</h4>
|
||||||
<span class="questionname">Instructions</span>
|
</td>
|
||||||
<span class="questiontext">To answer this quiz you need to ...</span>
|
</tr>
|
||||||
</th>
|
|
||||||
<td> </td>
|
{{#slots}}
|
||||||
<td> </td>
|
<tr>
|
||||||
<td> </td>
|
<td>{{displaynumber}}</td>
|
||||||
</tr>
|
<th scope="row"><label for="grade-item-choice-{{id}}">{{{displayname}}}</label></th>
|
||||||
<tr>
|
<td>
|
||||||
<td>1</td>
|
<select id="grade-item-choice-{{id}}">
|
||||||
<th scope="row">
|
{{#choices}}
|
||||||
<img class="icon activityicon" title="Short answer" alt="" role="presentation" src="http://localhost/moodle_head/theme/image.php/boost/qtype_multichoice/1677258549/icon">
|
<option value="{{id}}"{{#isselected}} selected="selected"{{/isselected}}>{{choice}}</option>
|
||||||
<span class="questionname">Beach 1</span>
|
{{/choices}}
|
||||||
<span class="questiontext">What colour is the sand?</span>
|
</select>
|
||||||
</th>
|
</td>
|
||||||
<td> </td>
|
</tr>
|
||||||
<td> </td>
|
{{/slots}}
|
||||||
<td>
|
{{/sections}}
|
||||||
<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">
|
</tbody>
|
||||||
2.00
|
</table>
|
||||||
<span class="quickediticon">
|
{{/hasslots}}
|
||||||
<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>
|
|
||||||
|
@ -26,6 +26,7 @@ Feature: Setup multiple grades for a quiz
|
|||||||
| activity | name | course |
|
| activity | name | course |
|
||||||
| quiz | Quiz 1 | C1 |
|
| quiz | Quiz 1 | C1 |
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: Navigation to, and display of, grading setup
|
Scenario: Navigation to, and display of, grading setup
|
||||||
Given the following "mod_quiz > grade items" exist:
|
Given the following "mod_quiz > grade items" exist:
|
||||||
| quiz | name |
|
| 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 "Intuition" "table_row"
|
||||||
And "Delete" "icon" should not exist in the "Intelligence" "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 "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
|
@javascript
|
||||||
Scenario: A grade item can be created and renamed
|
Scenario: A grade item can be created and renamed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user