-
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 to lifecycle block
- Loading branch information
1 parent
b4a5c5d
commit f0e2579
Showing
16 changed files
with
339 additions
and
13 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 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,86 @@ | ||
<?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/>. | ||
|
||
namespace block_lifecycle\external; | ||
|
||
use block_lifecycle\manager; | ||
use core_external\external_api; | ||
use core_external\external_function_parameters; | ||
use core_external\external_single_structure; | ||
use core_external\external_value; | ||
|
||
/** | ||
* External API for unfreeze a 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]> | ||
*/ | ||
class unfreeze_course extends external_api { | ||
/** | ||
* Returns description of method parameters. | ||
* | ||
* @return external_function_parameters | ||
*/ | ||
public static function execute_parameters() { | ||
return new external_function_parameters([ | ||
'courseid' => new external_value(PARAM_INT, 'Coruse ID', VALUE_REQUIRED), | ||
]); | ||
} | ||
|
||
/** | ||
* Returns description of method result value. | ||
* | ||
* @return \external_single_structure | ||
*/ | ||
public static function execute_returns() { | ||
return new external_single_structure([ | ||
'success' => new external_value(PARAM_BOOL, 'Result of request', VALUE_REQUIRED), | ||
'message' => new external_value(PARAM_TEXT, 'Error message', VALUE_OPTIONAL), | ||
]); | ||
} | ||
|
||
/** | ||
* Unfreeze a course | ||
* | ||
* @param int $courseid | ||
* @return array | ||
*/ | ||
public static function execute(int $courseid) { | ||
try { | ||
$params = self::validate_parameters( | ||
self::execute_parameters(), | ||
[ | ||
'courseid' => $courseid, | ||
] | ||
); | ||
|
||
// Unfreeze the course. | ||
manager::unfreeze_course($params['courseid']); | ||
|
||
return [ | ||
'success' => true, | ||
'message' => 'Enabled course editing successfully.', | ||
]; | ||
} catch (\Exception $e) { | ||
return [ | ||
'success' => false, | ||
'message' => $e->getMessage(), | ||
]; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -23,27 +23,30 @@ | |
* @author Alex Yeung <[email protected]> | ||
*/ | ||
|
||
$string['pluginname'] = 'Lifecycle'; | ||
$string['button:editsettings'] = 'Edit automatic Read-Only settings'; | ||
$string['button:toggleautoreadonly'] = 'Disable Automatic Read-Only'; | ||
$string['error:dateformat'] = 'Date must be in format YYYY-MM-DD'; | ||
$string['error:cannotgetscheduledfreezedate'] = 'Could not get the automatically suggested date.'; | ||
$string['error:updatepreferencessuccess'] = 'Auto read only settings updated successfully.'; | ||
$string['error:dateformat'] = 'Date must be in format YYYY-MM-DD'; | ||
$string['error:unfreeze_course'] = 'You do not have permission to enable editing.'; | ||
$string['error:updatepreferencesfailed'] = 'Failed to update read only settings.'; | ||
$string['error:updatepreferencessuccess'] = 'Auto read only settings updated successfully.'; | ||
$string['generalsettings'] = 'General Settings'; | ||
$string['help:togglefreezing'] = 'Disable Automatic Read-Only'; | ||
$string['help:togglefreezing_help'] = 'Disable Automatic Read-Only.'; | ||
$string['help:delayfreezedate'] = 'override Read-Only date'; | ||
$string['help:delayfreezedate_help'] = 'The date for a Read-Only override must be post the automatically suggested date, earlier dates may not be used.'; | ||
$string['help:togglefreezing'] = 'Disable Automatic Read-Only'; | ||
$string['help:togglefreezing_help'] = 'Disable Automatic Read-Only.'; | ||
$string['label:readonlydate'] = 'This course will be made automatically Read Only on: '; | ||
$string['label:readonlydateinput'] = 'Overrides Read-Only date:'; | ||
$string['label:unfreezebutton'] = 'Enable editing'; | ||
$string['lifecycle:addinstance'] = 'Add lifecycle block'; | ||
$string['lifecycle:coursereadonly'] = 'This Course is Read Only'; | ||
$string['lifecycle:enddate'] = 'This course\'s end date: {$a}'; | ||
$string['lifecycle:myaddinstance'] = 'Add my lifecycle block'; | ||
$string['lifecycle:overridecontextfreeze'] = 'Override default course context freezing settings'; | ||
$string['lifecycle:startdate'] = 'This course\'s start date: {$a}'; | ||
$string['lifecycle:coursereadonly'] = 'This Course is Read Only'; | ||
$string['lifecycle:unfreezecourse'] = 'Unfreeze course'; | ||
$string['lifecycle:view'] = 'View lifecycle block'; | ||
$string['pluginname'] = 'Lifecycle'; | ||
$string['privacy:metadata'] = 'The Lifecycle block does not store personal data'; | ||
$string['settings:academicyearstartdate'] = 'Academic year start date'; | ||
$string['settings:academicyearstartdate:desc'] = 'This field is used to calculate the current academic year period and in MM-DD format'; | ||
|
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
Oops, something went wrong.