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
adcbfbb6
Commit
adcbfbb6
authored
Jan 08, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix reset
parent
b13f9479
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
27 deletions
+31
-27
common/lib/xmodule/xmodule/combined_open_ended_module.py
+29
-26
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
+2
-1
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
View file @
adcbfbb6
...
...
@@ -142,6 +142,12 @@ class CombinedOpenEndedModule(XModule):
current_task_state
=
self
.
task_states
[
self
.
current_task_number
]
self
.
current_task_xml
=
self
.
task_xml
[
self
.
current_task_number
]
if
self
.
current_task_number
>
0
:
self
.
allow_reset
=
self
.
check_allow_reset
()
if
self
.
allow_reset
:
self
.
current_task_number
=
self
.
current_task_number
-
1
current_task_type
=
self
.
get_tag_name
(
self
.
current_task_xml
)
children
=
self
.
child_modules
()
...
...
@@ -149,11 +155,6 @@ class CombinedOpenEndedModule(XModule):
self
.
current_task_descriptor
=
children
[
'descriptors'
][
current_task_type
](
self
.
system
)
etree_xml
=
etree
.
fromstring
(
self
.
current_task_xml
)
if
self
.
current_task_number
>
0
:
self
.
allow_reset
=
self
.
check_allow_reset
()
if
self
.
allow_reset
:
return
False
self
.
current_task_parsed_xml
=
self
.
current_task_descriptor
.
definition_from_xml
(
etree_xml
,
self
.
system
)
if
current_task_state
is
None
and
self
.
current_task_number
==
0
:
self
.
current_task
=
children
[
'modules'
][
current_task_type
](
self
.
system
,
self
.
location
,
self
.
current_task_parsed_xml
,
self
.
current_task_descriptor
,
self
.
static_data
)
...
...
@@ -175,13 +176,14 @@ class CombinedOpenEndedModule(XModule):
return
True
def
check_allow_reset
(
self
):
if
self
.
current_task_number
>
0
:
last_response_data
=
self
.
get_last_response
(
self
.
current_task_number
-
1
)
current_response_data
=
self
.
get_current_attributes
(
self
.
current_task_number
)
if
not
self
.
allow_reset
:
if
self
.
current_task_number
>
0
:
last_response_data
=
self
.
get_last_response
(
self
.
current_task_number
-
1
)
current_response_data
=
self
.
get_current_attributes
(
self
.
current_task_number
)
if
current_response_data
[
'min_score_to_attempt'
]
>
last_response_data
[
'score'
]
or
current_response_data
[
'max_score_to_attempt'
]
<
last_response_data
[
'score'
]:
self
.
state
=
self
.
DONE
self
.
allow_reset
=
True
if
current_response_data
[
'min_score_to_attempt'
]
>
last_response_data
[
'score'
]
or
current_response_data
[
'max_score_to_attempt'
]
<
last_response_data
[
'score'
]:
self
.
state
=
self
.
DONE
self
.
allow_reset
=
True
return
self
.
allow_reset
...
...
@@ -198,6 +200,7 @@ class CombinedOpenEndedModule(XModule):
'task_number'
:
self
.
current_task_number
+
1
,
'status'
:
self
.
get_status
(),
}
log
.
debug
(
context
)
return
context
...
...
@@ -268,20 +271,18 @@ class CombinedOpenEndedModule(XModule):
def
update_task_states
(
self
):
changed
=
False
local_task_number
=
self
.
current_task_number
if
self
.
allow_reset
:
local_task_number
=
local_task_number
-
1
self
.
task_states
[
local_task_number
]
=
self
.
current_task
.
get_instance_state
()
current_task_state
=
json
.
loads
(
self
.
task_states
[
local_task_number
])
if
current_task_state
[
'state'
]
==
self
.
DONE
and
not
self
.
allow_reset
:
self
.
current_task_number
+=
1
if
self
.
current_task_number
>=
(
len
(
self
.
task_xml
)):
self
.
state
=
self
.
DONE
self
.
current_task_number
=
len
(
self
.
task_xml
)
-
1
else
:
self
.
state
=
self
.
INITIAL
changed
=
True
self
.
setup_next_task
()
if
not
self
.
allow_reset
:
self
.
task_states
[
self
.
current_task_number
]
=
self
.
current_task
.
get_instance_state
()
current_task_state
=
json
.
loads
(
self
.
task_states
[
self
.
current_task_number
])
if
current_task_state
[
'state'
]
==
self
.
DONE
:
self
.
current_task_number
+=
1
if
self
.
current_task_number
>=
(
len
(
self
.
task_xml
)):
self
.
state
=
self
.
DONE
self
.
current_task_number
=
len
(
self
.
task_xml
)
-
1
else
:
self
.
state
=
self
.
INITIAL
changed
=
True
self
.
setup_next_task
()
return
changed
def
update_task_states_ajax
(
self
,
return_html
):
...
...
@@ -335,7 +336,8 @@ class CombinedOpenEndedModule(XModule):
(error only present if not success)
"""
if
self
.
state
!=
self
.
DONE
:
return
self
.
out_of_sync_error
(
get
)
if
not
self
.
allow_reset
:
return
self
.
out_of_sync_error
(
get
)
if
self
.
attempts
>
self
.
max_attempts
:
return
{
...
...
@@ -350,6 +352,7 @@ class CombinedOpenEndedModule(XModule):
self
.
current_task
.
reset
(
self
.
system
)
self
.
task_states
[
self
.
current_task_number
]
=
self
.
current_task
.
get_instance_state
()
self
.
current_task_number
=
0
self
.
allow_reset
=
False
self
.
setup_next_task
()
return
{
'success'
:
True
,
'html'
:
self
.
get_html_nonsystem
()}
...
...
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
View file @
adcbfbb6
...
...
@@ -187,7 +187,7 @@ class @CombinedOpenEnded
reset
:
(
event
)
=>
event
.
preventDefault
()
if
@
child_state
==
'done'
if
@
child_state
==
'done'
or
@
allow_reset
==
"True"
$
.
postWithPrefix
"
#{
@
ajax_url
}
/reset"
,
{},
(
response
)
=>
if
response
.
success
@
answer_area
.
val
(
''
)
...
...
@@ -196,6 +196,7 @@ class @CombinedOpenEnded
@
message_wrapper
.
html
(
''
)
@
child_state
=
'initial'
@
combined_open_ended
.
after
(
response
.
html
).
remove
()
@
allow_reset
=
"False"
@
reinitialize
(
@
element
)
@
rebind
()
@
reset_button
.
hide
()
...
...
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