Skip to content

Commit

Permalink
CTP-2923 Minor improvements for marks transfer plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
aydevworks committed Jan 5, 2024
1 parent d43c1a1 commit cd965f8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 74 deletions.
2 changes: 1 addition & 1 deletion amd/build/dashboard.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/dashboard.min.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions amd/src/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,17 @@ function initPushMarkButtons(page, courseid) {
if (mabpushbuttons.length > 0) {
// Push grades when the user clicks on each enabled push button.
mabpushbuttons.forEach(function(button) {
button.addEventListener("click", async function() {
// Find the number of students to push grades.
let studentcount = button.getAttribute("data-numberofstudents");
let assessmentmappingid = button.getAttribute("data-assessmentmappingid");

// Disable the button if there is no assessment mapping ID.
if (assessmentmappingid === null) {
button.disabled = true;
return;
}
// Find the number of students to push grades.
let studentcount = button.getAttribute("data-numberofstudents");
let assessmentmappingid = button.getAttribute("data-assessmentmappingid");

// Disable the push button if there is no assessment mapping ID.
if (assessmentmappingid === null) {
button.disabled = true;
return;
}

button.addEventListener("click", async function() {
if (studentcount === '0') {
// Show an error message if there is no student to push grades.
showErrorMessageForButton(button, 'There are no marks to transfer.');
Expand Down
13 changes: 3 additions & 10 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@
*/
class renderer extends plugin_renderer_base {

/** @var string Push task status - requested */
const PUSH_STATUS_ICON_REQUESTED = 'requested';

/** @var string Push task status - queued */
const PUSH_STATUS_ICON_QUEUED = 'queued';

/** @var string Push task status - processing */
const PUSH_STATUS_ICON_PROCESSING = 'processing';

/** @var string Push task status - has push records */
const PUSH_STATUS_ICON_HAS_PUSH_RECORDS = 'has_push_records';

Expand Down Expand Up @@ -210,6 +201,8 @@ public function render_dashboard(array $moduledeliveries, int $courseid) : strin
['id' => $coursemodule->id]
);
$assessmentmapping->url = $coursemoduleurl->out(false);
$transferhistoryurl = new \moodle_url('/local/sitsgradepush/index.php', ['id' => $coursemodule->id]);
$assessmentmapping->transferhistoryurl = $transferhistoryurl->out(false);
$assessmentmapping->status =
$this->get_assessment_mapping_status_icon($componentgrade->assessmentmappingid);
$assessmentmapping->statusicon = $assessmentmapping->status->statusicon;
Expand All @@ -227,7 +220,7 @@ public function render_dashboard(array $moduledeliveries, int $courseid) : strin
'local_sitsgradepush/module_delivery_table',
[
'tableid' => $tableid,
'modcode' => $moduledelivery->modcode,
'moduledelivery' => $tableid,
'academicyear' => $moduledelivery->academicyear,
'level' => $moduledelivery->level,
'graduatetype' => $moduledelivery->graduatetype,
Expand Down
45 changes: 0 additions & 45 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

use context_course;
use context_module;
use local_sitsgradepush\assessment\assessmentfactory;
use moodle_exception;
use moodle_url;

Expand All @@ -39,9 +38,6 @@
// Course module ID.
$coursemoduleid = required_param('id', PARAM_INT);

// Initiate grade push and show push result.
$pushgrade = optional_param('pushgrade', 0, PARAM_INT);

// Get manager and check course module exists.
if (!$coursemodule = get_coursemodule_from_id(null, $coursemoduleid)) {
throw new moodle_exception('course module not found.', 'local_sitsgradepush');
Expand Down Expand Up @@ -85,47 +81,6 @@
$mappingids = [];

if (!empty($content)) {
// Check if asynchronous grade push is enabled.
$async = get_config('local_sitsgradepush', 'async');

// Check if this course module has pending task.
if ($async) {
// Get push button label.
$buttonlabel = get_string('label:pushgrade', 'local_sitsgradepush');
$disabled = '';
} else {
// Push grade and submission log.
if ($pushgrade == 1) {
// Loop through each mapping.
foreach ($content['mappings'] as $mapping) {
// Push grades for each student in the mapping.
foreach ($mapping->students as $student) {
$manager->push_grade_to_sits($mapping, $student->userid);
$manager->push_submission_log_to_sits($mapping, $student->userid);
}
}

// Refresh data after completed all pushes.
$content = $manager->get_assessment_data($coursemoduleid);
$buttonlabel = get_string('label:ok', 'local_sitsgradepush');
} else {
$url->param('pushgrade', 1);
$buttonlabel = get_string('label:pushgrade', 'local_sitsgradepush');
}
}

// Render push button if the assessment is mapped.
if ($manager->is_activity_mapped($coursemoduleid)) {
if ($async) {
echo $renderer->render_button('local_sitsgradepush_pushbutton_async', $buttonlabel, $disabled);
} else {
echo $renderer->render_link('local_sitsgradepush_pushbutton', $buttonlabel, $url->out(false));
}

} else {
echo '<p class="alert alert-danger">' . get_string('error:assessmentisnotmapped', 'local_sitsgradepush') . '</p>';
}

// Display grade push records for each mapping.
foreach ($content['mappings'] as $mapping) {
$mappingids[] = $mapping->id;
Expand Down
2 changes: 1 addition & 1 deletion lang/en/local_sitsgradepush.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

// Marks transfer dashboard page.
$string['dashboard:header'] = 'SITS Marks Transfer Dashboard';
$string['dashboard:modcode'] = 'MODULE CODE: {$a}';
$string['dashboard:moduledelivery'] = 'MODULE DELIVERY: {$a}';
$string['dashboard:academicyear'] = 'ACADEMIC YEAR: {$a}';
$string['dashboard:level'] = 'LEVEL: {$a}';
$string['dashboard:mapcode'] = 'MAP CODE: {$a}';
Expand Down
17 changes: 11 additions & 6 deletions templates/module_delivery_table.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
Example context (json):
{
"tableid": "PHAY0063-A7P-T1-2022",
"modcode": "PHAY0063",
"moduledelivery": "PHAY0063-A7P-T1-2022",
"academicyear": "2022",
"componentgrades":
{
Expand All @@ -66,6 +66,7 @@
"url": "http://test.m4.local:4001/mod/assign/view.php?id=960",
"statusicon": "<i class=\"fa-regular fa-file-lines\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Push records exist\"></i>",
"selectsourceurl": "http://test.m4.local:4001/local/sitsgradepush/select_source.php?courseid=2&mabid=22",
"transferhistoryurl": "http://test.m4.local:4001/local/sitsgradepush/index.php?id=22",
"numberofstudents": "10"
},
"disablechangesourcebutton": " disabled"
Expand All @@ -81,14 +82,18 @@
<tr>
<th colspan="5">
<div class="row">
<div class="col header-part" style="text-align: left">{{#str}} dashboard:modcode, local_sitsgradepush, {{modcode}} {{/str}}</div>
<div class="col header-part">{{#str}} dashboard:academicyear, local_sitsgradepush, {{academicyear}} {{/str}}</div>
<div class="col header-part" style="text-align: right">{{#str}} dashboard:level, local_sitsgradepush, {{level}} {{/str}} {{graduatetype}}</div>
<div class="col header-part" style="text-align: left">{{#str}} dashboard:moduledelivery, local_sitsgradepush, {{moduledelivery}} {{/str}}</div>
<div class="col header-part" style="text-align: right">{{#str}} dashboard:academicyear, local_sitsgradepush, {{academicyear}} {{/str}}</div>
</div>
</th>
</tr>
<tr>
<th colspan="5" style="text-align: left">{{#str}} dashboard:mapcode, local_sitsgradepush, {{mapcode}} {{/str}}</th>
<th colspan="5" style="text-align: left">
<div class="row">
<div class="col header-part" style="text-align: left">{{#str}} dashboard:mapcode, local_sitsgradepush, {{mapcode}} {{/str}}</div>
<div class="col header-part" style="text-align: right">{{#str}} dashboard:level, local_sitsgradepush, {{level}} {{/str}} {{graduatetype}}</div>
</div>
</th>
</tr>
<tr>
<th class="seq-col">{{#str}} dashboard:seq, local_sitsgradepush {{/str}}</th>
Expand Down Expand Up @@ -144,7 +149,7 @@
</span>
<span style="width: 20px">
{{#assessmentmapping}}
{{{statusicon}}}
<a href="{{transferhistoryurl}}" target="_blank" data-toggle="tooltip" data-placement="top">{{{statusicon}}}</a>
{{/assessmentmapping}}
{{^assessmentmapping}}
<i class="fa-solid fa-circle-info records-icon" data-toggle="tooltip" data-placement="top"
Expand Down

0 comments on commit cd965f8

Please sign in to comment.