Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
74ae54ca
Commit
74ae54ca
authored
May 22, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #28 from open-craft/fix-author-changes-ii
Test + fix an additional failure case
parents
ee363edf
4be1a4c8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
3 deletions
+62
-3
problem_builder/mentoring.py
+5
-0
problem_builder/tests/integration/base_test.py
+13
-0
problem_builder/tests/integration/test_author_changes.py
+43
-2
problem_builder/tests/integration/xml_templates/author_changes.xml
+1
-1
No files found.
problem_builder/mentoring.py
View file @
74ae54ca
...
...
@@ -281,6 +281,11 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
# Migrate stored data if necessary
self
.
migrate_fields
()
# Validate self.step:
num_steps
=
len
(
self
.
steps
)
if
self
.
step
>
num_steps
:
self
.
step
=
num_steps
fragment
=
Fragment
()
child_content
=
u""
...
...
problem_builder/tests/integration/base_test.py
View file @
74ae54ca
...
...
@@ -149,6 +149,19 @@ class MentoringAssessmentBaseTest(ProblemBuilderBaseTest):
self
.
assertIsNotNone
(
question_div
)
return
question_div
def
answer_mcq
(
self
,
number
,
name
,
value
,
mentoring
,
controls
,
is_last
=
False
):
self
.
expect_question_visible
(
number
,
mentoring
)
mentoring
.
find_element_by_css_selector
(
'input[name={}][value={}]'
.
format
(
name
,
value
))
.
click
()
controls
.
submit
.
click
()
if
is_last
:
self
.
wait_until_clickable
(
controls
.
review
)
controls
.
review
.
click
()
self
.
wait_until_hidden
(
controls
.
review
)
else
:
self
.
wait_until_clickable
(
controls
.
next_question
)
controls
.
next_question
.
click
()
class
GetChoices
(
object
):
""" Helper class for interacting with MCQ options """
...
...
problem_builder/tests/integration/test_author_changes.py
View file @
74ae54ca
...
...
@@ -2,7 +2,7 @@
If an author makes changes to the block after students have started using it, will bad things
happen?
"""
from
.base_test
import
ProblemBuilderBaseTest
from
.base_test
import
ProblemBuilderBaseTest
,
MentoringAssessmentBaseTest
import
re
...
...
@@ -12,7 +12,7 @@ class AuthorChangesTest(ProblemBuilderBaseTest):
"""
def
setUp
(
self
):
super
(
AuthorChangesTest
,
self
)
.
setUp
()
self
.
load_scenario
(
"author_changes.xml"
,
load_immediately
=
False
)
self
.
load_scenario
(
"author_changes.xml"
,
{
"mode"
:
"standard"
},
load_immediately
=
False
)
self
.
refresh_page
()
def
refresh_page
(
self
):
...
...
@@ -75,3 +75,44 @@ class AuthorChangesTest(ProblemBuilderBaseTest):
# Now, the student's score should be 1 out of 6 (only q3 is correct):
self
.
assertEqual
(
self
.
pb_block
.
score
.
percentage
,
17
)
class
AuthorChangesAssessmentTest
(
MentoringAssessmentBaseTest
):
"""
Test various scenarios involving author changes made to an assessment block already in use
"""
def
test_delete_question
(
self
):
""" Test that the assessment behaves correctly when deleting a question. """
pb_block_dom
,
controls
=
self
.
load_assessment_scenario
(
"author_changes.xml"
,
{
"mode"
:
"assessment"
})
# Answer each question, getting the first question wrong:
mentoring
=
pb_block_dom
.
find_element_by_css_selector
(
".mentoring"
)
self
.
answer_mcq
(
number
=
1
,
name
=
"q1"
,
value
=
"no"
,
mentoring
=
mentoring
,
controls
=
controls
,
is_last
=
False
)
self
.
answer_mcq
(
number
=
2
,
name
=
"q2"
,
value
=
"elegance"
,
mentoring
=
mentoring
,
controls
=
controls
,
is_last
=
False
)
pb_block_dom
.
find_element_by_css_selector
(
'textarea'
)
.
send_keys
(
"Hello world"
)
controls
.
submit
.
click
()
self
.
wait_until_clickable
(
controls
.
review
)
controls
.
review
.
click
()
self
.
wait_until_hidden
(
controls
.
review
)
# Delete question 3:
vertical
=
self
.
load_root_xblock
()
pb_block
=
vertical
.
runtime
.
get_block
(
vertical
.
children
[
0
])
self
.
assertEqual
(
pb_block
.
score
.
percentage
,
67
)
pb_block
.
children
=
[
pb_block
.
children
[
0
],
pb_block
.
children
[
1
]]
pb_block
.
save
()
pb_block_dom
,
controls
=
self
.
go_to_assessment
()
self
.
assertIn
(
"You scored 50
%
on this assessment."
,
pb_block_dom
.
text
)
self
.
assertIn
(
"You answered 1 question correctly."
,
pb_block_dom
.
text
)
self
.
assertIn
(
"You answered 1 question incorrectly."
,
pb_block_dom
.
text
)
controls
.
try_again
.
click
()
self
.
wait_until_hidden
(
controls
.
try_again
)
# Now answer again, getting a perfect score:
mentoring
=
pb_block_dom
.
find_element_by_css_selector
(
".mentoring"
)
self
.
answer_mcq
(
number
=
1
,
name
=
"q1"
,
value
=
"yes"
,
mentoring
=
mentoring
,
controls
=
controls
,
is_last
=
False
)
self
.
answer_mcq
(
number
=
2
,
name
=
"q2"
,
value
=
"elegance"
,
mentoring
=
mentoring
,
controls
=
controls
,
is_last
=
True
)
self
.
assertIn
(
"You scored 100
%
on this assessment."
,
mentoring
.
text
)
problem_builder/tests/integration/xml_templates/author_changes.xml
View file @
74ae54ca
<vertical_demo>
<problem-builder>
<problem-builder
mode=
"{{mode}}"
>
<pb-mcq
name=
"q1"
type=
"choices"
correct_choices=
'["yes"]'
question=
"So, do you like this Q1?"
>
<pb-choice
value=
"yes"
>
Yes
</pb-choice>
...
...
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