|
@ -14,6 +14,15 @@ |
|
|
// You should have received a copy of the GNU General Public License |
|
|
// You should have received a copy of the GNU General Public License |
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Import attendance sessions class. |
|
|
|
|
|
* |
|
|
|
|
|
* @package mod_attendance |
|
|
|
|
|
* @author Chris Wharton <chriswharton@catalyst.net.nz> |
|
|
|
|
|
* @copyright 2017 Catalyst IT |
|
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
namespace mod_attendance\import; |
|
|
namespace mod_attendance\import; |
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
|
defined('MOODLE_INTERNAL') || die(); |
|
@ -39,12 +48,16 @@ class sessions { |
|
|
/** @var array $sessions The sessions info */ |
|
|
/** @var array $sessions The sessions info */ |
|
|
protected $sessions = array(); |
|
|
protected $sessions = array(); |
|
|
|
|
|
|
|
|
|
|
|
/** @var array $mappings The mappings info */ |
|
|
protected $mappings = array(); |
|
|
protected $mappings = array(); |
|
|
|
|
|
|
|
|
|
|
|
/** @var int The id of the csv import */ |
|
|
protected $importid = 0; |
|
|
protected $importid = 0; |
|
|
|
|
|
|
|
|
|
|
|
/** @var csv_import_reader|null $importer */ |
|
|
protected $importer = null; |
|
|
protected $importer = null; |
|
|
|
|
|
|
|
|
|
|
|
/** @var array $foundheaders */ |
|
|
protected $foundheaders = array(); |
|
|
protected $foundheaders = array(); |
|
|
|
|
|
|
|
|
/** @var bool $useprogressbar Control whether importing should use progress bars or not. */ |
|
|
/** @var bool $useprogressbar Control whether importing should use progress bars or not. */ |
|
@ -110,8 +123,7 @@ class sessions { |
|
|
/** |
|
|
/** |
|
|
* Read the data from the mapping form. |
|
|
* Read the data from the mapping form. |
|
|
* |
|
|
* |
|
|
* @param |
|
|
* @param array $data The mapping data. |
|
|
* data array The mapping data. |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
protected function read_mapping_data($data) { |
|
|
protected function read_mapping_data($data) { |
|
|
if ($data) { |
|
|
if ($data) { |
|
@ -152,10 +164,8 @@ class sessions { |
|
|
/** |
|
|
/** |
|
|
* Get the a column from the imported data. |
|
|
* Get the a column from the imported data. |
|
|
* |
|
|
* |
|
|
* @param |
|
|
* @param array $row The imported raw row |
|
|
* array The imported raw row |
|
|
* @param int $index The column index we want |
|
|
* @param |
|
|
|
|
|
* index The column index we want |
|
|
|
|
|
* @return string The column data. |
|
|
* @return string The column data. |
|
|
*/ |
|
|
*/ |
|
|
protected function get_column_data($row, $index) { |
|
|
protected function get_column_data($row, $index) { |
|
@ -168,18 +178,12 @@ class sessions { |
|
|
/** |
|
|
/** |
|
|
* Constructor - parses the raw text for sanity. |
|
|
* Constructor - parses the raw text for sanity. |
|
|
* |
|
|
* |
|
|
* @param string $text |
|
|
* @param string $text The raw csv text. |
|
|
* The raw csv text. |
|
|
* @param string $encoding The encoding of the csv file. |
|
|
* @param string $encoding |
|
|
* @param string $delimiter The specified delimiter for the file. |
|
|
* The encoding of the csv file. |
|
|
* @param string $importid The id of the csv import. |
|
|
* @param |
|
|
* @param array $mappingdata The mapping data from the import form. |
|
|
* string delimiter The specified delimiter for the file. |
|
|
* @param bool $useprogressbar Whether progress bar should be displayed, to avoid html output on CLI. |
|
|
* @param |
|
|
|
|
|
* string importid The id of the csv import. |
|
|
|
|
|
* @param |
|
|
|
|
|
* array mappingdata The mapping data from the import form. |
|
|
|
|
|
* @param bool $useprogressbar |
|
|
|
|
|
* Whether progress bar should be displayed, to avoid html output on CLI. |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
public function __construct($text = null, $encoding = null, $delimiter = null, $importid = 0, |
|
|
public function __construct($text = null, $encoding = null, $delimiter = null, $importid = 0, |
|
|
$mappingdata = null, $useprogressbar = false) { |
|
|
$mappingdata = null, $useprogressbar = false) { |
|
|