Skip to content

Commit

Permalink
count sessions properly
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Nov 2, 2023
1 parent 5eb0236 commit 478160f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion amd/build/modform.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions amd/src/modform.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const init = () => {
sesscbx.forEach((cbx) => {
var cboxid = cbx.id.split('_')[4];
debugger;
if (cboxid == sessionid) {
cbx.checked = true;
}
if ((cboxid == sessionid) && (cboxid > 0)) {
cbx.checked = !cbx.checked;
}
});
}
/**
Expand Down
18 changes: 13 additions & 5 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function get_table_data(\stdClass $driprelease) : array {
$contentcounter = 0;
$sessioncounter = 0;
$selections = [];
$flag = false;
if (isset($driprelease->id)) {
$selections = $DB->get_records_menu('tool_driprelease_cmids', ['driprelease' => $driprelease->id],
null, 'id,coursemoduleid');
Expand All @@ -193,12 +194,11 @@ function get_table_data(\stdClass $driprelease) : array {
['id' => $cm->id],
'availability'
);
$availability = get_availability($record->availability);
$row['calculatedavailability']['start'] = $availability['from'] ?? '';
$row['calculatedavailability']['end'] = $availability['to'] ?? '';
$fromto = get_from_to($record->availability);
$row['calculatedavailability']['start'] = $fromto['from'] ?? '';
$row['calculatedavailability']['end'] = $fromto['to'] ?? '';
}
$row['sessioncounter'] = $sessioncounter;

$data[] = add_header($row);
}
$contentcounter++;
Expand All @@ -207,7 +207,15 @@ function get_table_data(\stdClass $driprelease) : array {
}
return $data ?? [];
}

function get_from_to($availability) {
$ob = json_decode($availability);
if (!$ob) {
return [];
}
$fromto['from'] = $ob->c[1]->t;
$fromto['to'] = $ob->c[2]->t;
return $fromto;
}
/**
* Simplify get_table_data
*
Expand Down
6 changes: 3 additions & 3 deletions templates/quiz.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
{{#isheader}}
<tr>
<td colspan="6">
<button id=sessionid_{{calculatedavailability.sessioncounter}}>Session</button>
{{#str}} session, tool_driprelease {{/str}} {{{calculatedavailability.sessioncounter}}}:
<button id=sessionid_{{sessioncounter}}>Session</button>
{{#str}} session, tool_driprelease {{/str}} {{{sessioncounter}}}:
{{#calculatedavailability.start}}
{{< core/time_element }}
{{$timestampval}}{{calculatedavailability.start}}{{/timestampval}}
Expand All @@ -98,7 +98,7 @@

{{^isheader}}
<tr>
<td> <input name = "select" type='checkbox' id='id_cmid_{{id}}_ses_{{calculatedavailability.sessioncounter}}' {{selected}} >
<td> <input name = "select" type='checkbox' id='id_cmid_{{id}}_ses_{{sessioncounter}}' {{selected}} >
</td>
<td><a href={{config.wwwroot}}/mod/quiz/view.php?id={{id}} >{{{name}}}</a></td><td>{{{intro}}}</td>
<td>{{questioncount}}</td>
Expand Down

0 comments on commit 478160f

Please sign in to comment.