Replaced plugin name and some logic
This commit is contained in:
parent
311e243ca5
commit
967571cd14
208 changed files with 5193 additions and 14416 deletions
120
.github/workflows/moodle-ci.yml
vendored
120
.github/workflows/moodle-ci.yml
vendored
|
@ -1,120 +0,0 @@
|
|||
name: Moodle Plugin CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:9.6
|
||||
env:
|
||||
POSTGRES_USER: 'postgres'
|
||||
POSTGRES_HOST_AUTH_METHOD: 'trust'
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
||||
mariadb:
|
||||
image: mariadb:10.5
|
||||
env:
|
||||
MYSQL_USER: 'root'
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- php: '7.4'
|
||||
moodle-branch: 'MOODLE_311_STABLE'
|
||||
database: pgsql
|
||||
- php: '7.4'
|
||||
moodle-branch: 'MOODLE_311_STABLE'
|
||||
database: mariadb
|
||||
- php: '7.3'
|
||||
moodle-branch: 'MOODLE_311_STABLE'
|
||||
database: pgsql
|
||||
- php: '7.3'
|
||||
moodle-branch: 'MOODLE_311_STABLE'
|
||||
database: mariadb
|
||||
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: plugin
|
||||
|
||||
- name: Setup PHP ${{ matrix.php }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
|
||||
- name: Initialise moodle-plugin-ci
|
||||
run: |
|
||||
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
|
||||
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
|
||||
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
|
||||
sudo locale-gen en_AU.UTF-8
|
||||
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
|
||||
|
||||
- name: Install moodle-plugin-ci
|
||||
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
|
||||
env:
|
||||
DB: ${{ matrix.database }}
|
||||
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
|
||||
MUSTACHE_IGNORE_NAMES: 'mobile_*.mustache'
|
||||
|
||||
- name: PHP Lint
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci phplint
|
||||
|
||||
- name: PHP Copy/Paste Detector
|
||||
continue-on-error: true # This step will show errors but will not fail
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci phpcpd
|
||||
|
||||
- name: PHP Mess Detector
|
||||
continue-on-error: true # This step will show errors but will not fail
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci phpmd
|
||||
|
||||
- name: Moodle Code Checker
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci codechecker --max-warnings 0
|
||||
|
||||
- name: Moodle PHPDoc Checker
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci phpdoc
|
||||
|
||||
- name: Validating
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci validate
|
||||
|
||||
- name: Check upgrade savepoints
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci savepoints
|
||||
|
||||
- name: Mustache Lint
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci mustache
|
||||
|
||||
- name: Grunt
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci grunt --max-lint-warnings 0
|
||||
|
||||
- name: PHPUnit tests
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
moodle-plugin-ci phpunit
|
||||
cd moodle
|
||||
vendor/bin/phpunit --fail-on-risky --disallow-test-output --filter tool_dataprivacy_metadata_registry_testcase
|
||||
vendor/bin/phpunit --fail-on-risky --disallow-test-output --filter core_externallib_testcase
|
||||
vendor/bin/phpunit --fail-on-risky --disallow-test-output --testsuite core_privacy_testsuite --filter provider_testcase
|
||||
|
||||
- name: Behat features
|
||||
if: ${{ always() }}
|
||||
run: moodle-plugin-ci behat --profile chrome
|
299
CHANGES.md
299
CHANGES.md
|
@ -1,299 +0,0 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
Note - All hash comments refer to the issue number. Eg. #169 refers to https://github.com/mdjnelson/moodle-mod_customcert/issues/169.
|
||||
|
||||
## [3.11.2] - 2021-??-??
|
||||
|
||||
### Fixed
|
||||
- Fix places not using the multi-language filter (#433).
|
||||
- Fix user IDs in the issue table not being mapped during restore (#449).
|
||||
- Fix emails displaying HTML entities encoded (#457).
|
||||
- Fix error message when we have custom profile fields (#465).
|
||||
- Respect multiple languages in manage template page title (#467).
|
||||
|
||||
### Added
|
||||
- You can now choose the course short or full name to display (#415).
|
||||
- You can now select the alignment for all text elements (#121).
|
||||
|
||||
## [3.11.1] - 2021-06-13
|
||||
|
||||
### Fixed
|
||||
- Usage of deprecated functions (#423)
|
||||
|
||||
## [3.10.1] - 2021-06-13
|
||||
|
||||
### Added
|
||||
- Usage of github actions (#407).
|
||||
- The ability to show the description on the course page (#406).
|
||||
- The ability to choose how to deliver the certificate (#401).
|
||||
|
||||
### Fixed
|
||||
- Managers are now able to download their students' certificates (#412).
|
||||
- Users being able to view the certificate before the required time set (#403).
|
||||
- Fixed the issue with displaying PDF when debugging is ON (#420).
|
||||
- Using incorrect context when sending emails (#402).
|
||||
- Use `cron_setup_user` when sending emails (#414).
|
||||
|
||||
## [3.8.5] - 2020-11-26
|
||||
|
||||
### Added
|
||||
|
||||
- Added ability to select outcomes in the Grade element (#329).
|
||||
- The Grade Item Name element now works with all grade items, whereas before it was just activities (#346).
|
||||
- Added enrolment start and end dates to the date element (#328).
|
||||
- Added username to userfield form element (#390).
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed unnecessary and confusing 'exampledata' string.
|
||||
- Do not email those who can manage the certificate (#376).
|
||||
- Do not force the PDF to be downloaded, instead send the file inline to the browser (#153).
|
||||
- Updated the 'emailstudents_help', 'emailteachers_help' and 'emailothers_help' strings to warn users about prematurely emailing the certificate (#276).
|
||||
- Do not email out certificates that contain no elements (#276).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Certificates now get marked as viewed via the mobile app (#342).
|
||||
- Custom fields not displaying properly (#359).
|
||||
- Fix repositioning elements page when resizing the browser (#343).
|
||||
- Prevent error when duplicate issues exist when using the code element (#363).
|
||||
- Implemented get_objectid_mapping for the course_module_viewed.php event to avoid warning (#374).
|
||||
- Fixed exception being thrown when loading a template that has an image element but no image selected (#369).
|
||||
- Fixed issue with PDF being generated without a name (#333).
|
||||
|
||||
## [3.8.4] - 2020-03-12
|
||||
|
||||
### Added
|
||||
|
||||
- Added extra Behat steps for new elements (#309).
|
||||
|
||||
### Changed
|
||||
|
||||
- When copying a site template the site images are also copied to the course context and then those copied images are used.
|
||||
Before, the elements would simply point to the site images. However, this meant when performing a backup/restore the
|
||||
images were not stored in the backup file (#298).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed the displaying of names of a custom user field (#326).
|
||||
- Do not allow '0' as a value for width or height in QR code (#321).
|
||||
|
||||
## [3.8.3] - 2020-03-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed foreign key violation (#331).
|
||||
|
||||
## [3.8.2] - 2019-12-16
|
||||
|
||||
### Added
|
||||
|
||||
- Added subplugins.json file (#312).
|
||||
- Re-added 'code' column to user report (#264).
|
||||
- Add 'userfullname' variable for email subject (#316).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Do not fail if multiple certificate issues (#304) and (#295).
|
||||
|
||||
## [3.7.1] - 2019-06-17
|
||||
|
||||
### Added
|
||||
|
||||
- Added new custom course field element (#274).
|
||||
- Added ability to specify the current date for date related elements (#289).
|
||||
|
||||
### Changed
|
||||
|
||||
- String improvements for the 'Date range' element.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Use negative numbers for constants in the 'Date range' element. The reason being that we may have a module
|
||||
that has an id matching one of these positive values. Sites which are using the 'Date range' element (sites
|
||||
which are **not** using this element do **not** have to do anything) will need to re-edit each element, select
|
||||
the date item again and save. An upgrade step was not created because it is impossible to tell if the site does
|
||||
actually want the constant or if they actually want the date for the module.
|
||||
|
||||
## [3.6.2] - 2019-05-28
|
||||
|
||||
### Changed
|
||||
|
||||
- Always send emails from the 'noreplyuser' (#165).
|
||||
|
||||
### Added
|
||||
|
||||
- Added QR code element (#146).
|
||||
- Added Date range element (#185).
|
||||
- Added the number of certificates issued above the report (#266).
|
||||
- Added new capability to control who can be issued a certificate (#270).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Failures when running unit tests for multiple activities (#282).
|
||||
- Check that a certificate is valid before downloading on 'My certificates' page (#269).
|
||||
|
||||
## [3.6.1] - 2018-12-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Make it clear what element values are just an example when previewing the PDF (#144).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Missing implementation for privacy provider (#260).
|
||||
- Use course module context when calling format_string/text (#200).
|
||||
- Exception being thrown when adding the 'teachername' element to site template (#261).
|
||||
|
||||
## [3.5.5] - 2018-12-20
|
||||
### Added
|
||||
|
||||
- GDPR: Add support for removal of users from a context (see MDL-62560) (#252).
|
||||
- Images can be made transparent (#186).
|
||||
- Set default values of activity instance settings (#180).
|
||||
- Allow element plugins to control if they can be added to a certificate (#225).
|
||||
- Allow element plugins to have their own admin settings (#213).
|
||||
- Added plaintext language variants for email bodies (#231).
|
||||
- Added possibility to selectively disable activity instance settings (#179).
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow verification of deleted users (#159).
|
||||
- The 'element' field in the 'customcert_elements' table has been changed from a Text field to varchar(255) (#241).
|
||||
- The 'Completion date' option in the 'date' element is only displayed when completion is enabled (#160).
|
||||
- Instead of assuming 2 decimal points for percentages, we now make use of the decimal value setting, which the
|
||||
function `grade_format_gradevalue` does by default if no decimal value is passed.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue with scales not displaying correctly (#242).
|
||||
- The report now respects the setting 'Show user identity' (#224).
|
||||
- Removed incorrect course reset logic (#223).
|
||||
- Description strings referring to the wrong setting (#254).
|
||||
|
||||
## [3.5.4] - 2018-07-13
|
||||
### Fixed
|
||||
|
||||
- Use custom fonts if present (#211).
|
||||
- Fix broken SQL on Oracle in the email certificate task (#187).
|
||||
- Fixed exception when clicking 'Add page' when template has not been saved (#154).
|
||||
- Only email teachers who are enrolled within the course (#176).
|
||||
- Only display teachers who are enrolled within the course in the dropdown (#171).
|
||||
|
||||
### Changed
|
||||
|
||||
- Multiple UX improvements to both the browser and mobile views (#207).
|
||||
- One big change here is combining the report and activity view page into one.
|
||||
- Allow short dates with leading zeros (#210).
|
||||
|
||||
## [3.5.3] - 2018-06-26
|
||||
### Fixed
|
||||
|
||||
- Respect filters in the 'My certificates' and 'Verify certificate' pages (#197).
|
||||
- Fixed reference to 'mod/certificate' capability.
|
||||
|
||||
### Changed
|
||||
|
||||
- Multiple UX improvements to both the browser and mobile views (#203).
|
||||
|
||||
## [3.5.2] - 2018-06-07
|
||||
### Fixed
|
||||
|
||||
- Hotfix to prevent misalignment of 'text' elements after last release (#196).
|
||||
|
||||
## [3.5.1] - 2018-06-06
|
||||
### Added
|
||||
- Mobile app support (#70).
|
||||
```
|
||||
This allows students to view the activity and download
|
||||
their certificate. It also allows teachers to view the
|
||||
list of issued certificates, with the ability to revoke
|
||||
any.
|
||||
|
||||
This is for the soon-to-be released Moodle Mobile v3.5.0
|
||||
(not to be confused with your Moodle site version) and
|
||||
will not work on Mobile versions earlier than this.
|
||||
|
||||
If you are running a Moodle site on version 3.4 or below
|
||||
you will need to install the local_mobile plugin in order
|
||||
for this to work.
|
||||
|
||||
If you are running a Moodle site on version 3.0 or below
|
||||
then you will need to upgrade.
|
||||
```
|
||||
- More font sizes (#148).
|
||||
- Added new download icon.
|
||||
```
|
||||
This was done because the core 'import' icon was mapped
|
||||
to the Font Awesome icon 'fa-level-up' which did not look
|
||||
appropriate. So, a new icon was added and that was mapped
|
||||
to the 'fa-download' icon.
|
||||
```
|
||||
### Fixed
|
||||
- No longer display the 'action' column and user picture URL when downloading the user report (#192).
|
||||
- Elements no longer ignore filters (#170).
|
||||
|
||||
## [3.4.1] - 2018-05-17
|
||||
### Added
|
||||
- GDPR Compliance (#189).
|
||||
|
||||
### Fixed
|
||||
- Race condition on certificate issues in scheduled task (#173).
|
||||
- Ensure we backup the 'verifyany' setting (#169).
|
||||
- Fixed encoding content links used by restore (#166).
|
||||
|
||||
## [3.3.9] - 2017-11-13
|
||||
### Added
|
||||
- Added capability ```mod/customcert:verifyallcertificates``` that provides a user with the ability to verify any certificate
|
||||
on the site by simply visiting the ```mod/customcert/verify_certificate.php``` page, rather than having to go to the
|
||||
verification link for each certificate.
|
||||
- Added site setting ```customcert/verifyallcertificates``` which when enabled allows any person (including users not logged in)
|
||||
to be able to verify any certificate on the site, rather than having to go to the verification link for each certificate.
|
||||
However, this only applies to certificates where ```Allow anyone to verify a certificate``` has been set to ```Yes``` in the
|
||||
certificate settings.
|
||||
- You can now display the grade and date of all grade items, not just the course and course activities.
|
||||
- Text has been added above the ```My certificates``` list to explain that it contains certificates that have been issued to
|
||||
avoid confusion as to why certificates may not be appearing.
|
||||
|
||||
### Changed
|
||||
- The course full name is now used in emails.
|
||||
|
||||
### Fixed
|
||||
- Added missing string used in course reset.
|
||||
|
||||
## [3.3.8] - 2017-09-04
|
||||
### Added
|
||||
- New digital signature element (uses existing functionality in the TCPDF library).
|
||||
- Ability to duplicate site templates via the manage templates page.
|
||||
- Ability to delete issued certificates for individual users on the course report page.
|
||||
|
||||
### Changed
|
||||
- Removed usage of magic getter and abuse of ```$this->element```. The variable ```$this->element``` will still be
|
||||
accessible by any third-party element plugins, though this is discouraged and the appropriate ```get_xxx()```
|
||||
method should be used instead. Using ```$this->element``` in ```definition_after_data()``` will no longer work.
|
||||
Please explicitly set the value of any custom fields you have in the form.
|
||||
|
||||
### Fixed
|
||||
- Added missing ```confirm_sesskey()``` checks.
|
||||
- Minor bug fixes.
|
||||
|
||||
## [3.3.7] - 2017-08-11
|
||||
### Added
|
||||
- Added much needed Behat test coverage.
|
||||
|
||||
### Changed
|
||||
- Minor language string changes.
|
||||
- Made changes to the UI when editing a certificate.
|
||||
- Moved the 'Add element' submit button below the list of elements.
|
||||
- Added icon next to the 'Delete page' link.
|
||||
- Changed the 'Add page' button to a link, added an icon and moved it's location to the right.
|
||||
- Do not make all submit buttons primary. MDL-59740 needs to be applied to your Moodle install in order to notice the change.
|
||||
|
||||
### Fixed
|
||||
- Issue where the date an activity was graded was not displaying at all.
|
||||
|
||||
## [3.3.6] - 2017-08-05
|
||||
### Changed
|
||||
- Renamed the column 'size' in the table 'customcert_elements' to 'fontsize' due to 'size' being a reserved word in Oracle.
|
57
ajax.php
57
ajax.php
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for 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/>.
|
||||
|
||||
/**
|
||||
* Handles AJAX requests for the customcert module.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
||||
if (!defined('AJAX_SCRIPT')) {
|
||||
define('AJAX_SCRIPT', true);
|
||||
}
|
||||
|
||||
$tid = required_param('tid', PARAM_INT);
|
||||
$values = required_param('values', PARAM_RAW);
|
||||
$values = json_decode($values);
|
||||
|
||||
// Make sure the template exists.
|
||||
$template = $DB->get_record('customcert_templates', array('id' => $tid), '*', MUST_EXIST);
|
||||
|
||||
// Set the template.
|
||||
$template = new \mod_customcert\template($template);
|
||||
// Perform checks.
|
||||
if ($cm = $template->get_cm()) {
|
||||
$courseid = $cm->course;
|
||||
require_login($courseid, false, $cm);
|
||||
} else {
|
||||
require_login();
|
||||
}
|
||||
// Make sure the user has the required capabilities.
|
||||
$template->require_manage();
|
||||
|
||||
// Loop through the data.
|
||||
foreach ($values as $value) {
|
||||
$element = new stdClass();
|
||||
$element->id = $value->id;
|
||||
$element->posx = $value->posx;
|
||||
$element->posy = $value->posy;
|
||||
$DB->update_record('customcert_elements', $element);
|
||||
}
|
2
amd/build/dialogue.min.js
vendored
2
amd/build/dialogue.min.js
vendored
|
@ -1,2 +0,0 @@
|
|||
define ("mod_customcert/dialogue",["core/yui"],function(a){var b=function(b,c,d,e,f){this.yuiDialogue=null;var g=this;if("undefined"==typeof f){f=!1}a.use("moodle-core-notification","timers",function(){var h="480px";if(f){h="800px"}g.yuiDialogue=new M.core.dialogue({headerContent:b,bodyContent:c,draggable:!0,visible:!1,center:!0,modal:!0,width:h});g.yuiDialogue.after("visibleChange",function(b){if(b.newVal){if("undefined"!=typeof d){a.soon(function(){d(g);g.yuiDialogue.centerDialogue()})}}else{if("undefined"!=typeof e){a.soon(function(){e(g)})}}});g.yuiDialogue.show()})};b.prototype.close=function(){this.yuiDialogue.hide();this.yuiDialogue.destroy()};b.prototype.getContent=function(){return this.yuiDialogue.bodyNode.getDOMNode()};return b});
|
||||
//# sourceMappingURL=dialogue.min.js.map
|
File diff suppressed because one or more lines are too long
2
amd/build/rearrange-area.min.js
vendored
2
amd/build/rearrange-area.min.js
vendored
|
@ -1,2 +0,0 @@
|
|||
define ("mod_customcert/rearrange-area",["jquery","core/yui","core/fragment","mod_customcert/dialogue","core/notification","core/str","core/templates","core/ajax"],function(a,b,c,d,f,g,h,i){var j=function(b){this._node=a(b);this._setEvents()};j.prototype.CUSTOMCERT_REF_POINT_TOPLEFT=0;j.prototype.CUSTOMCERT_REF_POINT_TOPCENTER=1;j.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT=2;j.prototype.PIXELSINMM=3.779527559055;j.prototype._setEvents=function(){this._node.on("click",".element",this._editElement.bind(this))};j.prototype._editElement=function(a){var e=a.currentTarget.id.substr(8),h=this._node.attr("data-contextid");c.loadFragment("mod_customcert","editelement",h,{elementid:e}).done(function(a,c){g.get_string("editelement","mod_customcert").done(function(f){b.use("moodle-core-formchangechecker",function(){new d(f,"<div id='elementcontent'></div>",this._editElementDialogueConfig.bind(this,e,a,c),void 0,!0)}.bind(this))}.bind(this))}.bind(this)).fail(f.exception)};j.prototype._editElementDialogueConfig=function(b,c,d,g){h.replaceNode("#elementcontent",c,d);this._setPositionInForm(b);var i=a(g.getContent());i.on("click","#id_submitbutton",function(c){M.core_formchangechecker.reset_form_dirty_state();this._saveElement(b).then(function(){this._getElementHTML(b).done(function(c){var d=this._node.find("#element-"+b),e=parseInt(a("#id_refpoint").val()),f="";if(e==this.CUSTOMCERT_REF_POINT_TOPLEFT){f="refpoint-left"}else if(e==this.CUSTOMCERT_REF_POINT_TOPCENTER){f="refpoint-center"}else if(e==this.CUSTOMCERT_REF_POINT_TOPRIGHT){f="refpoint-right"}d.empty().append(c);d.removeClass();d.addClass("element "+f);d.attr("data-refpoint",e);var h=a("#editelementform #id_posx").val(),i=a("#editelementform #id_posy").val();this._setPosition(b,e,h,i);g.close()}.bind(this))}.bind(this)).fail(f.exception);c.preventDefault()}.bind(this));i.on("click","#id_cancel",function(a){g.close();a.preventDefault()})};j.prototype._setPosition=function(a,c,d,e){var f=b.one("#element-"+a);d=b.one("#pdf").getX()+d*this.PIXELSINMM;e=b.one("#pdf").getY()+e*this.PIXELSINMM;var g=parseFloat(f.getComputedStyle("width")),h=f.width*this.PIXELSINMM;if(h&&g>h){g=h}switch(c){case this.CUSTOMCERT_REF_POINT_TOPCENTER:d-=g/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:d=d-g+2;break;}f.setX(d);f.setY(e)};j.prototype._setPositionInForm=function(c){var d=a("#editelementform #id_posx"),e=a("#editelementform #id_posy");if(d.length&&e.length){var f=b.one("#element-"+c),g=f.getX()-b.one("#pdf").getX(),h=f.getY()-b.one("#pdf").getY(),i=parseInt(f.getData("refpoint")),j=parseFloat(f.getComputedStyle("width"));switch(i){case this.CUSTOMCERT_REF_POINT_TOPCENTER:g+=j/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:g+=j;break;}g=Math.round(parseFloat(g/this.PIXELSINMM));h=Math.round(parseFloat(h/this.PIXELSINMM));d.val(g);e.val(h)}};j.prototype._getElementHTML=function(a){var b=this._node.attr("data-templateid"),c=i.call([{methodname:"mod_customcert_get_element_html",args:{templateid:b,elementid:a}}]);return c[0]};j.prototype._saveElement=function(b){var c=this._node.attr("data-templateid"),d=a("#editelementform").serializeArray(),e=i.call([{methodname:"mod_customcert_save_element",args:{templateid:c,elementid:b,values:d}}]);return e[0]};return{init:function init(a){new j(a)}}});
|
||||
//# sourceMappingURL=rearrange-area.min.js.map
|
File diff suppressed because one or more lines are too long
|
@ -1,101 +0,0 @@
|
|||
// 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/>.
|
||||
|
||||
/**
|
||||
* Wrapper for the YUI M.core.notification class. Allows us to
|
||||
* use the YUI version in AMD code until it is replaced.
|
||||
*
|
||||
* @module mod_customcert/dialogue
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['core/yui'], function(Y) {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {String} title Title for the window.
|
||||
* @param {String} content The content for the window.
|
||||
* @param {function} afterShow Callback executed after the window is opened.
|
||||
* @param {function} afterHide Callback executed after the window is closed.
|
||||
* @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).
|
||||
*/
|
||||
var dialogue = function(title, content, afterShow, afterHide, wide) {
|
||||
this.yuiDialogue = null;
|
||||
var parent = this;
|
||||
|
||||
// Default for wide is false.
|
||||
if (typeof wide == 'undefined') {
|
||||
wide = false;
|
||||
}
|
||||
|
||||
Y.use('moodle-core-notification', 'timers', function() {
|
||||
var width = '480px';
|
||||
if (wide) {
|
||||
width = '800px';
|
||||
}
|
||||
|
||||
parent.yuiDialogue = new M.core.dialogue({
|
||||
headerContent: title,
|
||||
bodyContent: content,
|
||||
draggable: true,
|
||||
visible: false,
|
||||
center: true,
|
||||
modal: true,
|
||||
width: width
|
||||
});
|
||||
|
||||
parent.yuiDialogue.after('visibleChange', function(e) {
|
||||
if (e.newVal) {
|
||||
// Delay the callback call to the next tick, otherwise it can happen that it is
|
||||
// executed before the dialogue constructor returns.
|
||||
if ((typeof afterShow !== 'undefined')) {
|
||||
Y.soon(function() {
|
||||
afterShow(parent);
|
||||
parent.yuiDialogue.centerDialogue();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if ((typeof afterHide !== 'undefined')) {
|
||||
Y.soon(function() {
|
||||
afterHide(parent);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
parent.yuiDialogue.show();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Close this window.
|
||||
*/
|
||||
dialogue.prototype.close = function() {
|
||||
this.yuiDialogue.hide();
|
||||
this.yuiDialogue.destroy();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get content.
|
||||
*
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
dialogue.prototype.getContent = function() {
|
||||
return this.yuiDialogue.bodyNode.getDOMNode();
|
||||
};
|
||||
|
||||
return dialogue;
|
||||
});
|
|
@ -1,212 +0,0 @@
|
|||
// 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/>.
|
||||
|
||||
/**
|
||||
* AMD module used when rearranging a custom certificate.
|
||||
*
|
||||
* @module mod_customcert/rearrange-area
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/yui', 'core/fragment', 'mod_customcert/dialogue', 'core/notification',
|
||||
'core/str', 'core/templates', 'core/ajax'],
|
||||
function($, Y, fragment, Dialogue, notification, str, template, ajax) {
|
||||
|
||||
/**
|
||||
* RearrangeArea class.
|
||||
*
|
||||
* @param {String} selector The rearrange PDF selector
|
||||
*/
|
||||
var RearrangeArea = function(selector) {
|
||||
this._node = $(selector);
|
||||
this._setEvents();
|
||||
};
|
||||
|
||||
RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPLEFT = 0;
|
||||
RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPCENTER = 1;
|
||||
RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT = 2;
|
||||
RearrangeArea.prototype.PIXELSINMM = 3.779527559055;
|
||||
|
||||
RearrangeArea.prototype._setEvents = function() {
|
||||
this._node.on('click', '.element', this._editElement.bind(this));
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._editElement = function(event) {
|
||||
var elementid = event.currentTarget.id.substr(8);
|
||||
var contextid = this._node.attr('data-contextid');
|
||||
var params = {
|
||||
'elementid': elementid
|
||||
};
|
||||
|
||||
fragment.loadFragment('mod_customcert', 'editelement', contextid, params).done(function(html, js) {
|
||||
str.get_string('editelement', 'mod_customcert').done(function(title) {
|
||||
Y.use('moodle-core-formchangechecker', function() {
|
||||
new Dialogue(
|
||||
title,
|
||||
'<div id=\'elementcontent\'></div>',
|
||||
this._editElementDialogueConfig.bind(this, elementid, html, js),
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this)).fail(notification.exception);
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._editElementDialogueConfig = function(elementid, html, js, popup) {
|
||||
// Place the content in the dialogue.
|
||||
template.replaceNode('#elementcontent', html, js);
|
||||
|
||||
// We may have dragged the element changing it's position.
|
||||
// Ensure the form has the current up-to-date location.
|
||||
this._setPositionInForm(elementid);
|
||||
|
||||
// Add events for when we save, close and cancel the page.
|
||||
var body = $(popup.getContent());
|
||||
body.on('click', '#id_submitbutton', function(e) {
|
||||
// Do not want to ask the user if they wish to stay on page after saving.
|
||||
M.core_formchangechecker.reset_form_dirty_state();
|
||||
// Save the data.
|
||||
this._saveElement(elementid).then(function() {
|
||||
// Update the DOM to reflect the adjusted value.
|
||||
this._getElementHTML(elementid).done(function(html) {
|
||||
var elementNode = this._node.find('#element-' + elementid);
|
||||
var refpoint = parseInt($('#id_refpoint').val());
|
||||
var refpointClass = '';
|
||||
if (refpoint == this.CUSTOMCERT_REF_POINT_TOPLEFT) {
|
||||
refpointClass = 'refpoint-left';
|
||||
} else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPCENTER) {
|
||||
refpointClass = 'refpoint-center';
|
||||
} else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPRIGHT) {
|
||||
refpointClass = 'refpoint-right';
|
||||
}
|
||||
elementNode.empty().append(html);
|
||||
// Update the ref point.
|
||||
elementNode.removeClass();
|
||||
elementNode.addClass('element ' + refpointClass);
|
||||
elementNode.attr('data-refpoint', refpoint);
|
||||
// Move the element.
|
||||
var posx = $('#editelementform #id_posx').val();
|
||||
var posy = $('#editelementform #id_posy').val();
|
||||
this._setPosition(elementid, refpoint, posx, posy);
|
||||
// All done.
|
||||
popup.close();
|
||||
}.bind(this));
|
||||
}.bind(this)).fail(notification.exception);
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
|
||||
body.on('click', '#id_cancel', function(e) {
|
||||
popup.close();
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {
|
||||
var element = Y.one('#element-' + elementid);
|
||||
|
||||
posx = Y.one('#pdf').getX() + posx * this.PIXELSINMM;
|
||||
posy = Y.one('#pdf').getY() + posy * this.PIXELSINMM;
|
||||
var nodewidth = parseFloat(element.getComputedStyle('width'));
|
||||
var maxwidth = element.width * this.PIXELSINMM;
|
||||
|
||||
if (maxwidth && (nodewidth > maxwidth)) {
|
||||
nodewidth = maxwidth;
|
||||
}
|
||||
|
||||
switch (refpoint) {
|
||||
case this.CUSTOMCERT_REF_POINT_TOPCENTER:
|
||||
posx -= nodewidth / 2;
|
||||
break;
|
||||
case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
|
||||
posx = posx - nodewidth + 2;
|
||||
break;
|
||||
}
|
||||
|
||||
element.setX(posx);
|
||||
element.setY(posy);
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._setPositionInForm = function(elementid) {
|
||||
var posxelement = $('#editelementform #id_posx');
|
||||
var posyelement = $('#editelementform #id_posy');
|
||||
|
||||
if (posxelement.length && posyelement.length) {
|
||||
var element = Y.one('#element-' + elementid);
|
||||
var posx = element.getX() - Y.one('#pdf').getX();
|
||||
var posy = element.getY() - Y.one('#pdf').getY();
|
||||
var refpoint = parseInt(element.getData('refpoint'));
|
||||
var nodewidth = parseFloat(element.getComputedStyle('width'));
|
||||
|
||||
switch (refpoint) {
|
||||
case this.CUSTOMCERT_REF_POINT_TOPCENTER:
|
||||
posx += nodewidth / 2;
|
||||
break;
|
||||
case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
|
||||
posx += nodewidth;
|
||||
break;
|
||||
}
|
||||
|
||||
posx = Math.round(parseFloat(posx / this.PIXELSINMM));
|
||||
posy = Math.round(parseFloat(posy / this.PIXELSINMM));
|
||||
|
||||
posxelement.val(posx);
|
||||
posyelement.val(posy);
|
||||
}
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._getElementHTML = function(elementid) {
|
||||
// Get the variables we need.
|
||||
var templateid = this._node.attr('data-templateid');
|
||||
|
||||
// Call the web service to get the updated element.
|
||||
var promises = ajax.call([{
|
||||
methodname: 'mod_customcert_get_element_html',
|
||||
args: {
|
||||
templateid: templateid,
|
||||
elementid: elementid
|
||||
}
|
||||
}]);
|
||||
|
||||
// Return the promise.
|
||||
return promises[0];
|
||||
};
|
||||
|
||||
RearrangeArea.prototype._saveElement = function(elementid) {
|
||||
// Get the variables we need.
|
||||
var templateid = this._node.attr('data-templateid');
|
||||
var inputs = $('#editelementform').serializeArray();
|
||||
|
||||
// Call the web service to save the element.
|
||||
var promises = ajax.call([{
|
||||
methodname: 'mod_customcert_save_element',
|
||||
args: {
|
||||
templateid: templateid,
|
||||
elementid: elementid,
|
||||
values: inputs
|
||||
}
|
||||
}]);
|
||||
|
||||
// Return the promise.
|
||||
return promises[0];
|
||||
};
|
||||
|
||||
return {
|
||||
init: function(selector) {
|
||||
new RearrangeArea(selector);
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||
// This file is part of the htmlcert module for 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
|
||||
|
@ -17,23 +17,23 @@
|
|||
/**
|
||||
* This file contains the backup tasks that provides all the settings and steps to perform a backup of the activity.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/backup_customcert_stepslib.php');
|
||||
require_once($CFG->dirroot . '/mod/htmlcert/backup/moodle2/backup_htmlcert_stepslib.php');
|
||||
|
||||
/**
|
||||
* Handles creating tasks to peform in order to create the backup.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class backup_customcert_activity_task extends backup_activity_task {
|
||||
class backup_htmlcert_activity_task extends backup_activity_task {
|
||||
|
||||
/**
|
||||
* Define particular settings this activity can have.
|
||||
|
@ -46,8 +46,8 @@ class backup_customcert_activity_task extends backup_activity_task {
|
|||
* Define particular steps this activity can have.
|
||||
*/
|
||||
protected function define_my_steps() {
|
||||
// The customcert only has one structure step.
|
||||
$this->add_step(new backup_customcert_activity_structure_step('customcert_structure', 'customcert.xml'));
|
||||
// The htmlcert only has one structure step.
|
||||
$this->add_step(new backup_htmlcert_activity_structure_step('htmlcert_structure', 'htmlcert.xml'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,13 +61,13 @@ class backup_customcert_activity_task extends backup_activity_task {
|
|||
|
||||
$base = preg_quote($CFG->wwwroot, "/");
|
||||
|
||||
// Link to the list of customcerts.
|
||||
$search = "/(".$base."\/mod\/customcert\/index.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@CUSTOMCERTINDEX*$2@$', $content);
|
||||
// Link to the list of htmlcerts.
|
||||
$search = "/(".$base."\/mod\/htmlcert\/index.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@HTMLCERTINDEX*$2@$', $content);
|
||||
|
||||
// Link to customcert view by moduleid.
|
||||
$search = "/(".$base."\/mod\/customcert\/view.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@CUSTOMCERTVIEWBYID*$2@$', $content);
|
||||
// Link to htmlcert view by moduleid.
|
||||
$search = "/(".$base."\/mod\/htmlcert\/view.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@HTMLCERTVIEWBYID*$2@$', $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||
// This file is part of the htmlcert module for 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
|
||||
|
@ -15,23 +15,23 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Define all the backup steps that will be used by the backup_customcert_activity_task.
|
||||
* Define all the backup steps that will be used by the backup_htmlcert_activity_task.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
/**
|
||||
* Define the complete customcert structure for backup, with file and id annotations.
|
||||
* Define the complete htmlcert structure for backup, with file and id annotations.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class backup_customcert_activity_structure_step extends backup_activity_structure_step {
|
||||
class backup_htmlcert_activity_structure_step extends backup_activity_structure_step {
|
||||
|
||||
/**
|
||||
* Define the structure of the backup file.
|
||||
|
@ -41,7 +41,7 @@ class backup_customcert_activity_structure_step extends backup_activity_structur
|
|||
protected function define_structure() {
|
||||
|
||||
// The instance.
|
||||
$customcert = new backup_nested_element('customcert', array('id'), array(
|
||||
$htmlcert = new backup_nested_element('htmlcert', array('id'), array(
|
||||
'templateid', 'name', 'intro', 'introformat', 'requiredtime', 'verifyany', 'emailstudents',
|
||||
'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified'));
|
||||
|
||||
|
@ -49,56 +49,35 @@ class backup_customcert_activity_structure_step extends backup_activity_structur
|
|||
$template = new backup_nested_element('template', array('id'), array(
|
||||
'name', 'contextid', 'timecreated', 'timemodified'));
|
||||
|
||||
// The pages.
|
||||
$pages = new backup_nested_element('pages');
|
||||
$page = new backup_nested_element('page', array('id'), array(
|
||||
'templateid', 'width', 'height', 'leftmargin', 'rightmargin',
|
||||
'sequence', 'timecreated', 'timemodified'));
|
||||
|
||||
// The elements.
|
||||
$element = new backup_nested_element('element', array('id'), array(
|
||||
'pageid', 'name', 'element', 'data', 'font', 'fontsize',
|
||||
'colour', 'posx', 'posy', 'width', 'refpoint', 'sequence',
|
||||
'alignment', 'timecreated', 'timemodified'));
|
||||
|
||||
// The issues.
|
||||
$issues = new backup_nested_element('issues');
|
||||
$issue = new backup_nested_element('issue', array('id'), array(
|
||||
'customcertid', 'userid', 'timecreated', 'emailed', 'code'));
|
||||
'htmlcertid', 'userid', 'timecreated', 'emailed', 'code'));
|
||||
|
||||
// Build the tree.
|
||||
$customcert->add_child($issues);
|
||||
$htmlcert->add_child($issues);
|
||||
$issues->add_child($issue);
|
||||
$customcert->add_child($template);
|
||||
$template->add_child($pages);
|
||||
$pages->add_child($page);
|
||||
$page->add_child($element);
|
||||
$htmlcert->add_child($template);
|
||||
|
||||
// Define sources.
|
||||
$customcert->set_source_table('customcert', array('id' => backup::VAR_ACTIVITYID));
|
||||
$htmlcert->set_source_table('htmlcert', array('id' => backup::VAR_ACTIVITYID));
|
||||
|
||||
// Define template source.
|
||||
$template->set_source_table('customcert_templates', array('contextid' => backup::VAR_CONTEXTID));
|
||||
|
||||
// Define page source.
|
||||
$page->set_source_table('customcert_pages', array('templateid' => backup::VAR_PARENTID));
|
||||
|
||||
// Define element source, each element belongs to a page.
|
||||
$element->set_source_table('customcert_elements', array('pageid' => backup::VAR_PARENTID));
|
||||
$template->set_source_table('htmlcert_templates', array('contextid' => backup::VAR_CONTEXTID));
|
||||
|
||||
// If we are including user info then save the issues.
|
||||
if ($this->get_setting_value('userinfo')) {
|
||||
$issue->set_source_table('customcert_issues', array('customcertid' => backup::VAR_ACTIVITYID));
|
||||
$issue->set_source_table('htmlcert_issues', array('htmlcertid' => backup::VAR_ACTIVITYID));
|
||||
}
|
||||
|
||||
// Annotate the user id's where required.
|
||||
$issue->annotate_ids('user', 'userid');
|
||||
|
||||
// Define file annotations.
|
||||
$customcert->annotate_files('mod_customcert', 'intro', null);
|
||||
$customcert->annotate_files('mod_customcert', 'image', null, context_course::instance($this->get_courseid())->id);
|
||||
$htmlcert->annotate_files('mod_htmlcert', 'intro', null);
|
||||
$htmlcert->annotate_files('mod_htmlcert', 'image', null, context_course::instance($this->get_courseid())->id);
|
||||
|
||||
// Return the root element (customcert), wrapped into standard activity structure.
|
||||
return $this->prepare_activity_structure($customcert);
|
||||
// Return the root element (htmlcert), wrapped into standard activity structure.
|
||||
return $this->prepare_activity_structure($htmlcert);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||
// This file is part of the htmlcert module for 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
|
||||
|
@ -15,25 +15,25 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Define all the restore steps that will be used by the restore_customcert_activity_task.
|
||||
* Define all the restore steps that will be used by the restore_htmlcert_activity_task.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/restore_customcert_stepslib.php');
|
||||
require_once($CFG->dirroot . '/mod/htmlcert/backup/moodle2/restore_htmlcert_stepslib.php');
|
||||
|
||||
/**
|
||||
* The class definition for assigning tasks that provide the settings and steps to perform a restore of the activity.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restore_customcert_activity_task extends restore_activity_task {
|
||||
class restore_htmlcert_activity_task extends restore_activity_task {
|
||||
|
||||
/**
|
||||
* Define particular settings this activity can have.
|
||||
|
@ -46,8 +46,8 @@ class restore_customcert_activity_task extends restore_activity_task {
|
|||
* Define particular steps this activity can have.
|
||||
*/
|
||||
protected function define_my_steps() {
|
||||
// The customcert only has one structure step.
|
||||
$this->add_step(new restore_customcert_activity_structure_step('customcert_structure', 'customcert.xml'));
|
||||
// The htmlcert only has one structure step.
|
||||
$this->add_step(new restore_htmlcert_activity_structure_step('htmlcert_structure', 'htmlcert.xml'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ class restore_customcert_activity_task extends restore_activity_task {
|
|||
public static function define_decode_contents() {
|
||||
$contents = array();
|
||||
|
||||
$contents[] = new restore_decode_content('customcert', array('intro'), 'customcert');
|
||||
$contents[] = new restore_decode_content('htmlcert', array('intro'), 'htmlcert');
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ class restore_customcert_activity_task extends restore_activity_task {
|
|||
public static function define_decode_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_decode_rule('CUSTOMCERTVIEWBYID', '/mod/customcert/view.php?id=$1', 'course_module');
|
||||
$rules[] = new restore_decode_rule('CUSTOMCERTINDEX', '/mod/customcert/index.php?id=$1', 'course');
|
||||
$rules[] = new restore_decode_rule('HTMLCERTVIEWBYID', '/mod/htmlcert/view.php?id=$1', 'course_module');
|
||||
$rules[] = new restore_decode_rule('HTMLCERTINDEX', '/mod/htmlcert/index.php?id=$1', 'course');
|
||||
|
||||
return $rules;
|
||||
|
||||
|
@ -76,46 +76,28 @@ class restore_customcert_activity_task extends restore_activity_task {
|
|||
|
||||
/**
|
||||
* Define the restore log rules that will be applied by the {@see restore_logs_processor} when restoring
|
||||
* customcert logs. It must return one array of {@see restore_log_rule} objects.
|
||||
* htmlcert logs. It must return one array of {@see restore_log_rule} objects.
|
||||
*
|
||||
* @return array the restore log rules
|
||||
*/
|
||||
public static function define_restore_log_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_log_rule('customcert', 'add', 'view.php?id={course_module}', '{customcert}');
|
||||
$rules[] = new restore_log_rule('customcert', 'update', 'view.php?id={course_module}', '{customcert}');
|
||||
$rules[] = new restore_log_rule('customcert', 'view', 'view.php?id={course_module}', '{customcert}');
|
||||
$rules[] = new restore_log_rule('customcert', 'received', 'view.php?id={course_module}', '{customcert}');
|
||||
$rules[] = new restore_log_rule('customcert', 'view report', 'view.php?id={course_module}', '{customcert}');
|
||||
$rules[] = new restore_log_rule('htmlcert', 'add', 'view.php?id={course_module}', '{htmlcert}');
|
||||
$rules[] = new restore_log_rule('htmlcert', 'update', 'view.php?id={course_module}', '{htmlcert}');
|
||||
$rules[] = new restore_log_rule('htmlcert', 'view', 'view.php?id={course_module}', '{htmlcert}');
|
||||
$rules[] = new restore_log_rule('htmlcert', 'received', 'view.php?id={course_module}', '{htmlcert}');
|
||||
$rules[] = new restore_log_rule('htmlcert', 'view report', 'view.php?id={course_module}', '{htmlcert}');
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called after all the activities in the backup have been restored. This allows us to get
|
||||
* the new course module ids, as they may have been restored after the customcert module, meaning no id
|
||||
* the new course module ids, as they may have been restored after the htmlcert module, meaning no id
|
||||
* was available at the time.
|
||||
*/
|
||||
public function after_restore() {
|
||||
global $DB;
|
||||
|
||||
// Get the customcert elements.
|
||||
$sql = "SELECT e.*
|
||||
FROM {customcert_elements} e
|
||||
INNER JOIN {customcert_pages} p
|
||||
ON e.pageid = p.id
|
||||
INNER JOIN {customcert} c
|
||||
ON p.templateid = c.templateid
|
||||
WHERE c.id = :customcertid";
|
||||
if ($elements = $DB->get_records_sql($sql, array('customcertid' => $this->get_activityid()))) {
|
||||
// Go through the elements for the certificate.
|
||||
foreach ($elements as $e) {
|
||||
// Get an instance of the element class.
|
||||
if ($e = \mod_customcert\element_factory::get_element_instance($e)) {
|
||||
$e->after_restore($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||
// This file is part of the htmlcert module for 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
|
||||
|
@ -15,23 +15,23 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Define all the restore steps that will be used by the restore_customcert_activity_task.
|
||||
* Define all the restore steps that will be used by the restore_htmlcert_activity_task.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
/**
|
||||
* Define the complete customcert structure for restore, with file and id annotations.
|
||||
* Define the complete htmlcert structure for restore, with file and id annotations.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restore_customcert_activity_structure_step extends restore_activity_structure_step {
|
||||
class restore_htmlcert_activity_structure_step extends restore_activity_structure_step {
|
||||
|
||||
/**
|
||||
* Define the different items to restore.
|
||||
|
@ -42,21 +42,15 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
|
|||
// The array used to store the path to the items we want to restore.
|
||||
$paths = array();
|
||||
|
||||
// The customcert instance.
|
||||
$paths[] = new restore_path_element('customcert', '/activity/customcert');
|
||||
// The htmlcert instance.
|
||||
$paths[] = new restore_path_element('htmlcert', '/activity/htmlcert');
|
||||
|
||||
// The templates.
|
||||
$paths[] = new restore_path_element('customcert_template', '/activity/customcert/template');
|
||||
|
||||
// The pages.
|
||||
$paths[] = new restore_path_element('customcert_page', '/activity/customcert/template/pages/page');
|
||||
|
||||
// The elements.
|
||||
$paths[] = new restore_path_element('customcert_element', '/activity/customcert/template/pages/page/element');
|
||||
$paths[] = new restore_path_element('htmlcert_template', '/activity/htmlcert/template');
|
||||
|
||||
// Check if we want the issues as well.
|
||||
if ($this->get_setting_value('userinfo')) {
|
||||
$paths[] = new restore_path_element('customcert_issue', '/activity/customcert/issues/issue');
|
||||
$paths[] = new restore_path_element('htmlcert_issue', '/activity/htmlcert/issues/issue');
|
||||
}
|
||||
|
||||
// Return the paths wrapped into standard activity structure.
|
||||
|
@ -64,11 +58,11 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
|
|||
}
|
||||
|
||||
/**
|
||||
* Handles restoring the customcert activity.
|
||||
* Handles restoring the htmlcert activity.
|
||||
*
|
||||
* @param stdClass $data the customcert data
|
||||
* @param stdClass $data the htmlcert data
|
||||
*/
|
||||
protected function process_customcert($data) {
|
||||
protected function process_htmlcert($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
|
@ -76,19 +70,19 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
|
|||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
// Insert the customcert record.
|
||||
$newitemid = $DB->insert_record('customcert', $data);
|
||||
// Insert the htmlcert record.
|
||||
$newitemid = $DB->insert_record('htmlcert', $data);
|
||||
|
||||
// Immediately after inserting record call this.
|
||||
$this->apply_activity_instance($newitemid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles restoring a customcert page.
|
||||
* Handles restoring a htmlcert templage.
|
||||
*
|
||||
* @param stdClass $data the customcert data
|
||||
* @param stdClass $data the htmlcert data
|
||||
*/
|
||||
protected function process_customcert_template($data) {
|
||||
protected function process_htmlcert_template($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
|
@ -98,71 +92,33 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
|
|||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$newitemid = $DB->insert_record('customcert_templates', $data);
|
||||
$this->set_mapping('customcert_template', $oldid, $newitemid);
|
||||
$newitemid = $DB->insert_record('htmlcert_templates', $data);
|
||||
$this->set_mapping('htmlcert_template', $oldid, $newitemid);
|
||||
|
||||
// Update the template id for the customcert.
|
||||
$customcert = new stdClass();
|
||||
$customcert->id = $this->get_new_parentid('customcert');
|
||||
$customcert->templateid = $newitemid;
|
||||
$DB->update_record('customcert', $customcert);
|
||||
// Update the template id for the htmlcert.
|
||||
$htmlcert = new stdClass();
|
||||
$htmlcert->id = $this->get_new_parentid('htmlcert');
|
||||
$htmlcert->templateid = $newitemid;
|
||||
$DB->update_record('htmlcert', $htmlcert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles restoring a customcert template.
|
||||
* Handles restoring a htmlcert issue.
|
||||
*
|
||||
* @param stdClass $data the customcert data
|
||||
* @param stdClass $data the htmlcert data
|
||||
*/
|
||||
protected function process_customcert_page($data) {
|
||||
protected function process_htmlcert_issue($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
$oldid = $data->id;
|
||||
|
||||
$data->templateid = $this->get_new_parentid('customcert_template');
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$newitemid = $DB->insert_record('customcert_pages', $data);
|
||||
$this->set_mapping('customcert_page', $oldid, $newitemid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles restoring a customcert element.
|
||||
*
|
||||
* @param stdclass $data the customcert data
|
||||
*/
|
||||
protected function process_customcert_element($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
$oldid = $data->id;
|
||||
|
||||
$data->pageid = $this->get_new_parentid('customcert_page');
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$newitemid = $DB->insert_record('customcert_elements', $data);
|
||||
$this->set_mapping('customcert_element', $oldid, $newitemid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles restoring a customcert issue.
|
||||
*
|
||||
* @param stdClass $data the customcert data
|
||||
*/
|
||||
protected function process_customcert_issue($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object) $data;
|
||||
$oldid = $data->id;
|
||||
|
||||
$data->customcertid = $this->get_new_parentid('customcert');
|
||||
$data->htmlcertid = $this->get_new_parentid('htmlcert');
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
|
||||
$newitemid = $DB->insert_record('customcert_issues', $data);
|
||||
$this->set_mapping('customcert_issue', $oldid, $newitemid);
|
||||
$newitemid = $DB->insert_record('htmlcert_issues', $data);
|
||||
$this->set_mapping('htmlcert_issue', $oldid, $newitemid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,9 +128,9 @@ class restore_customcert_activity_structure_step extends restore_activity_struct
|
|||
parent::after_execute();
|
||||
|
||||
// Add the files.
|
||||
$this->add_related_files('mod_customcert', 'intro', null);
|
||||
$this->add_related_files('mod_htmlcert', 'intro', null);
|
||||
|
||||
// Note - we can't use get_old_contextid() as it refers to the module context.
|
||||
$this->add_related_files('mod_customcert', 'image', null, $this->get_task()->get_info()->original_course_contextid);
|
||||
$this->add_related_files('mod_htmlcert', 'image', null, $this->get_task()->get_info()->original_course_contextid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// This file is part of the customcert module for Moodle - http://moodle.org/
|
||||
// This file is part of the htmlcert module for 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
|
||||
|
@ -17,12 +17,12 @@
|
|||
/**
|
||||
* Creates an upload form on the settings page.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
namespace mod_htmlcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
@ -31,8 +31,8 @@ require_once($CFG->libdir.'/adminlib.php');
|
|||
/**
|
||||
* Class extends admin setting class to allow/process an uploaded file
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @package mod_htmlcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_setting_link extends \admin_setting_configtext {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||