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
4922ab33
Commit
4922ab33
authored
Nov 12, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hook up reset button
parent
0ec7043e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
9 deletions
+41
-9
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
+31
-5
common/lib/xmodule/xmodule/self_assessment_module.py
+8
-3
lms/templates/self_assessment_prompt.html
+2
-1
No files found.
common/lib/xmodule/xmodule/js/src/selfassessment/display.coffee
View file @
4922ab33
...
@@ -4,6 +4,7 @@ class @SelfAssessment
...
@@ -4,6 +4,7 @@ class @SelfAssessment
@
id
=
@
el
.
data
(
'id'
)
@
id
=
@
el
.
data
(
'id'
)
@
ajax_url
=
@
el
.
data
(
'ajax-url'
)
@
ajax_url
=
@
el
.
data
(
'ajax-url'
)
@
state
=
@
el
.
data
(
'state'
)
@
state
=
@
el
.
data
(
'state'
)
allow_reset
=
@
el
.
data
(
'allow_reset'
)
# valid states: 'initial', 'assessing', 'request_hint', 'done'
# valid states: 'initial', 'assessing', 'request_hint', 'done'
# Where to put the rubric once we load it
# Where to put the rubric once we load it
...
@@ -14,17 +15,24 @@ class @SelfAssessment
...
@@ -14,17 +15,24 @@ class @SelfAssessment
@
hint_wrapper
=
@
$
(
'.hint-wrapper'
)
@
hint_wrapper
=
@
$
(
'.hint-wrapper'
)
@
message_wrapper
=
@
$
(
'.message-wrapper'
)
@
message_wrapper
=
@
$
(
'.message-wrapper'
)
@
check_button
=
@
$
(
'.submit-button'
)
@
check_button
=
@
$
(
'.submit-button'
)
@
reset_button
=
@
$
(
'.reset-button'
)
@
reset_button
.
click
@
reset
@
find_assessment_elements
()
@
find_assessment_elements
()
@
find_hint_elements
()
@
find_hint_elements
()
@
bind
()
if
allow_reset
@
reset_button
.
show
()
else
@
reset_button
.
hide
()
@
rebind
()
# locally scoped jquery.
# locally scoped jquery.
$
:
(
selector
)
->
$
:
(
selector
)
->
$
(
selector
,
@
el
)
$
(
selector
,
@
el
)
bind
:
()
=>
re
bind
:
()
=>
# rebind to the appropriate function for the current state
# rebind to the appropriate function for the current state
@
check_button
.
unbind
(
'click'
)
@
check_button
.
unbind
(
'click'
)
if
@
state
==
'initial'
if
@
state
==
'initial'
...
@@ -51,7 +59,7 @@ class @SelfAssessment
...
@@ -51,7 +59,7 @@ class @SelfAssessment
@
rubric_wrapper
.
html
(
response
.
rubric_html
)
@
rubric_wrapper
.
html
(
response
.
rubric_html
)
@
state
=
'assessing'
@
state
=
'assessing'
@
find_assessment_elements
()
@
find_assessment_elements
()
@
bind
()
@
re
bind
()
else
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
message
)
else
else
...
@@ -66,7 +74,7 @@ class @SelfAssessment
...
@@ -66,7 +74,7 @@ class @SelfAssessment
@
hint_wrapper
.
html
(
response
.
hint_html
)
@
hint_wrapper
.
html
(
response
.
hint_html
)
@
state
=
'request_hint'
@
state
=
'request_hint'
@
find_hint_elements
()
@
find_hint_elements
()
@
bind
()
@
re
bind
()
else
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
message
)
else
else
...
@@ -82,9 +90,27 @@ class @SelfAssessment
...
@@ -82,9 +90,27 @@ class @SelfAssessment
if
response
.
success
if
response
.
success
@
message_wrapper
.
html
(
response
.
message_html
)
@
message_wrapper
.
html
(
response
.
message_html
)
@
state
=
'done'
@
state
=
'done'
@
bind
()
@
rebind
()
if
response
.
allow_reset
@
reset_button
.
show
()
else
else
@
errors_area
.
html
(
response
.
message
)
@
errors_area
.
html
(
response
.
message
)
else
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
reset
:
(
event
)
=>
event
.
preventDefault
()
if
@
state
==
'done'
$
.
postWithPrefix
"
#{
@
ajax_url
}
/reset"
,
{},
(
response
)
=>
if
response
.
success
@
rubric_wrapper
.
html
(
''
)
@
hint_wrapper
.
html
(
''
)
@
message_wrapper
.
html
(
''
)
@
state
=
'initial'
@
rebind
()
@
reset_button
.
hide
()
else
@
errors_area
.
html
(
response
.
message
)
else
@
errors_area
.
html
(
'Problem state got out of sync. Try reloading the page.'
)
common/lib/xmodule/xmodule/self_assessment_module.py
View file @
4922ab33
...
@@ -121,6 +121,7 @@ class SelfAssessmentModule(XModule):
...
@@ -121,6 +121,7 @@ class SelfAssessmentModule(XModule):
#set context variables and render template
#set context variables and render template
previous_answer
=
self
.
student_answers
[
-
1
]
if
self
.
student_answers
else
''
previous_answer
=
self
.
student_answers
[
-
1
]
if
self
.
student_answers
else
''
allow_reset
=
self
.
state
==
self
.
DONE
and
self
.
attempts
<
self
.
max_attempts
context
=
{
context
=
{
'prompt'
:
self
.
prompt
,
'prompt'
:
self
.
prompt
,
'previous_answer'
:
previous_answer
,
'previous_answer'
:
previous_answer
,
...
@@ -129,6 +130,7 @@ class SelfAssessmentModule(XModule):
...
@@ -129,6 +130,7 @@ class SelfAssessmentModule(XModule):
'initial_hint'
:
self
.
get_hint_html
(),
'initial_hint'
:
self
.
get_hint_html
(),
'initial_message'
:
self
.
get_message_html
(),
'initial_message'
:
self
.
get_message_html
(),
'state'
:
self
.
state
,
'state'
:
self
.
state
,
'allow_reset'
:
allow_reset
,
}
}
html
=
self
.
system
.
render_template
(
'self_assessment_prompt.html'
,
context
)
html
=
self
.
system
.
render_template
(
'self_assessment_prompt.html'
,
context
)
...
@@ -297,7 +299,8 @@ class SelfAssessmentModule(XModule):
...
@@ -297,7 +299,8 @@ class SelfAssessmentModule(XModule):
Save the hint.
Save the hint.
Returns a dict { 'success': bool,
Returns a dict { 'success': bool,
'message_html': message_html,
'message_html': message_html,
'error': error-msg},
'error': error-msg,
'allow_reset': bool},
with the error key only present if success is False and message_html
with the error key only present if success is False and message_html
only if True.
only if True.
'''
'''
...
@@ -325,7 +328,8 @@ class SelfAssessmentModule(XModule):
...
@@ -325,7 +328,8 @@ class SelfAssessmentModule(XModule):
self
.
system
.
track_function
(
'save_hint'
,
event_info
)
self
.
system
.
track_function
(
'save_hint'
,
event_info
)
return
{
'success'
:
True
,
return
{
'success'
:
True
,
'message_html'
:
self
.
get_message_html
()}
'message_html'
:
self
.
get_message_html
(),
'allow_reset'
:
self
.
attempts
<
self
.
max_attempts
}
def
reset
(
self
,
get
):
def
reset
(
self
,
get
):
...
@@ -335,8 +339,9 @@ class SelfAssessmentModule(XModule):
...
@@ -335,8 +339,9 @@ class SelfAssessmentModule(XModule):
Returns {'success': bool, 'error': msg}
Returns {'success': bool, 'error': msg}
(error only present if not success)
(error only present if not success)
"""
"""
if
self
.
state
!=
DONE
:
if
self
.
state
!=
self
.
DONE
:
return
self
.
out_of_sync_error
(
get
)
return
self
.
out_of_sync_error
(
get
)
if
self
.
attempts
>
self
.
max_attempts
:
if
self
.
attempts
>
self
.
max_attempts
:
return
{
return
{
'success'
:
False
,
'success'
:
False
,
...
...
lms/templates/self_assessment_prompt.html
View file @
4922ab33
<section
id=
"self_assessment_${id}"
class=
"self-assessment"
data-ajax-url=
"${ajax_url}"
<section
id=
"self_assessment_${id}"
class=
"self-assessment"
data-ajax-url=
"${ajax_url}"
data-id=
"${id}"
data-state=
"${state}"
>
data-id=
"${id}"
data-state=
"${state}"
data-allow_reset=
"${allow_reset}"
>
<div
class=
"error"
></div>
<div
class=
"error"
></div>
<div
class=
"prompt"
>
<div
class=
"prompt"
>
${prompt}
${prompt}
...
@@ -16,4 +16,5 @@
...
@@ -16,4 +16,5 @@
<div
class=
"message-wrapper"
>
${initial_message}
</div>
<div
class=
"message-wrapper"
>
${initial_message}
</div>
<input
type=
"button"
value=
"Submit"
class=
"submit-button"
name=
"show"
/>
<input
type=
"button"
value=
"Submit"
class=
"submit-button"
name=
"show"
/>
<input
type=
"button"
value=
"Reset"
class=
"reset-button"
name=
"reset"
/>
</section>
</section>
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