diff options
-rw-r--r-- | yaksh/live_server_tests/selenium_test.py | 2 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 11 | ||||
-rw-r--r-- | yaksh/templates/yaksh/addteacher.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_detail.html | 308 | ||||
-rw-r--r-- | yaksh/views.py | 17 |
6 files changed, 144 insertions, 199 deletions
diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py index 01ccc96..7eeb22c 100644 --- a/yaksh/live_server_tests/selenium_test.py +++ b/yaksh/live_server_tests/selenium_test.py @@ -111,7 +111,7 @@ class SeleniumTest(): def close_quiz(self): quit_link_elem = WebDriverWait(self.driver, 5).until( - EC.presence_of_element_located((By.ID, "login_again")) + EC.presence_of_element_located((By.ID, "home")) ) quit_link_elem.click() diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index dfcaf2d..b497cc0 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -26,6 +26,15 @@ </nav><!-- /.navbar --> {% endblock %} {% block content %} + <script> + $(document).ready(function() { + var ele = document.getElementById('error_panel') + if (ele) { + ele.scrollIntoView(true); + window.scrollBy(0, -15); + } + }); + </script> <div class="container-fluid"> <div class="col-sm-3 col-md-2 sidebar"> <p> Question Navigator </p> @@ -64,7 +73,7 @@ </div> {% if question.type == 'code' %} {% if error_message %} - <div class="row"> + <div class="row" id="error_panel"> {% for error in error_message %} {% if error == "Correct answer" %} <div class="panel panel-success"> diff --git a/yaksh/templates/yaksh/addteacher.html b/yaksh/templates/yaksh/addteacher.html index 755ba20..478da77 100644 --- a/yaksh/templates/yaksh/addteacher.html +++ b/yaksh/templates/yaksh/addteacher.html @@ -27,7 +27,7 @@ {% else %} <center><b><u>Search Results</u></b></center><br> <center><b>Search results does not include teachers already added</b></center><br> - <table> + <table class="table table-striped"> <th></th> <th>Username</th> <th>First Name</th> @@ -51,6 +51,7 @@ {% endif %} {% endfor %} </table> + </br> <button class="btn" type="submit">Add Selected</button> {% endif %} {% endif %} diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 7bff206..45284c4 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -32,5 +32,5 @@ <center><h2> Good bye! </h2></center> <center><h4> {{message}} </h4></center> <br><center><h4>You may now close the browser.</h4></center><br> - <center><a href="{{URL_ROOT}}/exam/" id="login_again"> Login Again </a></center> + <center><a href="{{URL_ROOT}}/exam/" id="home"> Home </a></center> {% endblock content %} diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index 5fb92f9..dc85080 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -9,200 +9,136 @@ {% endblock %} {% block content %} <br/> -<div class="pull-right"> - <a class="btn btn-primary" href="{{URL_ROOT}}/exam/manage/toggle_status/{{ course.id }}/">{% if course.active %}Deactivate Course {% else %} Activate Course {% endif %}</a> -</div> -<br/> +<br> <div class="row"> - <div class="col-md-6"> - <center><b><u>Requests</u></b></center><br> - {% if course.get_requests %} - <input type="checkbox" class="checkall"/> <font size="2">Select all</font> - <div id="enroll-all"> - <form action="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/" method="post"> - {% csrf_token %} - {% for request in course.get_requests %} - <div class="well"> - <div class="row"> - <div class="col-md-3" style="padding-top:10px"> - <input type="checkbox" name="check" value="{{ request.id }}"> - <a href="#" data-toggle="modal" data-target="#request_detail_{{forloop.counter}}"> - {{ request.username }}</a> - <div class="modal fade" id="request_detail_{{forloop.counter}}" role="dialog"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal">×</button> - <h4 class="modal-title">Information for {{ request.username }} </h4> - </div> - <div class="modal-body"> - <table> - <tr> - <td><strong>Full Name :</strong></td> - <td> {{request.get_full_name}}</td> - </tr> - <tr> - <td><strong>Email ID :</strong></td> - <td> {{request.email}}</td> - </tr> - <tr> - <td><strong>Roll Number :</strong></td> - <td> {{request.profile.roll_number}}</td> - </tr> - <tr> - <td><strong>Institute :</strong></td> - <td> {{request.profile.institute}}</td> - </tr> - <tr> - <td><strong>Department :</strong></td> - <td> {{request.profile.department}}</td> - </tr> - <tr> - </table> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> - </div> - </div> + <div class="col-sm-3 col-md-2 sidebar"> + <ul class="nav nav-sidebar"> + <li><a href="#student-requests" id="request"> Requested Students </a></li> + <li><a href="#enrolled-students" id="enroll-students"> Enrolled Students </a></li> + <li><a href="#rejected-students" id="reject-students"> Rejected Students </a></li> + <li> + <a href="{{URL_ROOT}}/exam/manage/toggle_status/{{ course.id }}/"> + {% if course.active %}Deactivate Course {% else %} Activate Course {% endif %}</a> + </li> + </ul> </div> - </div> - </div> - <a class="btn btn-success" href="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/{{ request.id }}/"> Enroll </a> <a class="btn btn-danger" href="{{URL_ROOT}}/exam/manage/reject/{{ course.id }}/{{ request.id }}/"> Reject </a> +</div> +<div class="col-md-9 col-md-offset-2 main"> + <div class="row"> + <div id="student-requests"> + <center><b><u>Requests</u></b></center><br> + {% if course.get_requests %} + <input type="checkbox" class="checkall"/> <font size="2">Select all</font> + <div id="enroll-all"> + <table class="table table-striped"> + <th></th> + <th>Full Name</th> + <th>Email</th> + <th>Roll Number</th> + <th>Institute</th> + <th>Department</th> + <th>Enroll/Reject</th> + <form action="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/" method="post"> + {% csrf_token %} + {% for request in course.get_requests %} + <tr> + <td><input type="checkbox" name="check" value="{{ request.id }}"></td> + <td>{{request.get_full_name}}</td> + <td> {{request.email}}</td> + <td> {{request.profile.roll_number}}</td> + <td> {{request.profile.institute}}</td> + <td> {{request.profile.department}}</td> + <td> + <a class="btn btn-success" + href="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/{{ request.id }}/"> + Enroll </a> + <a class="btn btn-danger" + href="{{URL_ROOT}}/exam/manage/reject/{{ course.id }}/{{ request.id }}/"> + Reject </a> + </td> + </tr> + {% endfor %} + </table> + <button class="btn btn-success" type="submit" name='enroll' value='enroll'>Enroll Selected</button> </div> + {% endif %} + </form> </div> - {% endfor %} - <button class="btn success" type="submit" name='enroll' value='enroll'>Enroll Selected</button> - </div> - {% endif %} - </form> - </div> - <div class="col-md-6"> - <center><b><u>Rejected</u></b></center><br> - {% if course.get_rejected %} - <input type="checkbox" class="enroll"/> <font size="2">Select all</font> - <div id="enroll"> - {% for rejected in course.get_rejected %} - <form action="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/" method="post"> - {% csrf_token %} - <div class="well"> - <div class="row"> - <div class="col-md-4" style="padding-top:10px"> - <input type="checkbox" name="check" value="{{ rejected.id }}"> - <a href="#" data-toggle="modal" data-target="#reject_detail_{{forloop.counter}}"> - {{ rejected.username }}</a> - <div class="modal fade" id="reject_detail_{{forloop.counter}}" role="dialog"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal">×</button> - <h4 class="modal-title">Information for {{ rejected.username }} </h4> - </div> - <div class="modal-body"> - <table> - <tr> - <td><strong>Full Name :</strong></td> - <td> {{rejected.get_full_name}}</td> - </tr> - <tr> - <td><strong>Email ID :</strong></td> - <td> {{rejected.email}}</td> - </tr> - <tr> - <td><strong>Roll Number :</strong></td> - <td> {{rejected.profile.roll_number}}</td> - </tr> - <tr> - <td><strong>Institute :</strong></td> - <td> {{rejected.profile.institute}}</td> - </tr> - <tr> - <td><strong>Department :</strong></td> - <td> {{rejected.profile.department}}</td> - </tr> - <tr> - </table> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> - </div> - </div> - </div> - </div> - </div> - <a class="btn btn-success" href="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/{{ rejected.id }}/"> Enroll </a> + <br> + <div id="enrolled-students"> + <center><b><u>Enrolled</u></b></center><br> + {% if course.get_enrolled %} + <input type="checkbox" class="reject"/> <font size="2">Select all</font> + <div id="reject"> + <table class="table table-striped"> + <th></th> + <th>Full Name</th> + <th>Email</th> + <th>Roll Number</th> + <th>Institute</th> + <th>Department</th> + <th>Reject</th> + {% for enrolled in course.get_enrolled %} + <form action="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/" method="post"> + {% csrf_token %} + <tr> + <td><input type="checkbox" name="check" value="{{ enrolled.id }}"></td> + <td> {{ enrolled.get_full_name|title }} </td> + <td> {{enrolled.email}}</td> + <td> {{enrolled.profile.roll_number}}</td> + <td> {{enrolled.profile.institute}}</td> + <td> {{enrolled.profile.department}}</td> + <td><a class="btn btn-danger" + href="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/{{ enrolled.id }}/"> + Reject </a> + </td> + </tr> + {% endfor %} + </table> + <button class="btn btn-danger" type="submit" name='reject' value='reject'>Reject Selected</button> </div> + {% endif %} + </form> </div> - {% endfor %} - <button class="btn btn-success" type="submit" name='enroll' value='enroll'>Enroll Selected</button> - </div> - {% endif %} - </form> - </div> -</div> -<br> -<div class="row"> - <div class="col-md-6"> - <center><b><u>Enrolled</u></b></center><br> - {% if course.get_enrolled %} - <input type="checkbox" class="reject"/> <font size="2">Select all</font> - <div id="reject"> - {% for enrolled in course.get_enrolled %} - <form action="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/" method="post"> - {% csrf_token %} - <div class="well"> - <div class="row"> - <div class="col-md-4" style="padding-top:10px"> - <input type="checkbox" name="check" value="{{ enrolled.id }}"> - <a href="#" data-toggle="modal" data-target="#enroll_detail_{{forloop.counter}}"> - {{ enrolled.username }}</a> - <div class="modal fade" id="enroll_detail_{{forloop.counter}}" role="dialog"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal">×</button> - <h4 class="modal-title">Information for {{ enrolled.username }} </h4> - </div> - <div class="modal-body"> - <table> - <tr> - <td><strong>Full Name :</strong></td> - <td> {{enrolled.get_full_name}}</td> - </tr> - <tr> - <td><strong>Email ID :</strong></td> - <td> {{enrolled.email}}</td> - </tr> - <tr> - <td><strong>Roll Number :</strong></td> - <td> {{enrolled.profile.roll_number}}</td> - </tr> - <tr> - <td><strong>Institute :</strong></td> - <td> {{enrolled.profile.institute}}</td> - </tr> - <tr> - <td><strong>Department :</strong></td> - <td> {{enrolled.profile.department}}</td> - </tr> - <tr> - </table> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> - </div> - </div> - </div> - </div> - </div> - <a class="btn btn-danger" href="{{URL_ROOT}}/exam/manage/enrolled/reject/{{ course.id }}/{{ enrolled.id }}/"> Reject </a> + <br> + <div id="rejected-students"> + <center><b><u>Rejected</u></b></center><br> + {% if course.get_rejected %} + <input type="checkbox" class="enroll"/> <font size="2">Select all</font> + <div id="enroll"> + <table class="table table-striped"> + <th></th> + <th>Full Name</th> + <th>Email</th> + <th>Roll Number</th> + <th>Institute</th> + <th>Department</th> + <th>Enroll</th> + {% for rejected in course.get_rejected %} + <form action="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/" method="post"> + {% csrf_token %} + <tr> + <td><input type="checkbox" name="check" value="{{ rejected.id }}"></td> + <td>{{rejected.get_full_name|title}}</td> + <td> {{rejected.email}}</td> + <td> {{rejected.profile.roll_number}}</td> + <td> {{rejected.profile.institute}}</td> + <td> {{rejected.profile.department}}</td> + <td> + <a class="btn btn-success" + href="{{URL_ROOT}}/exam/manage/enroll/rejected/{{ course.id }}/{{ rejected.id }}/"> + Enroll </a> + </td> + </tr> + {% endfor %} + </table> + <br> + <button class="btn btn-success" type="submit" name='enroll' value='enroll'> + Enroll Selected</button> </div> + {% endif %} + </form> </div> - {% endfor %} - <button class="btn btn-danger" type="submit" name='reject' value='reject'>Reject Selected</button> - </div> - {% endif %} - </form> </div> </div> - {% endblock %} diff --git a/yaksh/views.py b/yaksh/views.py index 605d3f2..ae29508 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -348,7 +348,11 @@ def start(request, questionpaper_id=None, attempt_num=None): quest_paper = QuestionPaper.objects.get(id=questionpaper_id) except QuestionPaper.DoesNotExist: msg = 'Quiz not found, please contact your '\ - 'instructor/administrator. Please login again thereafter.' + 'instructor/administrator.' + return complete(request, msg, attempt_num, questionpaper_id=None) + if not quest_paper.fixed_questions.all() and not quest_paper.random_questions.all(): + msg = 'Quiz does not have Questions, please contact your '\ + 'instructor/administrator.' return complete(request, msg, attempt_num, questionpaper_id=None) if not quest_paper.quiz.course.is_enrolled(user): raise Http404('You are not allowed to view this page!') @@ -527,8 +531,8 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None): """Show a page to inform user that the quiz has been compeleted.""" user = request.user if questionpaper_id is None: - logout(request) - message = reason or "You are successfully logged out." + message = reason or "An Unexpected Error occurred. Please contact your '\ + 'instructor/administrator.'" context = {'message': message} return my_render_to_response('yaksh/complete.html', context) else: @@ -537,12 +541,7 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None): attempt_number=attempt_num) paper.update_marks() paper.set_end_time(timezone.now()) - if paper.percent == 100: - message = "You answered all the questions correctly.\ - You have been logged out successfully,\ - Thank You !" - else: - message = reason or "You are successfully logged out" + message = reason or "Quiz has been submitted" context = {'message': message, 'paper': paper} return my_render_to_response('yaksh/complete.html', context) |