Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTP-2495 Replace quiz deprecated methods #29

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/external/map_assessment.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function execute_parameters() {
'courseid' => new external_value(PARAM_INT, 'Coruse ID', VALUE_REQUIRED),
'coursemoduleid' => new external_value(PARAM_INT, 'Course Module ID', VALUE_REQUIRED),
'mabid' => new external_value(PARAM_INT, 'Assessment Component ID', VALUE_REQUIRED),
'partid' => new external_value(PARAM_INT, 'Assessment Part ID', VALUE_OPTIONAL),
'partid' => new external_value(PARAM_INT, 'Assessment Part ID', VALUE_DEFAULT, null),
]);
}

Expand Down
40 changes: 39 additions & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace local_sitsgradepush\privacy;

use core_privacy\local\metadata\collection;

/**
* Data provider class.
*
Expand All @@ -24,7 +26,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Alex Yeung <[email protected]>
*/
class provider implements \core_privacy\local\metadata\null_provider {
class provider implements
\core_privacy\local\metadata\null_provider,
\core_privacy\local\metadata\provider {

/**
* Get the language string identifier with the component's language
Expand All @@ -35,4 +39,38 @@ class provider implements \core_privacy\local\metadata\null_provider {
public static function get_reason() : string {
return 'privacy:metadata';
}

/**
* Returns metadata about this plugin.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
$collection->add_database_table('local_sitsgradepush_tfr_log', [
'type' => 'privacy:metadata:local_sitsgradepush_tfr_log:type',
'userid' => 'privacy:metadata:local_sitsgradepush_tfr_log:userid',
'request' => 'privacy:metadata:local_sitsgradepush_tfr_log:request',
'requestbody' => 'privacy:metadata:local_sitsgradepush_tfr_log:requestbody',
'response' => 'privacy:metadata:local_sitsgradepush_tfr_log:response',
'usermodified' => 'privacy:metadata:local_sitsgradepush_tfr_log:usermodified',
], 'privacy:metadata:local_sitsgradepush_tfr_log');

$collection->add_database_table('local_sitsgradepush_err_log', [
'message' => 'privacy:metadata:local_sitsgradepush_err_log:message',
'errortype' => 'privacy:metadata:local_sitsgradepush_err_log:errortype',
'requesturl' => 'privacy:metadata:local_sitsgradepush_err_log:requesturl',
'data' => 'privacy:metadata:local_sitsgradepush_err_log:data',
'response' => 'privacy:metadata:local_sitsgradepush_err_log:response',
'userid' => 'privacy:metadata:local_sitsgradepush_err_log:userid',
], 'privacy:metadata:local_sitsgradepush_err_log');

$collection->add_database_table('local_sitsgradepush_tasks', [
'userid' => 'privacy:metadata:local_sitsgradepush_tasks:userid',
'status' => 'privacy:metadata:local_sitsgradepush_tasks:status',
'info' => 'privacy:metadata:local_sitsgradepush_tasks:info',
], 'privacy:metadata:local_sitsgradepush_tasks');

return $collection;
}
}
33 changes: 27 additions & 6 deletions classes/submission/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,35 @@ private function get_best_attempt() {
require_once($CFG->dirroot.'/mod/quiz/locallib.php');

// Get student's quiz attempts.
$attemps = $DB->get_records(
'quiz_attempts',
['quiz' => $this->modinstance->id, 'userid' => $this->userid, 'preview' => 0, 'state' => quiz_attempt::FINISHED]
);
$attempts = quiz_get_user_attempts($this->modinstance->id, $this->userid);

// Throw error if no attempt found.
if ($attemps) {
return quiz_calculate_best_attempt($this->modinstance, $attemps);
if (!empty($attempts)) {
switch ($this->modinstance->grademethod) {
// Return the first attempt.
case QUIZ_ATTEMPTFIRST:
return reset($attempts);

// Return the last attempt.
case QUIZ_ATTEMPTLAST:
case QUIZ_GRADEAVERAGE:
return end($attempts);

// Return the highest grade attempt.
case QUIZ_GRADEHIGHEST:
default:
$maxattempt = null;
$maxsumgrades = -1;

foreach ($attempts as $attempt) {
if ($attempt->sumgrades > $maxsumgrades) {
$maxsumgrades = $attempt->sumgrades;
$maxattempt = $attempt;
}
}

return $maxattempt;
}
}

return null;
Expand Down
44 changes: 41 additions & 3 deletions lang/en/local_sitsgradepush.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
defined('MOODLE_INTERNAL') || die();

$string['pluginname'] = 'SITS Marks Transfer';
$string['privacy:metadata'] = 'This plugin does not store any personal data.';
$string['settings:apiclientselect'] = 'Select API client';
$string['settings:apiclient'] = 'API client';
$string['settings:apiclient:desc'] = 'Choose which API client to use';
Expand Down Expand Up @@ -67,11 +66,29 @@
$string['pushrecordsexist'] = 'Transfer records exist';
$string['pushrecordsnotexist'] = 'No transfer records';

// Marks Transfer index page.
// Marks transfer activity index page.
$string['index:header'] = 'SITS Marks Transfer History';
$string['index:student'] = 'Student';
$string['index:porticonumber'] = 'Portico number';
$string['index:grade'] = 'Grade';
$string['index:submissiondate'] = 'Submission date';
$string['index:lastmarktransfer'] = 'Last Mark Transfer';
$string['index:lastsublogtransfer'] = 'Last Submission Log Transfer';

// Marks Transfer dashboard page.
// Marks transfer dashboard page.
$string['dashboard:header'] = 'SITS Marks Transfer Dashboard';
$string['dashboard:modcode'] = 'MODULE CODE: {$a}';
$string['dashboard:academicyear'] = 'ACADEMIC YEAR: {$a}';
$string['dashboard:level'] = 'LEVEL: {$a}';
$string['dashboard:mapcode'] = 'MAP CODE: {$a}';
$string['dashboard:seq'] = 'SEQ';
$string['dashboard:title'] = 'TITLE';
$string['dashboard:weight'] = 'WEIGHT';
$string['dashboard:asttype'] = 'AST TYPE';
$string['dashboard:source'] = 'SOURCE';
$string['dashboard:actions'] = 'ACTIONS';
$string['dashboard:transfermark'] = 'Transfer Mark';
$string['dashboard:changesource'] = 'Change Source';

// Select source page.
$string['selectsource:header'] = 'Select Source';
Expand Down Expand Up @@ -130,3 +147,24 @@
$string['task:status:processing'] = 'Transfer task processing';
$string['task:status:completed'] = 'completed';
$string['task:status:failed'] = 'failed';

// Privacy strings.
$string['privacy:metadata'] = 'This plugin does not store any personal data.';
$string['privacy:metadata:local_sitsgradepush_tfr_log'] = 'Stores the marks transfer records.';
$string['privacy:metadata:local_sitsgradepush_tfr_log:type'] = 'The type of the transfer task.';
$string['privacy:metadata:local_sitsgradepush_tfr_log:userid'] = 'Whose this transfer task is for.';
$string['privacy:metadata:local_sitsgradepush_tfr_log:request'] = 'The request\'s URL';
$string['privacy:metadata:local_sitsgradepush_tfr_log:requestbody'] = 'The request\'s body';
$string['privacy:metadata:local_sitsgradepush_tfr_log:response'] = 'The response received from SITS';
$string['privacy:metadata:local_sitsgradepush_tfr_log:usermodified'] = 'The user who requested the transfer task.';
$string['privacy:metadata:local_sitsgradepush_err_log'] = 'Stores the error logs.';
$string['privacy:metadata:local_sitsgradepush_err_log:message'] = 'The error message.';
$string['privacy:metadata:local_sitsgradepush_err_log:errortype'] = 'The error type.';
$string['privacy:metadata:local_sitsgradepush_err_log:requesturl'] = 'The request\'s URL.';
$string['privacy:metadata:local_sitsgradepush_err_log:data'] = 'The data sent to SITS.';
$string['privacy:metadata:local_sitsgradepush_err_log:response'] = 'The response received from SITS.';
$string['privacy:metadata:local_sitsgradepush_err_log:userid'] = 'The user having the error.';
$string['privacy:metadata:local_sitsgradepush_tasks'] = 'Stores the transfer tasks.';
$string['privacy:metadata:local_sitsgradepush_tasks:userid'] = 'The user who requested the transfer task.';
$string['privacy:metadata:local_sitsgradepush_tasks:status'] = 'The status of the transfer task.';
$string['privacy:metadata:local_sitsgradepush_tasks:info'] = 'Additional information about the transfer task.';
10 changes: 5 additions & 5 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@
width: 5%;
}

.sitsgradepush-dasboard .module-delivery-table .assessment-col {
width: 15%;
}

.sitsgradepush-dasboard .module-delivery-table .mark-col {
width: 20%;
width: 35%;
}

.sitsgradepush-dasboard .module-delivery-table .action-col {
Expand Down Expand Up @@ -106,3 +102,7 @@
.sitsgradepush-select-source .container {
max-width: 90%;
}

.sitsgradepush-select-source .hidden {
display: none;
}
12 changes: 6 additions & 6 deletions templates/assessmentgrades.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
</tr>
{{/additionalinfo}}
<tr>
<th scope="col">Student</th>
<th scope="col">Portico number</th>
<th scope="col">Grade</th>
<th scope="col">Submission date</th>
<th scope="col">Last grade push</th>
<th scope="col">Last submission log push</th>
<th scope="col">{{#str}} index:student, local_sitsgradepush {{/str}}</th>
<th scope="col">{{#str}} index:porticonumber, local_sitsgradepush {{/str}}</th>
<th scope="col">{{#str}} index:grade, local_sitsgradepush {{/str}}</th>
<th scope="col">{{#str}} index:submissiondate, local_sitsgradepush {{/str}}</th>
<th scope="col">{{#str}} index:lastmarktransfer, local_sitsgradepush {{/str}}</th>
<th scope="col">{{#str}} index:lastsublogtransfer, local_sitsgradepush {{/str}}</th>
</tr>
</thead>
<tbody>
Expand Down
28 changes: 13 additions & 15 deletions templates/module_delivery_table.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,23 @@
<table id="{{tableid}}" class="module-delivery-table table table-hover table-bordered">
<thead>
<tr>
<th colspan="6">
<th colspan="5">
<div class="row">
<div class="col header-part" style="text-align: left">MODULE CODE: {{modcode}}</div>
<div class="col header-part">ACADEMIC YEAR: {{academicyear}}</div>
<div class="col header-part" style="text-align: right">LEVEL: {{level}} {{graduatetype}}</div>
<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>
</th>
</tr>
<tr>
<th colspan="6" style="text-align: left">MAP CODE: {{mapcode}}</th>
<th colspan="5" style="text-align: left">{{#str}} dashboard:mapcode, local_sitsgradepush, {{mapcode}} {{/str}}</th>
</tr>
<tr>
<th class="seq-col">SEQ</th>
<th class="title-col">TITLE</th>
<th class="weight-col">WGT</th>
<th class="assessment-col">AST TYPE</th>
<th class="mark-col">MARK TRANSFER</th>
<th class="action-col">ACTIONS</th>
<th class="seq-col">{{#str}} dashboard:seq, local_sitsgradepush {{/str}}</th>
<th class="title-col">{{#str}} dashboard:title, local_sitsgradepush {{/str}}</th>
<th class="weight-col">{{#str}} dashboard:weight, local_sitsgradepush {{/str}}</th>
<th class="mark-col">{{#str}} dashboard:source, local_sitsgradepush {{/str}}</th>
<th class="action-col">{{#str}} dashboard:actions, local_sitsgradepush {{/str}}</th>
</tr>
</thead>
<tbody>
Expand All @@ -103,10 +102,9 @@
<td class="seq-col">{{mabseq}}</td>
<td class="title-col">{{mabname}}</td>
<td class="weight-col">{{mabperc}}</td>
<td class="assessment-col">{{astcode}}</td>
<td class="mark-col">
{{#assessmentmapping}}
<a href="{{url}}" target="_blank" data-toggle="tooltip" data-placement="top" title="{{name}}">{{type}}</a>
<a href="{{url}}" target="_blank" data-toggle="tooltip" data-placement="top" title="{{type}}">{{name}}</a>
{{/assessmentmapping}}
{{^assessmentmapping}}
<a href="{{selectsourceurl}}" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top"
Expand All @@ -120,7 +118,7 @@
class="btn btn-secondary btn-sm change-source-button"
data-toggle="tooltip"
data-placement="top"
title="Change Source"
title="{{#str}} dashboard:changesource, local_sitsgradepush {{/str}}"
data-url="{{selectsourceurl}}"
{{#assessmentmapping}}
data-assessmentmappingid="{{id}}"
Expand All @@ -134,7 +132,7 @@
class="btn btn-warning btn-sm push-mark-button"
data-toggle="tooltip"
data-placement="top"
title="Push Mark"
title="{{#str}} dashboard:transfermark, local_sitsgradepush {{/str}}"
{{#assessmentmapping}}
data-assessmentmappingid="{{id}}"
{{/assessmentmapping}}
Expand Down
7 changes: 3 additions & 4 deletions templates/select_source_page.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<h2>Select Source</h2>
<div class="sitsgradepush-select-source">
<div class="centered-container">
<h2 class="mb-4">{{#str}} selectsource:header, local_sitsgradepush {{/str}}</h2>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6 d-flex">
Expand All @@ -43,21 +42,21 @@
</div>
</div>
<div class="col-md-6 d-flex">
<div id="create-new-activity" class="card-custom card-2 mb-3">
<div id="create-new-activity" class="card-custom card-2 mb-3 hidden">
<h5 class="card-title">
<i class="fa-solid fa-plus-circle"></i> {{#str}} selectsource:new, local_sitsgradepush {{/str}}
</h5>
</div>
</div>
<div class="col-md-6 d-flex">
<div id="gradebook-item" class="card-custom card-3 mb-3">
<div id="gradebook-item" class="card-custom card-3 mb-3 hidden">
<h5 class="card-title">
<i class="fa-solid fa-book-open"></i> {{#str}} selectsource:gradeitem, local_sitsgradepush {{/str}}
</h5>
</div>
</div>
<div class="col-md-6 d-flex">
<div id="advance-multiple-turnitin-activity" class="card-custom card-4 mb-3">
<div id="advance-multiple-turnitin-activity" class="card-custom card-4 mb-3 hidden">
<h5 class="card-title">
<i class="fa-solid fa-layer-group"></i> {{#str}} selectsource:mul_turnitin, local_sitsgradepush {{/str}}
</h5>
Expand Down