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
8c599f3e
Commit
8c599f3e
authored
Aug 28, 2017
by
Awais Jibran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not try to upload when popup is cancled during file upload
parent
7bee621d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
openassessment/xblock/static/js/openassessment-lms.min.js
+0
-0
openassessment/xblock/static/js/spec/lms/oa_response.js
+23
-0
openassessment/xblock/static/js/src/lms/oa_response.js
+13
-5
No files found.
openassessment/xblock/static/js/openassessment-lms.min.js
View file @
8c599f3e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
openassessment/xblock/static/js/spec/lms/oa_response.js
View file @
8c599f3e
...
@@ -679,4 +679,27 @@ describe("OpenAssessment.ResponseView", function() {
...
@@ -679,4 +679,27 @@ describe("OpenAssessment.ResponseView", function() {
view
.
uploadFiles
();
view
.
uploadFiles
();
expect
(
$
(
view
.
element
).
find
(
'.file__description'
).
length
).
toEqual
(
0
);
expect
(
$
(
view
.
element
).
find
(
'.file__description'
).
length
).
toEqual
(
0
);
});
});
it
(
"prevents user from submitting response when files selection is cancelled"
,
function
()
{
// Set fileupload to be required.
view
.
fileUploadResponse
=
'required'
;
// Change the response text
view
.
response
([
'Lorem ipsum 1'
,
'Lorem ipsum 2'
]);
view
.
handleResponseChanged
();
// Expect the unsaved warning to be enabled and save progress button is enabled.
expect
(
view
.
saveEnabled
()).
toBe
(
true
);
expect
(
view
.
saveStatus
()).
toContain
(
'This response has not been saved.'
);
// Assume user has selected no files (cancelled the file select pop-up) the event will
// trigger with no files selected. Expect Submit response button is disabled.
view
.
prepareUpload
([],
'image'
,
[]);
expect
(
view
.
submitEnabled
()).
toBe
(
false
);
// Expect there are no pending upload files & file upload button is disabled.
expect
(
view
.
hasPendingUploadFiles
()).
toEqual
(
false
);
expect
(
view
.
files
).
toEqual
(
null
);
expect
(
$
(
view
.
element
).
find
(
'.file__upload'
).
first
().
is
(
':disabled'
)).
toEqual
(
true
);
});
});
});
openassessment/xblock/static/js/src/lms/oa_response.js
View file @
8c599f3e
...
@@ -259,6 +259,14 @@ OpenAssessment.ResponseView.prototype = {
...
@@ -259,6 +259,14 @@ OpenAssessment.ResponseView.prototype = {
previewEnabled
:
function
(
enabled
)
{
previewEnabled
:
function
(
enabled
)
{
return
this
.
baseView
.
buttonEnabled
(
'.submission__preview'
,
enabled
);
return
this
.
baseView
.
buttonEnabled
(
'.submission__preview'
,
enabled
);
},
},
/**
Check if there is a file selected but not uploaded yet
Returns:
boolean: if we have pending files or not.
**/
hasPendingUploadFiles
:
function
()
{
return
this
.
files
!==
null
&&
!
this
.
filesUploaded
;
},
/**
/**
Set the save status message.
Set the save status message.
...
@@ -422,8 +430,7 @@ OpenAssessment.ResponseView.prototype = {
...
@@ -422,8 +430,7 @@ OpenAssessment.ResponseView.prototype = {
var
baseView
=
this
.
baseView
;
var
baseView
=
this
.
baseView
;
var
fileDefer
=
$
.
Deferred
();
var
fileDefer
=
$
.
Deferred
();
// check if there is a file selected but not uploaded yet
if
(
view
.
hasPendingUploadFiles
())
{
if
(
view
.
files
!==
null
&&
!
view
.
filesUploaded
)
{
var
msg
=
gettext
(
'Do you want to upload your file before submitting?'
);
var
msg
=
gettext
(
'Do you want to upload your file before submitting?'
);
if
(
confirm
(
msg
))
{
if
(
confirm
(
msg
))
{
fileDefer
=
view
.
uploadFiles
();
fileDefer
=
view
.
uploadFiles
();
...
@@ -533,7 +540,6 @@ OpenAssessment.ResponseView.prototype = {
...
@@ -533,7 +540,6 @@ OpenAssessment.ResponseView.prototype = {
var
fileType
=
null
;
var
fileType
=
null
;
var
fileName
=
''
;
var
fileName
=
''
;
var
errorCheckerTriggered
=
false
;
var
errorCheckerTriggered
=
false
;
var
sel
=
$
(
'.step--response'
,
this
.
element
);
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
totalSize
+=
files
[
i
].
size
;
totalSize
+=
files
[
i
].
size
;
...
@@ -582,12 +588,14 @@ OpenAssessment.ResponseView.prototype = {
...
@@ -582,12 +588,14 @@ OpenAssessment.ResponseView.prototype = {
if
(
!
errorCheckerTriggered
)
{
if
(
!
errorCheckerTriggered
)
{
this
.
baseView
.
toggleActionError
(
'upload'
,
null
);
this
.
baseView
.
toggleActionError
(
'upload'
,
null
);
this
.
files
=
files
;
if
(
files
.
length
>
0
)
{
this
.
files
=
files
;
}
this
.
updateFilesDescriptionsFields
(
files
,
descriptions
,
uploadType
);
this
.
updateFilesDescriptionsFields
(
files
,
descriptions
,
uploadType
);
}
}
if
(
this
.
files
===
null
)
{
if
(
this
.
files
===
null
)
{
sel
.
find
(
'.file__upload'
).
prop
(
'disabled'
,
true
);
$
(
this
.
element
)
.
find
(
'.file__upload'
).
prop
(
'disabled'
,
true
);
}
}
},
},
...
...
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