diff options
author | prathamesh | 2017-01-04 15:54:19 +0530 |
---|---|---|
committer | prathamesh | 2017-01-04 15:54:19 +0530 |
commit | 241ca3c2b8ab1b1824813833237435153e08b0e9 (patch) | |
tree | 624c6bb07dfe239c2773f93a6da4ca20376d1c73 | |
parent | 43f2313d75e24a8c11855fb9718e48c1c06fb26f (diff) | |
download | online_test-241ca3c2b8ab1b1824813833237435153e08b0e9.tar.gz online_test-241ca3c2b8ab1b1824813833237435153e08b0e9.tar.bz2 online_test-241ca3c2b8ab1b1824813833237435153e08b0e9.zip |
Student UI modification.
Added side navigation bar.
Edit and view Profile base template set properly.
Added a tab "Enrolled Courses" for students to only view the courses
they are enrolled in.
-rw-r--r-- | yaksh/static/yaksh/css/dashboard.css | 101 | ||||
-rw-r--r-- | yaksh/templates/base.html | 4 | ||||
-rw-r--r-- | yaksh/templates/manage.html | 4 | ||||
-rw-r--r-- | yaksh/templates/user.html | 30 | ||||
-rw-r--r-- | yaksh/templates/yaksh/editprofile.html | 19 | ||||
-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 |
10 files changed, 195 insertions, 134 deletions
diff --git a/yaksh/static/yaksh/css/dashboard.css b/yaksh/static/yaksh/css/dashboard.css new file mode 100644 index 0000000..bf76ec6 --- /dev/null +++ b/yaksh/static/yaksh/css/dashboard.css @@ -0,0 +1,101 @@ +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px; +} + + +/* + * 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: 20px; +} +@media (min-width: 768px) { + .main { + padding-right: 40px; + padding-left: 40px; + } +} +.main .page-header { + margin-top: 0; +} + + +/* + * Placeholder dashboard ideas + */ + +.placeholders { + margin-bottom: 30px; + text-align: center; +} +.placeholders h4 { + margin-bottom: 0; +} +.placeholder { + margin-bottom: 20px; +} +.placeholder img { + display: inline-block; + border-radius: 50%; +} diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index aade07a..b2560e8 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -42,12 +42,8 @@ <div class="page-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/manage.html b/yaksh/templates/manage.html index 807a54c..9744594 100644 --- a/yaksh/templates/manage.html +++ b/yaksh/templates/manage.html @@ -25,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 9745655..f79eb29 100644 --- a/yaksh/templates/user.html +++ b/yaksh/templates/user.html @@ -1,4 +1,7 @@ {% 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"> @@ -11,14 +14,29 @@ <a class="navbar-brand" href="{{ URL_ROOT }}/exam/manage/"> Online Test </a> </div> <div class= "collapse navbar-collapse" 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> + <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/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 9dfbda0..9ad5b49 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 7ecf6aa..257a383 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: |