diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 13 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/dashboard.css | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 14 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 67 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_video.html | 109 | ||||
-rw-r--r-- | yaksh/views.py | 29 |
7 files changed, 159 insertions, 79 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6622067..d4a73fa 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -668,6 +668,19 @@ class Course(models.Model): module.learning_unit.all().delete() learning_modules.delete() + def is_last_unit(self, module, unit_id): + last_unit = module.get_learning_units().last() + return unit_id == last_unit.id + + def next_module(self, current_module_id): + modules = self.get_learning_modules() + module_ids = list(modules.values_list("id", flat=True)) + current_unit_index = module_ids.index(current_module_id) + next_index = current_unit_index + 1 + if next_index == len(module_ids): + next_index = 0 + return modules.get(id=module_ids[next_index]) + def __str__(self): return self.name diff --git a/yaksh/static/yaksh/css/dashboard.css b/yaksh/static/yaksh/css/dashboard.css index 20a0339..b5b3648 100644 --- a/yaksh/static/yaksh/css/dashboard.css +++ b/yaksh/static/yaksh/css/dashboard.css @@ -38,7 +38,7 @@ body { z-index: 1000; display: block; padding: 20px; - overflow-x: hidden; + overflow-x: auto; overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ background-color: #f5f5f5; border-right: 1px solid #eee; diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index d0b7e4d..e4317fe 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -39,12 +39,12 @@ width="80" alt="YAKSH"></img>{% endblock %} <a href="{{URL_ROOT}}/exam/" id="home" class="btn btn-success"> Home </a> {% if module_id and not user == "moderator" %} {% if first_unit %} - <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info"> Next Unit + <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info"> Next <span class="glyphicon glyphicon-chevron-right"> </span> </a> {% else %} - <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}" class="btn btn-info"> Next Unit + <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}" class="btn btn-info"> Next <span class="glyphicon glyphicon-chevron-right"> </span> </a> diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index b6b9f7e..a1fd48a 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -75,7 +75,7 @@ <span class="label label-danger">Closed</span> {% endif %} <br><br> - <center><b><u>Teacher(s) Added to {{ course }}</u></b></center> + <center><b><u>Teacher(s) added to {{ course }}</u></b></center> <br> <form action="{{URL_ROOT}}/exam/manage/remove_teachers/{{ course.id }}/" method="post"> {% if course.get_teachers %} @@ -93,7 +93,7 @@ <button class="btn btn-danger" type="submit" data-toggle="tooltip" title="Remove Selected Teachers from this course">Remove Teachers</button> </div> {% else %} - <center><b>No Teacher(s) Added</b></center> + <center><b>No Teacher(s) added</b></center> {% endif %} </form> <br><br> @@ -209,7 +209,7 @@ <center><b><u> Course Creator</u></b><br> <h4>{{course.creator.get_full_name.title}}</h4> </center><br> - <center><b><u>Teacher(s) Added to {{ course }}</u></b></center> + <center><b><u>Teacher(s) added to {{ course }}</u></b></center> <br> <form action="{{URL_ROOT}}/exam/manage/remove_teachers/{{ course.id }}/" method="post"> {% if course.get_teachers %} @@ -228,7 +228,7 @@ <button class="btn btn-danger" type="submit" data-toggle="tooltip" title="Remove Selected Teachers from this course">Remove Teachers</button> </div> {% else %} - <center><b>No Teacher(s) Added</b></center> + <center><b>No Teacher(s) added</b></center> {% endif %} </form> <br><br> @@ -326,7 +326,7 @@ <a href="{{URL_ROOT}}/exam/manage/addquiz/" class="btn btn-primary">Add New Quiz</a> <a href="{{URL_ROOT}}/exam/manage/add_exercise/" class="btn btn-primary">Add New Exercise</a> {% if not quizzes %} - <center><h4> No new Quiz Added</h4></center> + <center><h4> No new Quiz added</h4></center> <br><br> {% else %} <center><h3> Quizzes </h3></center> @@ -380,7 +380,7 @@ {% if type == "lesson" %} <a href="{{URL_ROOT}}/exam/manage/courses/edit_lesson/" class="btn btn-primary">Add new Lesson</a> {% if not lessons %} - <center><h4> No new Lessons Added</h4></center> + <center><h4> No new Lessons added</h4></center> <br><br> {% else %} <center><h3> Lessons </h3></center> @@ -414,7 +414,7 @@ <a href="{{URL_ROOT}}/exam/manage/courses/add_module/" class="btn btn-primary"> Add new Module</a> {% if not learning_modules %} - <center><h4> No new learning modules Added</h4></center> + <center><h4> No new learning modules added</h4></center> <br><br> {% else %} <center><h3> Learning Modules </h3></center> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index c7e6efb..9d6ce48 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -110,37 +110,44 @@ question_type = "{{ question.type }}" {% block onload %} onload="updateTime();" {% endblock %} {% block learning_units %} -<center><h3>Lessons/Quizzes</h3></center> -<ul class="list"> -{% for unit in module.get_learning_units %} -<span> -<li> - -{% get_unit_status course module unit user as status %} - -{% if unit.quiz.id == paper.question_paper.quiz.id %} - <span class=" glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"></span> -{% endif %} +<center><h4>{{course.name}}</h4></center> + <br> + {% for learning_module in all_modules %} + {% if learning_module.id == module.id %} + <span class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"> + </span> + {% endif %} + <b><u><a href="{{URL_ROOT}}/exam/quizzes/view_module/{{learning_module.id}}/{{course.id}}">{{learning_module.name}}</u></b> + </a> + <ul class="list"> + {% for unit in learning_module.get_learning_units %} + <span> + <li> + {% get_unit_status course learning_module unit user as status %} -{% if unit.type == "quiz" %} - <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{module.id}}/{{course.id}}"> - {{ unit.quiz.description }} - </a> -{% else %} - <a href="{{ URL_ROOT }}/exam/show_lesson/{{unit.lesson.id}}/{{module.id}}/{{course.id}}"> - {{ unit.lesson.name }} - </a> -{% endif %} -{% if status == "completed" %} - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> -{% else %} - <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> -{% endif %} -</li> -</span> -<br> -{% endfor %} -</ul> + {% if unit.quiz.id == paper.question_paper.quiz.id %} + <span class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"> + </span> + {% endif %} + {% if unit.type == "quiz" %} + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> + {{ unit.quiz.description }} + </a> + {% else %} + <a href="{{ URL_ROOT }}/exam/show_lesson/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> + {{ unit.lesson.name }} + </a> + {% endif %} + {% if status == "completed" %} + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> + {% endif %} + </li> + </span> + {% endfor %} + </ul> + {% endfor %} {% endblock %} {% block main %} diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index 0490697..f4b59ac 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -1,42 +1,54 @@ {% extends "user.html" %} {% load custom_filters %} -{% block title %} {{ learning_module.name|title }} {% endblock %} +{% block title %} {{ learning_module.name }} {% endblock %} -{% block pagetitle %} {{ learning_module.name|title }} {% endblock %} +{% block pagetitle %} {{ learning_module.name }} +{% if state == "lesson" %} + : {{lesson.name}} +{% endif %} +{% endblock %} {% block main %} <div class="col-sm-3 col-md-2 sidebar"> - <center><h3>Lessons/Quizzes</h3></center> - <ul class="list"> - {% for unit in learning_units %} - <span> - <li> - {% get_unit_status course learning_module unit user as status %} + <center><h4>{{course.name}}</h4></center> + <br> + {% for module in all_modules %} + {% if module.id == learning_module.id %} + <span class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"> + </span> + {% endif %} + <b><u><a href="{{URL_ROOT}}/exam/quizzes/view_module/{{module.id}}/{{course.id}}">{{module}}</u></b> + </a> + <ul class="list"> + {% for unit in module.get_learning_units %} + <span> + <li> + {% get_unit_status course module unit user as status %} - {% if unit.id == current_unit.id %} - <span class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"> + {% if unit.id == current_unit.id %} + <span class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Currently on"> + </span> + {% endif %} + {% if unit.type == "quiz" %} + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{module.id}}/{{course.id}}"> + {{ unit.quiz.description }} + </a> + {% else %} + <a href="{{ URL_ROOT }}/exam/show_lesson/{{unit.lesson.id}}/{{module.id}}/{{course.id}}"> + {{ unit.lesson.name }} + </a> + {% endif %} + {% if status == "completed" %} + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> + {% endif %} + </li> </span> - {% endif %} - {% if unit.type == "quiz" %} - <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> - {{ unit.quiz.description }} - </a> - {% else %} - <a href="{{ URL_ROOT }}/exam/show_lesson/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> - {{ unit.lesson.name }} - </a> - {% endif %} - {% if status == "completed" %} - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> - {% else %} - <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> - {% endif %} - </li> - </span> - <br> + {% endfor %} + </ul> {% endfor %} - </ul> </div> {% if msg %} <center> @@ -49,16 +61,49 @@ <div class="panel panel-default" style="border: none; box-shadow: none;"> <div class="panel-body"> {{learning_module.html_data|safe}} + {% if learning_module.html_data%} + <hr> + {% endif %} + <center><h4>Following are the units in this modules</h4></center> + <table class="table"> + <tr> + <th>Unit Name</th> + <th>Unit Type</th> + </tr> + {% for unit in learning_module.get_learning_units %} + <tr> + <ul class="inputs-list"> + <td> + {% if unit.type == "quiz" %} + {{unit.quiz.description}} + {% else %} + {{unit.lesson.name}} + {% endif %} + </td> + <td> + {% if unit.type == "quiz" %} + {% if unit.quiz.is_exercise %} + Exercise + {% else %} + Quiz + {% endif %} + {% else %} + Lesson + {% endif %} + </td> + </ul> + </tr> + {% endfor %} + </table> </div> </div> <div style="text-align: center;"> - <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{first_unit.id}}/1" class="btn btn-info">First Unit + <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{first_unit.id}}/1" class="btn btn-info">Start <span class="glyphicon glyphicon-chevron-right"> </span> </a> </div> {% else %} -<center><h3>{{lesson.name}}</h3></center> <div class="panel panel-default" style="border: none; box-shadow: none;"> <div class="panel-body"> {{lesson.html_data|safe}} @@ -80,7 +125,7 @@ </div> {% endif %} <div style="text-align: center;"> - <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{current_unit.id}}" class="btn btn-info" style="display: inline-block;">Next Unit + <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{current_unit.id}}" class="btn btn-info" style="display: inline-block;">Next <span class="glyphicon glyphicon-chevron-right"> </span> </a> diff --git a/yaksh/views.py b/yaksh/views.py index 8fe4523..49249ca 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -504,7 +504,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, if learning_unit.has_prerequisite(): if not learning_unit.is_prerequisite_passed( user, learning_module, course): - msg = "You have not completed the prerequisite" + msg = "You have not completed the previous Lesson/Quiz/Exercise" if is_moderator(user): return prof_manage(request, msg=msg) return view_module(request, module_id=module_id, @@ -608,6 +608,7 @@ def show_question(request, question, paper, error_message=None, notification=Non files = FileUpload.objects.filter(question_id=question.id, hide=False) course = Course.objects.get(id=course_id) module = course.learning_module.get(id=module_id) + all_modules = course.get_learning_modules() context = { 'question': question, 'paper': paper, @@ -621,7 +622,8 @@ def show_question(request, question, paper, error_message=None, notification=Non 'module': module, 'can_skip': can_skip, 'delay_time': delay_time, - 'quiz_type': quiz_type + 'quiz_type': quiz_type, + 'all_modules': all_modules } answers = paper.get_previous_answers(question) if answers: @@ -2330,12 +2332,13 @@ def show_lesson(request, lesson_id, module_id, course_id): learn_module = course.learning_module.get(id=module_id) learn_unit = learn_module.learning_unit.get(lesson_id=lesson_id) learning_units = learn_module.get_learning_units() + all_modules = course.get_learning_modules() if learn_unit.has_prerequisite(): if not learn_unit.is_prerequisite_passed(user, learn_module, course): - msg = "You have not completed the prerequisite" + msg = "You have not completed previous Lesson/Quiz/Exercise" return view_module(request, learn_module.id, course_id, msg=msg) context = {'lesson': learn_unit.lesson, 'user': user, - 'course': course, 'state': "lesson", + 'course': course, 'state': "lesson", "all_modules": all_modules, 'learning_units': learning_units, "current_unit": learn_unit, 'learning_module': learn_module} return my_render_to_response('yaksh/show_video.html', context) @@ -2517,13 +2520,14 @@ def get_next_unit(request, course_id, module_id, current_unit_id, current_learning_unit = learning_module.learning_unit.get( id=current_unit_id) - course_status = CourseStatus.objects.filter( - user=user, course_id=course_id, - ) if first_unit: next_unit = current_learning_unit else: next_unit = learning_module.get_next_unit(current_learning_unit.id) + + course_status = CourseStatus.objects.filter( + user=user, course_id=course_id, + ) if not course_status.exists(): course_status = CourseStatus.objects.create( user=user, course_id=course_id @@ -2535,6 +2539,14 @@ def get_next_unit(request, course_id, module_id, current_unit_id, if not first_unit: course_status.completed_units.add(current_learning_unit.id) + # if last unit of current module go to next module + is_last_unit = course.is_last_unit(learning_module, + current_learning_unit.id) + if is_last_unit: + next_module = course.next_module(learning_module.id) + return my_redirect("/exam/quizzes/view_module/{0}/{1}/".format( + next_module.id, course.id)) + # make next available unit as current unit course_status.current_unit = next_unit course_status.save() @@ -2620,14 +2632,17 @@ def view_module(request, module_id, course_id, msg=None): msg = "{0} is either expired or not active".format(course.name) return course_modules(request, course_id, msg) learning_module = course.learning_module.get(id=module_id) + all_modules = course.get_learning_modules() if learning_module.has_prerequisite(): if not learning_module.is_prerequisite_passed(user, course): msg = "You have not completed the previous learning module" return course_modules(request, course_id, msg) + learning_units = learning_module.get_learning_units() context['learning_units'] = learning_units context['learning_module'] = learning_module context['first_unit'] = learning_units[0] + context['all_modules'] = all_modules context['user'] = user context['course'] = course context['state'] = "module" |