From a036819a0ca9c81fca85669660432f736ad23dcf Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 4 Apr 2018 15:39:57 +0530 Subject: Change in templates and js - Change course status template to view per student course progress - Change student dashboard to show progress for course and modules. - Add ajax to get per student data for course progress --- yaksh/static/yaksh/js/course.js | 97 +++++--------- yaksh/templates/yaksh/complete.html | 8 ++ yaksh/templates/yaksh/course_detail.html | 75 +++++------ yaksh/templates/yaksh/course_modules.html | 202 ++++++++++++++++-------------- yaksh/templates/yaksh/show_video.html | 6 +- yaksh/templates/yaksh/user_status.html | 44 +++++++ 6 files changed, 226 insertions(+), 206 deletions(-) create mode 100644 yaksh/templates/yaksh/user_status.html diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 1c64a3e..36e565a 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -42,7 +42,7 @@ $(function() { max_height: 200, height: 200 }); - }); +}); $("#send_mail").click(function(){ var subject = $("#subject").val(); @@ -66,79 +66,38 @@ $("#send_mail").click(function(){ return status; }); -// Download course status as csv -function exportTableToCSV($table, filename) { - var $headers = $table.find('tr:has(th)') - ,$rows = $table.find('tr:has(td)') - - // Temporary delimiter characters unlikely to be typed by keyboard - // This is to avoid accidentally splitting the actual contents - ,tmpColDelim = String.fromCharCode(11) // vertical tab character - ,tmpRowDelim = String.fromCharCode(0) // null character - - // actual delimiter characters for CSV format - ,colDelim = '","' - ,rowDelim = '"\r\n"'; - // Grab text from table into CSV formatted string - var csv = '"'; - csv += formatRows($headers.map(grabRow)); - csv += rowDelim; - csv += formatRows($rows.map(grabRow)) + '"'; - - // Data URI - var csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv); +// Table sorter for course details +$("table").tablesorter({}); - // For IE (tested 10+) - if (window.navigator.msSaveOrOpenBlob) { - var blob = new Blob([decodeURIComponent(encodeURI(csv))], { - type: "text/csv;charset=utf-8;" +// Get user course completion status +$('.user_data').click(function() { + var data = $(this).data('item-id'); + course_id = data.split("+")[0]; + student_id = data.split("+")[1]; + var status_div = $("#show_status_"+course_id+"_"+student_id); + if(!status_div.is(":visible")){ + var get_url = window.location.protocol + "//" + window.location.host + + "/exam/manage/get_user_status/" + course_id + "/" + student_id; + $.ajax({ + url: get_url, + timeout: 15000, + type: "GET", + dataType: "json", + contentType: 'application/json; charset=utf-8', + success: function(data) { + status_div.toggle(); + status_div.html(data.user_data); + }, + error: function(jqXHR, textStatus) { + alert("Unable to get user data. Please Try again later."); + } }); - navigator.msSaveBlob(blob, filename); } else { - $(this) - .attr({ - 'download': filename,'href': csvData - }); - } - - function formatRows(rows){ - return rows.get().join(tmpRowDelim) - .split(tmpRowDelim).join(rowDelim) - .split(tmpColDelim).join(colDelim); - } - // Grab and format a row from the table - function grabRow(i,row){ - var $row = $(row); - var $cols = $row.find('td'); - if(!$cols.length) $cols = $row.find('th'); - - return $cols.map(grabCol) - .get().join(tmpColDelim); + status_div.toggle(); } - // Grab and format a column from the table - function grabCol(j,col){ - var $col = $(col), - $text = $col.text(); - - return $text.replace('"', '""').replace("View Unit Status", '').replace("View Units", ""); // escape double quotes - - } -} - - -$("#export").click(function (event) { - var outputFile = $("#course_name").val().replace(" ", "_") + '.csv'; - - exportTableToCSV.apply(this, [$('#course_table'), outputFile]); }); -// Table sorter for course details -$("table").tablesorter({}); - -}); +$('[data-toggle="tooltip"]').tooltip(); -function view_status(unit){ - title_list = $(unit).attr("title").split("/"); - $(unit).attr("title", title_list.join("\n")); -} +}); // end document ready diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 0881bfe..567d01f 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -3,6 +3,14 @@ {% block pagetitle %}YAKSH{% endblock %} {% block content %} +{% if module_id and not user == "moderator" %} +
+
+ Note:- Please Click on the Next button to submit the quiz. Please do not close the browser + without clicking next. +
+
+{% endif %} {% csrf_token %} {% if paper.questions_answered.all or paper.questions_unanswered.all %}
diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index 9fcae68..d069b5d 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -2,7 +2,7 @@ {% load custom_filters %} {% block title %} Course Details {% endblock title %} -
+
{% block pagetitle %} Course Details for {{ course.name|title }} {% endblock %}
@@ -14,6 +14,12 @@ {% endblock %} {% block css %} + {% endblock %} {% block content %}
@@ -128,68 +134,51 @@ {% elif state == "course_status" %}
- Export to CSV

Course Status

- - + + + - - - - - - - - {% if modules %} - {% for module in modules %} - - {% endfor %} - {% else %} - - {% endif %} - {% for student in students %} + {% for student, grade, percent, unit in student_details %} + - {% if modules %} - {% for module in modules %} - - {% endfor %} - {% else %} - - {% endif %} {% endfor %} diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html index 6c93e97..5baa781 100644 --- a/yaksh/templates/yaksh/course_modules.html +++ b/yaksh/templates/yaksh/course_modules.html @@ -18,101 +18,117 @@ {% endif %} Grade: {% if grade %} {{ grade }} {% else %} Will be available once the course is complete {% endif %} -{% if learning_modules %} -
Sr No.StudentsTotalEmailCurrent UnitCourse Completion Percentage GradeModules
- {{module.name}} -
- ({{module.get_learning_units|length}} Units) -
- - View Units -
{{forloop.counter}}. + + {% if student.email %} + {{ student.email }} + {% else %} + {{ student.get_full_name|title}} + {% endif %} + + + - {{ student.get_full_name|title }} + {% if unit != "NA" %} + {% if unit.type == 'quiz' %} + {{unit.quiz.description}} + {% else %} + {{unit.lesson.name}} + {% endif %} + {% else %} + {{unit}} + {% endif%} - {% course_completion_percent course student as c_percent %} - {{c_percent}} % + {{percent}}% - {% course_grade course student as grade %} {{grade}} - {% module_completion_percent course module student as m_percent %} - {{m_percent}} % -
- - View Unit Status -
-------
- {% for module in learning_modules %} - - - + + {% endfor %} +
- - {{module.name|title}} - - - - - - View Lessons/Quizzes/Exercises -
- - - - - - - - {% for unit in module.get_learning_units %} - - - - - - - - {% endfor %} -
Lesson/Quiz/ExerciseStatusTypeView AnswerPaper
- {% if unit.type == "quiz" %} - {{unit.quiz.description}} - {% else %} - {{unit.lesson.name}} - {% endif %} - - {% get_unit_status course module unit user as status %} - {% if status == "completed" %} - {{status|title}} - - {% elif status == "inprogress" %} - {{status|title}} - - {% else %} - {{status|title}} - - {% endif %} - - {% if unit.type == "quiz" %} - {% if unit.quiz.is_exercise %} - Exercise - {% else %} - Quiz - {% endif %} - {% else %} - Lesson - {% endif %} - - {% if unit.type == "quiz" %} - {% if unit.quiz.view_answerpaper %} - - Can View +{% if modules %} +

+ Overall Course Progress +
+ {% if course_percentage <= 50 %} +
+ {% elif course_percentage <= 75 %} +
+ {% else %} +
+ {% endif %} + {{course_percentage}}% Completed +
+
+
+
+ + {% for module, percent in modules %} + + + + - - {% endfor %} -
+ + {{module.name|title}} + + + + + + View Lessons/Quizzes/Exercises +
+ + + + + + + + {% for unit in module.get_learning_units %} + + + + + + + {% endfor %} +
Lesson/Quiz/ExerciseStatusTypeView AnswerPaper
+ {% if unit.type == "quiz" %} + {{unit.quiz.description}} + {% else %} + {{unit.lesson.name}} + {% endif %} + + {% get_unit_status course module unit user as status %} + {% if status == "completed" %} + {{status|title}} + + {% elif status == "inprogress" %} + {{status|title}} + + {% else %} + {{status|title}} + + {% endif %} + + {% if unit.type == "quiz" %} + {% if unit.quiz.is_exercise %} + Exercise + {% else %} + Quiz + {% endif %} + {% else %} + Lesson + {% endif %} + + {% if unit.type == "quiz" %} + {% if unit.quiz.view_answerpaper %} + + Can View + {% else %} + + Cannot view now + {% endif %} + {% else %} + ------ + {% endif %} +
+
+
+
+ {% if percent <= 50 %} +
+ {% elif percent <= 75 %} +
{% else %} - - Cannot view now +
{% endif %} - {% else %} - ------ - {% endif %} -
-
-
- {% get_module_status user module course as module_status %} - Status: - {% if module_status == "completed" %} - - {{module_status|title}} - - {% elif module_status == "inprogress" %} - - {{module_status|title}} - - {% else %} - - {{module_status|title}} - - {% endif %} -
+ {{percent}}% Completed +
+ +
+ + {% else %}

No lectures found

{% endif %} diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index 17f9d86..eae3762 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -11,7 +11,11 @@ {% block main %}