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
4d2b35d2
Commit
4d2b35d2
authored
Mar 08, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #89 from edx/will/save-ui-tweaks
UI tweaks to save response
parents
b05d1134
460c5997
Hide 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 @
4d2b35d2
...
...
@@ -10,7 +10,7 @@ from django.template.loader import get_template
from
webob
import
Response
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
openassessment.xblock.grade_mixin
import
GradeMixin
...
...
@@ -205,6 +205,12 @@ class OpenAssessmentBlock(
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
(
default
=
u""
,
scope
=
Scope
.
user_state
,
...
...
apps/openassessment/xblock/static/js/src/oa_base.js
View file @
4d2b35d2
...
...
@@ -177,9 +177,10 @@ OpenAssessment.BaseUI.prototype = {
// Retrieve the student's response from the DOM
var
submission
=
$
(
'#submission__answer__value'
,
this
.
element
).
val
();
var
ui
=
this
;
$
(
'#response__save_status'
,
this
.
element
).
html
(
'Saving...'
);
this
.
server
.
save
(
submission
).
done
(
function
()
{
// 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
)
{
// TODO: display to the user
console
.
log
(
errMsg
);
...
...
apps/openassessment/xblock/submission_mixin.py
View file @
4d2b35d2
...
...
@@ -92,6 +92,7 @@ class SubmissionMixin(object):
if
'submission'
in
data
:
try
:
self
.
saved_response
=
unicode
(
data
[
'submission'
])
self
.
has_saved
=
True
except
:
return
{
'success'
:
False
,
'msg'
:
_
(
u"Could not save response submission"
)}
else
:
...
...
@@ -149,6 +150,16 @@ class SubmissionMixin(object):
pass
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
def
render_submission
(
self
,
data
,
suffix
=
''
):
"""Renders the Submission HTML section of the XBlock
...
...
@@ -183,7 +194,7 @@ class SubmissionMixin(object):
"student_score"
:
student_score
,
"step_status"
:
step_status
,
"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"
...
...
apps/openassessment/xblock/test/test_save_response.py
View file @
4d2b35d2
...
...
@@ -14,6 +14,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
def
test_default_saved_response_blank
(
self
,
xblock
):
resp
=
self
.
request
(
xblock
,
'render_submission'
,
json
.
dumps
({}))
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'
)
@scenario
(
'data/save_scenario.xml'
,
user_id
=
"Perleman"
)
...
...
@@ -31,6 +32,7 @@ class SaveResponseTest(XBlockHandlerTestCase):
submitted
=
submission_text
)
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"
)
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