Commit 465b0d3a authored by Bruno Martin's avatar Bruno Martin
Browse files

change activity for LeaningObject

parent 866c2e31
......@@ -417,7 +417,8 @@ class CourseStudent(models.Model):
.filter(user=self.user, unit__lesson__course=self.course)
def _plpc_course_finished(self):
activities = Activity.objects\
from courses_learning_objects.models import LearningObject, Answer
activities = LearningObject.objects\
.filter(unit__lesson__in=self.course.lessons
.filter(status='published'),
type='discussion')
......@@ -524,6 +525,7 @@ class CourseStudent(models.Model):
Returns a list with dictionaries with keys name (lesson name), slug (lesson slug) and progress (percent lesson progress, decimal)
"""
# TODO refator to make one query to count unts done for all lessons
from courses_learning_objects.models import LearningObject, Answer
progress_list = []
for lesson in self.course.lessons.filter(status='published'):
lesson_progress = {}
......@@ -536,7 +538,7 @@ class CourseStudent(models.Model):
units_done_len = self.units_done_by_lesson(lesson).count()
lesson_progress['progress'] = 100 * units_done_len / units_len
lesson_progress['finish'] = self.get_lesson_finish_time(lesson)
activities = Activity.objects.filter(unit__lesson=lesson, type='discussion')
activities = LearningObject.objects.filter(unit__lesson=lesson, type='discussion')
i = 0
for activity in activities:
i = i + 1
......@@ -848,8 +850,8 @@ class Lesson(PositionedModel):
return staticfiles_storage.url('img/lesson-default.png')
def activity_count(self):
from activities.models import Activity
return Activity.objects.filter(unit__lesson=self).count()
from courses_learning_objects.models import LearningObject
return LearningObject.objects.filter(unit__lesson=self).count()
def unit_count(self):
return self.units.all().count()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment