AutorÃa | Ultima modificación | Ver Log |
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_course/defaultactivitycompletion
Activity completion selector.
Example context (json):
{
"courseid": "2",
"sesskey": "AAAAAA",
"modules": [{
"id": "10",
"formattedname": "Assignment",
"canmanage": true,
"icon": "https://raw.githubusercontent.com/moodle/moodle/master/mod/assign/pix/icon.png",
"completionstatus": {
"string": "Manual",
"icon": "https://raw.githubusercontent.com/moodle/moodle/master/pix/i/completion-manual-enabled.png"
}
}]
}
}}
<fieldset class="fieldset-styled">
<legend>{{#str}}bulkactivitydetail, core_completion{{/str}}</legend>
<form method="post" action="editdefaultcompletion.php" class="mform mt-3 pt-3 border-top" id="theform">
<div class="row">
<div class="col">
<input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" aria-label="{{#str}}updateactivities, completion{{/str}}" disabled/>
</div>
</div>
<div class="row mb-1">
<div class="col-6">
<label class="custom-control ios-switch">
<input type="checkbox" class="mastercheck ios-switch-control-input form-check-input" aria-label="{{#str}}checkall, completion{{/str}}">
<span class="ios-switch-control-indicator"></span>
<strong class="text ml-3">{{#str}}activitieslabel, core_completion{{/str}}</strong>
</label>
</div>
<div class="col-6 px-0">
<label class="font-weight-bold">{{#str}}completion, core_completion{{/str}}</label>
<span>{{{helpicon}}}</span>
</div>
</div>
<div class="modules">
{{#modules}}
{{#canmanage}}
<div class="mb-1">
<div class="row no-gutters my-2 py-2 border-bottom">
<div class="col-6 align-items-center d-inline-flex">
<label class="custom-control ios-switch">
<input id="modtype_{{id}}" type="checkbox" class="ios-switch-control-input form-check-input" name="modids[]" value="{{id}}" aria-label="{{#str}}checkactivity, completion, {{{formattedname}}}{{/str}}">
<span class="ios-switch-control-indicator"></span>
</label>
<img class="iconlarge activityicon mr-2" src="{{icon}}" alt=" " role="presentation" />
<span>{{{formattedname}}}</span>
</div>
<div class="activity-completionstatus col-6">
<div class="d-inline-flex align-items-center">
{{#completionstatus.icon}}
{{{completionstatus.icon}}}
{{/completionstatus.icon}}
{{^completionstatus.icon}}
<span class="mr-3"></span>
{{/completionstatus.icon}}
<span class="text-muted muted ml-2">{{{completionstatus.string}}}</span>
</div>
</div>
</div>
</div>
{{/canmanage}}
{{/modules}}
</div>
<input type="hidden" name="id" value="{{courseid}}" />
<input type="hidden" name="sesskey" value="{{sesskey}}" />
<div class="row no-gutters mt-3">
<div class="col">
<input type="submit" value="{{#str}}edit{{/str}}" class="btn btn-sm btn-outline-primary" name="submitbutton" disabled/>
</div>
</div>
</form>
</fieldset>
{{#js}}
require([
'jquery',
], function($) {
$('.mastercheck').click(function() {
var checked = $('.mastercheck').is(':checked');
$('input[type=checkbox]').each(function() {
$(this).prop('checked', checked);
$(this).trigger('change');
});
});
$('input[type=checkbox][id^=modtype_]').change(function() {
if ($(this).is(':checked')) {
$('[name=submitbutton]').removeAttr('disabled');
} else {
// Is this the last activity checkbox to be un-checked? If so, disable the edit button.
var somechecked = false;
$('input[type=checkbox][id^=modtype_]').each(function() {
if ($(this).is(':checked')) {
somechecked = true;
return false;
}
return true;
});
if (!somechecked) {
$('[name=submitbutton]').attr('disabled', 'disabled');
}
}
});
});
{{/js}}