diff options
author | prathamesh | 2017-01-12 18:20:38 +0530 |
---|---|---|
committer | prathamesh | 2017-01-12 18:20:38 +0530 |
commit | fe6c5c3b561c514fa328807fb8a571a620e438cf (patch) | |
tree | 9d6ad230d683c1481f7d220bee191578127d36f0 | |
parent | 241ca3c2b8ab1b1824813833237435153e08b0e9 (diff) | |
download | online_test-fe6c5c3b561c514fa328807fb8a571a620e438cf.tar.gz online_test-fe6c5c3b561c514fa328807fb8a571a620e438cf.tar.bz2 online_test-fe6c5c3b561c514fa328807fb8a571a620e438cf.zip |
Exam interface improved
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 2 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/dashboard.css | 17 | ||||
-rw-r--r-- | yaksh/templates/base.html | 3 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 78 | ||||
-rw-r--r-- | yaksh/templates/user.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 163 |
6 files changed, 149 insertions, 116 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index 749a6ec..8ff88b4 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 index bf76ec6..3049ef0 100644 --- a/yaksh/static/yaksh/css/dashboard.css +++ b/yaksh/static/yaksh/css/dashboard.css @@ -4,7 +4,7 @@ /* Move down content because we have a fixed navbar that is 50px tall */ body { - padding-top: 50px; + padding-top:30px; } @@ -68,17 +68,21 @@ body { */ .main { - padding: 20px; + padding: 0px; } @media (min-width: 768px) { .main { - padding-right: 40px; - padding-left: 40px; + padding-right: 0px; + padding-left: 0px; } } -.main .page-header { +.main { margin-top: 0; } +.header { + margin: 30px 0 15px; + border-bottom: 1px solid #eee; +} /* @@ -99,3 +103,6 @@ body { display: inline-block; border-radius: 50%; } +.sidebar-right { + float: right; +} diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index b2560e8..35c6976 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -18,6 +18,7 @@ <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" /> {% block meta %} @@ -39,7 +40,7 @@ {% endblock %} <div class="container"> <div class="content"> - <div class="page-header"> + <div class="header"> <h3><center>{% block pagetitle %}{% endblock pagetitle %}</center></h2> </div> {% block content %} 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/user.html b/yaksh/templates/user.html index f79eb29..6f2137d 100644 --- a/yaksh/templates/user.html +++ b/yaksh/templates/user.html @@ -11,7 +11,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Online Test </a> + <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Yaksh </a> </div> <div class= "collapse navbar-collapse" id="navbar"> <ul class="nav navbar-nav navbar-right"> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 8b2012c..45413c9 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 %} @@ -200,13 +202,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 %} @@ -223,28 +225,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"> @@ -261,44 +245,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 %} |