Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
EvaP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CourseEval
EvaP
Commits
cf9cfff7
Unverified
Commit
cf9cfff7
authored
Feb 7, 2022
by
Kakadus
Committed by
GitHub
Feb 7, 2022
Browse files
Options
Downloads
Patches
Plain Diff
Fix #1691: Make evaluation weight add up to 100% (#1695)
parent
482aa81d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
evap/results/tests/test_views.py
+28
-1
28 additions, 1 deletion
evap/results/tests/test_views.py
evap/results/tools.py
+2
-2
2 additions, 2 deletions
evap/results/tools.py
with
30 additions
and
3 deletions
evap/results/tests/test_views.py
+
28
−
1
View file @
cf9cfff7
...
@@ -20,6 +20,7 @@ from evap.evaluation.models import (
...
@@ -20,6 +20,7 @@ from evap.evaluation.models import (
Evaluation
,
Evaluation
,
Question
,
Question
,
Questionnaire
,
Questionnaire
,
RatingAnswerCounter
,
Semester
,
Semester
,
UserProfile
,
UserProfile
,
)
)
...
@@ -31,7 +32,7 @@ from evap.evaluation.tests.tools import (
...
@@ -31,7 +32,7 @@ from evap.evaluation.tests.tools import (
)
)
from
evap.results.exporters
import
TextAnswerExporter
from
evap.results.exporters
import
TextAnswerExporter
from
evap.results.tools
import
cache_results
from
evap.results.tools
import
cache_results
from
evap.results.views
import
get_evaluations_with_prefetched_data
from
evap.results.views
import
get_evaluations_with_prefetched_data
,
warm_up_template_cache
from
evap.staff.tests.utils
import
WebTestStaffMode
,
helper_exit_staff_mode
,
run_in_staff_mode
from
evap.staff.tests.utils
import
WebTestStaffMode
,
helper_exit_staff_mode
,
run_in_staff_mode
...
@@ -264,6 +265,32 @@ class TestResultsView(WebTest):
...
@@ -264,6 +265,32 @@ class TestResultsView(WebTest):
caches
[
"
sessions
"
].
clear
()
caches
[
"
sessions
"
].
clear
()
caches
[
"
results
"
].
clear
()
caches
[
"
results
"
].
clear
()
def
test_evaluation_weight_sums
(
self
):
"""
Regression test for #1691
"""
student
=
baker
.
make
(
UserProfile
,
email
=
"
student@institution.example.com
"
)
course
=
baker
.
make
(
Course
)
published
=
baker
.
make
(
Evaluation
,
course
=
course
,
name_en
=
iter
([
"
ev1
"
,
"
ev2
"
,
"
ev3
"
]),
name_de
=
iter
([
"
ev1
"
,
"
ev2
"
,
"
ev3
"
]),
state
=
iter
([
Evaluation
.
State
.
NEW
,
Evaluation
.
State
.
PUBLISHED
,
Evaluation
.
State
.
PUBLISHED
]),
weight
=
iter
([
8
,
3
,
4
]),
is_single_result
=
True
,
_quantity
=
3
,
)[
1
:]
contributions
=
[
e
.
general_contribution
for
e
in
published
]
baker
.
make
(
RatingAnswerCounter
,
contribution
=
iter
(
contributions
),
answer
=
2
,
count
=
2
,
_quantity
=
len
(
published
))
warm_up_template_cache
(
published
)
page
=
self
.
app
.
get
(
self
.
url
,
user
=
student
)
decoded
=
page
.
body
.
decode
()
self
.
assertTrue
(
decoded
.
index
(
"
ev2
"
)
<
decoded
.
index
(
"
20%
"
)
<
decoded
.
index
(
"
ev3
"
)
<
decoded
.
index
(
"
26%
"
))
self
.
assertNotContains
(
page
,
"
53%
"
)
class
TestGetEvaluationsWithPrefetchedData
(
TestCase
):
class
TestGetEvaluationsWithPrefetchedData
(
TestCase
):
def
test_returns_correct_participant_count
(
self
):
def
test_returns_correct_participant_count
(
self
):
...
...
This diff is collapsed.
Click to expand it.
evap/results/tools.py
+
2
−
2
View file @
cf9cfff7
...
@@ -298,8 +298,8 @@ def get_evaluations_with_course_result_attributes(evaluations):
...
@@ -298,8 +298,8 @@ def get_evaluations_with_course_result_attributes(evaluations):
)
)
course_id_evaluation_weight_sum_pairs
=
(
course_id_evaluation_weight_sum_pairs
=
(
Course
.
objects
.
filter
(
evaluations__in
=
evaluations
)
Course
.
objects
.
annotate
(
Sum
(
"
evaluations__weight
"
)
)
.
annotate
(
Sum
(
"
evaluations__weight
"
))
.
filter
(
pk__in
=
Course
.
objects
.
filter
(
evaluations__in
=
evaluations
))
# is needed, see #1691
.
values_list
(
"
id
"
,
"
evaluations__weight__sum
"
)
.
values_list
(
"
id
"
,
"
evaluations__weight__sum
"
)
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment