From 355b05855b9d703562f5cdef310382dd8f69b342 Mon Sep 17 00:00:00 2001 From: goltz Date: Tue, 5 Nov 2019 13:58:54 +0100 Subject: [PATCH] 16513 grade sync now creates hashes for users if necessary --- gradesync.php | 11 +++++++++-- lang/en/mumie.php | 15 +++++++++++++++ lib.php | 2 +- version.php | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/gradesync.php b/gradesync.php index c5c0194..ccc4784 100644 --- a/gradesync.php +++ b/gradesync.php @@ -157,9 +157,15 @@ public static function get_xapi_grades($mumie, $syncids, $mumieids) { * @return string unique username for MUMIE servers derived from the moodle userid */ public static function get_sync_id($userid, $hashid) { + global $DB; $org = get_config('auth_mumie', 'mumie_org'); if ($hashid == 1) { - $userid = auth_mumie_get_hashed_id($userid); + $hashidtable = 'auth_mumie_id_hashes'; + $hash = auth_mumie_get_hashed_id($userid); + if (!$DB->get_record($hashidtable, array("the_user" => $userid))) { + $DB->insert_record($hashidtable, array("the_user" => $userid, "hash" => $hash)); + } + $userid = $hash; } return "GSSO_" . $org . "_" . $userid; } @@ -172,9 +178,10 @@ public static function get_sync_id($userid, $hashid) { */ public static function get_moodle_user_id($syncid, $hashid) { $userid = substr(strrchr($syncid, "_"), 1); + $hashidtable = 'auth_mumie_id_hashes'; if ($hashid == 1) { global $DB; - $userid = $DB->get_record('auth_mumie_id_hashes', array("hash" => $userid))->the_user; + $userid = $DB->get_record($hashidtable, array("hash" => $userid))->the_user; } return $userid; } diff --git a/lang/en/mumie.php b/lang/en/mumie.php index 7b7dd8b..eee53cc 100644 --- a/lang/en/mumie.php +++ b/lang/en/mumie.php @@ -73,3 +73,18 @@ Grades for MUMIE Tasks are only updated, when the gradebook is opened. If you want the current completion status of all students, remember to open the gradebook overview page first'; $string['gradetopassnotset'] = 'This MUMIE task does not have a grade to pass set so you cannot use this option. Please use the require grade setting instead.'; $string['gradetopassmustbeset'] = 'Grade to pass cannot be zero as this activity has its completion method set to require passing grade. Please set a non-zero value.'; + +// Used in mumieserver form. +$string['mumie_form_required'] = 'required'; +$string['mumie_form_server_not_existing'] = 'There is no MUMIE server for this URL'; +$string['mumie_form_already_existing_config'] = 'There is already a configuration for this URL prefix'; +$string['mumie_form_already_existing_name'] = 'There is already a configuration for this name'; +$string['mumie_form_title'] = 'Configure MUMIE Server'; +$string['mumie_form_server_config'] = 'MUMIE server configuration'; +$string['mumie_server_name'] = 'Server name'; +$string['mumie_server_name_help'] = 'Please insert a unique name for this configuration.'; +$string['mumie_form_server_btn_submit'] = 'Submit'; +$string['mumie_form_server_btn_cancel'] = 'Cancel'; +$string['mumie_url_prefix'] = 'MUMIE URL Prefix'; +$string['mumie_url_prefix_help'] = 'Specify the MUMIE URL prefix

e.g. https://www.ombplus.de/ombplus

There can only be a single configuration for any URL prefix.'; +$string['mumie_form_required_hashing_decision'] = 'An important admin decision about ID hashing is pending. MUMIE Tasks cannot be created or edited until a choice has been made.
Please contact your Moodle administrator!'; \ No newline at end of file diff --git a/lib.php b/lib.php index de7688b..baff291 100644 --- a/lib.php +++ b/lib.php @@ -39,7 +39,7 @@ function mumie_add_instance($mumie, $mform) { global $DB, $CFG; $mumie->timecreated = time(); $mumie->timemodified = $mumie->timecreated; - $mumie->use_hashed_id = get_config('auth_mumie', 'id_hashing_enabled'); + $mumie->use_hashed_id = 1; $mumie->id = $DB->insert_record("mumie", $mumie); mumie_grade_item_update($mumie); return $mumie->id; diff --git a/version.php b/version.php index f574707..47e2569 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2019110100; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2019110501; // The current module version (Date: YYYYMMDDXX). $plugin->component = 'mod_mumie'; // Full name of the plugin (used for diagnostics). $plugin->requires = 2015041700; $plugin->release = "v1.1";