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
3329af07
Commit
3329af07
authored
Mar 06, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force instance state to save periodically
parent
7ea3d70c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
common/lib/xmodule/xmodule/combined_open_ended_module.py
+7
-4
common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py
+14
-14
No files found.
common/lib/xmodule/xmodule/combined_open_ended_module.py
View file @
3329af07
...
@@ -155,11 +155,14 @@ class CombinedOpenEndedModule(XModule):
...
@@ -155,11 +155,14 @@ class CombinedOpenEndedModule(XModule):
def
get_html
(
self
):
def
get_html
(
self
):
self
.
save_instance_data
()
self
.
save_instance_data
()
return
self
.
child_module
.
get_html
()
return_value
=
self
.
child_module
.
get_html
()
return
return_value
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
):
self
.
save_instance_data
()
self
.
save_instance_data
()
return
self
.
child_module
.
handle_ajax
(
dispatch
,
get
)
return_value
=
self
.
child_module
.
handle_ajax
(
dispatch
,
get
)
self
.
save_instance_data
()
return
return_value
def
get_instance_state
(
self
):
def
get_instance_state
(
self
):
return
self
.
child_module
.
get_instance_state
()
return
self
.
child_module
.
get_instance_state
()
...
@@ -177,9 +180,9 @@ class CombinedOpenEndedModule(XModule):
...
@@ -177,9 +180,9 @@ class CombinedOpenEndedModule(XModule):
def
due_date
(
self
):
def
due_date
(
self
):
return
self
.
child_module
.
due_date
return
self
.
child_module
.
due_date
def
save_instance_dat
e
(
self
):
def
save_instance_dat
a
(
self
):
for
attribute
in
self
.
student_attributes
:
for
attribute
in
self
.
student_attributes
:
setattr
(
self
,
k
,
getattr
(
self
.
child_module
,
k
))
setattr
(
self
,
attribute
,
getattr
(
self
.
child_module
,
attribute
))
class
CombinedOpenEndedDescriptor
(
RawDescriptor
):
class
CombinedOpenEndedDescriptor
(
RawDescriptor
):
...
...
common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py
View file @
3329af07
...
@@ -134,7 +134,7 @@ class CombinedOpenEndedV1Module():
...
@@ -134,7 +134,7 @@ class CombinedOpenEndedV1Module():
self
.
student_attempts
=
instance_state
.
get
(
'student_attempts'
,
0
)
self
.
student_attempts
=
instance_state
.
get
(
'student_attempts'
,
0
)
#Allow reset is true if student has failed the criteria to move to the next child task
#Allow reset is true if student has failed the criteria to move to the next child task
self
.
allow
_reset
=
instance_state
.
get
(
'ready_to_reset'
,
False
)
self
.
ready_to
_reset
=
instance_state
.
get
(
'ready_to_reset'
,
False
)
self
.
attempts
=
self
.
instance_state
.
get
(
'attempts'
,
MAX_ATTEMPTS
)
self
.
attempts
=
self
.
instance_state
.
get
(
'attempts'
,
MAX_ATTEMPTS
)
self
.
is_scored
=
self
.
instance_state
.
get
(
'is_graded'
,
IS_SCORED
)
in
TRUE_DICT
self
.
is_scored
=
self
.
instance_state
.
get
(
'is_graded'
,
IS_SCORED
)
in
TRUE_DICT
self
.
accept_file_upload
=
self
.
instance_state
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
in
TRUE_DICT
self
.
accept_file_upload
=
self
.
instance_state
.
get
(
'accept_file_upload'
,
ACCEPT_FILE_UPLOAD
)
in
TRUE_DICT
...
@@ -237,8 +237,8 @@ class CombinedOpenEndedV1Module():
...
@@ -237,8 +237,8 @@ class CombinedOpenEndedV1Module():
self
.
current_task_xml
=
self
.
task_xml
[
self
.
current_task_number
]
self
.
current_task_xml
=
self
.
task_xml
[
self
.
current_task_number
]
if
self
.
current_task_number
>
0
:
if
self
.
current_task_number
>
0
:
self
.
allow
_reset
=
self
.
check_allow_reset
()
self
.
ready_to
_reset
=
self
.
check_allow_reset
()
if
self
.
allow
_reset
:
if
self
.
ready_to
_reset
:
self
.
current_task_number
=
self
.
current_task_number
-
1
self
.
current_task_number
=
self
.
current_task_number
-
1
current_task_type
=
self
.
get_tag_name
(
self
.
current_task_xml
)
current_task_type
=
self
.
get_tag_name
(
self
.
current_task_xml
)
...
@@ -291,7 +291,7 @@ class CombinedOpenEndedV1Module():
...
@@ -291,7 +291,7 @@ class CombinedOpenEndedV1Module():
Input: None
Input: None
Output: the allow_reset attribute of the current module.
Output: the allow_reset attribute of the current module.
"""
"""
if
not
self
.
allow
_reset
:
if
not
self
.
ready_to
_reset
:
if
self
.
current_task_number
>
0
:
if
self
.
current_task_number
>
0
:
last_response_data
=
self
.
get_last_response
(
self
.
current_task_number
-
1
)
last_response_data
=
self
.
get_last_response
(
self
.
current_task_number
-
1
)
current_response_data
=
self
.
get_current_attributes
(
self
.
current_task_number
)
current_response_data
=
self
.
get_current_attributes
(
self
.
current_task_number
)
...
@@ -299,9 +299,9 @@ class CombinedOpenEndedV1Module():
...
@@ -299,9 +299,9 @@ class CombinedOpenEndedV1Module():
if
(
current_response_data
[
'min_score_to_attempt'
]
>
last_response_data
[
'score'
]
if
(
current_response_data
[
'min_score_to_attempt'
]
>
last_response_data
[
'score'
]
or
current_response_data
[
'max_score_to_attempt'
]
<
last_response_data
[
'score'
]):
or
current_response_data
[
'max_score_to_attempt'
]
<
last_response_data
[
'score'
]):
self
.
state
=
self
.
DONE
self
.
state
=
self
.
DONE
self
.
allow
_reset
=
True
self
.
ready_to
_reset
=
True
return
self
.
allow
_reset
return
self
.
ready_to
_reset
def
get_context
(
self
):
def
get_context
(
self
):
"""
"""
...
@@ -315,7 +315,7 @@ class CombinedOpenEndedV1Module():
...
@@ -315,7 +315,7 @@ class CombinedOpenEndedV1Module():
context
=
{
context
=
{
'items'
:
[{
'content'
:
task_html
}],
'items'
:
[{
'content'
:
task_html
}],
'ajax_url'
:
self
.
system
.
ajax_url
,
'ajax_url'
:
self
.
system
.
ajax_url
,
'allow_reset'
:
self
.
allow
_reset
,
'allow_reset'
:
self
.
ready_to
_reset
,
'state'
:
self
.
state
,
'state'
:
self
.
state
,
'task_count'
:
len
(
self
.
task_xml
),
'task_count'
:
len
(
self
.
task_xml
),
'task_number'
:
self
.
current_task_number
+
1
,
'task_number'
:
self
.
current_task_number
+
1
,
...
@@ -475,7 +475,7 @@ class CombinedOpenEndedV1Module():
...
@@ -475,7 +475,7 @@ class CombinedOpenEndedV1Module():
Output: boolean indicating whether or not the task state changed.
Output: boolean indicating whether or not the task state changed.
"""
"""
changed
=
False
changed
=
False
if
not
self
.
allow
_reset
:
if
not
self
.
ready_to
_reset
:
self
.
task_states
[
self
.
current_task_number
]
=
self
.
current_task
.
get_instance_state
()
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
])
current_task_state
=
json
.
loads
(
self
.
task_states
[
self
.
current_task_number
])
if
current_task_state
[
'child_state'
]
==
self
.
DONE
:
if
current_task_state
[
'child_state'
]
==
self
.
DONE
:
...
@@ -624,7 +624,7 @@ class CombinedOpenEndedV1Module():
...
@@ -624,7 +624,7 @@ class CombinedOpenEndedV1Module():
Output: Dictionary to be rendered
Output: Dictionary to be rendered
"""
"""
self
.
update_task_states
()
self
.
update_task_states
()
return
{
'success'
:
True
,
'html'
:
self
.
get_html_nonsystem
(),
'allow_reset'
:
self
.
allow
_reset
}
return
{
'success'
:
True
,
'html'
:
self
.
get_html_nonsystem
(),
'allow_reset'
:
self
.
ready_to
_reset
}
def
reset
(
self
,
get
):
def
reset
(
self
,
get
):
"""
"""
...
@@ -633,7 +633,7 @@ class CombinedOpenEndedV1Module():
...
@@ -633,7 +633,7 @@ class CombinedOpenEndedV1Module():
Output: AJAX dictionary to tbe rendered
Output: AJAX dictionary to tbe rendered
"""
"""
if
self
.
state
!=
self
.
DONE
:
if
self
.
state
!=
self
.
DONE
:
if
not
self
.
allow
_reset
:
if
not
self
.
ready_to
_reset
:
return
self
.
out_of_sync_error
(
get
)
return
self
.
out_of_sync_error
(
get
)
if
self
.
student_attempts
>
self
.
attempts
:
if
self
.
student_attempts
>
self
.
attempts
:
...
@@ -645,14 +645,14 @@ class CombinedOpenEndedV1Module():
...
@@ -645,14 +645,14 @@ class CombinedOpenEndedV1Module():
self
.
student_attempts
,
self
.
attempts
)
self
.
student_attempts
,
self
.
attempts
)
}
}
self
.
state
=
self
.
INITIAL
self
.
state
=
self
.
INITIAL
self
.
allow
_reset
=
False
self
.
ready_to
_reset
=
False
for
i
in
xrange
(
0
,
len
(
self
.
task_xml
)):
for
i
in
xrange
(
0
,
len
(
self
.
task_xml
)):
self
.
current_task_number
=
i
self
.
current_task_number
=
i
self
.
setup_next_task
(
reset
=
True
)
self
.
setup_next_task
(
reset
=
True
)
self
.
current_task
.
reset
(
self
.
system
)
self
.
current_task
.
reset
(
self
.
system
)
self
.
task_states
[
self
.
current_task_number
]
=
self
.
current_task
.
get_instance_state
()
self
.
task_states
[
self
.
current_task_number
]
=
self
.
current_task
.
get_instance_state
()
self
.
current_task_number
=
0
self
.
current_task_number
=
0
self
.
allow
_reset
=
False
self
.
ready_to
_reset
=
False
self
.
setup_next_task
()
self
.
setup_next_task
()
return
{
'success'
:
True
,
'html'
:
self
.
get_html_nonsystem
()}
return
{
'success'
:
True
,
'html'
:
self
.
get_html_nonsystem
()}
...
@@ -669,7 +669,7 @@ class CombinedOpenEndedV1Module():
...
@@ -669,7 +669,7 @@ class CombinedOpenEndedV1Module():
'state'
:
self
.
state
,
'state'
:
self
.
state
,
'task_states'
:
self
.
task_states
,
'task_states'
:
self
.
task_states
,
'student_attempts'
:
self
.
student_attempts
,
'student_attempts'
:
self
.
student_attempts
,
'ready_to_reset'
:
self
.
allow
_reset
,
'ready_to_reset'
:
self
.
ready_to
_reset
,
}
}
return
json
.
dumps
(
state
)
return
json
.
dumps
(
state
)
...
@@ -703,7 +703,7 @@ class CombinedOpenEndedV1Module():
...
@@ -703,7 +703,7 @@ class CombinedOpenEndedV1Module():
entirely, in which case they will be in the self.DONE state), and if it is scored or not.
entirely, in which case they will be in the self.DONE state), and if it is scored or not.
@return: Boolean corresponding to the above.
@return: Boolean corresponding to the above.
"""
"""
return
(
self
.
state
==
self
.
DONE
or
self
.
allow
_reset
)
and
self
.
is_scored
return
(
self
.
state
==
self
.
DONE
or
self
.
ready_to
_reset
)
and
self
.
is_scored
def
get_score
(
self
):
def
get_score
(
self
):
"""
"""
...
...
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