diff --git a/README.md b/README.md index 2746781..63092b6 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ Fernsel, L. (2024) Let's audit Learning Analytics [Moodle Plugin]. Available at: author = {Linda Fernsel}, title={Let’s audit Learning Analytics [Moodle Plugin]}, url={https://github.com/LiFaytheGoblin/moodle-tool_lala/}, - version = {4.0.0}, - date = {2024-01-22}, + version = {4.0.1}, + date = {2024-02-05}, } ``` diff --git a/classes/dataset.php b/classes/dataset.php index a757a82..9e454cb 100644 --- a/classes/dataset.php +++ b/classes/dataset.php @@ -118,6 +118,8 @@ public function get_file_type(): string { } /** + * Restore the data for a model version to the cache from the stored CSV files. + * * @param array $options * @return void */ @@ -128,7 +130,9 @@ public function restore_raw_data(array $options): void { $this->data = dataset_helper::build_from_csv($filehandle, $options['analysisintervalkey']); } - /** Validate the evidence's options. + /** + * Validate the evidence's options. + * * @param array $options */ public function validate_restore_options(array $options) : void { diff --git a/classes/dataset_helper.php b/classes/dataset_helper.php index a222160..6e5c903 100644 --- a/classes/dataset_helper.php +++ b/classes/dataset_helper.php @@ -186,8 +186,12 @@ public static function replace_rows_in_dataset(array $dataset, array $newrows) : * @return array[] */ public static function merge(array $dataseta, array $datasetb) : array { - if (count($dataseta) < 1) return $datasetb; - if (count($datasetb) < 1) return $dataseta; + if (count($dataseta) < 1) { + return $datasetb; + } + if (count($datasetb) < 1) { + return $dataseta; + } $analysisintervalkeya = self::get_analysisintervalkey($dataseta); $analysisintervalkeyb = self::get_analysisintervalkey($datasetb); @@ -211,8 +215,12 @@ public static function merge(array $dataseta, array $datasetb) : array { * @return array */ public static function diff(array $dataseta, array $datasetb) : array { - if (count($dataseta) < 1) return $datasetb; - if (count($datasetb) < 1) return $dataseta; + if (count($dataseta) < 1) { + return $datasetb; + } + if (count($datasetb) < 1) { + return $dataseta; + } $sampleidsb = self::get_sampleids_used_in_dataset($datasetb); $rowsa = self::get_rows($dataseta); @@ -362,6 +370,13 @@ public static function validate(array $dataset) : void { } } + /** + * Transform a dataset (a two dimensional array) into a string which can be + * stored as a CSV. Elements at id '0' are treated as the header. + * + * @param array $dataset + * @return string + */ public static function serialize(array $dataset) : string { $str = ''; $columns = null; diff --git a/classes/evidence.php b/classes/evidence.php index 97a4018..969f191 100644 --- a/classes/evidence.php +++ b/classes/evidence.php @@ -251,16 +251,20 @@ public function set_raw_data(mixed $data): void { * * @param array $options */ - public abstract function restore_raw_data(array $options): void; + abstract public function restore_raw_data(array $options): void; /** * Validates the $options array passed to restore_raw_data. * * @param array $options */ - public abstract function validate_restore_options(array $options): void; - + abstract public function validate_restore_options(array $options): void; + /** + * Return the file that contains the evidence data. + * + * @return mixed + */ public function get_file() { if (!$this->serializedfilelocation) { throw new LogicException('No serialized file available to restore data from.'); diff --git a/classes/model.php b/classes/model.php index 2e3771a..bd97cd8 100644 --- a/classes/model.php +++ b/classes/model.php @@ -97,7 +97,9 @@ protected function get_file_type(): string { } /** - * @param array $options + * Restore the model from the stored .ser file. + * + * @param array $options (can be empty - not used) * @return void */ public function restore_raw_data(array $options): void { @@ -105,5 +107,13 @@ public function restore_raw_data(array $options): void { $this->data = unserialize($file->get_content()); } - public function validate_restore_options(array $options): void {} + /** + * No validation is needed for the restore options of the model class, + * since that parameter is not used. + * + * @param array $options + * @return void + */ + public function validate_restore_options(array $options): void { + } } diff --git a/classes/model_version.php b/classes/model_version.php index 21436a8..a6eae09 100644 --- a/classes/model_version.php +++ b/classes/model_version.php @@ -226,7 +226,8 @@ public static function create_scaffold_and_get_for_config(int $configid): int { * @return model_version * @throws Exception */ - public static function create(int $versionid, ?array $contexts = null, ?string $dataset = null, ?bool $anonymous = true): model_version { + public static function create(int $versionid, ?array $contexts = null, ?string $dataset = null, + ?bool $anonymous = true): model_version { $version = new model_version($versionid); try { @@ -597,7 +598,9 @@ public function get_shuffled_data(mixed $existingtrainingdataset, mixed $existin // So the second part needs to be the remaining data, but shuffled. if ($existingtrainingdataset !== false && !$existingtestdataset) { $trainingdata = $this->get_single_evidence('training_dataset'); // First part of reconstructed data. - if (!isset($trainingdata)) $trainingdata = []; + if (!isset($trainingdata)) { + $trainingdata = []; + } $remainingdata = dataset_helper::diff($data, $trainingdata); // Second part of reconstructed data. $remainingdatashuffled = dataset_helper::get_shuffled($remainingdata); return dataset_helper::merge($trainingdata, $remainingdatashuffled); diff --git a/classes/task/version_create.php b/classes/task/version_create.php index b63a046..0db389f 100644 --- a/classes/task/version_create.php +++ b/classes/task/version_create.php @@ -58,8 +58,10 @@ public function execute() { mtrace('Finished version ' . $data->versionid . '.'); } - /* + /** * Check whether the version creation task is active for a specific version. + * + * @param int $versionid */ public static function is_active($versionid) { global $DB; diff --git a/db/install.xml b/db/install.xml index e4b840d..25e17d2 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,5 +1,5 @@ - diff --git a/version.php b/version.php index 68d9bb2..6b13ba8 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'tool_lala'; -$plugin->release = '4.0.0'; -$plugin->version = 2024012213; +$plugin->release = '4.0.1'; +$plugin->version = 2024020508; $plugin->requires = 2022041900; $plugin->maturity = MATURITY_BETA;