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
3f95116a
Commit
3f95116a
authored
Nov 12, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only ask for hints if assessed as wrong
parent
92ab5af6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
17 deletions
+46
-17
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+11
-5
common/lib/xmodule/xmodule/self_assessment_module.py
+35
-12
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
3f95116a
...
...
@@ -72,7 +72,7 @@ class @SelfAssessment
@
find_assessment_elements
()
@
rebind
()
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
error
)
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
...
...
@@ -82,12 +82,18 @@ class @SelfAssessment
data
=
{
'assessment'
:
@
assessment
.
find
(
':selected'
).
text
()}
$
.
postWithPrefix
"
#{
@
ajax_url
}
/save_assessment"
,
data
,
(
response
)
=>
if
response
.
success
@
state
=
response
.
state
if
@
state
==
'request_hint'
@
hint_wrapper
.
html
(
response
.
hint_html
)
@
state
=
'request_hint'
@
find_hint_elements
()
else
if
@
state
==
'done'
@
message_wrapper
.
html
(
response
.
message_html
)
@
allow_reset
=
response
.
allow_reset
@
rebind
()
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
error
)
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
...
...
@@ -104,7 +110,7 @@ class @SelfAssessment
@
allow_reset
=
response
.
allow_reset
@
rebind
()
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
error
)
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
...
...
@@ -122,6 +128,6 @@ class @SelfAssessment
@
rebind
()
@
reset_button
.
hide
()
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
error
)
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
3f95116a
...
...
@@ -123,6 +123,10 @@ class SelfAssessmentModule(XModule):
self
.
submit_message
=
definition
[
'submitmessage'
]
self
.
hint_prompt
=
definition
[
'hintprompt'
]
def
_allow_reset
(
self
):
"""Can the module be reset?"""
return
self
.
state
==
self
.
DONE
and
self
.
attempts
<
self
.
max_attempts
def
get_html
(
self
):
#set context variables and render template
if
self
.
state
!=
self
.
INITIAL
and
self
.
student_answers
:
...
...
@@ -130,7 +134,6 @@ class SelfAssessmentModule(XModule):
else
:
previous_answer
=
''
allow_reset
=
self
.
state
==
self
.
DONE
and
self
.
attempts
<
self
.
max_attempts
context
=
{
'prompt'
:
self
.
prompt
,
'previous_answer'
:
previous_answer
,
...
...
@@ -139,7 +142,7 @@ class SelfAssessmentModule(XModule):
'initial_hint'
:
self
.
get_hint_html
(),
'initial_message'
:
self
.
get_message_html
(),
'state'
:
self
.
state
,
'allow_reset'
:
allow_reset
,
'allow_reset'
:
self
.
_allow_reset
()
,
}
html
=
self
.
system
.
render_template
(
'self_assessment_prompt.html'
,
context
)
...
...
@@ -247,7 +250,7 @@ class SelfAssessmentModule(XModule):
if
self
.
state
in
(
self
.
INITIAL
,
self
.
ASSESSING
):
return
''
if
self
.
state
==
self
.
REQUEST_HINT
and
len
(
self
.
hints
)
>
0
:
if
self
.
state
==
self
.
DONE
and
len
(
self
.
hints
)
>
0
:
# display the previous hint
hint
=
self
.
hints
[
-
1
]
else
:
...
...
@@ -286,7 +289,7 @@ class SelfAssessmentModule(XModule):
# they won't see the reset button once they're out of attempts.
return
{
'success'
:
False
,
'
message
'
:
'Too many attempts.'
'
error
'
:
'Too many attempts.'
}
if
self
.
state
!=
self
.
INITIAL
:
...
...
@@ -302,10 +305,17 @@ class SelfAssessmentModule(XModule):
def
save_assessment
(
self
,
get
):
"""
Save the assessment.
Save the assessment. If the student said they're right, don't ask for a
hint, and go straight to the done state. Otherwise, do ask for a hint.
Returns a dict { 'success': bool, 'state': state,
'hint_html': hint_html OR 'message_html': html and 'allow_reset',
'error': error-msg},
Returns a dict { 'success': bool, 'hint_html': hint_html 'error': error-msg},
with 'error' only present if 'success' is False, and 'hint
_html' only if success is true
with 'error' only present if 'success' is False, and 'hint_html' or
'message
_html' only if success is true
"""
n_answers
=
len
(
self
.
student_answers
)
...
...
@@ -315,14 +325,25 @@ class SelfAssessmentModule(XModule):
return
self
.
out_of_sync_error
(
get
,
msg
)
try
:
s
elf
.
scores
.
append
(
int
(
get
[
'assessment'
])
)
s
core
=
int
(
get
[
'assessment'
]
)
except
:
return
{
'success'
:
False
,
'error'
:
"Non-integer score value"
}
self
.
scores
.
append
(
score
)
d
=
{
'success'
:
True
,}
if
score
==
self
.
max_score
():
self
.
state
=
self
.
DONE
d
[
'message_html'
]
=
self
.
get_message_html
()
d
[
'allow_reset'
]
=
self
.
_allow_reset
()
else
:
self
.
state
=
self
.
REQUEST_HINT
d
[
'hint_html'
]
=
self
.
get_hint_html
()
d
[
'state'
]
=
self
.
state
return
d
# TODO: return different hint based on assessment value...
return
{
'success'
:
True
,
'hint_html'
:
self
.
get_hint_html
()}
def
save_hint
(
self
,
get
):
'''
...
...
@@ -334,7 +355,9 @@ class SelfAssessmentModule(XModule):
with the error key only present if success is False and message_html
only if True.
'''
if
self
.
state
!=
self
.
REQUEST_HINT
or
len
(
self
.
scores
)
!=
len
(
self
.
hints
)
+
1
:
if
self
.
state
!=
self
.
REQUEST_HINT
:
# Note: because we only ask for hints on wrong answers, may not have
# the same number of hints and answers.
return
self
.
out_of_sync_error
(
get
)
self
.
hints
.
append
(
get
[
'hint'
]
.
lower
())
...
...
@@ -356,7 +379,7 @@ class SelfAssessmentModule(XModule):
return
{
'success'
:
True
,
'message_html'
:
self
.
get_message_html
(),
'allow_reset'
:
self
.
attempts
<
self
.
max_attempts
}
'allow_reset'
:
self
.
_allow_reset
()
}
def
reset
(
self
,
get
):
...
...
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