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
40ff34ff
Commit
40ff34ff
authored
May 07, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restoring feedback on reload for stadnard-mode mentoring + tests
parent
395c4034
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
15 deletions
+48
-15
problem_builder/public/js/mentoring_standard_view.js
+8
-7
problem_builder/tests/integration/base_test.py
+7
-0
problem_builder/tests/integration/test_messages.py
+0
-7
problem_builder/tests/integration/test_questionnaire.py
+33
-1
No files found.
problem_builder/public/js/mentoring_standard_view.js
View file @
40ff34ff
...
...
@@ -28,8 +28,6 @@ function MentoringStandardView(runtime, element, mentoring) {
messagesDOM
.
prepend
(
'<div class="title1">'
+
gettext
(
'Feedback'
)
+
'</div>'
);
messagesDOM
.
show
();
}
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
}
function
handleSubmitError
(
jqXHR
,
textStatus
,
errorThrown
)
{
...
...
@@ -45,12 +43,10 @@ function MentoringStandardView(runtime, element, mentoring) {
mentoring
.
setContent
(
messagesDOM
,
errMsg
);
messagesDOM
.
show
();
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
}
}
function
calculate_results
(
handler_name
)
{
function
calculate_results
(
handler_name
,
disable_submit
)
{
var
data
=
{};
var
children
=
mentoring
.
children
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
...
...
@@ -64,14 +60,19 @@ function MentoringStandardView(runtime, element, mentoring) {
submitXHR
.
abort
();
}
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
)).
success
(
handleSubmitResults
).
error
(
handleSubmitError
);
if
(
disable_submit
)
{
var
disable_submit_callback
=
function
(){
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
};
submitXHR
.
success
(
disable_submit_callback
).
error
(
disable_submit_callback
);
}
}
function
get_results
(){
calculate_results
(
'get_results'
);
calculate_results
(
'get_results'
,
false
);
}
function
submit
()
{
calculate_results
(
'submit'
);
calculate_results
(
'submit'
,
true
);
}
function
clearResults
()
{
...
...
problem_builder/tests/integration/base_test.py
View file @
40ff34ff
...
...
@@ -85,6 +85,13 @@ class ProblemBuilderBaseTest(SeleniumXBlockTest, PopupCheckMixin):
submit
.
click
()
self
.
wait_until_disabled
(
submit
)
def
click_choice
(
self
,
container
,
choice_text
):
""" Click on the choice label with the specified text """
for
label
in
container
.
find_elements_by_css_selector
(
'.choices .choice label'
):
if
choice_text
in
label
.
text
:
label
.
click
()
break
class
MentoringBaseTest
(
SeleniumBaseTest
,
PopupCheckMixin
):
module_name
=
__name__
...
...
problem_builder/tests/integration/test_messages.py
View file @
40ff34ff
...
...
@@ -50,13 +50,6 @@ class MessagesTest(ProblemBuilderBaseTest):
message_text
=
message_text
[
8
:]
.
lstrip
()
self
.
assertEqual
(
MESSAGES
[
msg_type
],
message_text
)
def
click_choice
(
self
,
container
,
choice_text
):
""" Click on the choice label with the specified text """
for
label
in
container
.
find_elements_by_css_selector
(
'.choices .choice label'
):
if
choice_text
in
label
.
text
:
label
.
click
()
break
@ddt.data
(
(
"One"
,
COMPLETED
),
(
"Two"
,
COMPLETED
),
...
...
problem_builder/tests/integration/test_questionnaire.py
View file @
40ff34ff
...
...
@@ -24,7 +24,7 @@ import ddt
from
mock
import
patch
,
Mock
from
problem_builder
import
MentoringBlock
from
.base_test
import
MentoringBaseTest
from
.base_test
import
MentoringBaseTest
,
ProblemBuilderBaseTest
# Classes ###########################################################
...
...
@@ -292,3 +292,35 @@ class QuestionnaireBlockAprosThemeTest(QuestionnaireBlockTest):
Test MRQ/MCQ questions without the LMS theme which is on by default.
"""
pass
@ddt.ddt
class
ProblemBuilderQuestionnaireBlockTest
(
ProblemBuilderBaseTest
):
def
_get_choice_feedback_popup
(
self
,
mentoring
,
choice_index
):
choices
=
mentoring
.
find_elements_by_css_selector
(
".choices-list .choice"
)
target_choice
=
choices
[
choice_index
]
return
target_choice
.
find_element_by_css_selector
(
".choice-tips"
)
def
_get_messages_element
(
self
,
mentoring
):
return
mentoring
.
find_element_by_css_selector
(
'.messages'
)
@ddt.data
((
"One"
,
0
),
(
"Two"
,
1
))
@ddt.unpack
def
test_persists_feedback_on_page_reload
(
self
,
choice_value
,
choice_index
):
mentoring
=
self
.
load_scenario
(
"messages.xml"
,
{
"max_attempts"
:
1
})
self
.
click_choice
(
mentoring
,
choice_value
)
self
.
click_submit
(
mentoring
)
feedback_popup
=
self
.
_get_choice_feedback_popup
(
mentoring
,
choice_index
)
messages
=
self
.
_get_messages_element
(
mentoring
)
self
.
assertTrue
(
feedback_popup
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
# now, reload the page
mentoring
=
self
.
go_to_view
(
"student_view"
)
feedback_popup
=
self
.
_get_choice_feedback_popup
(
mentoring
,
choice_index
)
messages
=
self
.
_get_messages_element
(
mentoring
)
self
.
assertTrue
(
feedback_popup
.
is_displayed
())
self
.
assertTrue
(
messages
.
is_displayed
())
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