WeBWorK Main Forum

Is it possible to create two WeBWorK accounts from one D2L account using LTI?

Is it possible to create two WeBWorK accounts from one D2L account using LTI?

by Joseph Lo -
Number of replies: 2

I have successfully set up LTI with D2L, and all instructors can now sign in WeBWorK from D2L as "professors". But I am curious if it is possible for instructors to create a dummy student account on WeBWorK and sign in from the instructors' own D2L accounts. This will be useful if, for example, instructors need to see what students actually see.

I am aware that I can ask instructors to set $external_auth = 0 in course.conf and use WeBWorK authentication whenever they need to log in to the dummy account and then set $external_auth = 1 back after finish, but I want to find an easier way that ideally only needs to set up once on instructor's side.

I have tried to define $LTI_modify_user in authen_LTI.conf as follows:

$LTI_modify_user = sub {
    my $self = shift;
    my $user = shift;
    my $r = $self->{r};
    if (defined($r->param("custom_student_account"))) {
      if ($r->param("custom_student_account") eq "true") {
        $self->{user_id} = "sample_student";
#        $user->{user_id} = "sample_student";
      }
    }
};

This took a custom parameter "student_account = true" from D2L and could log in to WeBWorK front page as "sample_student" (provided that an account called "sample_student" is manually created in WeBWorK), but it kicked me out whenever I tried to open an assignment, check grades, or etc.

Another thing I tried was to modify /webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm but there was no effect no matter how I changed the code. It still worked as usual even if I renamed LTIAdvanced.pm to something unrecognizable.

Is it actually possible to create two logins from one D2L account? Thanks very much for any input.

In reply to Joseph Lo

Re: Is it possible to create two WeBWorK accounts from one D2L account using LTI?

by Danny Glin -

Is the "Act as" functionality in WeBWorK insufficient for instructors to see what a student sees?  You can act as a student by clicking on their username in the Classlist Editor.

I'm surprised that your modifications to $LTI_modify_user worked at all.  That code is designed to modify the user's data in WeBWorK once the user has been logged in, so I would expect the code that you quoted to log the instructor into their own account, and then try to change their username to sample_student.

Because the WeBWorK code is compiled into the apache process when it starts, any modifications you make to actual WeBWorK code (e.g. any .pm files) won't take effect until new apache processes are spawned, so to see the effects of your changes you should restart (or at least reload) apache.  It may be possible to do what you want by modifying LTIAdvanced.pm, though it likely isn't a standard use of LTI.

At University of Calgary they used to issue a second D2L account to instructors so they could see what a student sees in D2L (though I'm not sure if this is still the case).  If your instructors obtained a second D2L account then that could be associated with a student account in WeBWorK.

In reply to Danny Glin

Re: Is it possible to create two WeBWorK accounts from one D2L account using LTI?

by Joseph Lo -

Thanks very much for your reply.

The "Act as" only shows students' versions of the questions. It doesn't show what students actually see. It still shows everything meant to be hidden from students. It will be helpful for instructors who are new to WeBWorK to check what students actually see after creating an assignment.

I think your comment explains why $LTI_modify_user doesn't work when switching to a different user name. I am currently using $LTI_modify_user to restrict the auto-registering to WeBWorK by matching the D2L course name with the WeBWorK course name. With this, anyone accessing WeBWorK from a different course will require the course instructor to manually create their account first. Here's the code I have for now but I don't know if this could create unforeseeable problems.

$LTI_modify_user = sub {
    my $self = shift;
    my $user = shift;
    my $r = $self->{r};
    my $d2lTitle = substr $r->param("context_title"), 0, 9;
    my $wwTitle = substr $courseName, 0, 9;
    if ($d2lTitle ne $wwTitle) {
        $user->{user_id} = "";
    }
};

I totally forgot that I need to restart the server when modifying .pm files. This was exactly what I needed to do when modifying Units.pm. Thanks very much for reminding me.

Creating a second D2L account works. I have one and that works perfectly. But because we need to call IT when we need a second account and whenever we need to add this second account to a course, it could be a burden to have every instructor do the same. I am just looking for easier ways to do this.