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
4a2875cc
Commit
4a2875cc
authored
Jan 08, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document open ended child
parent
f858dce7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletions
+30
-1
common/lib/xmodule/xmodule/openendedchild.py
+30
-1
No files found.
common/lib/xmodule/xmodule/openendedchild.py
View file @
4a2875cc
...
@@ -72,7 +72,6 @@ class OpenEndedChild():
...
@@ -72,7 +72,6 @@ class OpenEndedChild():
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
static_data
,
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
static_data
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
# Load instance state
# Load instance state
if
instance_state
is
not
None
:
if
instance_state
is
not
None
:
instance_state
=
json
.
loads
(
instance_state
)
instance_state
=
json
.
loads
(
instance_state
)
...
@@ -102,6 +101,14 @@ class OpenEndedChild():
...
@@ -102,6 +101,14 @@ class OpenEndedChild():
self
.
setup_response
(
system
,
location
,
definition
,
descriptor
)
self
.
setup_response
(
system
,
location
,
definition
,
descriptor
)
def
setup_response
(
self
,
system
,
location
,
definition
,
descriptor
):
def
setup_response
(
self
,
system
,
location
,
definition
,
descriptor
):
"""
Needs to be implemented by the inheritors of this module. Sets up additional fields used by the child modules.
@param system: Modulesystem
@param location: Module location
@param definition: XML definition
@param descriptor: Descriptor of the module
@return: None
"""
pass
pass
def
latest_answer
(
self
):
def
latest_answer
(
self
):
...
@@ -123,6 +130,11 @@ class OpenEndedChild():
...
@@ -123,6 +130,11 @@ class OpenEndedChild():
return
self
.
history
[
-
1
]
.
get
(
'post_assessment'
,
""
)
return
self
.
history
[
-
1
]
.
get
(
'post_assessment'
,
""
)
def
new_history_entry
(
self
,
answer
):
def
new_history_entry
(
self
,
answer
):
"""
Adds a new entry to the history dictionary
@param answer: The student supplied answer
@return: None
"""
self
.
history
.
append
({
'answer'
:
answer
})
self
.
history
.
append
({
'answer'
:
answer
})
def
record_latest_score
(
self
,
score
):
def
record_latest_score
(
self
,
score
):
...
@@ -213,12 +225,25 @@ class OpenEndedChild():
...
@@ -213,12 +225,25 @@ class OpenEndedChild():
'error'
:
'The problem state got out-of-sync'
}
'error'
:
'The problem state got out-of-sync'
}
def
get_html
(
self
):
def
get_html
(
self
):
"""
Needs to be implemented by inheritors. Renders the HTML that students see.
@return:
"""
pass
pass
def
handle_ajax
(
self
):
def
handle_ajax
(
self
):
"""
Needs to be implemented by child modules. Handles AJAX events.
@return:
"""
pass
pass
def
is_submission_correct
(
self
,
score
):
def
is_submission_correct
(
self
,
score
):
"""
Checks to see if a given score makes the answer correct. Very naive right now (>66
%
is correct)
@param score: Numeric score.
@return: Boolean correct.
"""
correct
=
False
correct
=
False
if
(
isinstance
(
score
,(
int
,
long
,
float
,
complex
))):
if
(
isinstance
(
score
,(
int
,
long
,
float
,
complex
))):
score_ratio
=
int
(
score
)
/
float
(
self
.
max_score
())
score_ratio
=
int
(
score
)
/
float
(
self
.
max_score
())
...
@@ -226,6 +251,10 @@ class OpenEndedChild():
...
@@ -226,6 +251,10 @@ class OpenEndedChild():
return
correct
return
correct
def
is_last_response_correct
(
self
):
def
is_last_response_correct
(
self
):
"""
Checks to see if the last response in the module is correct.
@return: 'correct' if correct, otherwise 'incorrect'
"""
score
=
self
.
get_score
()[
'score'
]
score
=
self
.
get_score
()[
'score'
]
correctness
=
'correct'
if
self
.
is_submission_correct
(
score
)
else
'incorrect'
correctness
=
'correct'
if
self
.
is_submission_correct
(
score
)
else
'incorrect'
return
correctness
return
correctness
...
...
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