-
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 8b43832
Showing
13 changed files
with
377 additions
and
46 deletions.
There are no files selected for viewing
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
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", | ||
"coursename": "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,91 @@ | ||
<?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/>. | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); | ||
|
||
/** | ||
* Defines the behat steps for the block_lifecycle plugin. | ||
* | ||
* @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 behat_lifecycle extends behat_base { | ||
/** | ||
* Create custom field. | ||
* | ||
* @param TableNode $table | ||
* @throws \dml_exception | ||
* | ||
* @Given /^the following custom field exists for lifecycle block:$/ | ||
*/ | ||
public function the_following_custom_field_exists_for_lifecycle_block(TableNode $table): void { | ||
global $DB; | ||
|
||
$data = $table->getRowsHash(); | ||
|
||
// Create a new custom field category if it doesn't exist. | ||
$category = $DB->get_record( | ||
'customfield_category', | ||
['name' => $data['category'], | ||
'component' => 'core_course', | ||
'area' => 'course']); | ||
|
||
if (!$category) { | ||
$category = (object)[ | ||
'name' => $data['category'], | ||
'component' => 'core_course', | ||
'area' => 'course', | ||
'sortorder' => 1, | ||
'timecreated' => time(), | ||
'timemodified' => time(), | ||
]; | ||
$category->id = $DB->insert_record( | ||
'customfield_category', | ||
$category | ||
); | ||
} | ||
|
||
// Check if the field already exists. | ||
$fieldexists = $DB->record_exists('customfield_field', ['shortname' => $data['shortname'], 'categoryid' => $category->id]); | ||
|
||
// Create the custom field if not exists. | ||
if (!$fieldexists) { | ||
$field = (object)[ | ||
'shortname' => $data['shortname'], | ||
'name' => $data['name'], | ||
'type' => $data['type'], | ||
'categoryid' => $category->id, | ||
'sortorder' => 0, | ||
'configdata' => json_encode([ | ||
"required" => 0, | ||
"uniquevalues" => 0, | ||
"maxlength" => 4, | ||
"defaultvalue" => "", | ||
"ispassword" => 0, | ||
"displaysize" => 4, | ||
"locked" => 1, | ||
"visibility" => 0, | ||
]), | ||
'timecreated' => time(), | ||
'timemodified' => time(), | ||
]; | ||
$DB->insert_record('customfield_field', $field); | ||
} | ||
} | ||
} |
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,34 @@ | ||
@block @block_lifecycle | ||
|
||
Feature: Unfreeze a frozen course | ||
As a teacher with the appropriate permission | ||
I can click on the "Enable editing" button in the lifecycle block to unfreeze a frozen course | ||
|
||
Background: | ||
Given the following "users" exist: | ||
| username | firstname | lastname | idnumber | email | | ||
| teacher1 | Teacher1 | Test | tea1 | teacher1@example.com | | ||
And the following custom field exists for lifecycle block: | ||
| category | CLC | | ||
| shortname | course_year | | ||
| name | Course Year | | ||
| type | text | | ||
And the following "courses" exist: | ||
| fullname | shortname | format | customfield_course_year | startdate | enddate | | ||
| Course 1 | C1 | topics | ##now##%Y## | ## 2 days ago ## | ## yesterday ## | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| teacher1 | C1 | editingteacher | | ||
And the following "blocks" exist: | ||
| blockname | contextlevel | reference | pagetypepattern | defaultregion | | ||
| lifecycle | Course | C1 | course-view-* | side-pre | | ||
And the "C1" "Course" is context frozen | ||
|
||
@javascript | ||
Scenario: Unfreeze a frozen course | ||
Given I am on the "C1" course page logged in as teacher1 | ||
And edit mode should not be available on the current page | ||
And I should see "Enable editing" in the "Lifecycle" "block" | ||
And I click on "Enable editing" "text" | ||
And I press "Confirm" | ||
Then edit mode should be available on the current page |
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Alex Yeung <[email protected]> | ||
*/ | ||
class freezecontext_test extends \advanced_testcase { | ||
final class freezecontext_test extends \advanced_testcase { | ||
protected function setUp(): void { | ||
parent::setUp(); | ||
$this->resetAfterTest(); | ||
|
Oops, something went wrong.