diff --git a/Instructor/static/js/rubrics/rubric-grade-widget.js b/Instructor/static/js/rubrics/rubric-grade-widget.js index 0236d03..88065e3 100644 --- a/Instructor/static/js/rubrics/rubric-grade-widget.js +++ b/Instructor/static/js/rubrics/rubric-grade-widget.js @@ -53,8 +53,8 @@ function update_total_score(scores) { let max = 0; for (let i = 0; i < scores.length; i++) { let score = scores[i]; - total += score === -1 ? 0 : score; - max += score === -1 ? 0 : get_max(i); + total += score; + max += get_max(i); } report_lst[0] = `Grade: ${total.toFixed(1)}`; report_lst[1] = max.toFixed(1); diff --git a/Main/forms.py b/Main/forms.py index 352334f..d945082 100644 --- a/Main/forms.py +++ b/Main/forms.py @@ -136,14 +136,13 @@ class GradeReviewForm(ModelForm): """ scores = CharField(max_length=200, widget=GradeReviewWidget(), - help_text="Please fill out each row in the rubric." - " If a row does not apply to this specific assignment, select \"N/A\"") + help_text="Please fill out each row in the rubric.") _validation_schema = { "type": "array", "items": { "type": "number", - "minimum": -1 + "minimum": 0 } } diff --git a/Main/migrations/0003_auto_20211214_1313.py b/Main/migrations/0003_auto_20211214_1313.py new file mode 100644 index 0000000..155205f --- /dev/null +++ b/Main/migrations/0003_auto_20211214_1313.py @@ -0,0 +1,26 @@ +# Generated by Django 3.2.9 on 2021-12-14 13:13 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('Instructor', '0002_initial'), + ('Main', '0002_auto_20211214_1249'), + ] + + operations = [ + migrations.RemoveField( + model_name='review', + name='rubric', + ), + migrations.AddField( + model_name='review', + name='rubric', + field=models.ForeignKey(default=1, help_text='The rubric the reviewer will use to grade your code', + on_delete=django.db.models.deletion.CASCADE, related_name='source_rubric', + to='Instructor.rubric'), + preserve_default=False, + ), + ] diff --git a/Main/models.py b/Main/models.py index 57bf84e..3f355fa 100644 --- a/Main/models.py +++ b/Main/models.py @@ -90,7 +90,7 @@ class Review(BaseModel): schoology_id = models.CharField(max_length=10, null=True, help_text="The ID of the schoology assignment that this review pertains to") status = models.CharField(choices=Status.choices, default=Status.OPEN, max_length=1) - rubric = models.ForeignKey("Instructor.Rubric", on_delete=models.CASCADE, related_name="source_rubric", + rubric = models.ForeignKey("Instructor.Rubric", related_name="source_rubric", on_delete=models.CASCADE, help_text="The rubric the reviewer will use to grade your code") additional_comments = models.TextField(blank=True, null=True, help_text="Any additional comments you have on the code") @@ -126,14 +126,9 @@ class Review(BaseModel): """ if self.status == Review.Status.CLOSED: - my_score = 0 - max_score = self.rubric.max_score - for scoredRow in self.scoredrow_set.all(): - if scoredRow.score == -1: - max_score -= scoredRow.source_row.max_score - else: - my_score += scoredRow.score - return f'{my_score}/{max_score}' + my_score = self.scoredrow_set.all().aggregate(models.Sum('score')) + max_score = self.scoredrow_set.all().aggregate(models.Sum('source_row__max_score')) + return f'{my_score["score__sum"]}/{max_score["source_row__max_score__sum"]}' else: return None diff --git a/Main/templates/widgets/rubric_grade.html b/Main/templates/widgets/rubric_grade.html index cfd7a65..4f37cc6 100644 --- a/Main/templates/widgets/rubric_grade.html +++ b/Main/templates/widgets/rubric_grade.html @@ -17,8 +17,6 @@ {% endfor %} -