Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Deleted users cause 2108 errors if they are still main teachers #53

Open
alex-rowe opened this issue Jun 18, 2014 · 7 comments
Open

Deleted users cause 2108 errors if they are still main teachers #53

alex-rowe opened this issue Jun 18, 2014 · 7 comments

Comments

@alex-rowe
Copy link

We had some contractors set up courses and assignments and then their accounts were deleted. This has causes Turnitin to give us 2108 errors where the email address is not valid. The plagiarism plugin uses the main teacher in some parts to talk to TII such as getting scores and updating assignments. As a quick fix, I changed the deleted users email back to what it was which has allowed scores to be pulled down.

Can you have a look at what is below and see if that will work. Best case scenario would be for it to detect a deleted user and either update with an active user. I'm not sure if there are any other parts we need to look at, such as 'username' or 'uid'.

function turnitin_get_tii_user($tii, $user) {
    global $USER, $DB;
    if (is_number($user)) {
        //full user record needed
        $user = ($user == $USER->id ? $USER : $DB->get_record('user', array('id'=>$user)));
    }
    //check to see if the user is deleted and swap it back to their original email
    if ($user->deleted) {
        $user->email = substr($user->username, 0, strrpos($user->username, '.'));
    }
    $tii['username'] = $user->username;
    $tii['uem']      = $user->email;
    $tii['ufn']      = $user->firstname;
    $tii['uln']      = $user->lastname;
    $tii['uid']      = $user->username;

    return $tii;
}
@alex-rowe
Copy link
Author

Would it be better to create an event for "user_deleted" which removes/changes the main teacher?
If the mainteacher id is changed, does anything else need to be changed as well to get it working?

@danmarsden
Copy link
Owner

interesting - I'd be tempted to remove those entries and convert the mainuser to the main moodle admin account instead of continuing to use the old user - any assignments submitted by deleted users should probably just get ignored (if they aren't being ignored already)

does that make sense?

@alex-rowe
Copy link
Author

Agree about moving them to the main admin user. Assignments submitted by disabled users should be ignored, only main teachers should be handled.
Would that need a user deleted event to check if they are a main teacher for an assignment?

@danmarsden
Copy link
Owner

using a deleted event would possibly be easier but I'm not sure how reliable that will be. it would be nice to do a check when obtaining the user in turnitin_get_tii_user but that would need a bit more restructuring and it may not be worth it considering we are deprecating this version with the new one that Turnitin have developed.

@alex-rowe
Copy link
Author

That's what I thoughts. It's only happened to us twice and can't see it being much of a problem for the rest of the year as we move off this plugin and v1 to v2. I might just work in the hack to change the email for the remaining months

@danmarsden
Copy link
Owner

makes sense - good to know that this is a potential issue though - thanks!

@pauln
Copy link
Contributor

pauln commented Oct 13, 2014

We've just encountered this issue - I manually updated the "main teacher" for the affected assignments, and reset the status to 51 so it fetched the missing similarity scores. I've thus been thinking about ways to handle this situation without too much extra effort (given the deprecation)...

One option would be to catch the 2108 status code when attempting to retrieve the similarity score/report, and assign a new "main teacher" at that point (trying to pick from course teachers first, if there are none falling back to site admin?) - leaving the status code as 51 so that the next iteration of the cron will try again (without needing to add 2108 to the list of codes to retry). Alternatively, it may be possible to set the new "main teacher" (and then use them) in turnitin_get_tii_user - I haven't looked into what gets passed in to that function (to see whether it receives the cmid and can thus perform the update).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants