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
7eb4970f
Commit
7eb4970f
authored
Mar 14, 2013
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1671 from MITx/fix/will/save_button_regression
Fix/will/save button regression
parents
4b5837ff
ce5e8689
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
41 deletions
+67
-41
common/lib/xmodule/xmodule/capa_module.py
+27
-12
common/lib/xmodule/xmodule/tests/test_capa_module.py
+40
-29
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
7eb4970f
...
...
@@ -310,11 +310,26 @@ class CapaModule(XModule):
is_survey_question
=
(
self
.
max_attempts
==
0
)
needs_reset
=
self
.
is_completed
()
and
self
.
rerandomize
==
"always"
# If the student has unlimited attempts, and their answers
# are not randomized, then we do not need a save button
# because they can use the "Check" button without consequences.
#
# The consequences we want to avoid are:
# * Using up an attempt (if max_attempts is set)
# * Changing the current problem, and no longer being
# able to view it (if rerandomize is "always")
#
# In those cases. the if statement below is false,
# and the save button can still be displayed.
#
if
self
.
max_attempts
is
None
and
self
.
rerandomize
!=
"always"
:
return
False
# If the problem is closed (and not a survey question with max_attempts==0),
# then do NOT show the
reset
button
# then do NOT show the
save
button
# If we're waiting for the user to reset a randomized problem
# then do NOT show the
reset
button
if
(
self
.
closed
()
and
not
is_survey_question
)
or
needs_reset
:
# then do NOT show the
save
button
el
if
(
self
.
closed
()
and
not
is_survey_question
)
or
needs_reset
:
return
False
else
:
return
True
...
...
@@ -403,7 +418,7 @@ class CapaModule(XModule):
# if we want to show a check button, and False otherwise
# This works because non-empty strings evaluate to True
if
self
.
should_show_check_button
():
check_button
=
self
.
check_button_name
()
check_button
=
self
.
check_button_name
()
else
:
check_button
=
False
...
...
@@ -556,7 +571,7 @@ class CapaModule(XModule):
else
:
answers
=
self
.
lcp
.
get_question_answers
()
# answers (eg <solution>) may have embedded images
# answers (eg <solution>) may have embedded images
# but be careful, some problems are using non-string answer dicts
new_answers
=
dict
()
for
answer_id
in
answers
:
...
...
@@ -606,7 +621,7 @@ class CapaModule(XModule):
to 'input_1' in the returned dict)
'''
answers
=
dict
()
for
key
in
get
:
# e.g. input_resistor_1 ==> resistor_1
_
,
_
,
name
=
key
.
partition
(
'_'
)
...
...
@@ -729,7 +744,7 @@ class CapaModule(XModule):
event_info
[
'answers'
]
=
answers
# Too late. Cannot submit
if
self
.
closed
()
and
not
self
.
max_attempts
==
0
:
if
self
.
closed
()
and
not
self
.
max_attempts
==
0
:
event_info
[
'failure'
]
=
'closed'
self
.
system
.
track_function
(
'save_problem_fail'
,
event_info
)
return
{
'success'
:
False
,
...
...
@@ -747,7 +762,7 @@ class CapaModule(XModule):
self
.
system
.
track_function
(
'save_problem_success'
,
event_info
)
msg
=
"Your answers have been saved"
if
not
self
.
max_attempts
==
0
:
if
not
self
.
max_attempts
==
0
:
msg
+=
" but not graded. Hit 'Check' to grade them."
return
{
'success'
:
True
,
'msg'
:
msg
}
...
...
@@ -784,7 +799,7 @@ class CapaModule(XModule):
# reset random number generator seed (note the self.lcp.get_state()
# in next line)
self
.
lcp
.
seed
=
None
self
.
lcp
=
LoncapaProblem
(
self
.
definition
[
'data'
],
self
.
location
.
html_id
(),
self
.
lcp
.
get_state
(),
...
...
@@ -793,7 +808,7 @@ class CapaModule(XModule):
event_info
[
'new_state'
]
=
self
.
lcp
.
get_state
()
self
.
system
.
track_function
(
'reset_problem'
,
event_info
)
return
{
'success'
:
True
,
return
{
'success'
:
True
,
'html'
:
self
.
get_problem_html
(
encapsulate
=
False
)}
...
...
@@ -821,13 +836,13 @@ class CapaDescriptor(RawDescriptor):
def
get_context
(
self
):
_context
=
RawDescriptor
.
get_context
(
self
)
_context
.
update
({
'markdown'
:
self
.
metadata
.
get
(
'markdown'
,
''
),
'enable_markdown'
:
'markdown'
in
self
.
metadata
})
'enable_markdown'
:
'markdown'
in
self
.
metadata
})
return
_context
@property
def
editable_metadata_fields
(
self
):
"""Remove any metadata from the editable fields which have their own editor or shouldn't be edited by user."""
subset
=
[
field
for
field
in
super
(
CapaDescriptor
,
self
)
.
editable_metadata_fields
subset
=
[
field
for
field
in
super
(
CapaDescriptor
,
self
)
.
editable_metadata_fields
if
field
not
in
[
'markdown'
,
'empty'
]]
return
subset
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
7eb4970f
This diff is collapsed.
Click to expand it.
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