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
2615f20c
Commit
2615f20c
authored
May 18, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed submit button being enabled after page reload
parent
03621b1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
problem_builder/public/js/mentoring_standard_view.js
+16
-8
problem_builder/tests/integration/test_mentoring.py
+10
-0
No files found.
problem_builder/public/js/mentoring_standard_view.js
View file @
2615f20c
...
@@ -4,7 +4,7 @@ function MentoringStandardView(runtime, element, mentoring) {
...
@@ -4,7 +4,7 @@ function MentoringStandardView(runtime, element, mentoring) {
var
callIfExists
=
mentoring
.
callIfExists
;
var
callIfExists
=
mentoring
.
callIfExists
;
function
handleSubmitResults
(
response
)
{
function
handleSubmitResults
(
response
,
disable_submit
)
{
messagesDOM
.
empty
().
hide
();
messagesDOM
.
empty
().
hide
();
$
.
each
(
response
.
results
||
[],
function
(
index
,
result_spec
)
{
$
.
each
(
response
.
results
||
[],
function
(
index
,
result_spec
)
{
...
@@ -28,9 +28,16 @@ function MentoringStandardView(runtime, element, mentoring) {
...
@@ -28,9 +28,16 @@ function MentoringStandardView(runtime, element, mentoring) {
messagesDOM
.
prepend
(
'<div class="title1">'
+
mentoring
.
data
.
feedback_label
+
'</div>'
);
messagesDOM
.
prepend
(
'<div class="title1">'
+
mentoring
.
data
.
feedback_label
+
'</div>'
);
messagesDOM
.
show
();
messagesDOM
.
show
();
}
}
// this method is called on successful submission and on page load
// results will be empty only for initial load if no submissions was made
// in such case we must allow submission to support submitting empty read-only long answer recaps
if
(
disable_submit
||
response
.
results
.
length
>
0
)
{
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
}
}
}
function
handleSubmitError
(
jqXHR
,
textStatus
,
errorThrown
)
{
function
handleSubmitError
(
jqXHR
,
textStatus
,
errorThrown
,
disable_submit
)
{
if
(
textStatus
==
"error"
)
{
if
(
textStatus
==
"error"
)
{
var
errMsg
=
errorThrown
;
var
errMsg
=
errorThrown
;
// Check if there's a more specific JSON error message:
// Check if there's a more specific JSON error message:
...
@@ -44,6 +51,10 @@ function MentoringStandardView(runtime, element, mentoring) {
...
@@ -44,6 +51,10 @@ function MentoringStandardView(runtime, element, mentoring) {
mentoring
.
setContent
(
messagesDOM
,
errMsg
);
mentoring
.
setContent
(
messagesDOM
,
errMsg
);
messagesDOM
.
show
();
messagesDOM
.
show
();
}
}
if
(
disable_submit
)
{
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
}
}
}
function
calculate_results
(
handler_name
,
disable_submit
)
{
function
calculate_results
(
handler_name
,
disable_submit
)
{
...
@@ -59,12 +70,9 @@ function MentoringStandardView(runtime, element, mentoring) {
...
@@ -59,12 +70,9 @@ function MentoringStandardView(runtime, element, mentoring) {
if
(
submitXHR
)
{
if
(
submitXHR
)
{
submitXHR
.
abort
();
submitXHR
.
abort
();
}
}
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
)).
success
(
handleSubmitResults
).
error
(
handleSubmitError
);
submitXHR
=
$
.
post
(
handlerUrl
,
JSON
.
stringify
(
data
))
.
success
(
function
(
response
)
{
handleSubmitResults
(
response
,
disable_submit
);
})
if
(
disable_submit
)
{
.
error
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
handleSubmitError
(
jqXHR
,
textStatus
,
errorThrown
,
disable_submit
);
});
var
disable_submit_callback
=
function
(){
submitDOM
.
attr
(
'disabled'
,
'disabled'
);
};
submitXHR
.
success
(
disable_submit_callback
).
error
(
disable_submit_callback
);
}
}
}
function
get_results
(){
function
get_results
(){
...
...
problem_builder/tests/integration/test_mentoring.py
View file @
2615f20c
...
@@ -170,6 +170,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -170,6 +170,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
submit
=
mentoring
.
find_element_by_css_selector
(
'.submit input.input-main'
)
answer_checkmark
=
answer
.
find_element_by_xpath
(
"parent::*"
)
.
find_element_by_css_selector
(
".answer-checkmark"
)
answer_checkmark
=
answer
.
find_element_by_xpath
(
"parent::*"
)
.
find_element_by_css_selector
(
".answer-checkmark"
)
...
@@ -181,6 +182,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -181,6 +182,7 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
for
i
in
range
(
5
):
for
i
in
range
(
5
):
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
_assert_feedback_hidden
(
rating
,
i
)
self
.
assertFalse
(
messages
.
is_displayed
())
self
.
assertFalse
(
messages
.
is_displayed
())
self
.
assertFalse
(
submit
.
is_enabled
())
def
test_persists_feedback_on_page_reload
(
self
):
def
test_persists_feedback_on_page_reload
(
self
):
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
...
@@ -195,7 +197,15 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
...
@@ -195,7 +197,15 @@ class ProblemBuilderQuestionnaireBlockTest(ProblemBuilderBaseTest):
mentoring
=
self
.
go_to_view
(
"student_view"
)
mentoring
=
self
.
go_to_view
(
"student_view"
)
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
answer
,
mcq
,
mrq
,
rating
=
self
.
_get_controls
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
messages
=
self
.
_get_messages_element
(
mentoring
)
submit
=
mentoring
.
find_element_by_css_selector
(
'.submit input.input-main'
)
self
.
_standard_checks
(
answer
,
mcq
,
mrq
,
rating
,
messages
,
only_selected
=
True
)
self
.
_standard_checks
(
answer
,
mcq
,
mrq
,
rating
,
messages
,
only_selected
=
True
)
# after reloading submit is disabled...
self
.
assertFalse
(
submit
.
is_enabled
())
# ...until some changes are done
self
.
click_choice
(
mrq
,
"Its elegance"
)
self
.
assertTrue
(
submit
.
is_enabled
())
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
def
test_given_perfect_score_in_past_loads_current_result
(
self
):
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
mentoring
=
self
.
load_scenario
(
"feedback_persistence.xml"
)
...
...
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