Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
57756344
Commit
57756344
authored
Apr 23, 2014
by
Carson Gee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jasmine tests and factored out javascript functions to new file
parent
c7713064
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
54 deletions
+129
-54
common/test/acceptance/pages/lms/staff_view.py
+3
-0
lms/static/js/spec/staff_debug_actions_spec.js
+65
-0
lms/static/js/staff_debug_actions.js
+57
-0
lms/static/js_test.yml
+1
-0
lms/templates/courseware/xqa_interface.html
+2
-2
lms/templates/staff_problem_info.html
+1
-52
No files found.
common/test/acceptance/pages/lms/staff_view.py
View file @
57756344
...
...
@@ -79,5 +79,8 @@ class StaffDebugPage(PageObject):
@property
def
idash_msg
(
self
):
"""
Returns the value of #idash_msg
"""
self
.
wait_for_ajax
()
return
self
.
q
(
css
=
'#idash_msg'
)
.
text
lms/static/js/spec/staff_debug_actions_spec.js
0 → 100644
View file @
57756344
describe
(
'StaffDebugActions'
,
function
()
{
var
loc
=
'test_loc'
;
var
fixture_id
=
'sd_fu_'
+
loc
;
var
fixture
=
$
(
'<input id="'
+
fixture_id
+
'" placeholder="userman" />'
);
describe
(
'get_url '
,
function
()
{
it
(
'defines url to courseware ajax entry point'
,
function
()
{
spyOn
(
StaffDebug
,
"get_current_url"
).
andReturn
(
"/courses/edX/Open_DemoX/edx_demo_course/courseware/stuff"
);
expect
(
StaffDebug
.
get_url
(
'instructor'
)).
toBe
(
'/courses/edX/Open_DemoX/edx_demo_course/instructor'
);
});
});
describe
(
'get_user'
,
function
()
{
it
(
'gets the placeholder username if input field is empty'
,
function
()
{
$
(
'body'
).
append
(
fixture
);
expect
(
StaffDebug
.
get_user
(
loc
)).
toBe
(
'userman'
);
$
(
'#'
+
fixture_id
).
remove
();
});
it
(
'gets a filled in name if there is one'
,
function
()
{
$
(
'body'
).
append
(
fixture
);
$
(
'#'
+
fixture_id
).
val
(
'notuserman'
);
expect
(
StaffDebug
.
get_user
(
loc
)).
toBe
(
'notuserman'
);
$
(
'#'
+
fixture_id
).
val
(
''
);
$
(
'#'
+
fixture_id
).
remove
();
});
});
describe
(
'reset'
,
function
()
{
it
(
'makes an ajax call with the expected parameters'
,
function
()
{
$
(
'body'
).
append
(
fixture
);
spyOn
(
$
,
'ajax'
);
StaffDebug
.
reset
(
loc
)
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'type'
]).
toEqual
(
'POST'
);
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'data'
]).
toEqual
({
'action'
:
"Reset student's attempts"
,
'problem_for_student'
:
loc
,
'unique_student_identifier'
:
'userman'
});
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'url'
]).
toEqual
(
'/instructor'
);
$
(
'#'
+
fixture_id
).
remove
();
});
});
describe
(
'sdelete'
,
function
()
{
it
(
'makes an ajax call with the expected parameters'
,
function
()
{
$
(
'body'
).
append
(
fixture
);
spyOn
(
$
,
'ajax'
);
StaffDebug
.
sdelete
(
loc
)
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'type'
]).
toEqual
(
'POST'
);
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'data'
]).
toEqual
({
'action'
:
"Delete student state for module"
,
'problem_for_student'
:
loc
,
'unique_student_identifier'
:
'userman'
});
expect
(
$
.
ajax
.
mostRecentCall
.
args
[
0
][
'url'
]).
toEqual
(
'/instructor'
);
$
(
'#'
+
fixture_id
).
remove
();
});
});
});
lms/static/js/staff_debug_actions.js
0 → 100644
View file @
57756344
var
StaffDebug
=
(
function
(){
get_current_url
=
function
()
{
return
window
.
location
.
pathname
;
}
get_url
=
function
(
action
){
var
pathname
=
this
.
get_current_url
();
console
.
log
(
pathname
)
var
url
=
pathname
.
substr
(
0
,
pathname
.
indexOf
(
'/courseware'
))
+
'/'
+
action
;
return
url
;
}
get_user
=
function
(
locname
){
var
uname
=
$
(
'#sd_fu_'
+
locname
).
val
();
if
(
uname
==
""
){
uname
=
$
(
'#sd_fu_'
+
locname
).
attr
(
'placeholder'
);
}
return
uname
;
}
do_idash_action
=
function
(
locname
,
idaction
){
var
pdata
=
{
'action'
:
idaction
,
'problem_for_student'
:
locname
,
'unique_student_identifier'
:
get_user
(
locname
)
}
$
.
ajax
({
type
:
"POST"
,
url
:
get_url
(
'instructor'
),
data
:
pdata
,
success
:
function
(
data
){
var
msg
=
$
(
"#idash_msg"
,
data
);
$
(
"#result_"
+
locname
).
html
(
msg
);
},
error
:
function
(
request
,
status
,
error
)
{
$
(
"#result_"
+
locname
).
html
(
'<p id="idash_msg"><font color="red">'
+
gettext
(
'Something has gone wrong with this request. The server replied with a status of: '
)
+
error
+
'</font></p>'
);
},
dataType
:
'html'
});
}
reset
=
function
(
locname
){
do_idash_action
(
locname
,
"Reset student's attempts"
);
}
sdelete
=
function
(
locname
){
do_idash_action
(
locname
,
"Delete student state for module"
);
}
return
{
reset
:
reset
,
sdelete
:
sdelete
,
do_idash_action
:
do_idash_action
,
get_current_url
:
get_current_url
,
get_url
:
get_url
,
get_user
:
get_user
}
})();
lms/static/js_test.yml
View file @
57756344
...
...
@@ -51,6 +51,7 @@ lib_paths:
src_paths
:
-
coffee/src
-
js/src
-
js
# Paths to spec (test) JavaScript files
spec_paths
:
...
...
lms/templates/courseware/xqa_interface.html
View file @
57756344
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/jquery.leanModal.min.js')}"
></script>
<script
type=
"text/javascript"
src=
"${static.url('js/staff_debug_actions.js')}"
></script>
<script
type=
"text/javascript"
>
function
setup_debug
(
element_id
,
edit_link
,
staff_context
){
...
...
@@ -91,4 +92,4 @@ function getlog(element_id, staff_context){
};
</script>
\ No newline at end of file
</script>
lms/templates/staff_problem_info.html
View file @
57756344
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%
namespace
name=
'static'
file=
'/static_content.html'
/>
## The JS for this is defined in xqa_interface.html
${block_content}
...
...
@@ -53,58 +54,6 @@ ${block_content}
<h2>
${_('Staff Debug')}
</h2>
</header>
<script
type=
"text/javascript"
>
var
StaffDebug
=
(
function
(){
geturl
=
function
(
action
){
var
pathname
=
window
.
location
.
pathname
;
var
url
=
pathname
.
substr
(
0
,
pathname
.
indexOf
(
'/courseware'
))
+
'/'
+
action
;
return
url
;
}
get_user
=
function
(
locname
){
var
uname
=
$
(
'#sd_fu_'
+
locname
).
val
();
if
(
uname
==
""
){
uname
=
"${user.username}"
;
}
return
uname
;
}
do_idash_action
=
function
(
locname
,
idaction
){
var
pdata
=
{
'csrfmiddlewaretoken'
:
"${csrf_token}"
,
'action'
:
idaction
,
'problem_for_student'
:
locname
,
'unique_student_identifier'
:
get_user
(
locname
)
}
$
.
ajax
({
type
:
"POST"
,
url
:
geturl
(
'instructor'
),
data
:
pdata
,
success
:
function
(
data
){
var
msg
=
$
(
"#idash_msg"
,
data
);
$
(
"#result_"
+
locname
).
html
(
msg
);
},
error
:
function
(
request
,
status
,
error
)
{
$
(
"#result_"
+
locname
).
html
(
'<p id="idash_msg"><font color="red">${_('
Something
has
gone
wrong
with
this
request
.
The
server
replied
with
a
status
of
:
')}'
+
error
+
'</font></p>'
)
},
dataType
:
'html'
});
}
reset
=
function
(
locname
){
do_idash_action
(
locname
,
"Reset student's attempts"
);
}
sdelete
=
function
(
locname
){
do_idash_action
(
locname
,
"Delete student state for module"
);
}
return
{
reset
:
reset
,
sdelete
:
sdelete
,
do_idash_action
:
do_idash_action
}
})();
</script>
<hr
/>
<h3>
Actions
</h3>
<div>
...
...
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