diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 10 | ||||
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 2 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/dashboard.css | 89 | ||||
-rw-r--r-- | yaksh/templates/base.html | 13 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 78 | ||||
-rw-r--r-- | yaksh/templates/manage.html | 11 | ||||
-rw-r--r-- | yaksh/templates/user.html | 39 | ||||
-rw-r--r-- | yaksh/templates/yaksh/editprofile.html | 19 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 163 | ||||
-rw-r--r-- | yaksh/templates/yaksh/quizzes_user.html | 120 | ||||
-rw-r--r-- | yaksh/templates/yaksh/view_answerpaper.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/view_profile.html | 13 | ||||
-rw-r--r-- | yaksh/urls.py | 1 | ||||
-rw-r--r-- | yaksh/views.py | 35 |
14 files changed, 337 insertions, 258 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index c58d7f1..43dfe6b 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -76,13 +76,13 @@ class PythonAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get('success')) - self.assert_correct_output('AssertionError in: assert(add(1,2)==3)', + self.assert_correct_output('AssertionError in:\n assert(add(1,2)==3)', result.get('error') ) - self.assert_correct_output('AssertionError in: assert(add(-1,2)==1)', + self.assert_correct_output('AssertionError in:\n assert(add(-1,2)==1)', result.get('error') ) - self.assert_correct_output('AssertionError in: assert(add(-1,-2)==-3)', + self.assert_correct_output('AssertionError in:\n assert(add(-1,-2)==-3)', result.get('error') ) @@ -110,10 +110,10 @@ class PythonAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get('success')) self.assertEqual(result.get('weight'), 2.0) - self.assert_correct_output('AssertionError in: assert(add(-1,2)==1)', + self.assert_correct_output('AssertionError in:\n assert(add(-1,2)==1)', result.get('error') ) - self.assert_correct_output('AssertionError in: assert(add(-1,-2)==-3)', + self.assert_correct_output('AssertionError in:\n assert(add(-1,-2)==-3)', result.get('error') ) diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index ae86c46..daf1afe 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -77,7 +77,7 @@ class PythonAssertionEvaluator(BaseEvaluator): fname, lineno, func, text = info[-1] text = str(self.test_case) err = "Expected Test Case:\n{0}\n" \ - "Error - {1} {2} in: {3}\n".format( + "Error - {1} {2} in:\n {3}\n".format( self.test_case, type.__name__, str(value), diff --git a/yaksh/static/yaksh/css/dashboard.css b/yaksh/static/yaksh/css/dashboard.css new file mode 100644 index 0000000..28040c4 --- /dev/null +++ b/yaksh/static/yaksh/css/dashboard.css @@ -0,0 +1,89 @@ +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top:30px; +} + + +/* + * Global add-ons + */ + +.sub-header { + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +/* + * Top navigation + * Hide default border to remove 1px line. + */ +.navbar-fixed-top { + border: 0; +} + +/* + * Sidebar + */ + +@media (min-width: 768px) { + .sidebar { + position: fixed; + top: 51px; + bottom: 0; + left: 0; + z-index: 1000; + display: block; + padding: 20px; + overflow-x: hidden; + overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ + background-color: #f5f5f5; + border-right: 1px solid #eee; + } +} + +/* Sidebar navigation */ +.nav-sidebar { + margin-right: -21px; /* 20px padding + 1px border */ + margin-bottom: 20px; + margin-left: -20px; +} +.nav-sidebar > li > a { + padding-right: 20px; + padding-left: 20px; +} +.nav-sidebar > .active > a, +.nav-sidebar > .active > a:hover, +.nav-sidebar > .active > a:focus { + color: #fff; + background-color: #428bca; +} + + +/* + * Main content + */ + +.main { + padding: 0px; +} +@media (min-width: 768px) { + .main { + padding-right: 0px; + padding-left: 0px; + } +} +.main { + margin-top: 0; +} +.header { + margin: 30px 0 15px; + border-bottom: 1px solid #eee; +} + +.sidebar-right { + float: right; +} diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index 1609121..35c6976 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -18,14 +18,9 @@ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/font-awesome.css" type="text/css" /> <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/theme.css" type="text/css" /> <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/sticky-footer.css" type="text/css" /> + <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" /> - <style> - body { - padding-top: 20px; - padding-bottom: 20px; - } - </style> {% block meta %} <meta charset="utf-8"> <meta name="description" content=""> @@ -45,15 +40,11 @@ {% endblock %} <div class="container"> <div class="content"> - <div class="page-header"> + <div class="header"> <h3><center>{% block pagetitle %}{% endblock pagetitle %}</center></h2> </div> - <div class=row> - <div class=col-md-12> {% block content %} {% endblock %} - </div> - </div> </div> <footer class="footer"> <div class="container"> diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html new file mode 100644 index 0000000..19d760a --- /dev/null +++ b/yaksh/templates/exam.html @@ -0,0 +1,78 @@ +{% extends "base.html" %} +{% block css%} + <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" /> +{% endblock %} +{% block nav %} + <nav class="navbar navbar-fixed-top navbar-inverse"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="#"> Yaksh </a> + </div> + <div class= "collapse navbar-collapse" id="navbar"> + <form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" class="pull-right"> + {% csrf_token %} + <ul class="nav navbar-nav navbar"> + <li style="padding: 10px"><button class="btn btn-danger btn-sm" type="submit" name="quit">Quit Exam <span class="glyphicon glyphicon-off"></span></button></li> + </ul> + </form> + <div class="time-div" id="time_left"></div> + </div><!-- /.navbar --> + </div><!-- /.container --> + </nav><!-- /.navbar --> +{% endblock %} +{% block content %} +<div class="row"> + <div class="col-sm-3 col-md-2 sidebar"> + <p> Question Navigator </p> + <ul class="pagination pagination-sm"> + {% for qid in paper.questions.all %} + {% if qid in paper.questions_unanswered.all %} + {% if qid.id == question.id %} + <li class="active"><a style="width:25%" href="#"data-toggle="tooltip" + title="{{ qid.description|striptags }}" + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')">{{ forloop.counter }}</a></li> + {% else %} + <li><a style="width:25%" href="#" data-toggle="tooltip" title="{{ qid.description|striptags }}" + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')">{{ forloop.counter }}</a></li> + {% endif %} + {% endif %} + {% if qid in paper.questions_answered.all %} + <li class="disabled"><a style="background-color:#B4B8BA; width:25%" href="#" data-toggle="tooltip" title="{{ qid.description }}" >{{ forloop.counter }}</a></li> + {% endif %} + {% endfor %} + </ul> + <p>Question(s) left: <b>{{ paper.questions_left }}</b></p> + </div> + <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> + <div class="row"> + <div class="col-md-8"> + {% block main %} + {% endblock %} + </div> + {% if question.type == 'code' %} + {% if error_message %} + <div class="col-md-4"> + {% for error in error_message %} + {% if error == "Correct answer" %} + <div class="panel panel-success"> + {% else %} + <div class="panel panel-danger"> + {% endif %} + <div class="panel-heading">Testcase No. {{ forloop.counter }}</div> + <div class="panel-body"><pre><code>{{ error }}</code></pre></div> + </div> + {% endfor %} + + </div> + {% endif %} + {% endif %} + </div> + </div> + </div> +</div> +{% endblock %} diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html index eae4dd4..9744594 100644 --- a/yaksh/templates/manage.html +++ b/yaksh/templates/manage.html @@ -3,9 +3,14 @@ <nav class="navbar navbar-fixed-top navbar-inverse"> <div class="container"> <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Online Test </a> </div> - <div id="navbar"> + <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li><a href="{{ URL_ROOT }}/exam/manage/questions">Questions</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li> @@ -20,3 +25,7 @@ </div><!-- /.container --> </nav><!-- /.navbar --> {% endblock %} +{% block content %} + {% block main %} + {% endblock %} +{% endblock %} diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html index c18013b..6f2137d 100644 --- a/yaksh/templates/user.html +++ b/yaksh/templates/user.html @@ -1,19 +1,42 @@ {% extends "base.html" %} +{% block css%} + <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" /> +{% endblock %} {% block nav %} <nav class="navbar navbar-fixed-top navbar-inverse"> <div class="container"> <div class="navbar-header"> - <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Online Test </a> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Yaksh </a> </div> - <div id="navbar"> - <ul class="nav navbar-nav"> - <li><a href="{{ URL_ROOT }}/exam/quizzes">Quizzes</a></li> - <li><a href="{{ URL_ROOT }}/exam/results">Results</a></li> - <li><a href="{{ URL_ROOT }}/exam/viewprofile">My Profile</a></li> - <li><a href="{{ URL_ROOT }}/exam/changepassword">Change Password</a></li> - <li><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'>Log out</a></li> + <div class= "collapse navbar-collapse" id="navbar"> + <ul class="nav navbar-nav navbar-right"> + <li><a href="{{ URL_ROOT }}/exam/viewprofile"> {{ user.get_full_name.title }} </a></li> + <li><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'> <span class="glyphicon glyphicon-log-out">Logout </span></a></li> </ul> </div><!-- /.navbar --> </div><!-- /.container --> </nav><!-- /.navbar --> {% endblock %} +{% block content %} +<div class="row"> + <div class="col-sm-3 col-md-2 sidebar"> + <ul class="nav nav-sidebar"> + <li><a href="{{ URL_ROOT }}/exam/quizzes"> Home </a></li> + <li><a href="{{ URL_ROOT }}/exam/quizzes/enrolled/"> Enrolled Courses </a></li> + <li><a href="{{ URL_ROOT }}/exam/viewprofile"> Profile </a></li> + <li><a href="{{ URL_ROOT }}/exam/changepassword"> Change Password </a></li> + </ul> + </div> + <div class="col-sm-8 col-sm-offset-3 col-md-9 col-md-offset-2 main"> + <div class="row"> + {% block main %} + {% endblock %} + </div> + </div> +</div> +{% endblock %} diff --git a/yaksh/templates/yaksh/editprofile.html b/yaksh/templates/yaksh/editprofile.html index fc8539d..e5191ad 100644 --- a/yaksh/templates/yaksh/editprofile.html +++ b/yaksh/templates/yaksh/editprofile.html @@ -1,20 +1,13 @@ -{% extends "manage.html" %} - -{% block formtitle %} Please fill in the following details {% endblock %} - -{% block content %} -{% if msg %} -<center><h5>Your profile does not exist. Please fill in your details</h5></center> -{% endif %} +{% extends template %} +{% block pagetitle %} Please fill in the following details {% endblock %} +{% block main %} <form action="{{URL_ROOT}}/exam/editprofile/" method="post" > {% csrf_token %} <center> - <table class="span1"> + <table class="table table-bordered"> {{ form.as_table }} </table> </center> - <center><button class="btn" type="submit">Save</button> - <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/");'>Cancel</button> </center> + <button class="btn btn-primary pull-right" type="submit">Save Profile</button> </form> - -{% endblock content %} +{% endblock main %} diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 6473c2f..41634f2 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -1,23 +1,16 @@ -{% extends "base.html" %} +{% extends "exam.html" %} {% load custom_filters %} -{% block nav %} -<nav class="navbar navbar-fixed-top"> - <div class="container"> - <div class="navbar-header"> - </div> - - <div id="navbar"> - <div class="time-div" id="time_left"></div> - </ul> - </div><!-- /.navbar --> - </div><!-- /.container --> - </nav><!-- /.navbar --> -{% endblock %} -{% block pagetitle %} Yaksh Online Test {% endblock pagetitle %} +{% block pagetitle %} {{ paper.question_paper.quiz.description }} {% endblock pagetitle %} {% block css %} +<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" /> <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/question.css" type="text/css" /> <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/codemirror/lib/codemirror.css" type="text/css" /> +<style> + .CodeMirror{ + border-style: groove; + } +</style> {% endblock %} {% block script %} @@ -95,43 +88,52 @@ function call_skip(url) form.submit(); } </script> +<script> + $(document).ready(function(){ + // Codemirror object, language modes and initial content + // Get the textarea node + var textarea_node = document.querySelector('#answer'); + + var lang = "{{ question.language }}" + var mode_dict = { + 'python': 'python', + 'c': 'text/x-csrc', + 'cpp': 'text/x-c++src', + 'java': 'text/x-java', + 'bash': 'text/x-sh', + 'scilab': 'text/x-csrc' + } + + // Code mirror Options + var options = { + mode: mode_dict[lang], + gutter: true, + lineNumbers: true, + onChange: function (instance, changes) { + render(); + } + }; + + // Initialize the codemirror editor + var editor = CodeMirror.fromTextArea(textarea_node, options); + + // Setting code editors initial content + editor.setValue('{{ last_attempt|escape_quotes|safe }}') + + function reset_editor() { + editor.setValue('{{ last_attempt|escape_quotes|safe }}'); + editor.clearHistory(); + } + + + }); +</script> {% endblock script %} {% block onload %} onload="updateTime();" {% endblock %} -{% block content %} -<div class="row"> - <div class="col-md-6"> - <ul class="pagination pagination-lg"> - {% for qid in paper.questions.all %} - {% if qid in paper.questions_unanswered.all %} - {% if qid.id == question.id %} - <li class="active"><a href="#"data-toggle="tooltip" - title="{{ qid.description|striptags }}" - onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')">{{ forloop.counter }}</a></li> - {% else %} - <li><a href="#" data-toggle="tooltip" title="{{ qid.description|striptags }}" - onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')">{{ forloop.counter }}</a></li> - {% endif %} - {% endif %} - {% if qid in paper.questions_answered.all %} - <li class="disabled"><a style="background-color:#B4B8BA" href="#" data-toggle="tooltip" title="{{ qid.description }}" >{{ forloop.counter }}</a></li> - {% endif %} - {% endfor %} - </ul> - </div> - <div class="col-md-5"> - <h3>{{ paper.questions_left }} question(s) left in {{ paper.question_paper.quiz.description }}</h3> - </div> - <div class="col-md-1"> -<form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" class="pull-right"> - {% csrf_token %} - <button class="btn btn-danger " type="submit" name="quit">Quit Exam <span class="glyphicon glyphicon-off"></span></button> -</form> - </div> - -</div> +{% block main %} <p id="status"></p> <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" enctype="multipart/form-data"> {% csrf_token %} @@ -178,13 +180,13 @@ function call_skip(url) {% endif %} {% if question.type == "code" %} <div class="row"> - <div class="col-md-2"> - <h4>Program:</h4> + <div class="col-md-9"> + <h4>Write your program below:</h4> </div> - <div class="col-md-10"> + <div class="col-md-3"> <a href="#" class="pull-right" onclick="reset_editor()" name="reset" id="reset">Reset Answer <span class="glyphicon glyphicon-refresh"></span></a> </div> - </div> + </div> <textarea name="answer" id="answer"></textarea> <br> {% endif %} @@ -201,28 +203,10 @@ function call_skip(url) <button class="btn btn-primary" onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/')" name="skip" id="skip">Attempt Later <span class="glyphicon glyphicon-arrow-right"></span></button> {% endif %} </div> - {% if question.type == "code" %} - <div class="panel-footer"> - - {% if error_message %} - {% for error in error_message %} - {% if error == "Correct answer" %} - <div class="panel panel-success"> - {% else %} - <div class="panel panel-danger"> - {% endif %} - <div class="panel-heading">Testcase No. {{ forloop.counter }}</div> - <div class="panel-body"><pre><code>{{ error }}</code></pre></div> - </div> - {% endfor %} - - {% endif %} - </div> - {% endif %} </div> </div> - </form> + </form> <!-- Modal --> <div class="modal fade " id="upload_alert" > <div class="modal-dialog"> @@ -239,44 +223,7 @@ function call_skip(url) </div> </div> </div> +{% endblock main %} -<script> - // Codemirror object, language modes and initial content - // Get the textarea node - var textarea_node = document.querySelector('#answer'); - var lang = "{{ question.language }}" - var mode_dict = { - 'python': 'python', - 'c': 'text/x-csrc', - 'cpp': 'text/x-c++src', - 'java': 'text/x-java', - 'bash': 'text/x-sh', - 'scilab': 'text/x-csrc' - } - - // Code mirror Options - var options = { - mode: mode_dict[lang], - gutter: true, - lineNumbers: true, - - onChange: function (instance, changes) { - render(); - } - }; - - // Initialize the codemirror editor - var editor = CodeMirror.fromTextArea(textarea_node, options); - - // Setting code editors initial content - editor.setValue('{{ last_attempt|escape_quotes|safe }}') - - function reset_editor() { - editor.setValue('{{ last_attempt|escape_quotes|safe }}'); - editor.clearHistory(); - } - -</script> -{% endblock content %} diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html index 4ccbbc0..524d76f 100644 --- a/yaksh/templates/yaksh/quizzes_user.html +++ b/yaksh/templates/yaksh/quizzes_user.html @@ -1,14 +1,6 @@ {% extends "user.html" %} - - -{% block subtitle %}Hello {{ user.first_name }}, welcome to your dashboard !{% endblock %} - - -{% block pagetitle %} Student's Dashboard {% endblock pagetitle %} -{% block content %} - -<div class="row"> -<center><b><u>Available Courses</u></b></center><br> +{% block pagetitle %} {{ title }} {% endblock %} +{% block main %} {% for course in courses %} <div class="row well"> <div class="col-md-12"> @@ -31,93 +23,47 @@ </div> <div class="row"> - {% if user in course.students.all %} - {% if cannot_attempt %} - <p>You have not passed the prerequisite & hence you cannot take the quiz.</p> - {% endif %} - <h4>List of quizzes available for you</h4> - {% if not quizzes %} - <h5>No active quizzes for you</h5> - {% endif %} - <table class="table table-bordered"> - <th>Quiz</th> - <th>View Answer Paper</th> - <th>Pre requisite quiz</th> - {% for quiz in quizzes %} - {% if quiz.course_id == course.id %} - <tr> - {% if not quiz.is_expired %} - <td> - <a href="{{ URL_ROOT }}/exam/start/{{quiz.questionpaper_set.get.id}}">{{ quiz.description }}</a><br> - </td> - {% else %} - <td> - <a href="{{ URL_ROOT }}/exam/start/{{quiz.questionpaper_set.get.id}}">{{ quiz.description }}</a><br> - {{ quiz.description }} <span class="label label-danger">INACTIVE</span><br> - </td> - {% endif %} + {% if user in course.students.all %} + <table class="table table-bordered"> + <th>Quiz</th> + <th>View Answer Paper</th> + <th>Pre requisite quiz</th> + {% for quiz in course.get_quizzes %} + {% if quiz.active and quiz.course_id == course.id %} + <tr> + {% if not quiz.is_expired %} <td> - {% if quiz.view_answerpaper %} - <a href="{{ URL_ROOT }}/exam/view_answerpaper/{{ quiz.questionpaper_set.get.id }}/"><i class="fa fa-eye" aria-hidden="true"></i> Can View </a> - {% else%} - <a><i class="fa fa-eye-slash" aria-hidden="true"></i> Cannot view now </a> - {% endif %} + <a href="{{ URL_ROOT }}/exam/start/{{quiz.questionpaper_set.get.id}}">{{ quiz.description }}</a><br> </td> + {% else %} <td> - {% if quiz.prerequisite %} - You have to pass {{ quiz.prerequisite.description }} for taking {{ paper.quiz.description }} - {% else %} - No pre requisites for {{ quiz.description }} - {% endif %} + {{ quiz.description }} <span class="label label-danger">INACTIVE</span><br> </td> - </tr> {% endif %} - {% endfor %} - </table> - {% endif %} + <td> + {% if quiz.view_answerpaper %} + <a href="{{ URL_ROOT }}/exam/view_answerpaper/{{ quiz.questionpaper_set.get.id }}/"><i class="fa fa-eye" aria-hidden="true"></i> Can View </a> + {% else %} + <a><i class="fa fa-eye-slash" aria-hidden="true"></i> Cannot view now </a> + {% endif %} + </td> + <td> + {% if quiz.prerequisite %} + You have to pass {{ quiz.prerequisite.description }} for taking {{ paper.quiz.description }} + {% else %} + No pre requisites for {{ quiz.description }} + {% endif %} + </td> + </tr> + {% endif %} + {% endfor %} + </table> + {% endif %} </div> </div> </div><!--/row--> </br> {% endfor %} -</div> -<hr> -<h4>List of quizzes taken by you so far</h4> -{% if quizzes_taken %} - <table class="table table-bordered"> - <th>Quiz</th> - <th>Result</th> - <th>Marks Obtained</th> - <th>Total Marks</th> - <th>Percentage</th> - {% for paper in quizzes_taken %} - <tr> - <td> - {{ paper.question_paper.quiz.description }} - </td> - <td> - {% if paper.passed %} - <p>Pass</p> - {% else %} - <p>Fail</p> - {% endif %} - </td> - <td> - {{ paper.marks_obtained }} - </td> - <td> - {{ paper.question_paper.total_marks }} - </td> - <td> - {{ paper.percent }} - </td> - </tr> - {% endfor %} - </table> -{% else %} - <p>You have not taken any quiz yet !!</p> -{% endif %} - {% endblock %} diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html index 8dec5b3..cd607dd 100644 --- a/yaksh/templates/yaksh/view_answerpaper.html +++ b/yaksh/templates/yaksh/view_answerpaper.html @@ -2,7 +2,7 @@ {% block pagetitle %} Answer Paper for {{ quiz.description }}{% endblock pagetitle %} -{% block content %} +{% block main %} {% if not data.papers %} <p><b> You have not attempted the quiz {{ quiz.description }} </b></p> diff --git a/yaksh/templates/yaksh/view_profile.html b/yaksh/templates/yaksh/view_profile.html index becd205..5f06135 100644 --- a/yaksh/templates/yaksh/view_profile.html +++ b/yaksh/templates/yaksh/view_profile.html @@ -1,12 +1,8 @@ -{% extends "base.html" %} +{% extends template %} -{% block pagetitle %} My Profile {% endblock %} -{% block content %} -<ul> - <a class="btn btn-primary" href="{{ URL_ROOT }}/exam/editprofile/">Edit Profile</a> - <a class="btn btn-primary" href="{{ URL_ROOT }}/exam/">Back to Home</a> -</ul> - <table class="table"> +{% block pagetitle %} Profile {% endblock %} +{% block main %} + <table class="table table-bordered"> <tr> <th><label for="id_first_name"><h5>First name:</h5></label></th> <th><label for="id_first_name"><h5>{{ user.first_name }}</h5></label></th> @@ -36,4 +32,5 @@ <th><label for="id_position"><h5>{{ user.profile.position }}</h5></label></th> </tr> </table> + <a class="btn btn-primary pull-right" href="{{ URL_ROOT }}/exam/editprofile/">Edit Profile</a> {% endblock %} diff --git a/yaksh/urls.py b/yaksh/urls.py index 036c6a3..bdf14ea 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -31,6 +31,7 @@ urlpatterns += [ url(r'^$', views.index), url(r'^login/$', views.user_login, name='login'), url(r'^quizzes/$', views.quizlist_user, name='quizlist_user'), + url(r'^quizzes/(?P<enrolled>\w+)/$', views.quizlist_user, name='quizlist_user'), url(r'^results/$', views.results_user), url(r'^start/$', views.start), url(r'^start/(?P<questionpaper_id>\d+)/$', views.start), diff --git a/yaksh/views.py b/yaksh/views.py index 0d54f8a..14faa9b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -105,18 +105,16 @@ def user_register(request): @login_required -def quizlist_user(request): +def quizlist_user(request, enrolled=None): """Show All Quizzes that is available to logged-in user.""" user = request.user - avail_quizzes = Quiz.objects.get_active_quizzes() - user_answerpapers = AnswerPaper.objects.filter(user=user) - courses = Course.objects.filter(active=True, is_trial=False) - - context = { 'quizzes': avail_quizzes, - 'user': user, - 'courses': courses, - 'quizzes_taken': user_answerpapers, - } + if enrolled is not None: + courses = user.students.all() + title = 'Enrolled Courses' + else: + courses = Course.objects.filter(active=True, is_trial=False) + title = 'All Courses' + context = {'user': user, 'courses': courses, 'title': title} return my_render_to_response("yaksh/quizzes_user.html", context) @@ -1065,10 +1063,14 @@ def view_profile(request): """ view moderators and users profile """ user = request.user ci = RequestContext(request) - - context = {} + if is_moderator(user): + template = 'manage.html' + else: + template = 'user.html' + context = {'template': template} if has_profile(user): - return my_render_to_response('yaksh/view_profile.html', {'user':user}) + context['user'] = user + return my_render_to_response('yaksh/view_profile.html', context) else: form = ProfileForm(user=user) msg = True @@ -1082,10 +1084,13 @@ def view_profile(request): def edit_profile(request): """ edit profile details facility for moderator and students """ - context = {} user = request.user ci = RequestContext(request) - + if is_moderator(user): + template = 'manage.html' + else: + template = 'user.html' + context = {'template': template} if has_profile(user): profile = Profile.objects.get(user_id=user.id) else: |