Add Safe Browser enhancements and quiz security features - #877
Add Safe Browser enhancements and quiz security features#877SayaliGangurde48 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Please resolve the comments.
Also,
A. Keep multiple questions in the quiz and do testing.
And with multiple attempts to students
B. Please check!
- Selecting full-screen mode exits automatically whenever the user moves to the next question.
(So user has to every time click Enter full screen mode) - Check if audio or camera permission is not given by the user,
then it should not allow student to start the exam! - On some violations it shows Time up and quits the quiz.
- Also, after the violations it shows the page quit exam Yes or No.
If No is clicked then it starts the exam again with a new attempt.
This should not be allowed from here.
C. Check the flow for Quiz taken by the moderator as a Student or Teacher,
from the moderator's add quiz interface, then safe browser mode is not activated.
D. Camera and audio output is available where?
Means as a teacher how can he/she see?
E. Try to break the system in all the possible way.
JS is acting like a shield here, and the backend django is serving as per the behavior submitted by JS. If user tricks JS, then the backend will not be aware. So, some mechanism,
were there is a dedicated communication between the JS and the backend. And a state should be maintained.
Also, we need to sure if in between the user attempts to violate or stop the camera or audio, it should be tracked.
F. We need to ensure that unit/integration tests are added.
| <div class="card-body"> | ||
|
|
||
| {% if questionpaper.quiz.is_expired %} | ||
| <div class="alert alert-error"> |
There was a problem hiding this comment.
So, these are formatting changes, and no code changes here or addition of code. There are various places this has happened so it makes the PR a bit heavy. I request to remove the formatting changes from this PR, there can be a separate PR for this later.
Wherever i can locate i will comment "formatting changes", can be undone.
| <div class="container"> | ||
| <div class="card"> | ||
| <div class="card-header"> | ||
| {{questionpaper.quiz.description}} |
|
|
||
| {% if questionpaper.quiz.is_expired %} | ||
| <div class="alert alert-error"> | ||
| This Quiz has expired. You can no longer attempt this Quiz. |
There was a problem hiding this comment.
formatting changes
Below as well can be seen, kindly undo.
|
|
||
| <strong> | ||
| This is your Attempt {{ attempt_num }} | ||
| of {{ questionpaper.quiz.attempts_allowed }}. |
There was a problem hiding this comment.
If infinite attempts allowed then it will display "-1"
In this case it should show "infinite"
|
|
||
| </script> | ||
|
|
||
| <script> |
There was a problem hiding this comment.
Please make a separate JS file for this and include only when safe exam is selected.
| for tc_id in order | ||
| ] | ||
| except TestCaseOrder.DoesNotExist: | ||
| testcase_order = TestCaseOrder.objects.get( |
There was a problem hiding this comment.
Why this change? It does the same thing.
| for f in files: | ||
| zip_file.writestr( | ||
| os.path.join("additional_files", os.path.basename(f.file.name)), | ||
| os.path.join( |
There was a problem hiding this comment.
Below "formatting changes"
| from stats.models import TrackLesson | ||
| from yaksh.forms import ( | ||
| UserRegisterForm, UserLoginForm, QuizForm, QuestionForm, | ||
| UserRegisterForm, UserLoginForm, QuizForm,SafeBrowserForm,QuestionForm, |
There was a problem hiding this comment.
Put space after comma
|
|
||
| return my_render_to_response(request, 'yaksh/course_detail.html', context) | ||
|
|
||
| import json |
There was a problem hiding this comment.
Already imported in the file on the top.
| return my_render_to_response(request, 'yaksh/course_detail.html', context) | ||
|
|
||
| import json | ||
| from django.views.decorators.http import require_POST |
There was a problem hiding this comment.
Please put this import at the top along with other django.views.decorators imports
| ids = [ | ||
| int(x) | ||
| for x in testcase_order.order.split(",") | ||
| if x.strip() |
There was a problem hiding this comment.
if tc_id.strip() can be added to the existing code
| "use strict"; | ||
|
|
||
| var violationCount = 0; | ||
| var MAX_VIOLATIONS = 3; |
There was a problem hiding this comment.
This shouldn't be a constant.
| {% endif %}. | ||
| </strong> | ||
|
|
||
| {% if is_retry %} |
There was a problem hiding this comment.
is_retry = attempt_number > 1
So the message below will be displayed for normal attempts as well! (one without safe exam mode)
|
|
||
| ids = [ | ||
| int(tc_id) | ||
| for tc_id in testcase_order.order.split(",") |
There was a problem hiding this comment.
testcase_order not defined!
I suggest remove this fix as it is fixed in a different PR with tests
| else: | ||
| order = module.get_unit_order("quiz", quiz) | ||
|
|
||
| added_quiz = form.save(commit=False) |
There was a problem hiding this comment.
This will try to save invalid form as well!
| @require_POST | ||
| @login_required | ||
| def report_violation(request): | ||
| data = json.loads(request.body) |
There was a problem hiding this comment.
What if no answer paper or missing fields in JSON.
Error handling needed.
Also below, AnswerPaper not found should be caught
| paper.status = "completed" | ||
| paper.end_time = timezone.now() | ||
|
|
||
| print("SAFE BROWSER TERMINATED =", paper.terminated_by_safe_browser) |
|
|
||
| paper.save() | ||
|
|
||
| print( |
|
|
||
|
|
||
| @require_POST | ||
| @login_required |
|
|
||
|
|
||
| @require_POST | ||
| @login_required |
|
Please test Camera permission denied then what happens. I suggest you add tests for:
Then make the changes to your code. Then do manual testing as well. |
Summary
This PR adds Safe Browser functionality for Yaksh quizzes to provide a more secure online examination environment.
Changes Made