#88 Make plugins DB codechecker happy
This commit is contained in:
parent
db879187bf
commit
fdc5bde3d4
54 changed files with 760 additions and 395 deletions
40
.travis.yml
Normal file
40
.travis.yml
Normal file
|
@ -0,0 +1,40 @@
|
|||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
|
||||
env:
|
||||
global:
|
||||
- MOODLE_BRANCH=MOODLE_32_STABLE
|
||||
matrix:
|
||||
- DB=pgsql
|
||||
- DB=mysqli
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- cd ../..
|
||||
- composer selfupdate
|
||||
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
|
||||
script:
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
- moodle-plugin-ci codechecker
|
||||
- moodle-plugin-ci csslint
|
||||
- moodle-plugin-ci shifter
|
||||
- moodle-plugin-ci jshint
|
||||
- moodle-plugin-ci validate
|
||||
- moodle-plugin-ci phpunit
|
||||
- moodle-plugin-ci behat
|
||||
|
4
ajax.php
4
ajax.php
|
@ -22,12 +22,12 @@
|
|||
* @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);
|
||||
}
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
||||
$tid = required_param('tid', PARAM_INT);
|
||||
$values = required_param('values', PARAM_RAW);
|
||||
$values = json_decode($values);
|
||||
|
|
2
amd/build/rearrange-area.min.js
vendored
2
amd/build/rearrange-area.min.js
vendored
|
@ -1 +1 @@
|
|||
define(["jquery","core/yui","core/fragment","mod_customcert/dialogue","core/notification","core/str","core/templates","core/ajax"],function(a,b,c,d,e,f,g,h){var i=function(b){this._node=a(b),this._setEvents()};return i.prototype.CUSTOMCERT_REF_POINT_TOPLEFT=0,i.prototype.CUSTOMCERT_REF_POINT_TOPCENTER=1,i.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT=2,i.prototype.PIXELSINMM=3.779527559055,i.prototype._setEvents=function(){this._node.on("click",".element",this._editElement.bind(this))},i.prototype._editElement=function(a){var g=a.currentTarget.id.substr(8),h=this._node.attr("data-contextid"),i={elementid:g};c.loadFragment("mod_customcert","editelement",h,i).done(function(a,c){f.get_string("editelement","mod_customcert").done(function(e){b.use("moodle-core-formchangechecker",function(){new d(e,"<div id='elementcontent'></div>",this._editElementDialogueConfig.bind(this,g,a,c),(void 0),(!0))}.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype._editElementDialogueConfig=function(b,c,d,e){g.replaceNode("#elementcontent",c,d),this._setPositionInForm(b);var f=a(e.getContent());f.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),f=parseInt(a("#id_refpoint").val()),g="";f==this.CUSTOMCERT_REF_POINT_TOPLEFT?g="refpoint-left":f==this.CUSTOMCERT_REF_POINT_TOPCENTER?g="refpoint-center":f==this.CUSTOMCERT_REF_POINT_TOPRIGHT&&(g="refpoint-right"),d.empty().append(c),d.removeClass(),d.addClass("element "+g),d.attr("data-refpoint",f);var h=a("#editelementform #id_posx").val(),i=a("#editelementform #id_posy").val();this._setPosition(b,f,h,i),e.close()}.bind(this))}.bind(this)),c.preventDefault()}.bind(this)),f.on("click","#id_cancel",function(a){e.close(),a.preventDefault()}.bind(this))},i.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;switch(h&&g>h&&(g=h),c){case this.CUSTOMCERT_REF_POINT_TOPCENTER:d-=g/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:d=d-g+2}f.setX(d),f.setY(e)},i.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}g=Math.round(parseFloat(g/this.PIXELSINMM)),h=Math.round(parseFloat(h/this.PIXELSINMM)),d.val(g),e.val(h)}},i.prototype._getElementHTML=function(a){var b=this._node.attr("data-templateid"),c=h.call([{methodname:"mod_customcert_get_element_html",args:{templateid:b,elementid:a}}]);return c[0]},i.prototype._saveElement=function(b){var c=this._node.attr("data-templateid"),d=a("#editelementform").serializeArray(),e=h.call([{methodname:"mod_customcert_save_element",args:{templateid:c,elementid:b,values:d}}]);return e[0]},{init:function(a){new i(a)}}});
|
||||
define(["jquery","core/yui","core/fragment","mod_customcert/dialogue","core/notification","core/str","core/templates","core/ajax"],function(a,b,c,d,e,f,g,h){var i=function(b){this._node=a(b),this._setEvents()};return i.prototype.CUSTOMCERT_REF_POINT_TOPLEFT=0,i.prototype.CUSTOMCERT_REF_POINT_TOPCENTER=1,i.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT=2,i.prototype.PIXELSINMM=3.779527559055,i.prototype._setEvents=function(){this._node.on("click",".element",this._editElement.bind(this))},i.prototype._editElement=function(a){var g=a.currentTarget.id.substr(8),h=this._node.attr("data-contextid"),i={elementid:g};c.loadFragment("mod_customcert","editelement",h,i).done(function(a,c){f.get_string("editelement","mod_customcert").done(function(e){b.use("moodle-core-formchangechecker",function(){new d(e,"<div id='elementcontent'></div>",this._editElementDialogueConfig.bind(this,g,a,c),(void 0),(!0))}.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype._editElementDialogueConfig=function(b,c,d,e){g.replaceNode("#elementcontent",c,d),this._setPositionInForm(b);var f=a(e.getContent());f.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),f=parseInt(a("#id_refpoint").val()),g="";f==this.CUSTOMCERT_REF_POINT_TOPLEFT?g="refpoint-left":f==this.CUSTOMCERT_REF_POINT_TOPCENTER?g="refpoint-center":f==this.CUSTOMCERT_REF_POINT_TOPRIGHT&&(g="refpoint-right"),d.empty().append(c),d.removeClass(),d.addClass("element "+g),d.attr("data-refpoint",f);var h=a("#editelementform #id_posx").val(),i=a("#editelementform #id_posy").val();this._setPosition(b,f,h,i),e.close()}.bind(this))}.bind(this)),c.preventDefault()}.bind(this)),f.on("click","#id_cancel",function(a){e.close(),a.preventDefault()})},i.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;switch(h&&g>h&&(g=h),c){case this.CUSTOMCERT_REF_POINT_TOPCENTER:d-=g/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:d=d-g+2}f.setX(d),f.setY(e)},i.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}g=Math.round(parseFloat(g/this.PIXELSINMM)),h=Math.round(parseFloat(h/this.PIXELSINMM)),d.val(g),e.val(h)}},i.prototype._getElementHTML=function(a){var b=this._node.attr("data-templateid"),c=h.call([{methodname:"mod_customcert_get_element_html",args:{templateid:b,elementid:a}}]);return c[0]},i.prototype._saveElement=function(b){var c=this._node.attr("data-templateid"),d=a("#editelementform").serializeArray(),e=h.call([{methodname:"mod_customcert_save_element",args:{templateid:c,elementid:b,values:d}}]);return e[0]},{init:function(a){new i(a)}}});
|
|
@ -42,7 +42,7 @@ define(['core/yui'], function(Y) {
|
|||
wide = false;
|
||||
}
|
||||
|
||||
Y.use('moodle-core-notification', 'timers', function () {
|
||||
Y.use('moodle-core-notification', 'timers', function() {
|
||||
var width = '480px';
|
||||
if (wide) {
|
||||
width = '800px';
|
||||
|
@ -91,10 +91,12 @@ define(['core/yui'], function(Y) {
|
|||
|
||||
/**
|
||||
* Get content.
|
||||
*
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
dialogue.prototype.getContent = function() {
|
||||
return this.yuiDialogue.bodyNode.getDOMNode();
|
||||
};
|
||||
|
||||
return /** @alias module:mod_customcert/dialogue */ dialogue;
|
||||
return dialogue;
|
||||
});
|
||||
|
|
|
@ -23,190 +23,191 @@
|
|||
*/
|
||||
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) {
|
||||
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 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.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._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
|
||||
};
|
||||
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
|
||||
);
|
||||
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));
|
||||
e.preventDefault();
|
||||
}.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.
|
||||
body.on('click', '#id_cancel', function(e) {
|
||||
popup.close();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
body.on('click', '#id_cancel', function(e) {
|
||||
popup.close();
|
||||
e.preventDefault();
|
||||
}.bind(this));
|
||||
};
|
||||
RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {
|
||||
var element = Y.one('#element-' + elementid);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
});
|
||||
);
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the backup tasks that provides all the settings and steps to perform
|
||||
* one complete backup of the activity.
|
||||
* 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>
|
||||
|
@ -29,6 +28,10 @@ require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/backup_customcert_s
|
|||
|
||||
/**
|
||||
* Handles creating tasks to peform in order to create the backup.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class backup_customcert_activity_task extends backup_activity_task {
|
||||
|
||||
|
@ -49,6 +52,9 @@ class backup_customcert_activity_task extends backup_activity_task {
|
|||
|
||||
/**
|
||||
* Code the transformations to perform in the activity in order to get transportable (encoded) links.
|
||||
*
|
||||
* @param string $content
|
||||
* @return mixed|string
|
||||
*/
|
||||
static public function encode_content_links($content) {
|
||||
global $CFG;
|
||||
|
@ -56,11 +62,11 @@ 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]+)/";
|
||||
$search = "/(".$base."\/mod\/customcert\/index.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@customcertINDEX*$2@$', $content);
|
||||
|
||||
// Link to customcert view by moduleid.
|
||||
$search ="/(".$base."\/mod\/customcert\/view.php\?id\=)([0-9]+)/";
|
||||
$search = "/(".$base."\/mod\/customcert\/view.php\?id\=)([0-9]+)/";
|
||||
$content = preg_replace($search, '$@customcertVIEWBYID*$2@$', $content);
|
||||
|
||||
return $content;
|
||||
|
|
|
@ -26,6 +26,10 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|||
|
||||
/**
|
||||
* Define the complete customcert structure for backup, with file and id annotations.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class backup_customcert_activity_structure_step extends backup_activity_structure_step {
|
||||
|
||||
|
|
|
@ -27,8 +27,11 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|||
require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/restore_customcert_stepslib.php');
|
||||
|
||||
/**
|
||||
* The class definition for assigning restore tasks that provides all the settings and steps
|
||||
* to perform one complete restore of the activity.
|
||||
* 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>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restore_customcert_activity_task extends restore_activity_task {
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|||
|
||||
/**
|
||||
* Define the complete customcert structure for restore, with file and id annotations.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restore_customcert_activity_structure_step extends restore_activity_structure_step {
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
/**
|
||||
* Creates an upload form on the settings page.
|
||||
*
|
||||
|
@ -23,10 +21,19 @@ namespace mod_customcert;
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
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>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_setting_link extends \admin_setting_configtext {
|
||||
|
||||
|
@ -40,6 +47,18 @@ class admin_setting_link extends \admin_setting_configtext {
|
|||
*/
|
||||
protected $linkname;
|
||||
|
||||
/**
|
||||
* The admin_setting_link constructor.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $visiblename
|
||||
* @param string $description
|
||||
* @param string $linkname
|
||||
* @param mixed|string $link
|
||||
* @param int|null $defaultsetting
|
||||
* @param string $paramtype
|
||||
* @param null $size
|
||||
*/
|
||||
public function __construct($name, $visiblename, $description, $linkname, $link, $defaultsetting,
|
||||
$paramtype = PARAM_RAW, $size=null) {
|
||||
$this->link = $link;
|
||||
|
|
|
@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* Class certificate.
|
||||
*
|
||||
* Helper functionality for certificates.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class certificate {
|
||||
|
||||
|
@ -202,7 +206,7 @@ class certificate {
|
|||
if ($logs = $DB->get_recordset_sql($sql, $params)) {
|
||||
foreach ($logs as $log) {
|
||||
if (!isset($login)) {
|
||||
// For the first time $login is not set so the first log is also the first login
|
||||
// For the first time $login is not set so the first log is also the first login.
|
||||
$login = $log->$timefield;
|
||||
$lasthit = $log->$timefield;
|
||||
$totaltime = 0;
|
||||
|
@ -215,7 +219,7 @@ class certificate {
|
|||
} else {
|
||||
$totaltime += $delay;
|
||||
}
|
||||
// Now the actual log became the previous log for the next cycle
|
||||
// Now the actual log became the previous log for the next cycle.
|
||||
$lasthit = $log->$timefield;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the form for handling editing a customcert element.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the form for handling the layout of the customcert instance.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
@ -34,12 +42,12 @@ require_once($CFG->dirroot . '/mod/customcert/includes/colourpicker.php');
|
|||
class edit_form extends \moodleform {
|
||||
|
||||
/**
|
||||
* The id of the template being used.
|
||||
* @var int The id of the template being used.
|
||||
*/
|
||||
protected $tid = null;
|
||||
|
||||
/**
|
||||
* The total number of pages for this cert.
|
||||
* @var int The total number of pages for this cert.
|
||||
*/
|
||||
protected $numpages = 1;
|
||||
|
||||
|
@ -123,8 +131,8 @@ class edit_form extends \moodleform {
|
|||
/**
|
||||
* Some basic validation.
|
||||
*
|
||||
* @param $data
|
||||
* @param $files
|
||||
* @param array $data
|
||||
* @param array $files
|
||||
* @return array the errors that were found
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
|
@ -285,7 +293,8 @@ class edit_form extends \moodleform {
|
|||
if ($this->numpages > 1) {
|
||||
// Link to delete the element.
|
||||
$deletelink = new \moodle_url($editlink, $editlinkparams + array('action' => 'deletepage', 'aid' => $page->id));
|
||||
$deletelink = \html_writer::tag('a', get_string('deletecertpage', 'customcert'), array('href' => $deletelink->out(false), 'class' => 'deletebutton'));
|
||||
$deletelink = \html_writer::tag('a', get_string('deletecertpage', 'customcert'),
|
||||
array('href' => $deletelink->out(false), 'class' => 'deletebutton'));
|
||||
$mform->addElement('html', \html_writer::tag('div', $deletelink, array('class' => 'deletebutton')));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* Class element
|
||||
*
|
||||
* All customercert element plugins are based on this class.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class element {
|
||||
|
||||
|
@ -216,7 +220,9 @@ abstract class element {
|
|||
*
|
||||
* @param \restore_customcert_activity_task $restore
|
||||
*/
|
||||
public function after_restore($restore) { }
|
||||
public function after_restore($restore) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter for read only access.
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides useful functions related to elements.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* Provides useful functions related to elements.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
|
@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* Class helper.
|
||||
*
|
||||
* Provides useful functions related to elements.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class element_helper {
|
||||
|
||||
|
@ -56,7 +60,7 @@ class element_helper {
|
|||
* @param string $content the content to render
|
||||
*/
|
||||
public static function render_content($pdf, $element, $content) {
|
||||
list($font, $attr) = \mod_customcert\element_helper::get_font($element);
|
||||
list($font, $attr) = self::get_font($element);
|
||||
$pdf->setFont($font, $attr, $element->size);
|
||||
$fontcolour = \TCPDF_COLORS::convertHTMLColorToDec($element->colour, $fontcolour);
|
||||
$pdf->SetTextColor($fontcolour['R'], $fontcolour['G'], $fontcolour['B']);
|
||||
|
@ -107,7 +111,7 @@ class element_helper {
|
|||
* @return string the html
|
||||
*/
|
||||
public static function render_html_content($element, $content) {
|
||||
list($font, $attr) = \mod_customcert\element_helper::get_font($element);
|
||||
list($font, $attr) = self::get_font($element);
|
||||
$fontstyle = 'font-family: ' . $font;
|
||||
if (strpos($attr, 'B') !== false) {
|
||||
$fontstyle .= ': font-weight: bold';
|
||||
|
@ -196,7 +200,7 @@ class element_helper {
|
|||
public static function validate_form_element_colour($data) {
|
||||
$errors = array();
|
||||
// Validate the colour.
|
||||
if (!\mod_customcert\element_helper::validate_colour($data['colour'])) {
|
||||
if (!self::validate_colour($data['colour'])) {
|
||||
$errors['colour'] = get_string('invalidcolour', 'customcert');
|
||||
}
|
||||
return $errors;
|
||||
|
|
|
@ -34,6 +34,10 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_module_viewed extends \core\event\course_module_viewed {
|
||||
|
||||
/**
|
||||
* Initialises the event.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'customcert';
|
||||
parent::init();
|
||||
|
|
|
@ -27,11 +27,11 @@ defined('MOODLE_INTERNAL') || die();
|
|||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
/**
|
||||
* This is the external API for this tool.
|
||||
*
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
* This is the external API for this tool.
|
||||
*
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class external extends \external_api {
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,13 +14,20 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the form for loading customcert templates.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
|
||||
/**
|
||||
* The form for loading customcert templates.
|
||||
*
|
||||
|
|
|
@ -77,6 +77,12 @@ class verify_certificate_result implements templatable, renderable {
|
|||
$this->certificatename = $result->certificatename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to export the renderer data in a format that is suitable for a mustache template.
|
||||
*
|
||||
* @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
|
||||
* @return \stdClass|array
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$result = new \stdClass();
|
||||
$result->userprofileurl = $this->userprofileurl;
|
||||
|
|
|
@ -68,6 +68,12 @@ class verify_certificate_results implements templatable, renderable {
|
|||
$this->issues = $result->issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to export the renderer data in a format that is suitable for a mustache template.
|
||||
*
|
||||
* @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
|
||||
* @return \stdClass|array
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$result = new \stdClass();
|
||||
$result->success = $this->success;
|
||||
|
|
|
@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* Class helper.
|
||||
*
|
||||
* Provides useful functions.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class page_helper {
|
||||
|
||||
|
|
|
@ -27,6 +27,13 @@ use core\plugininfo\base;
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Subplugin info class.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcertelement extends base {
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
/**
|
||||
* Class represents a customcert template.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2015 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
@ -28,6 +29,7 @@ defined('MOODLE_INTERNAL') || die();
|
|||
/**
|
||||
* Class represents a customcert template.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
@ -70,7 +72,7 @@ class template {
|
|||
$savedata = new \stdClass();
|
||||
$savedata->id = $this->id;
|
||||
$savedata->name = $data->name;
|
||||
$savedata->timemodified= time();
|
||||
$savedata->timemodified = time();
|
||||
|
||||
$DB->update_record('customcert_templates', $savedata);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the class that handles uploading files.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
@ -21,7 +29,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Handles uploading files
|
||||
* Handles uploading files.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
|
@ -43,7 +51,8 @@ class upload_image_form extends \moodleform {
|
|||
'maxbytes' => $CFG->maxbytes,
|
||||
'subdirs' => 1,
|
||||
'accepted_types' => 'image');
|
||||
$mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $this->filemanageroptions);
|
||||
$mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '',
|
||||
$this->filemanageroptions);
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
@ -56,7 +65,8 @@ class upload_image_form extends \moodleform {
|
|||
|
||||
// Editing existing instance - copy existing files into draft area.
|
||||
$draftitemid = file_get_submitted_draft_itemid('customcertimage');
|
||||
file_prepare_draft_area($draftitemid, \context_system::instance()->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
|
||||
file_prepare_draft_area($draftitemid, \context_system::instance()->id, 'mod_customcert', 'image', 0,
|
||||
$this->filemanageroptions);
|
||||
$element = $mform->getElement('customcertimage');
|
||||
$element->setValue($draftitemid);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This files contains the form for verifying a certificate.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
@ -21,7 +29,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
/**
|
||||
* The form for verifying a certificate
|
||||
* The form for verifying a certificate.
|
||||
*
|
||||
* @package mod_customcert
|
||||
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$functions = array(
|
||||
'mod_customcert_save_element' => array(
|
||||
'classname' => 'mod_customcert\external',
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element background image's core interaction API.
|
||||
*
|
||||
* @package customcertelement_bgimage
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_bgimage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
@ -34,7 +42,8 @@ class element extends \customcertelement_image\element {
|
|||
*/
|
||||
public function render_form_elements($mform) {
|
||||
$mform->addElement('select', 'image', get_string('image', 'customcertelement_image'), self::get_images());
|
||||
$mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $this->filemanageroptions);
|
||||
$mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '',
|
||||
$this->filemanageroptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element border's core interaction API.
|
||||
*
|
||||
* @package customcertelement_border
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_border;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element categoryname's core interaction API.
|
||||
*
|
||||
* @package customcertelement_categoryname
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_categoryname;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element code's core interaction API.
|
||||
*
|
||||
* @package customcertelement_code
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_code;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
@ -45,7 +53,8 @@ class element extends \mod_customcert\element {
|
|||
// Get the customcert this page belongs to.
|
||||
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
|
||||
// Now we can get the issue for this user.
|
||||
$issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id), '*', MUST_EXIST);
|
||||
$issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id),
|
||||
'*', MUST_EXIST);
|
||||
$code = $issue->code;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element coursename's core interaction API.
|
||||
*
|
||||
* @package customcertelement_coursename
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_coursename;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the customcert element date's core interaction API.
|
||||
*
|
||||
* @package customcertelement_date
|
||||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace customcertelement_date;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
@ -107,7 +115,8 @@ class element extends \mod_customcert\element {
|
|||
// Get the customcert this page belongs to.
|
||||
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
|
||||
// Now we can get the issue for this user.
|
||||
$issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id), '*', MUST_EXIST);
|
||||
$issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id),
|
||||
'*', MUST_EXIST);
|
||||
|
||||
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
|
||||
$date |