Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
460c5997
Commit
460c5997
authored
Mar 08, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI tweaks to save response
parent
01ddf348
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
3 deletions
+23
-3
apps/openassessment/xblock/openassessmentblock.py
+7
-1
apps/openassessment/xblock/static/js/src/oa_base.js
+2
-1
apps/openassessment/xblock/submission_mixin.py
+12
-1
apps/openassessment/xblock/test/test_save_response.py
+2
-0
No files found.
apps/openassessment/xblock/openassessmentblock.py
View file @
460c5997
...
@@ -10,7 +10,7 @@ from django.template.loader import get_template
...
@@ -10,7 +10,7 @@ from django.template.loader import get_template
from
webob
import
Response
from
webob
import
Response
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
List
,
Scope
,
String
from
xblock.fields
import
List
,
Scope
,
String
,
Boolean
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
openassessment.xblock.grade_mixin
import
GradeMixin
from
openassessment.xblock.grade_mixin
import
GradeMixin
...
@@ -205,6 +205,12 @@ class OpenAssessmentBlock(
...
@@ -205,6 +205,12 @@ class OpenAssessmentBlock(
help
=
"The student's submission that others will be assessing."
help
=
"The student's submission that others will be assessing."
)
)
has_saved
=
Boolean
(
default
=
False
,
scope
=
Scope
.
user_state
,
help
=
"Indicates whether the user has saved a response"
)
saved_response
=
String
(
saved_response
=
String
(
default
=
u""
,
default
=
u""
,
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
...
...
apps/openassessment/xblock/static/js/src/oa_base.js
View file @
460c5997
...
@@ -177,9 +177,10 @@ OpenAssessment.BaseUI.prototype = {
...
@@ -177,9 +177,10 @@ OpenAssessment.BaseUI.prototype = {
// Retrieve the student's response from the DOM
// Retrieve the student's response from the DOM
var
submission
=
$
(
'#submission__answer__value'
,
this
.
element
).
val
();
var
submission
=
$
(
'#submission__answer__value'
,
this
.
element
).
val
();
var
ui
=
this
;
var
ui
=
this
;
$
(
'#response__save_status'
,
this
.
element
).
html
(
'Saving...'
);
this
.
server
.
save
(
submission
).
done
(
function
()
{
this
.
server
.
save
(
submission
).
done
(
function
()
{
// Update the "saved" icon
// Update the "saved" icon
$
(
'#response__save_status'
,
this
.
element
).
replaceWith
(
"Sav
ed"
);
$
(
'#response__save_status'
,
this
.
element
).
html
(
"Saved but not submitt
ed"
);
}).
fail
(
function
(
errMsg
)
{
}).
fail
(
function
(
errMsg
)
{
// TODO: display to the user
// TODO: display to the user
console
.
log
(
errMsg
);
console
.
log
(
errMsg
);
...
...
apps/openassessment/xblock/submission_mixin.py
View file @
460c5997
...
@@ -87,6 +87,7 @@ class SubmissionMixin(object):
...
@@ -87,6 +87,7 @@ class SubmissionMixin(object):
if
'submission'
in
data
:
if
'submission'
in
data
:
try
:
try
:
self
.
saved_response
=
unicode
(
data
[
'submission'
])
self
.
saved_response
=
unicode
(
data
[
'submission'
])
self
.
has_saved
=
True
except
:
except
:
return
{
'success'
:
False
,
'msg'
:
_
(
u"Could not save response submission"
)}
return
{
'success'
:
False
,
'msg'
:
_
(
u"Could not save response submission"
)}
else
:
else
:
...
@@ -144,6 +145,16 @@ class SubmissionMixin(object):
...
@@ -144,6 +145,16 @@ class SubmissionMixin(object):
pass
pass
return
submissions
[
0
]
if
submissions
else
None
return
submissions
[
0
]
if
submissions
else
None
@property
def
save_status
(
self
):
"""
Return a string indicating whether the response has been saved.
Returns:
unicode
"""
return
_
(
u'Saved but not submitted'
)
if
self
.
has_saved
else
_
(
u'Not saved'
)
@XBlock.handler
@XBlock.handler
def
render_submission
(
self
,
data
,
suffix
=
''
):
def
render_submission
(
self
,
data
,
suffix
=
''
):
"""Renders the Submission HTML section of the XBlock
"""Renders the Submission HTML section of the XBlock
...
@@ -178,7 +189,7 @@ class SubmissionMixin(object):
...
@@ -178,7 +189,7 @@ class SubmissionMixin(object):
"student_score"
:
student_score
,
"student_score"
:
student_score
,
"step_status"
:
step_status
,
"step_status"
:
step_status
,
"saved_response"
:
self
.
saved_response
,
"saved_response"
:
self
.
saved_response
,
"save_status"
:
_
(
'Saved but not submitted'
)
if
len
(
self
.
saved_response
)
>
0
else
_
(
"Not saved"
),
"save_status"
:
self
.
save_status
}
}
path
=
"openassessmentblock/response/oa_response.html"
path
=
"openassessmentblock/response/oa_response.html"
...
...
apps/openassessment/xblock/test/test_save_response.py
View file @
460c5997
...
@@ -14,6 +14,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
...
@@ -14,6 +14,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
def
test_default_saved_response_blank
(
self
,
xblock
):
def
test_default_saved_response_blank
(
self
,
xblock
):
resp
=
self
.
request
(
xblock
,
'render_submission'
,
json
.
dumps
({}))
resp
=
self
.
request
(
xblock
,
'render_submission'
,
json
.
dumps
({}))
self
.
assertIn
(
'<textarea id="submission__answer__value" placeholder=""></textarea>'
,
resp
)
self
.
assertIn
(
'<textarea id="submission__answer__value" placeholder=""></textarea>'
,
resp
)
self
.
assertIn
(
'<div id="response__save_status">Not saved</div>'
,
resp
)
@ddt.file_data
(
'data/save_responses.json'
)
@ddt.file_data
(
'data/save_responses.json'
)
@scenario
(
'data/save_scenario.xml'
,
user_id
=
"Perleman"
)
@scenario
(
'data/save_scenario.xml'
,
user_id
=
"Perleman"
)
...
@@ -31,6 +32,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
...
@@ -31,6 +32,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
submitted
=
submission_text
submitted
=
submission_text
)
)
self
.
assertIn
(
expected_html
,
resp
.
decode
(
'utf-8'
))
self
.
assertIn
(
expected_html
,
resp
.
decode
(
'utf-8'
))
self
.
assertIn
(
'<div id="response__save_status">Saved but not submitted</div>'
,
resp
)
@scenario
(
'data/save_scenario.xml'
,
user_id
=
"Valchek"
)
@scenario
(
'data/save_scenario.xml'
,
user_id
=
"Valchek"
)
def
test_overwrite_saved_response
(
self
,
xblock
):
def
test_overwrite_saved_response
(
self
,
xblock
):
...
...
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