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
fd00b4aa
Commit
fd00b4aa
authored
Apr 17, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for TIM-474. Disable submit buttons during transaction.
parent
f2334ad9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
2 deletions
+178
-2
apps/openassessment/xblock/static/js/openassessment.min.js
+0
-0
apps/openassessment/xblock/static/js/spec/oa_peer.js
+57
-0
apps/openassessment/xblock/static/js/spec/oa_self.js
+65
-0
apps/openassessment/xblock/static/js/src/oa_base.js
+56
-2
No files found.
apps/openassessment/xblock/static/js/openassessment.min.js
View file @
fd00b4aa
This diff is collapsed.
Click to expand it.
apps/openassessment/xblock/static/js/spec/oa_peer.js
0 → 100644
View file @
fd00b4aa
/**
Tests for OpenAssessment Peer view.
**/
describe
(
"OpenAssessment.PeerView"
,
function
()
{
// Stub server
var
StubServer
=
function
()
{
var
successPromise
=
$
.
Deferred
(
function
(
defer
)
{
defer
.
resolve
();
}
).
promise
();
this
.
peerAssess
=
function
(
optionsSelected
,
feedback
)
{
return
$
.
Deferred
(
function
(
defer
)
{
defer
.
resolve
();
}).
promise
();
};
this
.
render
=
function
(
step
)
{
return
successPromise
;
};
};
// Stub runtime
var
runtime
=
{};
// Stubs
var
server
=
null
;
// View under test
var
view
=
null
;
beforeEach
(
function
()
{
// Load the DOM fixture
jasmine
.
getFixtures
().
fixturesPath
=
'base/fixtures'
;
loadFixtures
(
'oa_peer_assessment.html'
);
// Create a new stub server
server
=
new
StubServer
();
// Create the object under test
var
el
=
$
(
"#openassessment"
).
get
(
0
);
view
=
new
OpenAssessment
.
BaseView
(
runtime
,
el
,
server
);
});
it
(
"re-enables the peer assess button on error"
,
function
()
{
// Simulate a server error
spyOn
(
server
,
'peerAssess'
).
andCallFake
(
function
()
{
expect
(
view
.
peerSubmitEnabled
()).
toBe
(
false
);
return
$
.
Deferred
(
function
(
defer
)
{
defer
.
rejectWith
(
this
,
[
'ENOUNKNOWN'
,
'Error occurred!'
]);
}).
promise
();
});
view
.
peerAssess
();
// Expect the submit button to have been re-enabled
expect
(
view
.
peerSubmitEnabled
()).
toBe
(
true
);
});
});
apps/openassessment/xblock/static/js/spec/oa_self.js
0 → 100644
View file @
fd00b4aa
/**
Tests for OpenAssessment Self view.
**/
describe
(
"OpenAssessment.SelfView"
,
function
()
{
// Stub server
var
StubServer
=
function
()
{
var
successPromise
=
$
.
Deferred
(
function
(
defer
)
{
defer
.
resolve
();
}
).
promise
();
this
.
selfAssess
=
function
(
optionsSelected
)
{
return
$
.
Deferred
(
function
(
defer
)
{
defer
.
resolve
();
}).
promise
();
};
this
.
render
=
function
(
step
)
{
return
successPromise
;
};
};
// Stub base view
var
StubBaseView
=
function
()
{
this
.
showLoadError
=
function
(
msg
)
{};
this
.
toggleActionError
=
function
(
msg
,
step
)
{};
this
.
setUpCollapseExpand
=
function
(
sel
)
{};
};
// Stub runtime
var
runtime
=
{};
// Stubs
var
server
=
null
;
// View under test
var
view
=
null
;
beforeEach
(
function
()
{
// Load the DOM fixture
jasmine
.
getFixtures
().
fixturesPath
=
'base/fixtures'
;
loadFixtures
(
'oa_self_assessment.html'
);
// Create a new stub server
server
=
new
StubServer
();
// Create the object under test
var
el
=
$
(
"#openassessment"
).
get
(
0
);
view
=
new
OpenAssessment
.
BaseView
(
runtime
,
el
,
server
);
});
it
(
"re-enables the self assess button on error"
,
function
()
{
// Simulate a server error
spyOn
(
server
,
'selfAssess'
).
andCallFake
(
function
()
{
expect
(
view
.
selfSubmitEnabled
()).
toBe
(
false
);
return
$
.
Deferred
(
function
(
defer
)
{
defer
.
rejectWith
(
this
,
[
'ENOUNKNOWN'
,
'Error occurred!'
]);
}).
promise
();
});
view
.
selfAssess
();
// Expect the submit button to have been re-enabled
expect
(
view
.
selfSubmitEnabled
()).
toBe
(
true
);
});
});
apps/openassessment/xblock/static/js/src/oa_base.js
View file @
fd00b4aa
...
...
@@ -216,6 +216,54 @@ OpenAssessment.BaseView.prototype = {
},
/**
Enable/disable the peer assess button button.
Check that whether the peer assess button is enabled.
Args:
enabled (bool): If specified, set the state of the button.
Returns:
bool: Whether the button is enabled.
Examples:
>> view.peerSubmitEnabled(true); // enable the button
>> view.peerSubmitEnabled(); // check whether the button is enabled
>> true
**/
peerSubmitEnabled
:
function
(
enabled
)
{
var
button
=
$
(
'#peer-assessment--001__assessment__submit'
,
this
.
element
);
if
(
typeof
enabled
===
'undefined'
)
{
return
!
button
.
hasClass
(
'is--disabled'
);
}
else
{
button
.
toggleClass
(
'is--disabled'
,
!
enabled
)
}
},
/**
Enable/disable the self assess button.
Check that whether the self assess button is enabled.
Args:
enabled (bool): If specified, set the state of the button.
Returns:
bool: Whether the button is enabled.
Examples:
>> view.selfSubmitEnabled(true); // enable the button
>> view.selfSubmitEnabled(); // check whether the button is enabled
>> true
**/
selfSubmitEnabled
:
function
(
enabled
)
{
var
button
=
$
(
'#self-assessment--001__assessment__submit'
,
this
.
element
);
if
(
typeof
enabled
===
'undefined'
)
{
return
!
button
.
hasClass
(
'is--disabled'
);
}
else
{
button
.
toggleClass
(
'is--disabled'
,
!
enabled
)
}
},
/**
Send an assessment to the server and update the view.
**/
peerAssess
:
function
()
{
...
...
@@ -261,11 +309,14 @@ OpenAssessment.BaseView.prototype = {
// Send the assessment to the server
var
view
=
this
;
this
.
toggleActionError
(
'peer'
,
null
);
view
.
toggleActionError
(
'peer'
,
null
);
view
.
peerSubmitEnabled
(
false
);
this
.
server
.
peerAssess
(
optionsSelected
,
feedback
).
done
(
successFunction
).
fail
(
function
(
errMsg
)
{
view
.
toggleActionError
(
'peer'
,
errMsg
);
view
.
peerSubmitEnabled
(
true
);
});
},
...
...
@@ -283,7 +334,9 @@ OpenAssessment.BaseView.prototype = {
// Send the assessment to the server
var
view
=
this
;
this
.
toggleActionError
(
'self'
,
null
);
view
.
toggleActionError
(
'self'
,
null
);
view
.
selfSubmitEnabled
(
false
);
this
.
server
.
selfAssess
(
optionsSelected
).
done
(
function
()
{
view
.
renderPeerAssessmentStep
();
...
...
@@ -293,6 +346,7 @@ OpenAssessment.BaseView.prototype = {
}
).
fail
(
function
(
errMsg
)
{
view
.
toggleActionError
(
'self'
,
errMsg
);
view
.
selfSubmitEnabled
(
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