Skip to content

Commit

Permalink
Add setting for graded by column
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarat87 committed Aug 20, 2024
1 parent 0ad73f7 commit 65b445c
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 7 deletions.
4 changes: 3 additions & 1 deletion classes/btec.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public function get_data(\cm_info $cm) : array {
global $DB;
$sql = "SELECT gbf.id AS ggfid, crs.shortname AS course, asg.name AS assignment, asg.grade as gradeoutof, gd.name AS btec,
criteria.shortname, criteria.description as definition, criteria.description , gbf.score,
gbf.remark, gbf.criterionid, marker.username AS grader,
gbf.remark, gbf.criterionid, marker.username AS graderusername,
marker.firstname AS graderfirstname, marker.lastname AS graderlastname,
marker.email AS graderemail,
stu.id AS userid, stu.idnumber AS idnumber, stu.firstname, stu.lastname,
stu.username AS username, gin.timemodified AS modified,ag.id, ag.grade,
assign_comment.commenttext as overallfeedback
Expand Down
4 changes: 3 additions & 1 deletion classes/guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function get_data(\assign $assign, \cm_info $cm) :array {
$sql = "SELECT fillings.id AS ggfid, cm.course AS course, asg.name AS assignment,
asg.grade as gradeoutof,gd.name AS guide,
criteria.description,criteria.shortname,
fillings.score, fillings.remark, fillings.criterionid, rubm.username AS grader,
fillings.score, fillings.remark, fillings.criterionid, rubm.username AS graderusername,
rubm.firstname AS graderfirstname, rubm.lastname AS graderlastname,
rubm.email AS graderemail,
stu.id AS userid, stu.idnumber AS idnumber, stu.firstname, stu.lastname,
stu.username, stu.email, ag.timemodified AS modified, ag.grade,
assign_comment.commenttext as overallfeedback
Expand Down
4 changes: 3 additions & 1 deletion classes/rubref.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function get_data(\assign $assign, \cm_info $cm) : array {
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,
stu.username, stu.email, rubm.username AS graderusername,
rubm.firstname AS graderfirstname, rubm.lastname AS graderlastname,
rubm.email AS graderemail,
gin.timemodified AS modified,
ctx.instanceid, ag.grade, asg.blindmarking, assign_comment.commenttext as overallfeedback
FROM {assign} asg
Expand Down
4 changes: 3 additions & 1 deletion classes/rubric.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function get_data(\assign $assign, \cm_info $cm) : array {
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,
stu.username, stu.email, rubm.username AS graderusername,
rubm.firstname AS graderfirstname, rubm.lastname AS graderlastname,
rubm.email AS graderemail,
ag.timemodified AS modified,
ctx.instanceid, ag.grade, asg.blindmarking, assign_comment.commenttext as overallfeedback
FROM {assign} asg
Expand Down
4 changes: 3 additions & 1 deletion classes/rubric_ranges.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public function get_data(\assign $assign, \cm_info $cm): array {
level.definition, grf.remark, grf.grade as grade_rub_range, grf.criterionid,
stu.id AS userid, stu.idnumber AS idnumber,
stu.firstname, stu.lastname, stu.username,
stu.username, stu.email, CONCAT(rubm.firstname, ' - ',rubm.lastname) AS grader,
stu.username, stu.email, rubm.username AS graderusername,
rubm.firstname AS graderfirstname, rubm.lastname AS graderlastname,
rubm.email AS graderemail,
ag.timemodified AS modified,
ctx.instanceid, ag.grade, asg.blindmarking, assign_comment.commenttext as overallfeedback
FROM {assign} asg
Expand Down
6 changes: 6 additions & 0 deletions lang/en/report_advancedgrading.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@
$string['viewsubmissions_help'] = 'View submissions';
$string['enable_javascriptlayout'] = 'Enable javascript layout';
$string['enable_javascriptlayout_desc'] = 'Adds paging and sorting to the table layout, may add a performance overhead';
$string['profilefieldsgradeby'] = 'Profile fields graded by';
$string['profilefieldsgradeby_desc'] = 'Additional user fields shown in report for column \'Graded By\'';
$string['graderusername'] = 'Username';
$string['graderfirstname'] = 'First name';
$string['graderlastname'] = 'Last name';
$string['graderemail'] = 'Email address';
18 changes: 17 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function get_grades(array $data, array $dbrecords): array {

$gi = [
'overallfeedback' => $grade->overallfeedback,
'grader' => $grade->grader,
'grader' => gradedbydata($grade),
'timegraded' => $grade->modified,
'grade' => $formattedgrade
];
Expand Down Expand Up @@ -418,3 +418,19 @@ function output_header(string $filename, string$filetype) : bool {
header('Content-Disposition: attachment;filename="' . $filename);
return true;
}

/**
* Return the data for the graded by column following the config.
*
* @param array $gradedata
* @return string The corresponding data from the settings.
*/
function gradedbydata($gradedata): string {
$graderprofileconfig = trim(get_config('report_advancedgrading', 'profilefieldsgradeby'));
$gradedbyfields = empty($graderprofileconfig) ? [] : explode(',', $graderprofileconfig);
$fielddata = [];
foreach ($gradedbyfields as $field) {
$fielddata[] = $gradedata->$field;
}
return implode(' - ', $fielddata);
}
19 changes: 19 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,23 @@
['username' => 1],
$choices
));

$rawchoicesgradeby = [
'graderusername',
'graderfirstname',
'graderlastname',
'graderemail',
];
$choices = [];
foreach ($rawchoicesgradeby as $choice) {
$choices[$choice] = new lang_string($choice, 'report_advancedgrading');
}

$settings->add(new admin_setting_configmulticheckbox(
'report_advancedgrading/profilefieldsgradeby',
new lang_string('profilefieldsgradeby', 'report_advancedgrading'),
new lang_string('profilefieldsgradeby_desc', 'report_advancedgrading'),
['graderusername' => 1],
$choices
));
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2024030400; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024081900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021051715; // Moodle 3.11.
$plugin->release = '1.0';
$plugin->supported = [311, 404];
Expand Down

0 comments on commit 65b445c

Please sign in to comment.