Skip to content

Commit

Permalink
16513 grade sync now creates hashes for users if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
goltz committed Nov 5, 2019
1 parent 90b3269 commit 355b058
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
11 changes: 9 additions & 2 deletions gradesync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions lang/en/mumie.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <i>grade to pass</i> set so you cannot use this option. Please use the require grade setting instead.';
$string['gradetopassmustbeset'] = '<i>Grade to pass</i> 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 <br><br> e.g. <b>https://www.ombplus.de/ombplus</b> <br><br> 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. <br>Please contact your Moodle administrator!';
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 355b058

Please sign in to comment.