-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CTP-1685 add unfreeze function in lifecycle block
- Loading branch information
1 parent
66ba4e7
commit e16ecf2
Showing
10 changed files
with
126 additions
and
165 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{{! | ||
This file is part the Local Analytics plugin for Moodle | ||
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 block_lifecycle/unfreeze_button | ||
Template for displaying the unfreeze button to unfreeze a frozen course. | ||
Classes required for JS: | ||
* none | ||
Data attributes required for JS: | ||
* none | ||
Context variables required for this template: | ||
* url - string The URL to the unfreeze page. | ||
* coursefullname - string The full name of the course. | ||
Example context (json): | ||
{ | ||
"url": "http://test.m44.local/blocks/lifecycle/unfreeze.php?id=5", | ||
"coursefullname": 'Test Course 1' | ||
} | ||
}} | ||
<button type="button" | ||
class="btn btn-primary w-100" | ||
data-confirmation="modal" | ||
data-confirmation-title-str='["label:unfreezebutton", "block_lifecycle"]' | ||
data-confirmation-content-str='["confirmcontextunlock", "admin", {"contextname": "{{coursename}}"}]' | ||
data-confirmation-yes-button-str='["confirm"]' | ||
data-confirmation-destination="{{url}}" | ||
> | ||
Enable editing | ||
<span class="sr-only"> for course {{coursename}}</span> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
// 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/>. | ||
|
||
/** | ||
* unfreeze page for block_lifecycle to unfreeze a frozen course. | ||
* | ||
* @package block_lifecycle | ||
* @copyright 2024 onwards University College London {@link https://www.ucl.ac.uk/} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Alex Yeung <[email protected]> | ||
*/ | ||
|
||
namespace block_lifecycle; | ||
|
||
use context_course; | ||
use core\output\notification; | ||
use moodle_exception; | ||
use moodle_url; | ||
|
||
require_once('../../config.php'); | ||
|
||
// Course ID. | ||
$courseid = required_param('id', PARAM_INT); | ||
|
||
// Get course context. | ||
$context = context_course::instance($courseid); | ||
|
||
// Get course instance. | ||
if (!$course = get_course($courseid)) { | ||
throw new moodle_exception('course not found.', 'block_lifecycle'); | ||
} | ||
|
||
// Make sure user is authenticated. | ||
require_login($course); | ||
|
||
// Check user's capability. | ||
require_capability('block/lifecycle:unfreezecourse', $context); | ||
|
||
// Unfreeze the course. | ||
try { | ||
manager::unfreeze_course($courseid); | ||
// Unfreeze done. Redirect back to the course page. | ||
redirect(new moodle_url('/course/view.php', ['id' => $courseid])); | ||
} catch (moodle_exception $e) { | ||
// Unfreeze failed. Redirect back to the course page with error message. | ||
redirect(new moodle_url('/course/view.php', ['id' => $courseid]), $e->getMessage(), null, notification::NOTIFY_ERROR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters