@ -42,6 +42,8 @@ define('ATT_SORT_FIRSTNAME', 2);
define('ATTENDANCE_AUTOMARK_DISABLED', 0);
define('ATTENDANCE_AUTOMARK_DISABLED', 0);
define('ATTENDANCE_AUTOMARK_ALL', 1);
define('ATTENDANCE_AUTOMARK_ALL', 1);
define('ATTENDANCE_AUTOMARK_CLOSE', 2);
define('ATTENDANCE_AUTOMARK_CLOSE', 2);
define('ATTENDANCE_AUTOMARK_ACTIVITYCOMPLETION', 3);
define('ATTENDANCE_SHAREDIP_DISABLED', 0);
define('ATTENDANCE_SHAREDIP_DISABLED', 0);
define('ATTENDANCE_SHAREDIP_MINUTES', 1);
define('ATTENDANCE_SHAREDIP_MINUTES', 1);
@ -788,6 +790,12 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
}
}
$sess->automark = $formdata->automark;
$sess->automark = $formdata->automark;
$sess->automarkcompleted = 0;
$sess->automarkcompleted = 0;
if (!empty($formdata->automarkcmid)) {
$sess->automarkcmid = $formdata->automarkcmid;
} else {
$sess->automarkcmid = 0;
}
if (!empty($formdata->preventsharedip)) {
if (!empty($formdata->preventsharedip)) {
$sess->preventsharedip = $formdata->preventsharedip;
$sess->preventsharedip = $formdata->preventsharedip;
}
}
@ -852,6 +860,13 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
$sess->studentpassword = '';
$sess->studentpassword = '';
$sess->automark = 0;
$sess->automark = 0;
$sess->automarkcompleted = 0;
$sess->automarkcompleted = 0;
if (!empty($formdata->automarkcmid)) {
$sess->automarkcmid = $formdata->automarkcmid;
} else {
$sess->automarkcmid = 0;
}
$sess->absenteereport = $absenteereport;
$sess->absenteereport = $absenteereport;
$sess->includeqrcode = 0;
$sess->includeqrcode = 0;
$sess->rotateqrcode = 0;
$sess->rotateqrcode = 0;
@ -1150,15 +1165,49 @@ function attendance_session_get_highest_status(mod_attendance_structure $att, $a
* @return array
* @return array
*/
*/
function attendance_get_automarkoptions() {
function attendance_get_automarkoptions() {
$options = array();
$options = array();
$options[ATTENDANCE_AUTOMARK_DISABLED] = get_string('noautomark', 'attendance');
$options[ATTENDANCE_AUTOMARK_DISABLED] = get_string('noautomark', 'attendance');
if (strpos(get_config('tool_log', 'enabled_stores'), 'logstore_standard') !== false) {
if (strpos(get_config('tool_log', 'enabled_stores'), 'logstore_standard') !== false) {
$options[ATTENDANCE_AUTOMARK_ALL] = get_string('automarkall', 'attendance');
$options[ATTENDANCE_AUTOMARK_ALL] = get_string('automarkall', 'attendance');
}
}
$options[ATTENDANCE_AUTOMARK_CLOSE] = get_string('automarkclose', 'attendance');
$options[ATTENDANCE_AUTOMARK_CLOSE] = get_string('automarkclose', 'attendance');
$options[ATTENDANCE_AUTOMARK_ACTIVITYCOMPLETION] = get_string('onactivitycompletion', 'attendance');
return $options;
return $options;
}
}
/**
* Get course module names associated to this course, if they're visible and complete.
* @param int $id - course id.
* @return array $automarkcmoptions - list of course module names associated to this course.
*/
function attendance_get_coursemodulenames($id) {
global $DB;
$automarkcmoptions = [];
$sql = "SELECT DISTINCT cm.id, cm.module, m.name
FROM {course_modules} cm
JOIN {modules} m ON m.id = cm.module
WHERE cm.course = :cmcourse
AND cm.visible = :cmvisible
AND cm.completion = :cmcompletion";
$coursemodulenames = $DB->get_records_sql($sql, array(
'cmcourse' => $id,
'cmvisible' => 1,
'cmcompletion' => 1
));
if ($coursemodulenames) {
foreach ($coursemodulenames as $coursemodulename) {
$automarkcmoptions[$coursemodulename->id] = format_string($coursemodulename->name);
}
}
return $automarkcmoptions;
}
/**
/**
* Get available sharedip options.
* Get available sharedip options.
*
*