Skip to content

Commit

Permalink
updated javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Oct 30, 2023
1 parent 2241262 commit fdc4d83
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 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.

23 changes: 13 additions & 10 deletions amd/src/modform.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,31 @@ export const init = () => {
* @param {*} e
*/
function cmidClick(e) {
debugger;
console.log('hello');
var id = e.currentTarget.id.split('_')[2];
var checkboxid = 'id_activitygroup_activity_' +id;
var checkbox = document.getElementById(checkboxid);
checkbox.checked = !checkbox.checked;
configureSelectAll();
configureSessions();
}


function configureSessions(){
var sessions = document.querySelectorAll('input[id*="_ses_"]');
sessions.forEach(function(e) {
e.addEventListener('click', sessionClick());
});
var selectButtons = document.querySelectorAll('button[id^="sessionid_"]');
selectButtons.forEach(function(e) {
e.addEventListener('click', sessionClick);
})
}
function sessionClick(e){
debugger;
console.log('hello');
var sessionid = e.currentTarget.id.split('_')[3];
// debugger;
// console.log(sessionid);
var sessionid = e.currentTarget.id.split('_')[1];
sesscbx = document.querySelectorAll('input[id^="id_cmid_"]');
sesscbx.forEach((cbx) => {
var cboxid = cbx.id.split('_')[4];
if (cboxid == sessionid) {
cbx.checked = !cbx.checked;
}
});
}
/**
* Set up the selectAll checkbox
Expand Down
2 changes: 2 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ function get_table_data(\stdClass $driprelease) : array {
$row['calculatedavailability'] = driprelease_calculate_availability($driprelease, $sessioncounter);
$sessioncounter++;
}

$data[] = add_header($row);
}
$contentcounter++;
$row['modtype'] = $driprelease->modtype;
$row['sessioncounter'] = $sessioncounter;
$data[] = row_fill($row, $cm);
}
return $data ?? [];
Expand Down
9 changes: 7 additions & 2 deletions templates/quiz.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@

{{#isheader}}
<tr>
<td colspan="6 ">{{#str}} session, tool_driprelease {{/str}} {{{calculatedavailability.sessioncounter}}}: {{calculatedavailability.startformatted}} - {{calculatedavailability.endformatted}}</td>
<td colspan="6">
<button id=sessionid_{{calculatedavailability.sessioncounter}}>Session</button>
{{#str}} session, tool_driprelease {{/str}} {{{calculatedavailability.sessioncounter}}}:
{{calculatedavailability.startformatted}} - {{calculatedavailability.endformatted}}
</td>
</tr>

{{/isheader}}

{{^isheader}}
<tr>
<td> <input name = "select" type='checkbox' id='id_cmid_{{id}}' {{selected}} >
<td> <input name = "select" type='checkbox' id='id_cmid_{{id}}_ses_{{calculatedavailability.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 fdc4d83

Please sign in to comment.