Skip to content

Commit 2be30c3

Browse files
committed
Merge branch 'issue@reports' into paralapraca
2 parents 4683ad4 + e0030ea commit 2be30c3

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

core/models.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,30 @@ def units_done(self):
338338
return StudentProgress.objects.exclude(complete=None) \
339339
.filter(user=self.user, unit__lesson__course=self.course)
340340

341-
@property
342-
def course_finished(self):
341+
def _plpc_course_finished(self):
342+
activities = Activity.objects\
343+
.filter(unit__lesson__in=self.course.lessons
344+
.filter(status='published'),
345+
type='discussion')
346+
answers = Answer.objects\
347+
.filter(activity__in=activities, user=self.user)
348+
349+
return self.percent_progress() > self.min_percent_to_complete() and \
350+
activities.count() == answers.count()
351+
352+
def _course_finished(self):
343353
return self.percent_progress() >= \
344354
self.course.min_percent_to_complete
345355

346-
def can_emmit_receipt(self):
356+
@property
357+
def course_finished(self):
358+
return self._plpc_course_finished()
347359

360+
def can_emmit_receipt(self):
348361
if not self.get_current_class().user_can_certificate and not self.course_finished:
349362
return False
350-
351363
if self.get_current_class().user_can_certificate_even_without_progress and self.certificate.type == 'certificate':
352364
return True
353-
354365
return self.course_finished
355366

356367
def get_current_class(self):

0 commit comments

Comments
 (0)