From d43c1a1d775161adc6dc9f51e28e8941340806a2 Mon Sep 17 00:00:00 2001 From: Alex Yeung Date: Fri, 22 Dec 2023 16:53:12 +0000 Subject: [PATCH] CTP-2812 Hide submission log information --- classes/output/renderer.php | 9 +++++++-- db/access.php | 5 +++++ index.php | 4 ++-- lang/en/local_sitsgradepush.php | 1 + templates/assessmentgrades.mustache | 21 ++++++++++++--------- version.php | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/classes/output/renderer.php b/classes/output/renderer.php index cdf0611..dc16ecc 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -71,7 +71,7 @@ public function __construct(moodle_page $page, $target) { * @return string Rendered HTML * @throws \moodle_exception */ - public function render_button(string $id, string $name, string $disabled = '', $class = '') : string { + public function render_button(string $id, string $name, string $disabled = '', string $class = '') : string { return $this->output->render_from_template( 'local_sitsgradepush/button', ['id' => $id, 'name' => $name, 'disabled' => $disabled, 'class' => $class] @@ -95,10 +95,11 @@ public function render_link(string $id, string $name, string $url) : string { * Render the assessment push status table. * * @param \stdClass $mapping Assessment mapping + * @param int $courseid Course ID * @return string Rendered HTML * @throws \moodle_exception */ - public function render_assessment_push_status_table(\stdClass $mapping) : string { + public function render_assessment_push_status_table(\stdClass $mapping, int $courseid) : string { $students = null; // Modify the timestamp format and add the label for the last push result. if (!empty($mapping->students)) { @@ -129,6 +130,9 @@ public function render_assessment_push_status_table(\stdClass $mapping) : string // Check if there is any task info to display. $additionalinfo = $lasttasktext || $hastaskinprogress; + // Check if the user has the capability to see the submission log column. + $showsublogcolumn = has_capability('local/sitsgradepush:showsubmissionlogcolumn', \context_course::instance($courseid)); + // Render the table. return $this->output->render_from_template('local_sitsgradepush/assessmentgrades', [ 'mappingid' => $mappingid, @@ -136,6 +140,7 @@ public function render_assessment_push_status_table(\stdClass $mapping) : string 'students' => $students, 'lasttask' => $lasttasktext, 'additionalinfo' => $additionalinfo, + 'showsublogcolumn' => $showsublogcolumn, ]); } diff --git a/db/access.php b/db/access.php index 5337930..53d1805 100644 --- a/db/access.php +++ b/db/access.php @@ -38,4 +38,9 @@ 'contextlevel' => CONTEXT_COURSE, 'archetypes' => [], ], + 'local/sitsgradepush:showsubmissionlogcolumn' => [ + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => [], + ], ]; diff --git a/index.php b/index.php index be542c2..351edb6 100644 --- a/index.php +++ b/index.php @@ -129,12 +129,12 @@ // Display grade push records for each mapping. foreach ($content['mappings'] as $mapping) { $mappingids[] = $mapping->id; - echo $renderer->render_assessment_push_status_table($mapping); + echo $renderer->render_assessment_push_status_table($mapping, $coursemodule->course); } // Display invalid students. if (!empty($content['invalidstudents']->students)) { - echo $renderer->render_assessment_push_status_table($content['invalidstudents']); + echo $renderer->render_assessment_push_status_table($content['invalidstudents'], $coursemodule->course); } } else { echo '

' . get_string('error:assessmentisnotmapped', 'local_sitsgradepush') . '

'; diff --git a/lang/en/local_sitsgradepush.php b/lang/en/local_sitsgradepush.php index 952aa12..f7c4580 100644 --- a/lang/en/local_sitsgradepush.php +++ b/lang/en/local_sitsgradepush.php @@ -141,6 +141,7 @@ // Capability strings. $string['sitsgradepush:mapassessment'] = 'Map assessment component to Moodle activity'; $string['sitsgradepush:pushgrade'] = 'Transfer Marks to SITS'; +$string['sitsgradepush:showsubmissionlogcolumn'] = 'Show Submission Log column'; // Task strings. $string['task:pushtask:name'] = 'Schedule Transfer Task'; diff --git a/templates/assessmentgrades.mustache b/templates/assessmentgrades.mustache index 0a6c4d0..e2a294a 100644 --- a/templates/assessmentgrades.mustache +++ b/templates/assessmentgrades.mustache @@ -32,7 +32,7 @@ Example context (json): { "tabletitle":"PHAY0063-2022-T1-A7P-001 Coursework 4000 word written case studies (50%)", - "additionalinfo":true, + "additionalinfo":false, "students":[{ "firstname":"Test", "lastname":"User", @@ -62,12 +62,14 @@ {{/additionalinfo}} - {{#str}} index:student, local_sitsgradepush {{/str}} - {{#str}} index:porticonumber, local_sitsgradepush {{/str}} - {{#str}} index:grade, local_sitsgradepush {{/str}} - {{#str}} index:submissiondate, local_sitsgradepush {{/str}} - {{#str}} index:lastmarktransfer, local_sitsgradepush {{/str}} - {{#str}} index:lastsublogtransfer, local_sitsgradepush {{/str}} + Student + Portico number + Grade + Submission date + Last grade push + {{#showsublogcolumn}} + Last submission log push + {{/showsublogcolumn}} @@ -78,8 +80,9 @@ {{marks}} {{handindatetime}} {{{lastgradepushresultlabel}}}{{lastgradepushtime}} - {{{lastsublogpushresultlabel}}}{{lastsublogpushtime}} - + {{#showsublogcolumn}} + {{{lastsublogpushresultlabel}}}{{lastsublogpushtime}} + {{/showsublogcolumn}} {{/students}} diff --git a/version.php b/version.php index c6293c8..53f454f 100644 --- a/version.php +++ b/version.php @@ -27,7 +27,7 @@ $plugin->component = 'local_sitsgradepush'; $plugin->release = '0.1.0'; -$plugin->version = 2023121900; +$plugin->version = 2023122200; $plugin->requires = 2021051708; $plugin->maturity = MATURITY_ALPHA; $plugin->dependencies = [