Add ability to specify the current date for date related elements (#289)
This commit is contained in:
parent
7756d928ac
commit
36d178bda3
4 changed files with 20 additions and 0 deletions
|
@ -51,6 +51,11 @@ define('CUSTOMCERT_DATE_COURSE_START', '-3');
|
||||||
*/
|
*/
|
||||||
define('CUSTOMCERT_DATE_COURSE_END', '-4');
|
define('CUSTOMCERT_DATE_COURSE_END', '-4');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date - Current date
|
||||||
|
*/
|
||||||
|
define('CUSTOMCERT_DATE_CURRENT_DATE', '-5');
|
||||||
|
|
||||||
require_once($CFG->dirroot . '/lib/grade/constants.php');
|
require_once($CFG->dirroot . '/lib/grade/constants.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +78,7 @@ class element extends \mod_customcert\element {
|
||||||
// Get the possible date options.
|
// Get the possible date options.
|
||||||
$dateoptions = array();
|
$dateoptions = array();
|
||||||
$dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date');
|
$dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date');
|
||||||
|
$dateoptions[CUSTOMCERT_DATE_CURRENT_DATE] = get_string('currentdate', 'customcertelement_date');
|
||||||
$completionenabled = $CFG->enablecompletion && ($COURSE->id == SITEID || $COURSE->enablecompletion);
|
$completionenabled = $CFG->enablecompletion && ($COURSE->id == SITEID || $COURSE->enablecompletion);
|
||||||
if ($completionenabled) {
|
if ($completionenabled) {
|
||||||
$dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date');
|
$dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date');
|
||||||
|
@ -145,6 +151,8 @@ class element extends \mod_customcert\element {
|
||||||
|
|
||||||
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
|
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
|
||||||
$date = $issue->timecreated;
|
$date = $issue->timecreated;
|
||||||
|
} else if ($dateitem == CUSTOMCERT_DATE_CURRENT_DATE) {
|
||||||
|
$date = time();
|
||||||
} else if ($dateitem == CUSTOMCERT_DATE_COMPLETION) {
|
} else if ($dateitem == CUSTOMCERT_DATE_COMPLETION) {
|
||||||
// Get the last completion date.
|
// Get the last completion date.
|
||||||
$sql = "SELECT MAX(c.timecompleted) as timecompleted
|
$sql = "SELECT MAX(c.timecompleted) as timecompleted
|
||||||
|
|
|
@ -26,6 +26,7 @@ $string['completiondate'] = 'Completion date';
|
||||||
$string['courseenddate'] = 'Course end date';
|
$string['courseenddate'] = 'Course end date';
|
||||||
$string['coursegradedate'] = 'Course grade date';
|
$string['coursegradedate'] = 'Course grade date';
|
||||||
$string['coursestartdate'] = 'Course start date';
|
$string['coursestartdate'] = 'Course start date';
|
||||||
|
$string['currentdate'] = 'Current date';
|
||||||
$string['dateformat'] = 'Date format';
|
$string['dateformat'] = 'Date format';
|
||||||
$string['dateformat_help'] = 'This is the format of the date that will be displayed';
|
$string['dateformat_help'] = 'This is the format of the date that will be displayed';
|
||||||
$string['dateitem'] = 'Date item';
|
$string['dateitem'] = 'Date item';
|
||||||
|
|
|
@ -99,6 +99,11 @@ class element extends \mod_customcert\element {
|
||||||
*/
|
*/
|
||||||
const DATE_COURSE_GRADE = -5;
|
const DATE_COURSE_GRADE = -5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date - Course current date
|
||||||
|
*/
|
||||||
|
const DATE_CURRENT_DATE = -6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function renders the form elements when adding a customcert element.
|
* This function renders the form elements when adding a customcert element.
|
||||||
*
|
*
|
||||||
|
@ -110,6 +115,7 @@ class element extends \mod_customcert\element {
|
||||||
// Get the possible date options.
|
// Get the possible date options.
|
||||||
$dateoptions = array();
|
$dateoptions = array();
|
||||||
$dateoptions[self::DATE_ISSUE] = get_string('issueddate', 'customcertelement_daterange');
|
$dateoptions[self::DATE_ISSUE] = get_string('issueddate', 'customcertelement_daterange');
|
||||||
|
$dateoptions[self::DATE_CURRENT_DATE] = get_string('currentdate', 'customcertelement_daterange');
|
||||||
$dateoptions[self::DATE_COMPLETION] = get_string('completiondate', 'customcertelement_daterange');
|
$dateoptions[self::DATE_COMPLETION] = get_string('completiondate', 'customcertelement_daterange');
|
||||||
$dateoptions[self::DATE_COURSE_START] = get_string('coursestartdate', 'customcertelement_daterange');
|
$dateoptions[self::DATE_COURSE_START] = get_string('coursestartdate', 'customcertelement_daterange');
|
||||||
$dateoptions[self::DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_daterange');
|
$dateoptions[self::DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_daterange');
|
||||||
|
@ -346,6 +352,10 @@ class element extends \mod_customcert\element {
|
||||||
$date = $issue->timecreated;
|
$date = $issue->timecreated;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case self::DATE_CURRENT_DATE:
|
||||||
|
$date = time();
|
||||||
|
break;
|
||||||
|
|
||||||
case self::DATE_COMPLETION:
|
case self::DATE_COMPLETION:
|
||||||
// Get the last completion date.
|
// Get the last completion date.
|
||||||
$sql = "SELECT MAX(c.timecompleted) as timecompleted
|
$sql = "SELECT MAX(c.timecompleted) as timecompleted
|
||||||
|
|
|
@ -29,6 +29,7 @@ $string['completiondate'] = 'Completion date';
|
||||||
$string['courseenddate'] = 'Course end date';
|
$string['courseenddate'] = 'Course end date';
|
||||||
$string['coursegradedate'] = 'Course grade date';
|
$string['coursegradedate'] = 'Course grade date';
|
||||||
$string['coursestartdate'] = 'Course start date';
|
$string['coursestartdate'] = 'Course start date';
|
||||||
|
$string['currentdate'] = 'Current date';
|
||||||
$string['dateitem'] = 'Date item';
|
$string['dateitem'] = 'Date item';
|
||||||
$string['dateitem_help'] = 'This will be the date that is printed on the certificate';
|
$string['dateitem_help'] = 'This will be the date that is printed on the certificate';
|
||||||
$string['dateranges'] = 'Date ranges';
|
$string['dateranges'] = 'Date ranges';
|
||||||
|
|
Loading…
Reference in a new issue