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
24689024
Commit
24689024
authored
Jan 07, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor open ended module
parent
5333e5e1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
95 deletions
+38
-95
common/lib/xmodule/xmodule/open_ended_module.py
+0
-54
common/lib/xmodule/xmodule/openendedchild.py
+38
-0
common/lib/xmodule/xmodule/self_assessment_module.py
+0
-41
No files found.
common/lib/xmodule/xmodule/open_ended_module.py
View file @
24689024
...
...
@@ -411,7 +411,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
<other request-specific values here > }
'''
handlers
=
{
'problem_get'
:
self
.
get_problem
,
'save_answer'
:
self
.
save_answer
,
'score_update'
:
self
.
update_score
,
'save_post_assessment'
:
self
.
message_post
,
...
...
@@ -429,23 +428,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
get_problem
(
self
,
get
,
system
):
return
self
.
get_html
(
system
)
def
reset_problem
(
self
,
get
,
system
):
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
def
out_of_sync_error
(
self
,
get
,
msg
=
''
):
"""
return dict out-of-sync error message, and also log.
"""
log
.
warning
(
"Assessment module state out sync. state:
%
r, get:
%
r.
%
s"
,
self
.
state
,
get
,
msg
)
return
{
'success'
:
False
,
'error'
:
'The problem state got out-of-sync'
}
def
save_answer
(
self
,
get
,
system
):
if
self
.
attempts
>
self
.
max_attempts
:
# If too many attempts, prevent student from saving answer and
...
...
@@ -483,19 +465,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
return
dict
()
# No AJAX return is needed
def
change_state
(
self
,
new_state
):
"""
A centralized place for state changes--allows for hooks. If the
current state matches the old state, don't run any hooks.
"""
if
self
.
state
==
new_state
:
return
self
.
state
=
new_state
if
self
.
state
==
self
.
DONE
:
self
.
attempts
+=
1
def
get_html
(
self
,
system
):
#set context variables and render template
if
self
.
state
!=
self
.
INITIAL
:
...
...
@@ -525,29 +494,6 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
html
=
system
.
render_template
(
'open_ended.html'
,
context
)
return
html
def
get_progress
(
self
):
'''
For now, just return last score / max_score
'''
if
self
.
_max_score
>
0
:
try
:
return
Progress
(
self
.
get_score
()[
'score'
],
self
.
_max_score
)
except
Exception
as
err
:
log
.
exception
(
"Got bad progress"
)
return
None
return
None
def
reset
(
self
,
system
):
"""
If resetting is allowed, reset the state.
Returns {'success': bool, 'error': msg}
(error only present if not success)
"""
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
class
OpenEndedDescriptor
(
XmlDescriptor
,
EditingDescriptor
):
"""
Module for adding self assessment questions to courses
...
...
common/lib/xmodule/xmodule/openendedchild.py
View file @
24689024
...
...
@@ -206,5 +206,43 @@ class OpenEndedChild():
return
{
'score'
:
score
if
score
is
not
None
else
0
,
'total'
:
self
.
_max_score
}
def
reset
(
self
,
system
):
"""
If resetting is allowed, reset the state.
Returns {'success': bool, 'error': msg}
(error only present if not success)
"""
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
def
get_progress
(
self
):
'''
For now, just return last score / max_score
'''
if
self
.
_max_score
>
0
:
try
:
return
Progress
(
self
.
get_score
()[
'score'
],
self
.
_max_score
)
except
Exception
as
err
:
log
.
exception
(
"Got bad progress"
)
return
None
return
None
def
out_of_sync_error
(
self
,
get
,
msg
=
''
):
"""
return dict out-of-sync error message, and also log.
"""
log
.
warning
(
"Assessment module state out sync. state:
%
r, get:
%
r.
%
s"
,
self
.
state
,
get
,
msg
)
return
{
'success'
:
False
,
'error'
:
'The problem state got out-of-sync'
}
def
get_html
(
self
):
pass
def
handle_ajax
(
self
):
pass
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
24689024
...
...
@@ -116,18 +116,6 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
html
=
system
.
render_template
(
'self_assessment_prompt.html'
,
context
)
return
html
def
get_progress
(
self
):
'''
For now, just return last score / max_score
'''
if
self
.
_max_score
>
0
:
try
:
return
Progress
(
self
.
get_score
()[
'score'
],
self
.
_max_score
)
except
Exception
as
err
:
log
.
exception
(
"Got bad progress"
)
return
None
return
None
def
handle_ajax
(
self
,
dispatch
,
get
,
system
):
"""
...
...
@@ -158,15 +146,6 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
out_of_sync_error
(
self
,
get
,
msg
=
''
):
"""
return dict out-of-sync error message, and also log.
"""
log
.
warning
(
"Assessment module state out sync. state:
%
r, get:
%
r.
%
s"
,
self
.
state
,
get
,
msg
)
return
{
'success'
:
False
,
'error'
:
'The problem state got out-of-sync'
}
def
get_rubric_html
(
self
,
system
):
"""
Return the appropriate version of the rubric, based on the state.
...
...
@@ -296,7 +275,6 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
d
[
'state'
]
=
self
.
state
return
d
def
save_hint
(
self
,
get
,
system
):
'''
Save the hint.
...
...
@@ -320,25 +298,6 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
'allow_reset'
:
self
.
_allow_reset
()}
def
reset
(
self
,
system
):
"""
If resetting is allowed, reset the state.
Returns {'success': bool, 'error': msg}
(error only present if not success)
"""
#if self.state != self.DONE:
# return self.out_of_sync_error(get)
#if self.attempts > self.max_attempts:
# return {
# 'success': False,
# 'error': 'Too many attempts.'
# }
self
.
change_state
(
self
.
INITIAL
)
return
{
'success'
:
True
}
class
SelfAssessmentDescriptor
(
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