MDL-74610 quiz mulitple grades: display the grade items that exist

AMOS BEGIN
 CPY [gradeitems,core_grades],[gradeitems,mod_quiz]
AMOS END
This commit is contained in:
Tim Hunt
2024-04-09 14:59:41 +01:00
parent e499098838
commit d4d66c2e28
4 changed files with 79 additions and 108 deletions
+17 -1
View File
@@ -45,6 +45,22 @@ class edit_grading_page implements renderable, templatable {
}
public function export_for_template(renderer_base $output) {
return [];
$gradeitems = [];
foreach ($this->structure->get_grade_items() as $gradeitem) {
$gradeitem = clone($gradeitem);
unset($gradeitem->quizid);
$gradeitem->displayname = format_string($gradeitem->name);
$gradeitem->isused = $this->structure->is_grade_item_used($gradeitem->id);
$gradeitems[] = $gradeitem;
}
$slots = $this->structure->get_slots();
return [
'gradeitems' => $gradeitems,
'hasgradeitems' => !empty($gradeitems),
'nogradeitems' => ['message' => get_string('gradeitemsnoneyet', 'quiz')],
'slots' => $slots,
];
}
}
+6 -1
View File
@@ -191,7 +191,7 @@ $string['completionminattemptserror'] = 'Minimum number of attempts must be lowe
$string['completionpassorattemptsexhausteddesc'] = 'Student must achieve a passing grade, or exhaust all available attempts to complete this activity';
$string['completionattemptsexhausted'] = 'Passing grade or all available attempts completed';
$string['completionattemptsexhausted_help'] = 'Mark quiz complete when the student has exhausted the maximum number of attempts.';
$string['complexgrading'] = 'Complex grading setup';
$string['complexgrading'] = 'Multiple grade setup';
$string['configadaptive'] = 'If you choose Yes for this option then the student will be allowed multiple responses to a question even within the same attempt at the quiz.';
$string['configattemptsallowed'] = 'Restriction on the number of attempts students are allowed at the quiz.';
$string['configdecimaldigits'] = 'Number of digits that should be shown after the decimal point when displaying grades.';
@@ -440,6 +440,11 @@ $string['gradeaverage'] = 'Average grade';
$string['gradeboundary'] = 'Grade boundary';
$string['gradeessays'] = 'Grade essays';
$string['gradehighest'] = 'Highest grade';
$string['gradeitemdelete'] = 'Delete grade item {$a}';
$string['gradeitemnewname'] = 'New name for grade item {$a}';
$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.';
$string['grademethod'] = 'Grading method';
$string['grademethod_help'] = 'When multiple attempts are allowed, the following methods are available for calculating the final quiz grade:
+49 -103
View File
@@ -30,123 +30,69 @@
Example context (json):
{
"gradeitems": [
{
"id": 123,
"sortorder": 1,
"name": "Reading & writing",
"displayname": "Reading & writing",
"isused": true
}
],
"hasgradeitems": true,
"nogradeitems": {
"message": "This quiz does not yet have any grade items defined."
}
}
}}
<h2>Quiz grading setup (advanced view)</h2>
<h2>{{#str}} gradeitemsetup, quiz {{/str}}</h2>
<h3>Grade items</h3>
<h3>{{#str}} gradeitems, quiz {{/str}}</h3>
<table class="table table-striped table-responsive">
{{^hasgradeitems}}
{{#nogradeitems}}
{{> core/notification_info}}
{{/nogradeitems}}
{{/hasgradeitems}}
{{#hasgradeitems}}
<table class="generaltable table-responsive">
<thead>
<tr>
<th scope="col">Grade item</th>
<th scope="col">Max mark</th>
<th scope="col">Actions</th>
<th scope="col">{{#str}} gradeitem, grades {{/str}}</th>
<th scope="col">{{#str}} actions {{/str}}</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 1" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429000" data-value="1" data-editlabel="New name for Grade item 1" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item name">
Spelling
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item name" role="img" aria-label="Edit grade item name"></i>
</span>
</a>
</span>
</th>
<td>
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 1 maximum" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429000" data-value="1" data-editlabel="New maximum for Grade item 1" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item maximum">
8.00
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item maximum" role="img" aria-label="Edit grade item maximum"></i>
</span>
</a>
</span>
</td>
<td class="align-middle">
<a href="#" data-delete-itemid="429001">
<i class="icon fa fa-trash fa-fw" title="Delete this grade item" role="img" aria-label="Delete this grade item"></i>
</a>
</td>
</tr>
<tr>
<th scope="row">
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 2" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429001" data-value="1" data-editlabel="New name for Grade item 2" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item name">
Grammar
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item name" role="img" aria-label="Edit grade item name"></i>
</span>
</a>
</span>
</th>
<td>
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 2 maximum" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429001" data-value="1" data-editlabel="New maximum for Grade item 2" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item maximum">
8.00
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item maximum" role="img" aria-label="Edit grade item maximum"></i>
</span>
</a>
</span>
</td>
<td class="align-middle">
<a href="#" data-delete-itemid="429001">
<i class="icon fa fa-trash fa-fw" title="Delete this grade item" role="img" aria-label="Delete this grade item"></i>
</a>
</td>
</tr>
<tr>
<th scope="row">
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 3" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429002" data-value="1" data-editlabel="New name for Grade item 3" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item name">
Comprehension
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item name" role="img" aria-label="Edit grade item name"></i>
</span>
</a>
</span>
</th>
<td>
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade item 3 maximum" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429002" data-value="1" data-editlabel="New maximum for Grade item 3" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit grade item maximum">
8.00
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit grade item maximum" role="img" aria-label="Edit grade item maximum"></i>
</span>
</a>
</span>
</td>
<td class="align-middle">
<a href="#" data-delete-itemid="429001">
<i class="icon fa fa-trash fa-fw" title="Delete this grade item" role="img" aria-label="Delete this grade item"></i>
</a>
</td>
</tr>
<tr>
<th scope="row">Total</th>
<td>
<span class="inplaceeditable inplaceeditable-text" data-inplaceeditable="Grade total maximum" data-component="mod_quiz" data-itemtype="slotdisplaynumber" data-itemid="429000" data-value="1" data-editlabel="New maximum for total grade" data-type="text" data-options="">
<a href="#" class="quickeditlink aalink" data-inplaceeditablelink="1" title="Edit total grade maximum">
24.00
<span class="quickediticon">
<i class="icon fa fa-pencil fa-fw " title="Edit total grade maximum" role="img" aria-label="Edit total grade maximum"></i>
</span>
</a>
</span>
</td>
<td>&nbsp;</td>
</tr>
{{#gradeitems}}
<tr data-quiz-grade-item-id="{{id}}">
<th scope="row">
<span class="inplaceeditable inplaceeditable-text"
data-raw-name="{{name}}" data-editlabel="{{#str}} gradeitemnewname, quiz, {{{displayname}}} {{/str}}">
<a href="#" class="quickeditlink aalink">
{{{displayname}}}
<span class="quickediticon">
{{#pix}}t/editstring, core{{/pix}}
</span>
</a>
</span>
</th>
<td class="align-middle">
{{^isused}}
<a href="#" data-action-delete>
{{#pix}} t/delete, core, {{#str}} gradeitemdelete, quiz, {{{name}}} {{/str}} {{/pix}}
</a>
{{/isused}}
</td>
</tr>
{{/gradeitems}}
</tbody>
</table>
{{/hasgradeitems}}
<div class="mb-5">
<button type="button" class="btn btn-secondary">Add grade item</button>
<button type="button" class="btn btn-secondary">Set up one grade item per section</button>
<button type="button" class="btn btn-secondary" id="mod_quiz-add_grade_item">{{#str}} additem, grades{{/str}}</button>
</div>
<h3>Mark scheme</h3>
@@ -28,9 +28,10 @@ Feature: Setup multiple grades for a quiz
Scenario: Navigation to, and display of, grading setup
Given the following "mod_quiz > grade items" exist:
| quiz | name |
| Quiz 1 | Intuition |
| Quiz 1 | Intelligence |
| quiz | name |
| Quiz 1 | Intuition |
| Quiz 1 | Intelligence |
| Quiz 1 | Unused grade item |
And quiz "Quiz 1" contains the following questions:
| question | page | grade item |
| Question A | 1 | Intuition |
@@ -38,3 +39,6 @@ Feature: Setup multiple grades for a quiz
| Question C | 2 | Intuition |
When I am on the "Quiz 1" "mod_quiz > multiple grades setup" page logged in as teacher
Then I should see "Grade items"
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"