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
1f3e1218
Commit
1f3e1218
authored
Aug 02, 2017
by
Awais Jibran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix empty file description in ORA response
parent
4ceb210b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
25 deletions
+35
-25
openassessment/xblock/static/js/spec/lms/oa_response.js
+25
-11
openassessment/xblock/static/js/src/lms/oa_response.js
+1
-1
openassessment/xblock/submission_mixin.py
+9
-13
No files found.
openassessment/xblock/static/js/spec/lms/oa_response.js
View file @
1f3e1218
...
...
@@ -626,6 +626,10 @@ describe("OpenAssessment.ResponseView", function() {
function
getFileUploadField
()
{
return
$
(
view
.
element
).
find
(
'.file__upload'
).
first
();
}
function
expectFileUploadButton
(
disabled
)
{
view
.
checkFilesDescriptions
();
expect
(
getFileUploadField
().
is
(
':disabled'
)).
toEqual
(
disabled
);
}
spyOn
(
view
,
'updateFilesDescriptionsFields'
).
and
.
callThrough
();
var
files
=
[{
type
:
'image/jpeg'
,
size
:
1024
,
name
:
'picture1.jpg'
,
data
:
''
},
...
...
@@ -634,26 +638,36 @@ describe("OpenAssessment.ResponseView", function() {
expect
(
getFileUploadField
().
is
(
':disabled'
)).
toEqual
(
true
);
expect
(
view
.
updateFilesDescriptionsFields
).
toHaveBeenCalledWith
(
files
,
undefined
,
'image'
);
var
firstDescriptionField1
=
$
(
view
.
element
).
find
(
'.file__description__0'
).
first
();
var
firstDescriptionField2
=
$
(
view
.
element
).
find
(
'.file__description__1'
).
first
();
//
set the first description field (the second is still empty)
//
Only set the first description field and the second field remain empty.
// and check that upload button is disabled
var
firstDescriptionField1
=
$
(
view
.
element
).
find
(
'.file__description__0'
).
first
();
$
(
firstDescriptionField1
).
val
(
'test'
);
view
.
checkFilesDescriptions
();
expect
(
getFileUploadField
().
is
(
':disabled'
)).
toEqual
(
true
);
$
(
firstDescriptionField1
).
val
(
'test1'
);
$
(
firstDescriptionField2
).
val
(
''
);
expectFileUploadButton
(
true
);
// set the second description field (now both descriptions are not empty)
// Set the second description field to be only spaces (given first description has value).
// and check that upload button is disabled
$
(
firstDescriptionField2
).
val
(
' '
);
expectFileUploadButton
(
true
)
// Set the both description fields to contain only spaces.
// and check that upload button is disabled
$
(
firstDescriptionField1
).
val
(
' '
);
$
(
firstDescriptionField2
).
val
(
' '
);
expectFileUploadButton
(
true
)
// set the both description field to contain non empty values.
// and check that upload button is enabled
var
firstDescriptionField2
=
$
(
view
.
element
).
find
(
'.file__description__1'
).
first
(
);
$
(
firstDescriptionField1
).
val
(
'test1'
);
$
(
firstDescriptionField2
).
val
(
'test2'
);
view
.
checkFilesDescriptions
();
expect
(
getFileUploadField
().
is
(
':disabled'
)).
toEqual
(
false
);
expectFileUploadButton
(
false
)
// remove value in the first upload field
// and check that upload button is disabled
$
(
firstDescriptionField1
).
val
(
''
);
view
.
checkFilesDescriptions
();
expect
(
getFileUploadField
().
is
(
':disabled'
)).
toEqual
(
true
);
expectFileUploadButton
(
true
)
});
it
(
"removes description fields after files upload"
,
function
()
{
...
...
openassessment/xblock/static/js/src/lms/oa_response.js
View file @
1f3e1218
...
...
@@ -666,7 +666,7 @@ OpenAssessment.ResponseView.prototype = {
var
filesDescriptions
=
[];
$
(
this
.
element
).
find
(
'.file__description'
).
each
(
function
()
{
var
filesDescriptionVal
=
$
(
this
).
val
(
);
var
filesDescriptionVal
=
$
.
trim
(
$
(
this
).
val
()
);
if
(
filesDescriptionVal
)
{
filesDescriptions
.
push
(
filesDescriptionVal
);
}
else
{
...
...
openassessment/xblock/submission_mixin.py
View file @
1f3e1218
...
...
@@ -400,24 +400,20 @@ class SubmissionMixin(object):
"""
urls
=
[]
if
'file_keys'
in
submission
[
'answer'
]:
keys
=
submission
[
'answer'
]
.
get
(
'file_keys'
,
[])
file_
keys
=
submission
[
'answer'
]
.
get
(
'file_keys'
,
[])
descriptions
=
submission
[
'answer'
]
.
get
(
'files_descriptions'
,
[])
for
idx
,
key
in
enumerate
(
keys
):
url
=
self
.
_get_url_by_file_key
(
key
)
if
url
:
description
=
''
try
:
description
=
descriptions
[
idx
]
except
IndexError
:
pass
urls
.
append
((
url
,
description
))
for
idx
,
key
in
enumerate
(
file_keys
):
file_download_url
=
self
.
_get_url_by_file_key
(
key
)
if
file_download_url
:
file_description
=
descriptions
[
idx
]
.
strip
()
if
idx
<
len
(
descriptions
)
else
''
urls
.
append
((
file_download_url
,
file_description
))
else
:
break
elif
'file_key'
in
submission
[
'answer'
]:
key
=
submission
[
'answer'
]
.
get
(
'file_key'
,
''
)
url
=
self
.
_get_url_by_file_key
(
key
)
if
url
:
urls
.
append
((
url
,
''
))
file_download_
url
=
self
.
_get_url_by_file_key
(
key
)
if
file_download_
url
:
urls
.
append
((
file_download_
url
,
''
))
return
urls
@staticmethod
...
...
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