Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ebed8cd4
Commit
ebed8cd4
authored
Aug 20, 2015
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9339 from edx/ziafazal/SOL-493
ziafazal/SOL-493: Fetch scores via ScoresClient
parents
63a49d6d
05e2cc94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
lms/djangoapps/courseware/entrance_exams.py
+13
-16
lms/djangoapps/courseware/tests/test_entrance_exam.py
+4
-2
No files found.
lms/djangoapps/courseware/entrance_exams.py
View file @
ebed8cd4
...
...
@@ -4,8 +4,7 @@ This file contains all entrance exam related utils/logic.
from
django.conf
import
settings
from
courseware.access
import
has_access
from
courseware.model_data
import
FieldDataCache
from
courseware.models
import
StudentModule
from
courseware.model_data
import
FieldDataCache
,
ScoresClient
from
opaque_keys.edx.keys
import
UsageKey
from
student.models
import
EntranceExamConfiguration
from
util.milestones_helpers
import
get_required_content
...
...
@@ -88,21 +87,19 @@ def _calculate_entrance_exam_score(user, course_descriptor, exam_modules):
"""
Calculates the score (percent) of the entrance exam using the provided modules
"""
# All of the exam module ids
exam_module_ids
=
[
exam_module
.
location
for
exam_module
in
exam_modules
]
# All of the corresponding student module records
student_modules
=
StudentModule
.
objects
.
filter
(
student
=
user
,
course_id
=
course_descriptor
.
id
,
module_state_key__in
=
exam_module_ids
,
)
student_module_dict
=
{}
for
student_module
in
student_modules
:
student_module_dict
[
unicode
(
student_module
.
module_state_key
)]
=
{
'grade'
:
student_module
.
grade
,
'max_grade'
:
student_module
.
max_grade
}
scores_client
=
ScoresClient
(
course_descriptor
.
id
,
user
.
id
)
locations
=
[
exam_module
.
location
for
exam_module
in
exam_modules
]
scores_client
.
fetch_scores
(
locations
)
# Iterate over all of the exam modules to get score of user for each of them
for
exam_module
in
exam_modules
:
exam_module_score
=
scores_client
.
get
(
exam_module
.
location
)
if
exam_module_score
:
student_module_dict
[
unicode
(
exam_module
.
location
)]
=
{
'grade'
:
exam_module_score
.
correct
,
'max_grade'
:
exam_module_score
.
total
}
exam_percentage
=
0
module_percentages
=
[]
ignore_categories
=
[
'course'
,
'chapter'
,
'sequential'
,
'vertical'
]
...
...
lms/djangoapps/courseware/tests/test_entrance_exam.py
View file @
ebed8cd4
...
...
@@ -283,13 +283,15 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
test entrance exam score. we will hit the method get_entrance_exam_score to verify exam score.
"""
exam_score
=
get_entrance_exam_score
(
self
.
request
,
self
.
course
)
with
self
.
assertNumQueries
(
1
):
exam_score
=
get_entrance_exam_score
(
self
.
request
,
self
.
course
)
self
.
assertEqual
(
exam_score
,
0
)
answer_entrance_exam_problem
(
self
.
course
,
self
.
request
,
self
.
problem_1
)
answer_entrance_exam_problem
(
self
.
course
,
self
.
request
,
self
.
problem_2
)
exam_score
=
get_entrance_exam_score
(
self
.
request
,
self
.
course
)
with
self
.
assertNumQueries
(
1
):
exam_score
=
get_entrance_exam_score
(
self
.
request
,
self
.
course
)
# 50 percent exam score should be achieved.
self
.
assertGreater
(
exam_score
*
100
,
50
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment