summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/models.py3
-rw-r--r--yaksh/templates/yaksh/course_progress.html13
-rw-r--r--yaksh/urls.py2
-rw-r--r--yaksh/views.py25
4 files changed, 41 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index e161543..072c1b5 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -648,6 +648,9 @@ class LearningUnit(models.Model):
order=self.order, type="lesson", lesson=new_lesson)
return new_unit
+ def __str__(self):
+ return self.lesson.name if self.lesson else self.quiz.description
+
###############################################################################
class LearningModule(models.Model):
diff --git a/yaksh/templates/yaksh/course_progress.html b/yaksh/templates/yaksh/course_progress.html
index a833c92..826f84b 100644
--- a/yaksh/templates/yaksh/course_progress.html
+++ b/yaksh/templates/yaksh/course_progress.html
@@ -4,10 +4,19 @@
{% if student_details %}
<div class="text-center">
<h3>Course Progress</h3>
- <div class="col">
- Number Of Students: {{ students_no }}
+ <br>
+ <div class="row">
+ <div class="col">
+ Number Of Students: {{ students_no }}
+ </div>
+ <div class="col">
+ <a href="{% url 'yaksh:download_course_progress' course.id %}" class="btn btn-info">
+ <i class="fa fa-download"></i>&nbsp;Download Data
+ </a>
+ </div>
</div>
</div>
+ <br>
{% include "yaksh/paginator.html" %}
<table class="tablesorter table table-bordered table-responsive-sm" id="course_table" data-sortlist="[0,0]">
<thead>
diff --git a/yaksh/urls.py b/yaksh/urls.py
index 49c3d4f..b53d335 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -218,4 +218,6 @@ urlpatterns = [
views.get_course_modules, name="get_course_modules"),
url(r'^manage/course/teachers/(?P<course_id>\d+)',
views.course_teachers, name="course_teachers"),
+ url(r'^manage/download/course/progress/(?P<course_id>\d+)',
+ views.download_course_progress, name="download_course_progress"),
]
diff --git a/yaksh/views.py b/yaksh/views.py
index 5d2d560..58fe6e2 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -3155,3 +3155,28 @@ def get_course_modules(request, course_id):
modules = course.get_learning_modules()
context = {"modules": modules, "is_modules": True, "course": course}
return my_render_to_response(request, 'yaksh/course_detail.html', context)
+
+
+@login_required
+@email_verified
+def download_course_progress(request, course_id):
+ user = request.user
+ if not is_moderator(user):
+ raise Http404('You are not allowed to view this page!')
+ course = get_object_or_404(Course, pk=course_id)
+ if not course.is_creator(user) and not course.is_teacher(user):
+ raise Http404('This course does not belong to you')
+ students = course.students.order_by("-id")
+ stud_details = [(student.get_full_name(), course.get_grade(student),
+ course.get_completion_percent(student),
+ course.get_current_unit(student))
+ for student in students]
+ response = HttpResponse(content_type='text/csv')
+ response['Content-Disposition'] = 'attachment; filename="{0}.csv"'.format(
+ (course.name).lower().replace(' ', '_'))
+ header = ['Name', 'Grade', 'Completion Percent', 'Current Unit']
+ writer = csv.writer(response)
+ writer.writerow(header)
+ for student in stud_details:
+ writer.writerow(student)
+ return response