Skip to content

Commit

Permalink
Added 3 files so as to support the rubric refined/flex grading method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Jan 5, 2024
1 parent 934adcc commit 2b43901
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 0 deletions.
105 changes: 105 additions & 0 deletions classes/rubref.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
// 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/>.

/**
* 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 .= '<tr>';
$rows .= get_student_cells($data, $student);
foreach (array_keys($data['criterion']) as $crikey) {
$rows .= '<td>' . $student['grades'][$crikey]['score'] . '</td>';
$rows .= '<td>' . $student['grades'][$crikey]['definition'] .'</td>';
$rows .= '<td>' . $student['grades'][$crikey]['feedback'] . '</td>';
}
$rows .= get_summary_cells($student);
$rows .= '</tr>';
}
}
if ($rows == "") {
$rows .= '<tr> <td>' . get_string('nomarkedsubmissions', 'report_advancedgrading') . '</td>';
for ($i = 0; $i < $data['colcount'] - 1; $i++) {
$rows .= '<td></td>';
}
$rows .= '</tr>';
}
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;
}
}
64 changes: 64 additions & 0 deletions rubref.mustache
Original file line number Diff line number Diff line change
@@ -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
<http: //www.gnu.org/licenses />.
}}
{{!
@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"
}
]
}
}}
<div>

<table id="rubref-header" class="table table-hover table-bordered table-striped" style="width:101%;" >
<thead>
<tr>
<th colspan={{{studentspan}}}>
{{#str}}student, report_advancedgrading{{/str}}
</th>
{{#criteria}}
<th colspan={{{criteriaspan}}} class="align-top">{{description}}</th>
{{/criteria}}
<th colspan={{{summaryspan}}} >{{#str}}gradesummary, report_advancedgrading{{/str}}</th>
</tr>
<tr>
{{{studentheaders}}}
{{#criteria}}
<th {{{headerstyle}}} ><b>{{#str}}score, report_advancedgrading {{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}definition, report_advancedgrading {{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}feedback, report_advancedgrading{{/str}}</b></th>
{{/criteria}}
<th {{{headerstyle}}} ><b>{{#str}}overall_feedback, report_advancedgrading{{/str}} </b></th>
<th {{{headerstyle}}} ><b>{{#str}}grade, report_advancedgrading{{/str}} </b></th>
<th {{{headerstyle}}} ><b>{{#str}}gradedby, report_advancedgrading{{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}timegraded, report_advancedgrading {{/str}}</b></th>
{{{summaryheader}}}
</tr>
</thead>
<tbody>
{{{rows}}}
</tbody>
</table>
</div>
64 changes: 64 additions & 0 deletions rubref.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
// 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/>.

/**
* 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);
64 changes: 64 additions & 0 deletions templates/rubref.mustache
Original file line number Diff line number Diff line change
@@ -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
<http: //www.gnu.org/licenses />.
}}
{{!
@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"
}
]
}
}}
<div>

<table id="rubref-header" class="table table-hover table-bordered table-striped" style="width:101%;" >
<thead>
<tr>
<th colspan={{{studentspan}}}>
{{#str}}student, report_advancedgrading{{/str}}
</th>
{{#criteria}}
<th colspan={{{criteriaspan}}} class="align-top">{{description}}</th>
{{/criteria}}
<th colspan={{{summaryspan}}} >{{#str}}gradesummary, report_advancedgrading{{/str}}</th>
</tr>
<tr>
{{{studentheaders}}}
{{#criteria}}
<th {{{headerstyle}}} ><b>{{#str}}score, report_advancedgrading {{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}definition, report_advancedgrading {{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}feedback, report_advancedgrading{{/str}}</b></th>
{{/criteria}}
<th {{{headerstyle}}} ><b>{{#str}}overall_feedback, report_advancedgrading{{/str}} </b></th>
<th {{{headerstyle}}} ><b>{{#str}}grade, report_advancedgrading{{/str}} </b></th>
<th {{{headerstyle}}} ><b>{{#str}}gradedby, report_advancedgrading{{/str}}</b></th>
<th {{{headerstyle}}} ><b>{{#str}}timegraded, report_advancedgrading {{/str}}</b></th>
{{{summaryheader}}}
</tr>
</thead>
<tbody>
{{{rows}}}
</tbody>
</table>
</div>

0 comments on commit 2b43901

Please sign in to comment.