From b3f5721f3cf4225902000f2f76e5138135383792 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 8 Feb 2018 14:29:38 +0530 Subject: Add weightage for Quiz and Create Grading System App App Name: grades Grading System provides with the grade for a given value. It contains different grade ranges. Has its own default grading system. Allows you to modify and add grading system wth grade ranges. To be done: - Need to add README - Good UI - There are fields like can_be_used and order in models for future use. - More tests App name: Yaksh Now every quiz has a default weightage of 100%, can be changed. An aggregate is calculated for a given course. Using grades app a grade is provide to the aggregate value. --- yaksh/models.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index f065190..f76feed 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -35,7 +35,7 @@ from yaksh.code_server import ( from yaksh.settings import SERVER_POOL_PORT, SERVER_HOST_NAME from django.conf import settings from django.forms.models import model_to_dict - +from grades.models import GradingSystem languages = ( ("python", "Python"), @@ -311,7 +311,8 @@ class Quiz(models.Model): allow_skip = models.BooleanField("Allow students to skip questions", default=True) - weightage = models.FloatField(default=1.0) + weightage = models.FloatField(help_text='Will be considered as percentage', + default=100) is_exercise = models.BooleanField(default=False) @@ -551,6 +552,8 @@ class Course(models.Model): null=True ) + grading_system = models.ForeignKey(GradingSystem, null=True, blank=True) + objects = CourseManager() def _create_duplicate_instance(self, creator, course_name=None): @@ -737,6 +740,33 @@ class CourseStatus(models.Model): grade = models.CharField(max_length=255, null=True, blank=True) total_marks = models.FloatField(default=0.0) + def set_grade(self): + grade = self.course.grading_system.get_grade(self.total_marks) + self.grade = grade + + def calculate_total_marks(self): + if self.is_course_complete(): + quizzes = self.course.get_quizzes() + total_weightage = 0 + sum = 0 + for quiz in quizzes: + total_weightage += quiz.weightage + marks = AnswerPaper.objects.get_user_best_of_attempts_marks( + quiz, self.user.id, self.course.id) + out_of = quiz.questionpaper_set.first().total_marks + sum += (marks/out_of)*quiz.weightage + self.total_marks = (sum/total_weightage)*100 + self.set_grade() + + + def is_course_complete(self): + modules = self.course.get_learning_modules() + complete = False + for module in modules: + complete = module.get_status(self.user, self.course) == 'completed' + if not complete: + break + return complete ############################################################################### class ConcurrentUser(models.Model): -- cgit From f06a5d2ffbb1a06320935841a4ba24720e651985 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Tue, 13 Feb 2018 12:48:19 +0530 Subject: Change default grading system behaviour Cannot edit default system. Code as per PEP8 standards. Updates grade after regrade or manual grading Field change from total marks to percentage Removed unused fields from grades app --- yaksh/models.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index f76feed..1ecb1f8 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -738,13 +738,22 @@ class CourseStatus(models.Model): course = models.ForeignKey(Course) user = models.ForeignKey(User) grade = models.CharField(max_length=255, null=True, blank=True) - total_marks = models.FloatField(default=0.0) + percentage = models.FloatField(default=0.0) + + def get_grade(self): + return self.grade def set_grade(self): - grade = self.course.grading_system.get_grade(self.total_marks) - self.grade = grade + if self.is_course_complete(): + self.calculate_percentage() + if self.course.grading_system is None: + grading_system = GradingSystem.objects.get(name='default') + else: + grading_system = self.course.grading_system + grade = grading_system.get_grade(self.percentage) + self.grade = grade - def calculate_total_marks(self): + def calculate_percentage(self): if self.is_course_complete(): quizzes = self.course.get_quizzes() total_weightage = 0 @@ -755,8 +764,7 @@ class CourseStatus(models.Model): quiz, self.user.id, self.course.id) out_of = quiz.questionpaper_set.first().total_marks sum += (marks/out_of)*quiz.weightage - self.total_marks = (sum/total_weightage)*100 - self.set_grade() + self.percentage = (sum/total_weightage)*100 def is_course_complete(self): -- cgit From 65c368a1360a83c2b10458ec61a4b74d9ac8e9f5 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 1 Mar 2018 19:00:55 +0530 Subject: Show student grade in course status page --- yaksh/models.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 1ecb1f8..32d7b3d 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -725,6 +725,14 @@ class Course(models.Model): percent = round((count / len(modules))) return percent + def get_grade(self, user): + course_status = CourseStatus.objects.filter(course=self, user=user) + if course_status.exists(): + grade = course_status.first().get_grade() + else: + grade = "NA" + return grade + def __str__(self): return self.name @@ -752,6 +760,7 @@ class CourseStatus(models.Model): grading_system = self.course.grading_system grade = grading_system.get_grade(self.percentage) self.grade = grade + self.save() def calculate_percentage(self): if self.is_course_complete(): @@ -765,7 +774,7 @@ class CourseStatus(models.Model): out_of = quiz.questionpaper_set.first().total_marks sum += (marks/out_of)*quiz.weightage self.percentage = (sum/total_weightage)*100 - + self.save() def is_course_complete(self): modules = self.course.get_learning_modules() @@ -776,6 +785,7 @@ class CourseStatus(models.Model): break return complete + ############################################################################### class ConcurrentUser(models.Model): concurrent_user = models.OneToOneField(User) -- cgit