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
b788a2e5
Commit
b788a2e5
authored
Jan 25, 2018
by
attiyaishaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not try to upload/submit when uploaded file is moved or deleted.
parent
9b6f447a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
15 deletions
+53
-15
openassessment/xblock/static/js/spec/lms/oa_response.js
+18
-1
openassessment/xblock/static/js/src/lms/oa_response.js
+35
-14
No files found.
openassessment/xblock/static/js/spec/lms/oa_response.js
View file @
b788a2e5
...
...
@@ -702,4 +702,20 @@ describe("OpenAssessment.ResponseView", function() {
expect
(
view
.
files
).
toEqual
(
null
);
expect
(
$
(
view
.
element
).
find
(
'.file__upload'
).
first
().
is
(
':disabled'
)).
toEqual
(
true
);
});
});
it
(
"prevents user from uploading files when file is moved or deleted"
,
function
()
{
spyOn
(
view
.
baseView
,
'toggleActionError'
).
and
.
callThrough
();
view
.
fileUploadResponse
=
'optional'
;
var
file
=
[{
type
:
'image/jpeg'
,
size
:
0
,
name
:
'picture.jpg'
,
data
:
''
}];
view
.
prepareUpload
(
file
,
'image'
,
[
'test1'
]);
view
.
uploadFiles
();
expect
(
view
.
hasAllUploadFiles
()).
toEqual
(
false
);
expect
(
view
.
baseView
.
toggleActionError
).
toHaveBeenCalledWith
(
'upload'
,
"Your file "
+
file
[
0
].
name
+
" has been deleted or path has been changed."
);
});
});
\ No newline at end of file
openassessment/xblock/static/js/src/lms/oa_response.js
View file @
b788a2e5
...
...
@@ -125,13 +125,15 @@ OpenAssessment.ResponseView.prototype = {
eventObject
.
preventDefault
();
var
previouslyUploadedFiles
=
sel
.
find
(
'.submission__answer__file'
).
length
?
true
:
false
;
$
(
'.submission__answer__display__file'
,
view
.
element
).
removeClass
(
'is--hidden'
);
if
(
previouslyUploadedFiles
)
{
var
msg
=
gettext
(
'After you upload new files all your previously uploaded files will be overwritten. Continue?'
);
// jscs:ignore maximumLineLength
if
(
confirm
(
msg
))
{
if
(
view
.
hasAllUploadFiles
())
{
if
(
previouslyUploadedFiles
)
{
var
msg
=
gettext
(
'After you upload new files all your previously uploaded files will be overwritten. Continue?'
);
// jscs:ignore maximumLineLength
if
(
confirm
(
msg
))
{
view
.
uploadFiles
();
}
}
else
{
view
.
uploadFiles
();
}
}
else
{
view
.
uploadFiles
();
}
}
);
...
...
@@ -267,7 +269,24 @@ OpenAssessment.ResponseView.prototype = {
hasPendingUploadFiles
:
function
()
{
return
this
.
files
!==
null
&&
!
this
.
filesUploaded
;
},
/**
Check if there is a selected file moved or deleted before uploading
Returns:
boolean: if we have deleted/moved files or not.
**/
hasAllUploadFiles
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
files
.
length
;
i
++
)
{
var
file
=
this
.
files
[
i
];
if
(
file
.
size
===
0
)
{
this
.
baseView
.
toggleActionError
(
'upload'
,
gettext
(
"Your file "
+
file
.
name
+
" has been deleted or path has been changed."
));
this
.
submitEnabled
(
true
);
return
false
;
}
}
return
true
;
},
/**
Set the save status message.
Retrieve the save status message.
...
...
@@ -431,16 +450,18 @@ OpenAssessment.ResponseView.prototype = {
var
fileDefer
=
$
.
Deferred
();
if
(
view
.
hasPendingUploadFiles
())
{
var
msg
=
gettext
(
'Do you want to upload your file before submitting?'
);
if
(
confirm
(
msg
))
{
fileDefer
=
view
.
uploadFiles
();
if
(
fileDefer
===
false
)
{
return
;
}
}
else
{
view
.
submitEnabled
(
true
);
if
(
!
view
.
hasAllUploadFiles
())
{
return
;
}
else
{
var
msg
=
gettext
(
'Do you want to upload your file before submitting?'
);
if
(
confirm
(
msg
))
{
fileDefer
=
view
.
uploadFiles
();
if
(
fileDefer
===
false
)
{
return
;
}
}
}
}
else
{
fileDefer
.
resolve
();
}
...
...
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