Browse Source

Add missing fields to csv and set defaults when not mapped.

MOODLE_34_STABLE
Dan Marsden 7 years ago
parent
commit
10f85fffbd
  1. 47
      classes/import/sessions.php

47
classes/import/sessions.php

@ -91,7 +91,10 @@ class sessions {
get_string('studentscanmark', 'attendance'), get_string('studentscanmark', 'attendance'),
get_string('passwordgrp', 'attendance'), get_string('passwordgrp', 'attendance'),
get_string('randompassword', 'attendance'), get_string('randompassword', 'attendance'),
get_string('subnet', 'attendance') get_string('subnet', 'attendance'),
get_string('automark', 'attendance'),
get_string('autoassignstatus', 'attendance'),
get_string('absenteereport', 'attendance')
); );
} }
@ -125,7 +128,10 @@ class sessions {
'studentscanmark' => $data->header9, 'studentscanmark' => $data->header9,
'passwordgrp' => $data->header10, 'passwordgrp' => $data->header10,
'randompassword' => $data->header11, 'randompassword' => $data->header11,
'subnet' => $data->header12 'subnet' => $data->header12,
'automark' => $data->header13,
'autoassignstatus' => $data->header14,
'absenteereport' => $data->header15
); );
} else { } else {
return array( return array(
@ -141,7 +147,10 @@ class sessions {
'studentscanmark' => 9, 'studentscanmark' => 9,
'passwordgrp' => 10, 'passwordgrp' => 10,
'randompassword' => 11, 'randompassword' => 11,
'subnet' => 12 'subnet' => 12,
'automark' => 13,
'autoassignstatus' => 14,
'absenteereport' => 15
); );
} }
} }
@ -184,6 +193,8 @@ class sessions {
require_once($CFG->libdir . '/csvlib.class.php'); require_once($CFG->libdir . '/csvlib.class.php');
$pluginconfig = get_config('attendance');
$type = 'sessions'; $type = 'sessions';
if (! $importid) { if (! $importid) {
@ -272,18 +283,40 @@ class sessions {
$session->repeaton = $this->get_column_data($row, $mapping['repeaton']); $session->repeaton = $this->get_column_data($row, $mapping['repeaton']);
$session->repeatevery = $this->get_column_data($row, $mapping['repeatevery']); $session->repeatevery = $this->get_column_data($row, $mapping['repeatevery']);
$session->repeatuntil = $this->get_column_data($row, $mapping['repeatuntil']); $session->repeatuntil = $this->get_column_data($row, $mapping['repeatuntil']);
$session->studentscanmark = $this->get_column_data($row, $mapping['studentscanmark']);
$session->passwordgrp = $this->get_column_data($row, $mapping['passwordgrp']); $session->passwordgrp = $this->get_column_data($row, $mapping['passwordgrp']);
$session->randompassword = $this->get_column_data($row, $mapping['randompassword']);
// Set session subnet restriction. Use the default activity level subnet if there isn't one set for this session.
$session->subnet = $this->get_column_data($row, $mapping['subnet']); $session->subnet = $this->get_column_data($row, $mapping['subnet']);
// Set session subnet restriction. Use the default activity level subnet if there isn't one set for this session.
if (empty($session->subnet)) { if (empty($session->subnet)) {
$session->usedefaultsubnet = '1'; $session->usedefaultsubnet = '1';
} else { } else {
$session->usedefaultsubnet = ''; $session->usedefaultsubnet = '';
} }
if ($mapping['studentscanmark'] == -1) {
$session->studentscanmark = $pluginconfig->studentscanmark_default;
} else {
$session->studentscanmark = $this->get_column_data($row, $mapping['studentscanmark']);
}
if ($mapping['randompassword'] == -1) {
$session->randompassword = $pluginconfig->randompassword_default;
} else {
$session->randompassword = $this->get_column_data($row, $mapping['randompassword']);
}
if ($mapping['automark'] == -1) {
$session->automark = $pluginconfig->automark_default;
} else {
$session->automark = $this->get_column_data($row, $mapping['automark']);
}
if ($mapping['autoassignstatus'] == -1) {
$session->autoassignstatus = $pluginconfig->autoassignstatus;
} else {
$session->autoassignstatus = $this->get_column_data($row, $mapping['autoassignstatus']);
}
if ($mapping['absenteereport'] == -1) {
$session->absenteereport = $pluginconfig->absenteereport_default;
} else {
$session->absenteereport = $this->get_column_data($row, $mapping['absenteereport']);
}
$session->statusset = 0; $session->statusset = 0;
$sessions[] = $session; $sessions[] = $session;

Loading…
Cancel
Save