diff options
author | prathamesh | 2018-02-08 14:29:38 +0530 |
---|---|---|
committer | adityacp | 2018-03-21 17:32:41 +0530 |
commit | b3f5721f3cf4225902000f2f76e5138135383792 (patch) | |
tree | 21ab4b9c9d4ad5d900c1de15f7254faea689094b /yaksh | |
parent | 06abd01fd28eb10aafd18dd60b790549e0233edc (diff) | |
download | online_test-b3f5721f3cf4225902000f2f76e5138135383792.tar.gz online_test-b3f5721f3cf4225902000f2f76e5138135383792.tar.bz2 online_test-b3f5721f3cf4225902000f2f76e5138135383792.zip |
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.
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 2 | ||||
-rw-r--r-- | yaksh/models.py | 34 | ||||
-rw-r--r-- | yaksh/templates/manage.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_modules.html | 1 | ||||
-rw-r--r-- | yaksh/views.py | 6 |
5 files changed, 42 insertions, 4 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 258a1ee..6e70d46 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -279,7 +279,7 @@ class CourseForm(forms.ModelForm): class Meta: model = Course fields = ['name', 'enrollment', 'active', 'code', 'instructions', - 'start_enroll_time', 'end_enroll_time'] + 'start_enroll_time', 'end_enroll_time', 'grading_system'] class ProfileForm(forms.ModelForm): 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): diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html index 17ce23e..2590655 100644 --- a/yaksh/templates/manage.html +++ b/yaksh/templates/manage.html @@ -18,7 +18,8 @@ <li><a href="{{ URL_ROOT }}/exam/manage/courses">Courses</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li> - <li><a href="{{ URL_ROOT }}/exam/manage/grader"> Grader </a></li> + <li><a href="{{ url_root }}/exam/manage/grader"> Grader </a></li> + <li><a href="{% url 'grades:grading_systems'%}"> Grading Systems </a></li> <li><a href="{{ URL_ROOT }}/exam/reset/changepassword">Change Password</a></li> <li><a href="{{ URL_ROOT }}/exam/viewprofile"> {{ user.get_full_name.title }} </a></li> <li><a href="{{URL_ROOT}}/exam/logout/" id="logout">Logout</a></li> diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html index fad1be0..eba7409 100644 --- a/yaksh/templates/yaksh/course_modules.html +++ b/yaksh/templates/yaksh/course_modules.html @@ -17,6 +17,7 @@ <center>{{ msg }}</center> </div> {% endif %} +<b>Grade: {% if grade %} {{ grade }} {% else %} Will be available once the course is complete {% endif %}</b> {% if learning_modules %} {% for module in learning_modules %} <div class="row well"> diff --git a/yaksh/views.py b/yaksh/views.py index 011b417..30b454b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2710,6 +2710,12 @@ def course_modules(request, course_id, msg=None): learning_modules = course.get_learning_modules() context = {"course": course, "learning_modules": learning_modules, "user": user, "msg": msg} + course_status = CourseStatus.objects.filter(course=course, user=user) + if course_status.exists(): + course_status = course_status.first() + if course_status.is_course_complete() and not course_status.grade: + course_status.calculate_total_marks() + context['grade'] = course_status.grade return my_render_to_response('yaksh/course_modules.html', context) |