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
2a68f9b1
Commit
2a68f9b1
authored
Nov 02, 2017
by
Dillon Dumesnil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved tests(exclamation point)
parent
70fff66e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
137 deletions
+178
-137
openedx/tests/xblock_integration/test_review_xblock.py
+176
-136
requirements/edx/github.txt
+2
-1
No files found.
openedx/tests/xblock_integration/test_review_xblock.py
View file @
2a68f9b1
"""
"""
Test scenarios for the review xblock.
Test scenarios for the review xblock.
"""
"""
import
ddt
import
unittest
import
unittest
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -10,15 +11,14 @@ from nose.plugins.attrib import attr
...
@@ -10,15 +11,14 @@ from nose.plugins.attrib import attr
from
lms.djangoapps.courseware.tests.factories
import
GlobalStaffFactory
from
lms.djangoapps.courseware.tests.factories
import
GlobalStaffFactory
from
lms.djangoapps.courseware.tests.helpers
import
LoginEnrollmentTestCase
from
lms.djangoapps.courseware.tests.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
review
import
get_review_ids
from
review
import
get_review_ids
import
crum
import
crum
class
TestReviewXBlock
(
Shared
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestReviewXBlock
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Create the test environment with the review xblock.
Create the test environment with the review xblock.
"""
"""
...
@@ -27,18 +27,16 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -27,18 +27,16 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
]
]
XBLOCK_NAMES
=
[
'review'
]
XBLOCK_NAMES
=
[
'review'
]
@classmethod
def
setUp
(
self
):
def
setUpClass
(
cls
):
super
(
TestReviewXBlock
,
self
)
.
setUp
()
# Nose runs setUpClass methods even if a class decorator says to skip
# Nose runs setUpClass methods even if a class decorator says to skip
# the class: https://github.com/nose-devs/nose/issues/946
# the class: https://github.com/nose-devs/nose/issues/946
# So, skip the test class here if we are not in the LMS.
# So, skip the test class here if we are not in the LMS.
if
settings
.
ROOT_URLCONF
!=
'lms.urls'
:
if
settings
.
ROOT_URLCONF
!=
'lms.urls'
:
raise
unittest
.
SkipTest
(
'Test only valid in lms'
)
raise
unittest
.
SkipTest
(
'Test only valid in lms'
)
super
(
TestReviewXBlock
,
cls
)
.
setUpClass
()
# Set up for the actual course
# Set up for the actual course
cls
.
course_actual
=
CourseFactory
.
create
(
self
.
course_actual
=
CourseFactory
.
create
(
display_name
=
'Review_Test_Course_ACTUAL'
,
display_name
=
'Review_Test_Course_ACTUAL'
,
org
=
'DillonX'
,
org
=
'DillonX'
,
number
=
'DAD101x'
,
number
=
'DAD101x'
,
...
@@ -46,147 +44,139 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -46,147 +44,139 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
)
)
# There are multiple sections so the learner can load different
# There are multiple sections so the learner can load different
# problems, but should only be shown review problems from what they have loaded
# problems, but should only be shown review problems from what they have loaded
with
cls
.
store
.
bulk_operations
(
cls
.
course_actual
.
id
,
emit_signals
=
False
):
with
self
.
store
.
bulk_operations
(
self
.
course_actual
.
id
,
emit_signals
=
False
):
cls
.
chapter_actual
=
ItemFactory
.
create
(
self
.
chapter_actual
=
ItemFactory
.
create
(
parent
=
cls
.
course_actual
,
display_name
=
'Overview'
parent
=
self
.
course_actual
,
display_name
=
'Overview'
)
)
cls
.
section1_actual
=
ItemFactory
.
create
(
self
.
section1_actual
=
ItemFactory
.
create
(
parent
=
cls
.
chapter_actual
,
display_name
=
'Section 1'
parent
=
self
.
chapter_actual
,
display_name
=
'Section 1'
)
)
cls
.
unit1_actual
=
ItemFactory
.
create
(
self
.
unit1_actual
=
ItemFactory
.
create
(
parent
=
cls
.
section1_actual
,
display_name
=
'New Unit 1'
parent
=
self
.
section1_actual
,
display_name
=
'New Unit 1'
)
)
cls
.
xblock1_actual
=
ItemFactory
.
create
(
self
.
xblock1_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_actual
,
parent
=
self
.
unit1_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 1'
display_name
=
'Problem 1'
)
)
cls
.
xblock2_actual
=
ItemFactory
.
create
(
self
.
xblock2_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_actual
,
parent
=
self
.
unit1_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 2'
display_name
=
'Problem 2'
)
)
cls
.
xblock3_actual
=
ItemFactory
.
create
(
self
.
xblock3_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_actual
,
parent
=
self
.
unit1_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 3'
display_name
=
'Problem 3'
)
)
cls
.
xblock4_actual
=
ItemFactory
.
create
(
self
.
xblock4_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_actual
,
parent
=
self
.
unit1_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 4'
display_name
=
'Problem 4'
)
)
cls
.
section2_actual
=
ItemFactory
.
create
(
self
.
section2_actual
=
ItemFactory
.
create
(
parent
=
cls
.
chapter_actual
,
display_name
=
'Section 2'
parent
=
self
.
chapter_actual
,
display_name
=
'Section 2'
)
)
cls
.
unit2_actual
=
ItemFactory
.
create
(
self
.
unit2_actual
=
ItemFactory
.
create
(
parent
=
cls
.
section2_actual
,
display_name
=
'New Unit 2'
parent
=
self
.
section2_actual
,
display_name
=
'New Unit 2'
)
)
cls
.
xblock5_actual
=
ItemFactory
.
create
(
self
.
xblock5_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit2_actual
,
parent
=
self
.
unit2_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 5'
display_name
=
'Problem 5'
)
)
cls
.
section3_actual
=
ItemFactory
.
create
(
self
.
section3_actual
=
ItemFactory
.
create
(
parent
=
cls
.
chapter_actual
,
display_name
=
'Section 3'
parent
=
self
.
chapter_actual
,
display_name
=
'Section 3'
)
)
cls
.
unit3_actual
=
ItemFactory
.
create
(
self
.
unit3_actual
=
ItemFactory
.
create
(
parent
=
cls
.
section3_actual
,
display_name
=
'New Unit 3'
parent
=
self
.
section3_actual
,
display_name
=
'New Unit 3'
)
)
cls
.
xblock6_actual
=
ItemFactory
.
create
(
self
.
xblock6_actual
=
ItemFactory
.
create
(
parent
=
cls
.
unit3_actual
,
parent
=
self
.
unit3_actual
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 6'
display_name
=
'Problem 6'
)
)
# This is the actual review xBlock
# This is the actual review xBlock
# When implemented, the review is in its own section as a
# When implemented, the review is in its own section as a
# stand-alone unit.
# stand-alone unit.
cls
.
review_section_actual
=
ItemFactory
.
create
(
self
.
review_section_actual
=
ItemFactory
.
create
(
parent
=
cls
.
chapter_actual
,
display_name
=
'Review Subsection'
parent
=
self
.
chapter_actual
,
display_name
=
'Review Subsection'
)
)
cls
.
review_unit_actual
=
ItemFactory
.
create
(
self
.
review_unit_actual
=
ItemFactory
.
create
(
parent
=
cls
.
review_section_actual
,
display_name
=
'Review Unit'
parent
=
self
.
review_section_actual
,
display_name
=
'Review Unit'
)
cls
.
review_xblock_actual
=
ItemFactory
.
create
(
parent
=
cls
.
review_unit_actual
,
category
=
'review'
,
display_name
=
'Review Tool'
)
)
cls
.
course_actual_url
=
reverse
(
self
.
course_actual_url
=
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
'course_id'
:
unicode
(
cls
.
course_actual
.
id
),
'course_id'
:
unicode
(
self
.
course_actual
.
id
),
'chapter'
:
'Overview'
,
'chapter'
:
'Overview'
,
'section'
:
'Welcome'
,
'section'
:
'Welcome'
,
}
}
)
)
# Set up for the review course where the review problems are hosted
# Set up for the review course where the review problems are hosted
cls
.
course_review
=
CourseFactory
.
create
(
self
.
course_review
=
CourseFactory
.
create
(
display_name
=
'Review_Test_Course_REVIEW'
,
display_name
=
'Review_Test_Course_REVIEW'
,
org
=
'DillonX'
,
org
=
'DillonX'
,
number
=
'DAD101
rx
'
,
number
=
'DAD101
x_review
'
,
run
=
'3T2017'
run
=
'3T2017'
)
)
with
cls
.
store
.
bulk_operations
(
cls
.
course_review
.
id
,
emit_signals
=
True
):
with
self
.
store
.
bulk_operations
(
self
.
course_review
.
id
,
emit_signals
=
True
):
cls
.
chapter_review
=
ItemFactory
.
create
(
self
.
chapter_review
=
ItemFactory
.
create
(
parent
=
cls
.
course_review
,
display_name
=
'Overview'
parent
=
self
.
course_review
,
display_name
=
'Overview'
)
)
cls
.
section_review
=
ItemFactory
.
create
(
self
.
section_review
=
ItemFactory
.
create
(
parent
=
cls
.
chapter_review
,
display_name
=
'Welcome'
parent
=
self
.
chapter_review
,
display_name
=
'Welcome'
)
)
cls
.
unit1_review
=
ItemFactory
.
create
(
self
.
unit1_review
=
ItemFactory
.
create
(
parent
=
cls
.
section_review
,
display_name
=
'New Unit 1'
parent
=
self
.
section_review
,
display_name
=
'New Unit 1'
)
)
cls
.
xblock1_review
=
ItemFactory
.
create
(
self
.
xblock1_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_review
,
parent
=
self
.
unit1_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 1'
display_name
=
'Problem 1'
)
)
cls
.
xblock2_review
=
ItemFactory
.
create
(
self
.
xblock2_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_review
,
parent
=
self
.
unit1_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 2'
display_name
=
'Problem 2'
)
)
cls
.
xblock3_review
=
ItemFactory
.
create
(
self
.
xblock3_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_review
,
parent
=
self
.
unit1_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 3'
display_name
=
'Problem 3'
)
)
cls
.
xblock4_review
=
ItemFactory
.
create
(
self
.
xblock4_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit1_review
,
parent
=
self
.
unit1_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 4'
display_name
=
'Problem 4'
)
)
cls
.
unit2_review
=
ItemFactory
.
create
(
self
.
unit2_review
=
ItemFactory
.
create
(
parent
=
cls
.
section_review
,
display_name
=
'New Unit 2'
parent
=
self
.
section_review
,
display_name
=
'New Unit 2'
)
)
cls
.
xblock5_review
=
ItemFactory
.
create
(
self
.
xblock5_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit2_review
,
parent
=
self
.
unit2_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 5'
display_name
=
'Problem 5'
)
)
cls
.
unit3_review
=
ItemFactory
.
create
(
self
.
unit3_review
=
ItemFactory
.
create
(
parent
=
cls
.
section_review
,
display_name
=
'New Unit 3'
parent
=
self
.
section_review
,
display_name
=
'New Unit 3'
)
)
cls
.
xblock6_review
=
ItemFactory
.
create
(
self
.
xblock6_review
=
ItemFactory
.
create
(
parent
=
cls
.
unit3_review
,
parent
=
self
.
unit3_review
,
category
=
'problem'
,
category
=
'problem'
,
display_name
=
'Problem 6'
display_name
=
'Problem 6'
)
)
cls
.
course_review_url
=
reverse
(
self
.
course_review_url
=
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
'course_id'
:
unicode
(
cls
.
course_review
.
id
),
'course_id'
:
unicode
(
self
.
course_review
.
id
),
'chapter'
:
'Overview'
,
'chapter'
:
'Overview'
,
'section'
:
'Welcome'
,
'section'
:
'Welcome'
,
}
}
)
)
def
setUp
(
self
):
super
(
TestReviewXBlock
,
self
)
.
setUp
()
for
idx
,
student
in
enumerate
(
self
.
STUDENTS
):
for
idx
,
student
in
enumerate
(
self
.
STUDENTS
):
username
=
'u{}'
.
format
(
idx
)
username
=
'u{}'
.
format
(
idx
)
self
.
create_account
(
username
,
student
[
'email'
],
student
[
'password'
])
self
.
create_account
(
username
,
student
[
'email'
],
student
[
'password'
])
...
@@ -203,6 +193,7 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -203,6 +193,7 @@ class TestReviewXBlock(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
@attr
(
shard
=
1
)
@attr
(
shard
=
1
)
@ddt.ddt
class
TestReviewFunctions
(
TestReviewXBlock
):
class
TestReviewFunctions
(
TestReviewXBlock
):
"""
"""
Check that the essential functions of the Review xBlock work as expected.
Check that the essential functions of the Review xBlock work as expected.
...
@@ -218,6 +209,12 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -218,6 +209,12 @@ class TestReviewFunctions(TestReviewXBlock):
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
review_xblock_actual
=
ItemFactory
.
create
(
parent
=
self
.
review_unit_actual
,
category
=
'review'
,
display_name
=
'Review Tool'
,
)
# Loading the review section
# Loading the review section
response
=
self
.
client
.
get
(
reverse
(
response
=
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
...
@@ -229,25 +226,29 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -229,25 +226,29 @@ class TestReviewFunctions(TestReviewXBlock):
))
))
expected_h2
=
'Nothing to review'
expected_h2
=
'Nothing to review'
expected_p
=
'Oh no! You have not interacted with enough problems yet to have any to review. '
\
'Go back and try more problems so you have content to review.'
self
.
assertIn
(
expected_h2
,
response
.
content
)
self
.
assertIn
(
expected_h2
,
response
.
content
)
self
.
assertIn
(
expected_p
,
response
.
content
)
def
test_too_few_review_problems
(
self
):
@ddt.data
(
2
,
5
,
6
,
7
)
def
test_too_few_review_problems
(
self
,
num_desired
):
"""
"""
If a user does not have enough problems to review, they should
If a user does not have enough problems to review, they should
receive a response to go out and try more problems so they have
receive a response to go out and try more problems so they have
material to review.
material to review.
TODO: This test is hardcoded to assume the number of review
problems to show is > 1 (which it should be). Ideally this could
be dependent on the number of desired review problems
"""
"""
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
# Loading 1 problem so the learner has something in the CSM
# Want to load fewer problems than num_desired
if
num_desired
>
4
:
self
.
client
.
get
(
reverse
(
'courseware_section'
,
kwargs
=
{
'course_id'
:
self
.
course_actual
.
id
,
'chapter'
:
self
.
chapter_actual
.
location
.
name
,
'section'
:
self
.
section1_actual
.
location
.
name
,
}
))
if
num_desired
>
5
:
self
.
client
.
get
(
reverse
(
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
...
@@ -256,6 +257,22 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -256,6 +257,22 @@ class TestReviewFunctions(TestReviewXBlock):
'section'
:
self
.
section2_actual
.
location
.
name
,
'section'
:
self
.
section2_actual
.
location
.
name
,
}
}
))
))
if
num_desired
>
6
:
self
.
client
.
get
(
reverse
(
'courseware_section'
,
kwargs
=
{
'course_id'
:
self
.
course_actual
.
id
,
'chapter'
:
self
.
chapter_actual
.
location
.
name
,
'section'
:
self
.
section3_actual
.
location
.
name
,
}
))
self
.
review_xblock_actual
=
ItemFactory
.
create
(
parent
=
self
.
review_unit_actual
,
category
=
'review'
,
display_name
=
'Review Tool'
,
num_desired
=
num_desired
)
# Loading the review section
# Loading the review section
response
=
self
.
client
.
get
(
reverse
(
response
=
self
.
client
.
get
(
reverse
(
...
@@ -268,25 +285,19 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -268,25 +285,19 @@ class TestReviewFunctions(TestReviewXBlock):
))
))
expected_h2
=
'Nothing to review'
expected_h2
=
'Nothing to review'
expected_p
=
'Oh no! You have not interacted with enough problems yet to have any to review. '
\
'Go back and try more problems so you have content to review.'
self
.
assertIn
(
expected_h2
,
response
.
content
)
self
.
assertIn
(
expected_h2
,
response
.
content
)
self
.
assertIn
(
expected_p
,
response
.
content
)
def
test_review_problems
(
self
):
@ddt.data
(
2
,
3
,
4
,
5
,
6
)
def
test_review_problems
(
self
,
num_desired
):
"""
"""
If a user has enough problems to review, they should
If a user has enough problems to review, they should
receive a response where there are review problems for them to try.
receive a response where there are review problems for them to try.
TODO: This test is hardcoded to assume the number of review
problems to show is <= 5. Ideally this should
be dependent on the number of desired review problems
"""
"""
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
# Loading
5
problems so the learner has enough problems in the CSM
# Loading problems so the learner has enough problems in the CSM
self
.
client
.
get
(
reverse
(
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
...
@@ -303,7 +314,21 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -303,7 +314,21 @@ class TestReviewFunctions(TestReviewXBlock):
'section'
:
self
.
section2_actual
.
location
.
name
,
'section'
:
self
.
section2_actual
.
location
.
name
,
}
}
))
))
self
.
client
.
get
(
reverse
(
'courseware_section'
,
kwargs
=
{
'course_id'
:
self
.
course_actual
.
id
,
'chapter'
:
self
.
chapter_actual
.
location
.
name
,
'section'
:
self
.
section3_actual
.
location
.
name
,
}
))
self
.
review_xblock_actual
=
ItemFactory
.
create
(
parent
=
self
.
review_unit_actual
,
category
=
'review'
,
display_name
=
'Review Tool'
,
num_desired
=
num_desired
)
# Loading the review section
# Loading the review section
response
=
self
.
client
.
get
(
reverse
(
response
=
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
...
@@ -314,37 +339,36 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -314,37 +339,36 @@ class TestReviewFunctions(TestReviewXBlock):
}
}
))
))
expected_header_text
=
'Below are 5 review problems for you to try out and see '
\
expected_header_text
=
'Review Component'
'how well you have mastered the material of this class'
# The problems are defaulted to correct upon load
# The problems are defaulted to correct upon load, so the
# correctness text should be displayed as follows
# This happens because the problems "raw_possible" field is 0 and the
# This happens because the problems "raw_possible" field is 0 and the
# "raw_earned" field is also 0.
# "raw_earned" field is also 0.
expected_correctness_text
=
'When you originally tried this problem, you ended '
\
expected_correctness_text
=
'correct'
'up being correct after 0 attempts.'
expected_problems
=
[
'Review Problem 1'
,
'Review Problem 2'
,
'Review Problem 3'
,
expected_problems
=
[
'Review Problem 1'
,
'Review Problem 2'
,
'Review Problem 3'
,
'Review Problem 4'
,
'Review Problem 5'
]
'Review Problem 4'
,
'Review Problem 5'
,
'Review Problem 6'
]
expected_url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
rx
/3T2017+type@problem+block@'
expected_url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
x_review
/3T2017+type@problem+block@'
self
.
assertIn
(
expected_header_text
,
response
.
content
)
self
.
assertIn
(
expected_header_text
,
response
.
content
)
self
.
assertEqual
(
response
.
content
.
count
(
expected_correctness_text
),
5
)
self
.
assertEqual
(
response
.
content
.
count
(
expected_correctness_text
),
num_desired
)
# Since the problems are randomly selected, we have to check
# the correct number of problems are returned.
count
=
0
for
problem
in
expected_problems
:
for
problem
in
expected_problems
:
self
.
assertIn
(
problem
,
response
.
content
)
if
problem
in
response
.
content
:
self
.
assertEqual
(
response
.
content
.
count
(
expected_url_beginning
),
5
)
count
+=
1
self
.
assertEqual
(
count
,
num_desired
)
self
.
assertEqual
(
response
.
content
.
count
(
expected_url_beginning
),
num_desired
)
def
test_review_problem_urls
(
self
):
@ddt.data
(
1
,
2
,
3
,
4
,
5
,
6
)
def
test_review_problem_urls
(
self
,
num_desired
):
"""
"""
Verify that the URLs returned from the Review xBlock are valid and
Verify that the URLs returned from the Review xBlock are valid and
correct URLs for the problems the learner has seen.
correct URLs for the problems the learner has seen.
TODO: This test is hardcoded to assume the number of review
problems to show is 5. Ideally this should
be dependent on the number of desired review problems
"""
"""
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
# Loading
5
problems so the learner has enough problems in the CSM
# Loading problems so the learner has enough problems in the CSM
self
.
client
.
get
(
reverse
(
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
...
@@ -361,38 +385,49 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -361,38 +385,49 @@ class TestReviewFunctions(TestReviewXBlock):
'section'
:
self
.
section2_actual
.
location
.
name
,
'section'
:
self
.
section2_actual
.
location
.
name
,
}
}
))
))
self
.
client
.
get
(
reverse
(
'courseware_section'
,
kwargs
=
{
'course_id'
:
self
.
course_actual
.
id
,
'chapter'
:
self
.
chapter_actual
.
location
.
name
,
'section'
:
self
.
section3_actual
.
location
.
name
,
}
))
user
=
User
.
objects
.
get
(
email
=
self
.
STUDENTS
[
0
][
'email'
])
user
=
User
.
objects
.
get
(
email
=
self
.
STUDENTS
[
0
][
'email'
])
crum
.
set_current_user
(
user
)
crum
.
set_current_user
(
user
)
result_urls
=
get_review_ids
.
get_problems
(
5
,
self
.
course_actual
.
id
)
result_urls
=
get_review_ids
.
get_problems
(
num_desired
,
self
.
course_actual
.
id
)
url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
rx
/3T2017+type@problem+block@'
url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
x_review
/3T2017+type@problem+block@'
expected_urls
=
[
expected_urls
=
[
(
url_beginning
+
'i4x://DillonX/DAD101x/problem/Problem_1'
,
'correct'
,
0
),
(
url_beginning
+
'Problem_1'
,
True
,
0
),
(
url_beginning
+
'i4x://DillonX/DAD101x/problem/Problem_2'
,
'correct'
,
0
),
(
url_beginning
+
'Problem_2'
,
True
,
0
),
(
url_beginning
+
'i4x://DillonX/DAD101x/problem/Problem_3'
,
'correct'
,
0
),
(
url_beginning
+
'Problem_3'
,
True
,
0
),
(
url_beginning
+
'i4x://DillonX/DAD101x/problem/Problem_4'
,
'correct'
,
0
),
(
url_beginning
+
'Problem_4'
,
True
,
0
),
(
url_beginning
+
'i4x://DillonX/DAD101x/problem/Problem_5'
,
'correct'
,
0
)
(
url_beginning
+
'Problem_5'
,
True
,
0
),
(
url_beginning
+
'Problem_6'
,
True
,
0
)
]
]
# Since the problems are randomly selected, we have to check
# the correct number of urls are returned.
count
=
0
for
url
in
expected_urls
:
for
url
in
expected_urls
:
self
.
assertIn
(
url
,
result_urls
)
if
url
in
result_urls
:
count
+=
1
self
.
assertEqual
(
count
,
num_desired
)
def
test_review_problem_urls_unique_problem
(
self
):
@ddt.data
(
1
,
2
,
3
,
4
,
5
)
def
test_review_problem_urls_unique_problem
(
self
,
num_desired
):
"""
"""
Verify that the URLs returned from the Review xBlock are valid and
Verify that the URLs returned from the Review xBlock are valid and
correct URLs for the problems the learner has seen. This test will give
correct URLs for the problems the learner has seen. This test will give
a unique problem to a learner and verify only that learner sees
a unique problem to a learner and verify only that learner sees
it as a review
it as a review
TODO: This test is hardcoded to assume the number of review
problems to show is 5. Ideally this should
be dependent on the number of desired review problems
"""
"""
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_actual
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
self
.
enroll_student
(
self
.
STUDENTS
[
0
][
'email'
],
self
.
STUDENTS
[
0
][
'password'
],
self
.
course_review
)
# Loading
5
problems so the learner has enough problems in the CSM
# Loading problems so the learner has enough problems in the CSM
self
.
client
.
get
(
reverse
(
self
.
client
.
get
(
reverse
(
'courseware_section'
,
'courseware_section'
,
kwargs
=
{
kwargs
=
{
...
@@ -412,21 +447,26 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -412,21 +447,26 @@ class TestReviewFunctions(TestReviewXBlock):
user
=
User
.
objects
.
get
(
email
=
self
.
STUDENTS
[
0
][
'email'
])
user
=
User
.
objects
.
get
(
email
=
self
.
STUDENTS
[
0
][
'email'
])
crum
.
set_current_user
(
user
)
crum
.
set_current_user
(
user
)
result_urls
=
get_review_ids
.
get_problems
(
5
,
self
.
course_actual
.
id
)
result_urls
=
get_review_ids
.
get_problems
(
num_desired
,
self
.
course_actual
.
id
)
url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
rx
/3T2017+type@problem+block@'
url_beginning
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
x_review
/3T2017+type@problem+block@'
expected_urls
=
[
expected_urls
=
[
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_1'
,
'correct'
,
0
),
(
url_beginning
+
'
Problem_1'
,
True
,
0
),
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_2'
,
'correct'
,
0
),
(
url_beginning
+
'
Problem_2'
,
True
,
0
),
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_3'
,
'correct'
,
0
),
(
url_beginning
+
'
Problem_3'
,
True
,
0
),
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_4'
,
'correct'
,
0
),
(
url_beginning
+
'
Problem_4'
,
True
,
0
),
# This is the unique problem
# This is the unique problem
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_6'
,
'correct'
,
0
)
(
url_beginning
+
'
Problem_6'
,
True
,
0
)
]
]
expected_not_loaded_problem
=
(
url_beginning
+
'
i4x://DillonX/DAD101x/problem/Problem_5'
,
'correct'
,
0
)
expected_not_loaded_problem
=
(
url_beginning
+
'
Problem_5'
,
True
,
0
)
# Since the problems are randomly selected, we have to check
# the correct number of urls are returned.
count
=
0
for
url
in
expected_urls
:
for
url
in
expected_urls
:
self
.
assertIn
(
url
,
result_urls
)
if
url
in
result_urls
:
count
+=
1
self
.
assertEqual
(
count
,
num_desired
)
self
.
assertNotIn
(
expected_not_loaded_problem
,
result_urls
)
self
.
assertNotIn
(
expected_not_loaded_problem
,
result_urls
)
"""
"""
...
@@ -460,7 +500,7 @@ class TestReviewFunctions(TestReviewXBlock):
...
@@ -460,7 +500,7 @@ class TestReviewFunctions(TestReviewXBlock):
crum
.
set_current_user
(
user
)
crum
.
set_current_user
(
user
)
result_url
=
get_review_ids
.
get_vertical
(
self
.
course_actual
.
id
)
result_url
=
get_review_ids
.
get_vertical
(
self
.
course_actual
.
id
)
expected_url
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
rx
/3T2017+type@'
\
expected_url
=
'https://courses.edx.org/xblock/block-v1:DillonX/DAD101
x_review
/3T2017+type@'
\
'vertical+block@
i4x://DillonX/DAD101x/chapter/
New_Unit_1'
'vertical+block@New_Unit_1'
self
.
assertEqual
(
result_url
,
expected_url
)
self
.
assertEqual
(
result_url
,
expected_url
)
requirements/edx/github.txt
View file @
2a68f9b1
...
@@ -108,4 +108,5 @@ git+https://github.com/mitodl/edx-sga.git@d019b8a050c056db535e3ff13c93096145a932
...
@@ -108,4 +108,5 @@ git+https://github.com/mitodl/edx-sga.git@d019b8a050c056db535e3ff13c93096145a932
git+https://github.com/open-craft/xblock-poll@7ba819b968fe8faddb78bb22e1fe7637005eb414#egg=xblock-poll==1.2.7
git+https://github.com/open-craft/xblock-poll@7ba819b968fe8faddb78bb22e1fe7637005eb414#egg=xblock-poll==1.2.7
git+https://github.com/edx-solutions/xblock-drag-and-drop-v2@v2.0.18#egg=xblock-drag-and-drop-v2==2.0.18
git+https://github.com/edx-solutions/xblock-drag-and-drop-v2@v2.0.18#egg=xblock-drag-and-drop-v2==2.0.18
# TODO: Deploy xblock-review to PyPI and pin it before going to master. Talk to Feanil if any questions
# TODO: Deploy xblock-review to PyPI and pin it before going to master. Talk to Feanil if any questions
-e git+https://github.com/Dillon-Dumesnil/xblock-review@master#egg=xblock-review
# For the purpose of being able to build during this PR time, I'm setting the branch to PR. Will switch to PyPI later
-e git+https://github.com/Dillon-Dumesnil/xblock-review@PR#egg=xblock-review
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