Skip to content

Commit

Permalink
CTP-2495 Replace quiz deprecated methods
Browse files Browse the repository at this point in the history
CTP-2889 Tweaks dashboard page
CTP-2890 Fix external api phpunit test
  • Loading branch information
aydevworks committed Dec 5, 2023
1 parent 1fed4f1 commit 34c8054
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 41 deletions.
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
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
26 changes: 22 additions & 4 deletions lang/en/local_sitsgradepush.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,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.
$string['dashboard:header'] = 'SITS Marks Transfer Dashboard';
// 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 @@ -103,7 +121,7 @@
$string['error:duplicatedtask'] = 'There is already a transfer task in queue / processing for this assessment mapping.';
$string['error:tasknotfound'] = 'Transfer task not found.';
$string['error:multiplemappingsnotsupported'] = 'Multiple assessment component mappings is not supported by {$a}';
$string['error:studentnotfound'] = 'Student with idnumber {$a->idnumber} not found for component grade {$a->componentgrade}';
$string['error:studentnotfound'] = 'Student with idnumber {$a->idnumber} not found for component marks {$a->componentgrade}';
$string['error:coursemodulenotfound'] = 'Course module not found. ID: {$a}';
$string['error:duplicatemapping'] = 'Cannot map multiple assessment components with same module delivery to an activity. Mapcode: {$a}';
$string['error:nomoduledeliveryfound'] = 'No module delivery found.';
Expand Down
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

0 comments on commit 34c8054

Please sign in to comment.