Skip to content

Commit

Permalink
Move the form and add some context to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed May 7, 2024
1 parent cc24820 commit 595a545
Show file tree
Hide file tree
Showing 17 changed files with 263 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_assign\gradingapp;

/**
* This file contains the forms to create and edit an instance of this module
*
Expand All @@ -36,7 +38,7 @@
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_assign_grade_form extends moodleform {
class form extends \moodleform {
/** @var assignment $assignment */
private $assignment;

Expand Down
3 changes: 1 addition & 2 deletions mod/assign/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,6 @@ public static function submit_grading_form($assignmentid, $userid, $jsonformdata
global $CFG, $USER;

require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/assign/gradeform.php');

$params = self::validate_parameters(self::submit_grading_form_parameters(),
array(
Expand Down Expand Up @@ -1595,7 +1594,7 @@ public static function submit_grading_form($assignmentid, $userid, $jsonformdata
$formparams = array($assignment, $customdata, $options);

// Data is injected into the form by the last param for the constructor.
$mform = new mod_assign_grade_form(null, $formparams, 'post', '', null, true, $data);
$mform = new mod_assign\gradingapp\form(null, $formparams, 'post', '', null, true, $data);
$validateddata = $mform->get_data();

if ($validateddata) {
Expand Down
13 changes: 3 additions & 10 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3962,8 +3962,6 @@ protected function view_single_grading_panel($args) {

$o = '';

require_once($CFG->dirroot . '/mod/assign/gradeform.php');

// Need submit permission to submit an assignment.
require_capability('mod/assign:grade', $this->context);

Expand Down Expand Up @@ -4086,7 +4084,7 @@ protected function view_single_grading_panel($args) {
$data = (object) array_merge($data, $args['formdata']);
}
$formparams = array($this, $data, $pagination);
$mform = new mod_assign_grade_form(null,
$mform = new mod_assign\gradingapp\form(null,
$formparams,
'post',
'',
Expand Down Expand Up @@ -4127,8 +4125,6 @@ protected function view_single_grade_page($mform) {
$o = '';
$instance = $this->get_instance();

require_once($CFG->dirroot . '/mod/assign/gradeform.php');

// Need submit permission to submit an assignment.
require_capability('mod/assign:grade', $this->context);

Expand Down Expand Up @@ -4277,7 +4273,7 @@ protected function view_single_grade_page($mform) {
'userid' => $userid,
'attemptnumber' => $attemptnumber);
$formparams = array($this, $data, $pagination);
$mform = new mod_assign_grade_form(null,
$mform = new mod_assign\gradingapp\form(null,
$formparams,
'post',
'',
Expand Down Expand Up @@ -4676,7 +4672,6 @@ protected function view_grading_page() {
$o = '';
// Need submit permission to submit an assignment.
$this->require_view_grades();
require_once($CFG->dirroot . '/mod/assign/gradeform.php');

$this->add_grade_notices();

Expand Down Expand Up @@ -8751,8 +8746,6 @@ public function save_grade($userid, $data) {
*/
protected function process_save_grade(&$mform) {
global $CFG, $SESSION;
// Include grade form.
require_once($CFG->dirroot . '/mod/assign/gradeform.php');

require_sesskey();

Expand Down Expand Up @@ -8787,7 +8780,7 @@ protected function process_save_grade(&$mform) {
'last' => $last,
'attemptnumber' => $attemptnumber,
'userid' => $userid);
$mform = new mod_assign_grade_form(null,
$mform = new mod_assign\gradingapp\form(null,
array($this, $data, $gradeformparams),
'post',
'',
Expand Down
9 changes: 4 additions & 5 deletions mod/assign/templates/gradingapp/actionmenu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@
Example context (json):
{
"downloadall": "https://moodle.org"
"downloadall": "http://example.com/downloadall"
}

}}
<div class="container-fluid tertiary-navigation">
<div class="row">
{{#downloadall}}
<div class="navitem ml-sm-auto">
<a class="btn btn-secondary" href="{{downloadall}}">{{#str}}downloadall, mod_assign{{/str}}</a>
</div>
<div class="navitem ml-sm-auto">
<a class="btn btn-secondary" href="{{downloadall}}">{{#str}}downloadall, mod_assign{{/str}}</a>
</div>
{{/downloadall}}
</div>
</div>
14 changes: 9 additions & 5 deletions mod/assign/templates/gradingapp/actions.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
Data attributes required for JS:
* data-region
Context variables required for this template:
* see mod/assign/classes/output/grading_app.php
Example context (json):
{
"defaultsendnotifications": true,
"showreview": true,
"helpicon": true
}

This template is initially hidden, and is only displayed after the current user info has been loaded.
}}
Expand Down Expand Up @@ -60,7 +64,7 @@
{{/showreview}}
</div>
{{#js}}
require(['mod_assign/gradingapp/actions'], function(GradingActions) {
new GradingActions('[data-region="grade-actions"]');
});
require(['mod_assign/gradingapp/actions'], function(GradingActions) {
new GradingActions('[data-region="grade-actions"]');
});
{{/js}}
68 changes: 56 additions & 12 deletions mod/assign/templates/gradingapp/attempt_history_chooser.mustache
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
{{!
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/>.
}}
{{!
@template mod_assign/gradingapp/attempt_history_chooser
Foo
Classes required for JS:
*
Data attributes required for JS:
*
Example context (json):
{
"submissioncount": 2,
"submissions": [
{
"attemptnumber": 1,
"attemptsummary": "Attempt 1",
"statussummary": "Submitted for grading"
},
{
"attemptnumber": 2,
"attemptsummary": "Attempt 2",
"statussummary": "Submitted for grading"
}
]
}
}}
{{#submissioncount}}
<div>
<a class="btn btn-secondary" href="#" data-region="attempt-chooser" data-submissions="submissions-list-{{uniqid}}">{{#str}}viewadifferentattempt, mod_assign{{/str}}</a>
<div class="hide" id="submissions-list-{{uniqid}}">
<div data-region="submissions-list">
{{#submissions}}
<label class="radio">
<input type="radio" name="select-attemptnumber" value="{{attemptnumber}}"/>
{{attemptsummary}}
<br><em>{{statussummary}}</em>
</label>
{{/submissions}}
<div>
<a class="btn btn-secondary" href="#" data-region="attempt-chooser" data-submissions="submissions-list-{{uniqid}}">{{#str}}viewadifferentattempt, mod_assign{{/str}}</a>
<div class="hide" id="submissions-list-{{uniqid}}">
<div data-region="submissions-list">
{{#submissions}}
<label class="radio">
<input type="radio" name="select-attemptnumber" value="{{attemptnumber}}"/>
{{attemptsummary}}
<br><em>{{statussummary}}</em>
</label>
{{/submissions}}
</div>
</div>
</div>
</div>
{{/submissioncount}}
55 changes: 31 additions & 24 deletions mod/assign/templates/gradingapp/grading_app.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,49 @@
Data attributes required for JS:
* data-region, data-first-userid, data-courseid, data-contextid, data-assignmentid
Context variables required for this template:
* see mod/assign/classes/output/grading_app.php
Example context (json):
{
"userid": 2,
"courseid": 3,
"contextid": 4,
"assignmentid": 5,
"showreview": true,
"showuseridentity": true
}

This template includes ajax functionality, so it cannot be shown in the template library.
}}
<div data-region="grading-navigation-panel" data-first-userid="{{userid}}" data-courseid="{{courseid}}" data-showuseridentity="{{showuseridentity}}">
{{> mod_assign/gradingapp/navigation }}
{{> mod_assign/gradingapp/navigation }}
</div>
{{#showreview}}
<div data-region="review-panel">
<a href="#" data-region="review-panel-toggle">
<div class="collapse-icon">{{#pix}} t/expanded, core, {{#str}} collapsereviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="expand-icon">
<div class="ltr-icon">{{#pix}} t/collapsed, core, {{#str}} expandreviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="rtl-icon">{{#pix}} t/collapsed_rtl, core, {{#str}} expandreviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="toggle-text">{{#str}} clickexpandreviewpanel, mod_assign {{/str}}</div>
</div>
</a>
<div data-region="review-panel-content">
<div data-region="review">
{{> mod_assign/gradingapp/review_panel }}
<div data-region="review-panel">
<a href="#" data-region="review-panel-toggle">
<div class="collapse-icon">{{#pix}} t/expanded, core, {{#str}} collapsereviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="expand-icon">
<div class="ltr-icon">{{#pix}} t/collapsed, core, {{#str}} expandreviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="rtl-icon">{{#pix}} t/collapsed_rtl, core, {{#str}} expandreviewpanel, mod_assign {{/str}} {{/pix}}</div>
<div class="toggle-text">{{#str}} clickexpandreviewpanel, mod_assign {{/str}}</div>
</div>
</a>
<div data-region="review-panel-content">
<div data-region="review">
{{> mod_assign/loading }}
</div>
</div>
</div>
</div>
{{/showreview}}
<div data-region="grade-panel" {{^showreview}}class="fullwidth"{{/showreview}}>
<div data-region="grade" data-contextid="{{contextid}}" data-assignmentid="{{assignmentid}}">
{{> mod_assign/gradingapp/panel }}
</div>
<div data-region="grade" data-contextid="{{contextid}}" data-assignmentid="{{assignmentid}}">
{{> mod_assign/gradingapp/panel }}
</div>
</div>
<div data-region="grade-actions-panel">
<div data-region="grade-actions">
<div class="tool_usertours-resettourcontainer float-left"></div>
{{> mod_assign/gradingapp/actions }}
</div>
<div data-region="grade-actions">
<div class="tool_usertours-resettourcontainer float-left"></div>
{{> mod_assign/gradingapp/actions }}
</div>
</div>
<div data-region="overlay" class="moodle-has-zindex">
{{> mod_assign/gradingapp/save_in_progress }}
{{> mod_assign/gradingapp/save_in_progress }}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@
* list of fields from mod_assign_list_participants webservice
Example context (json):
{ "id": "4",
"fullname": "Mr T",
"requiregrading": "true",
"identity": "email, phone, etc"
{
"fullname": "Mr T",
"identity": "[email protected], T"
}
}}
<span>{{fullname}} <small>{{identity}}</small> {{#requiregrading}}<abbr title="{{#str}}filterrequiregrading, mod_assign{{/str}}">*</abbr>{{/requiregrading}}</span>
<span>
{{fullname}}
<small>{{identity}}</small>
{{#requiregrading}}
<abbr title="{{#str}}filterrequiregrading, mod_assign{{/str}}">*</abbr>
{{/requiregrading}}
</span>
Loading

0 comments on commit 595a545

Please sign in to comment.