From 2b43901aa197d8f718f1c2836204c5ad9e86460e Mon Sep 17 00:00:00 2001 From: Marcus Green Date: Fri, 5 Jan 2024 14:00:29 +0000 Subject: [PATCH] Added 3 files so as to support the rubric refined/flex grading method --- classes/rubref.php | 105 ++++++++++++++++++++++++++++++++++++++ rubref.mustache | 64 +++++++++++++++++++++++ rubref.php | 64 +++++++++++++++++++++++ templates/rubref.mustache | 64 +++++++++++++++++++++++ 4 files changed, 297 insertions(+) create mode 100644 classes/rubref.php create mode 100644 rubref.mustache create mode 100644 rubref.php create mode 100644 templates/rubref.mustache diff --git a/classes/rubref.php b/classes/rubref.php new file mode 100644 index 0000000..1aa684f --- /dev/null +++ b/classes/rubref.php @@ -0,0 +1,105 @@ +. + +/** + * This is the external API for this report. + * + * @package report_advancedgrading + * @copyright 2022 Marcus Green + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace report_advancedgrading; + +/** + * Logic to process data for assignments using the rubref grading ethod + * + * @copyright 2022 Marcus Green + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class rubref { + + /** + * Assemble the table rows for grading informationin an array from the database records returned. + * for each student + * + * @param array $data + * @return string + */ + public function get_rows(array $data): string { + $rows = ''; + if (isset($data['students'])) { + foreach ($data['students'] as $student) { + $rows .= ''; + $rows .= get_student_cells($data, $student); + foreach (array_keys($data['criterion']) as $crikey) { + $rows .= '' . $student['grades'][$crikey]['score'] . ''; + $rows .= '' . $student['grades'][$crikey]['definition'] .''; + $rows .= '' . $student['grades'][$crikey]['feedback'] . ''; + } + $rows .= get_summary_cells($student); + $rows .= ''; + } + } + if ($rows == "") { + $rows .= ' ' . get_string('nomarkedsubmissions', 'report_advancedgrading') . ''; + for ($i = 0; $i < $data['colcount'] - 1; $i++) { + $rows .= ''; + } + $rows .= ''; + } + return $rows; + } + /** + * Query the database for the student grades. + * + * @param \assign $assign + * @param \cm_info $cm + * @return array + */ + public function get_data(\assign $assign, \cm_info $cm) : array { + global $DB; + $sql = "SELECT grf.id as grfid, + cm.course, asg.name as assignment,asg.grade as gradeoutof, + criteria.description, grf.levelmarks as score, + level.definition, grf.remark, grf.criterionid, + stu.id AS userid, stu.idnumber AS idnumber, + stu.firstname, stu.lastname, stu.username, + stu.username, stu.email, rubm.username AS grader, + gin.timemodified AS modified, + ctx.instanceid, ag.grade, asg.blindmarking, assign_comment.commenttext as overallfeedback + FROM {assign} asg + JOIN {course_modules} cm ON cm.instance = asg.id + JOIN {context} ctx ON ctx.instanceid = cm.id + JOIN {grading_areas} ga ON ctx.id=ga.contextid + JOIN {grading_definitions} gd ON ga.id = gd.areaid + JOIN {gradingform_rubref_criteria} criteria ON (criteria.definitionid = gd.id) + JOIN {gradingform_rubref_levels} level ON (level.criterionid = criteria.id) + JOIN {grading_instances} gin ON gin.definitionid = gd.id + JOIN {assign_grades} ag ON ag.id = gin.itemid + LEFT JOIN {assignfeedback_comments} assign_comment on assign_comment.grade = ag.id + JOIN {user} stu ON stu.id = ag.userid + JOIN {user} rubm ON rubm.id = ag.grader + JOIN {gradingform_rubref_fillings} grf ON (grf.instanceid = gin.id) + AND (grf.criterionid = criteria.id) AND (grf.levelid = level.id) + WHERE cm.id = :assignid AND gin.status = 0 + AND stu.deleted = 0 + ORDER BY lastname ASC, firstname ASC, userid ASC, criteria.sortorder ASC"; + + $data = $DB->get_records_sql($sql, ['assignid' => $cm->id]); + $data = set_blindmarking($data, $assign, $cm); + return $data; + } +} diff --git a/rubref.mustache b/rubref.mustache new file mode 100644 index 0000000..54cec6d --- /dev/null +++ b/rubref.mustache @@ -0,0 +1,64 @@ +{{! +This file is part of Moodle - https://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 +. +}} +{{! + @template report_advancedgrading/rubref + Template for rendering rubref report output + Example context (json): + { + "header": [ + { + "coursename": "public-tab", + "assignment": "Public comments", + "gradingmethod": "Public comments' content", + "definition": "rubref Criteria" + } + ] + } +}} +
+ + + + + + {{#criteria}} + + {{/criteria}} + + + + {{{studentheaders}}} + {{#criteria}} + + + + {{/criteria}} + + + + + {{{summaryheader}}} + + + + {{{rows}}} + +
+ {{#str}}student, report_advancedgrading{{/str}} + {{description}}{{#str}}gradesummary, report_advancedgrading{{/str}}
{{#str}}score, report_advancedgrading {{/str}}{{#str}}definition, report_advancedgrading {{/str}}{{#str}}feedback, report_advancedgrading{{/str}}{{#str}}overall_feedback, report_advancedgrading{{/str}} {{#str}}grade, report_advancedgrading{{/str}} {{#str}}gradedby, report_advancedgrading{{/str}}{{#str}}timegraded, report_advancedgrading {{/str}}
+
diff --git a/rubref.php b/rubref.php new file mode 100644 index 0000000..5467ea5 --- /dev/null +++ b/rubref.php @@ -0,0 +1,64 @@ +. + +/** + * Exports an Excel spreadsheet of the grades in a rubref-graded assignment. + * + * @package report_advancedgrading + * @copyright 2022 Marcus Green + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +require(__DIR__ . '../../../config.php'); +require_once(__DIR__ . '/../../report/advancedgrading/locallib.php'); +require_once(__DIR__ . '/../../lib/excellib.class.php'); +require_once(__DIR__ . '/../../grade/lib.php'); + +$data['courseid'] = required_param('id', PARAM_INT); // Course ID. +require_login($data['courseid']); +use report_advancedgrading\rubref; + +$dload = optional_param("dload", '', PARAM_BOOL); + +$data['headerstyle'] = ''; + +$data['reportname'] = get_string('rubrefreportname', 'report_advancedgrading'); +$data['grademethod'] = 'rubref'; +$data['modid'] = required_param('modid', PARAM_INT); // CM ID. + +$data = init($data); +require_capability('mod/assign:grade', $data['context']); + +$rubref = new rubref(); +$data['dbrecords'] = $rubref->get_data($data['assign'], $data['cm']); + +$data = user_fields($data, $data['dbrecords']); +if (isset($data['students'])) { + $data = add_groups($data, $data['courseid']); + $data = get_grades($data, $data['dbrecords']); +} + + +// Each rubref criteria has a score,definition and feedback column. +$data['criteriaspan'] = 3; +$data['colcount'] += count($data['criteria']) * 3; +$data['rows'] = $rubref->get_rows($data); + +$form = $OUTPUT->render_from_template('report_advancedgrading/form', $data); +$table = $OUTPUT->render_from_template('report_advancedgrading/header', $data); +$table .= $OUTPUT->render_from_template('report_advancedgrading/rubref', $data); + +send_output($form, $dload, $data, $table); diff --git a/templates/rubref.mustache b/templates/rubref.mustache new file mode 100644 index 0000000..1377c2f --- /dev/null +++ b/templates/rubref.mustache @@ -0,0 +1,64 @@ +{{! +This file is part of Moodle - https://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 +. +}} +{{! + @template report_advancedgrading/rubref + Template for rendering rubref report output + Example context (json): + { + "header": [ + { + "coursename": "public-tab", + "assignment": "Public comments", + "gradingmethod": "Public comments' content", + "definition": "rubref Criteria" + } + ] + } +}} +
+ + + + + + {{#criteria}} + + {{/criteria}} + + + + {{{studentheaders}}} + {{#criteria}} + + + + {{/criteria}} + + + + + {{{summaryheader}}} + + + + {{{rows}}} + +
+ {{#str}}student, report_advancedgrading{{/str}} + {{description}}{{#str}}gradesummary, report_advancedgrading{{/str}}
{{#str}}score, report_advancedgrading {{/str}}{{#str}}definition, report_advancedgrading {{/str}}{{#str}}feedback, report_advancedgrading{{/str}}{{#str}}overall_feedback, report_advancedgrading{{/str}} {{#str}}grade, report_advancedgrading{{/str}} {{#str}}gradedby, report_advancedgrading{{/str}}{{#str}}timegraded, report_advancedgrading {{/str}}
+
\ No newline at end of file