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
517c79e0
Commit
517c79e0
authored
Dec 28, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing state tracking
parent
cd764d3d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
6 deletions
+32
-6
common/lib/xmodule/xmodule/combined_open_ended_module.py
+32
-6
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
View file @
517c79e0
...
...
@@ -74,10 +74,9 @@ class CombinedOpenEndedModule(XModule):
# element.
# Scores are on scale from 0 to max_score
self
.
current_task_number
=
instance_state
.
get
(
'current_task_number'
,
0
)
self
.
task
s
=
instance_state
.
get
(
'task
s'
,
[])
self
.
task
_states
=
instance_state
.
get
(
'task_state
s'
,
[])
self
.
state
=
instance_state
.
get
(
'state'
,
'initial'
)
self
.
problems
=
instance_state
.
get
(
'problems'
,
[])
self
.
attempts
=
instance_state
.
get
(
'attempts'
,
0
)
self
.
max_attempts
=
int
(
self
.
metadata
.
get
(
'attempts'
,
MAX_ATTEMPTS
))
...
...
@@ -94,24 +93,51 @@ class CombinedOpenEndedModule(XModule):
return
tag
def
setup_next_task
(
self
):
current_task_state
=
None
if
self
.
state
in
[
self
.
ASSESSING
,
self
.
DONE
]:
self
.
current_task
=
self
.
tasks
[
len
(
self
.
tasks
)
-
1
]
return
True
current_task_state
=
self
.
task_states
[
len
(
self
.
task_states
)
-
1
]
log
.
debug
(
self
.
task_states
)
self
.
current_task_xml
=
self
.
task_xml
[
self
.
current_task_number
]
current_task_type
=
self
.
get_tag_name
(
self
.
current_task_xml
)
if
current_task_type
==
"selfassessment"
:
self
.
current_task_descriptor
=
self_assessment_module
.
SelfAssessmentDescriptor
(
self
.
system
)
self
.
current_task_parsed_xml
=
self
.
current_task_descriptor
.
definition_from_xml
(
etree
.
fromstring
(
self
.
current_task_xml
),
self
.
system
)
if
current_task_state
is
None
:
self
.
current_task
=
self_assessment_module
.
SelfAssessmentModule
(
self
.
system
,
self
.
location
,
self
.
current_task_parsed_xml
,
self
.
current_task_descriptor
)
self
.
task_states
.
append
(
self
.
current_task
.
get_instance_state
())
self
.
state
=
self
.
ASSESSING
else
:
self
.
current_task
=
self_assessment_module
.
SelfAssessmentModule
(
self
.
system
,
self
.
location
,
self
.
current_task_parsed_xml
,
self
.
current_task_descriptor
,
instance_state
=
current_task_state
)
return
True
def
get_html
(
self
):
html
=
self
.
current_task
.
get_html
(
self
.
system
)
return
rewrite_links
(
html
,
self
.
rewrite_content_links
)
return_html
=
rewrite_links
(
html
,
self
.
rewrite_content_links
)
self
.
task_states
[
len
(
self
.
task_states
)
-
1
]
=
self
.
current_task
.
get_instance_state
()
return
return_html
def
handle_ajax
(
self
,
dispatch
,
get
):
return
self
.
current_task
.
handle_ajax
(
dispatch
,
get
,
self
.
system
)
return_html
=
self
.
current_task
.
handle_ajax
(
dispatch
,
get
,
self
.
system
)
self
.
task_states
[
len
(
self
.
task_states
)
-
1
]
=
self
.
current_task
.
get_instance_state
()
return
return_html
def
get_instance_state
(
self
):
"""
Get the current score and state
"""
state
=
{
'version'
:
self
.
STATE_VERSION
,
'current_task_number'
:
self
.
current_task_number
,
'state'
:
self
.
state
,
'task_states'
:
self
.
task_states
,
'attempts'
:
self
.
attempts
,
}
return
json
.
dumps
(
state
)
class
CombinedOpenEndedDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
"""
...
...
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