Adding enrollment start & end date options (#328)
This commit is contained in:
parent
007446ab33
commit
22b156be8f
3 changed files with 36 additions and 1 deletions
|
@ -56,6 +56,16 @@ define('CUSTOMCERT_DATE_COURSE_END', '-4');
|
|||
*/
|
||||
define('CUSTOMCERT_DATE_CURRENT_DATE', '-5');
|
||||
|
||||
/**
|
||||
* Date - Enrollment start
|
||||
*/
|
||||
define('CUSTOMCERT_DATE_ENROLLMENT_START', '-6');
|
||||
|
||||
/**
|
||||
* Date - Entrollment end
|
||||
*/
|
||||
define('CUSTOMCERT_DATE_ENROLLMENT_END', '-7');
|
||||
|
||||
require_once($CFG->dirroot . '/lib/grade/constants.php');
|
||||
|
||||
/**
|
||||
|
@ -83,6 +93,9 @@ class element extends \mod_customcert\element {
|
|||
if ($completionenabled) {
|
||||
$dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date');
|
||||
}
|
||||
$dateoptions[CUSTOMCERT_DATE_ENROLLMENT_START] = get_string('enrollmentstartdate', 'customcertelement_date');
|
||||
$dateoptions[CUSTOMCERT_DATE_ENROLLMENT_END] = get_string('enrollmentenddate', 'customcertelement_date');
|
||||
|
||||
$dateoptions[CUSTOMCERT_DATE_COURSE_START] = get_string('coursestartdate', 'customcertelement_date');
|
||||
$dateoptions[CUSTOMCERT_DATE_COURSE_END] = get_string('courseenddate', 'customcertelement_date');
|
||||
$dateoptions[CUSTOMCERT_DATE_COURSE_GRADE] = get_string('coursegradedate', 'customcertelement_date');
|
||||
|
@ -164,6 +177,26 @@ class element extends \mod_customcert\element {
|
|||
$date = $timecompleted->timecompleted;
|
||||
}
|
||||
}
|
||||
} else if ($dateitem == CUSTOMCERT_DATE_ENROLLMENT_START) {
|
||||
// Get the enrollment start date
|
||||
$sql = "SELECT ue.timestart FROM {enrol} e JOIN {user_enrolments} ue ON ue.enrolid = e.id
|
||||
WHERE e.courseid = :courseid
|
||||
AND ue.userid = :userid";
|
||||
if ($timestart = $DB->get_record_sql($sql, array('userid' => $issue->userid, 'courseid' => $courseid))) {
|
||||
if (!empty($timestart->timestart)) {
|
||||
$date = $timestart->timestart;
|
||||
}
|
||||
}
|
||||
} else if ($dateitem == CUSTOMCERT_DATE_ENROLLMENT_END) {
|
||||
// Get the enrollment end date
|
||||
$sql = "SELECT ue.timeend FROM {enrol} e JOIN {user_enrolments} ue ON ue.enrolid = e.id
|
||||
WHERE e.courseid = :courseid
|
||||
AND ue.userid = :userid";
|
||||
if ($timeend = $DB->get_record_sql($sql, array('userid' => $issue->userid, 'courseid' => $courseid))) {
|
||||
if (!empty($timeend->timeend)) {
|
||||
$date = $timeend->timeend;
|
||||
}
|
||||
}
|
||||
} else if ($dateitem == CUSTOMCERT_DATE_COURSE_START) {
|
||||
$date = $DB->get_field('course', 'startdate', array('id' => $courseid));
|
||||
} else if ($dateitem == CUSTOMCERT_DATE_COURSE_END) {
|
||||
|
|
|
@ -26,6 +26,8 @@ $string['completiondate'] = 'Completion date';
|
|||
$string['courseenddate'] = 'Course end date';
|
||||
$string['coursegradedate'] = 'Course grade date';
|
||||
$string['coursestartdate'] = 'Course start date';
|
||||
$string['enrollmentstartdate'] = 'Enrollment start date';
|
||||
$string['enrollmentenddate'] = 'Enrollment end date';
|
||||
$string['currentdate'] = 'Current date';
|
||||
$string['dateformat'] = 'Date format';
|
||||
$string['dateformat_help'] = 'This is the format of the date that will be displayed';
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2019052000; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2019052001; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2019052000; // Requires this Moodle version (3.7).
|
||||
$plugin->component = 'customcertelement_date';
|
||||
|
|
Loading…
Reference in a new issue