Teacher Assisted Tests - Teacher submits students results

londonstone
Forums
Hi Guys, First off, great distribution. I can see you have put lots of time and effort into Opigno, and I wish you the success you deserve from it. I have a case where I would like teachers to input the results for children with learning diffuculties, or who are unable to submit themselves (i.e too young to type). One solution is that teacher logs in as each student to take each lesson/course. But could the teacher select the student from a list, and then perform the lesson/quiz with them, and submite the results to the students account? So teacher is the logged-in user, but the test is taken and submitted to another users account. Would it be possible? I have quite good coding skills, but thought it wise to ask you as you know the code base and structure very well, and this may be a useful feature for others in future. Best wishes.
Profile picture for user James Aparicio
James Aparicio

Hi londonstone,

Hi londonstone, Thank you for your interest in opigno. Results are not a content type that can be easily be edited by drupal core. They consist of a custom database structure created by the quiz module. You can access the results form at node/*/results/*. This form is implemented by the quiz module. I suppose the best approach is to add the user field to this form and let the teacher just edit the user at the end of a quiz. Another solution would be to store the selected user in session and then at the end of the quiz, change the user, but i think the first solution would be faster for you to get it working. Best regards
Profile picture for user James Aparicio
James Aparicio

Also keep in mind that both

Also keep in mind that both of those solutions would not let the teacher to be taking more than one "quiz as a student" at the same time. What you could also do it after you choose the student you want to take the quiz for, log that student in, save the teacher flag in the student session and relog as the teacher once the quiz has been finished. This way a teacher could be doing more than one "quiz as a student" since in this case it would actually be the student account taking the quiz. Allowing one user to be able to take quizes by other users, without one of these "workarounds" would require a significant change to the quiz module code base.
londonstone

Thanks

Thanks for the quick and helpful reply. I really like the idea of teacher selecting one student first and then that being stored in a global variable, which updated the user id before the quiz saves. I will look at the quiz module code to see if that's possible. I envision having a user block on left sidebar showing current selected users picture/profile, so it's obvious which user teacher is submitting for/logged in as. The problem with teacher logging in under student account is that they would need to know all passwords etc, and have to log back into their account with password at the end. There are modules that let admins switch user accounts during development (masquerade, etc), But I don't want teacher being able to log into admin role, or student to be able to log into teacher. I will also look at these modules to see if the give a secure and easy way of switching accounts. If so this may be the best way to go. Submitting as the logged in user seems best, avoids having to modify any code, but maybe involves more work for the teacher. I will look at the quiz sumbit functions and see if it's easy to change the UID from a global variable there.
Profile picture for user James Aparicio
James Aparicio

Hi londonstone, when clicking

Hi londonstone, when clicking on the take button after you have chosen the user, you would automatically log in the student user, it would not require the teacher to insert the student password, and would redirect the student to the take page. The same thing at the end. The teacher wouldn't even notice. Quiz uses the global user variable everywhere. It was build from the principle that the logged user is the one taking the quiz. Also it keeps track of your current progress on a quiz. Imagine that you selected a student to do the quiz for, and you did not finish it. And then you start doing a quiz for another student. When you start the quiz you will be at the question you ended with the first student. Best regards
londonstone

Thanks

I'm glad I spoke to you first. You obviously have a very good understanding of how quiz module works. One last question. Once quiz is finished, how would teacher get back into thier own account? Would it be safe to set a session variable like "teacher_test=1" and if that is set have a button to exit student account and re-log in teacher. Or is the only secure way for teacher to logoff student, and sign back into own account? I will investigate other multi login modules to see how they handle it.
londonstone

hook_quiz_begin() is the

hook_quiz_begin() is the function where you need to... change user to student set flag (session variable with Md5 hash) storing original teachers uid And and hook_quiz_finished is where you set... check if teacher flag exists and Md5 hash matches, if so swicth back to teacher user. Seems quite straight forward, thanks so much for pointing me in the right direction.
Profile picture for user James Aparicio
James Aparicio

Hi londonstone,

Hi londonstone, You would hook into the finish quiz form submit. And check if the variable is set logging back the teacher. I do not see a security issue here. Drupal is a very secure platform. The Session variable is on the server side. The worst case scenario, if the session is hijacked, the hijacker still cannot set information to the session variable. So even if by some unknown reason he finds a security hole to hijack the session, the only difference is that he can from a student account get access to a teacher account (during that short period that he is). But if he can hijack the student session, why not hijack the teacher session? It is the same machine. It is the teacher that now is using the student account. Best regards
Profile picture for user James Aparicio
James Aparicio

If you dont want the

If you dont want the interface where the teacher selects the user before taking the quiz you can check the Masquerade module. Best regards