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
e7f5a808
Commit
e7f5a808
authored
Jun 26, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test failure after progress introduction
parent
119c44aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
lms/static/coffee/spec/helper.coffee
+3
-1
lms/static/coffee/spec/modules/problem_spec.coffee
+18
-16
lms/static/coffee/src/modules/problem.coffee
+1
-3
No files found.
lms/static/coffee/spec/helper.coffee
View file @
e7f5a808
...
...
@@ -20,10 +20,12 @@ jasmine.stubRequests = ->
settings
.
success
data
:
jasmine
.
stubbedMetadata
[
match
[
1
]]
else
if
match
=
settings
.
url
.
match
/static\/subs\/(.+)\.srt\.sjson/
settings
.
success
jasmine
.
stubbedCaption
else
if
settings
.
url
.
match
/modx\/problem\/.+\/problem_get$/
settings
.
success
html
:
readFixtures
(
'problem_content.html'
)
else
if
settings
.
url
==
'/calculate'
||
settings
.
url
==
'/6002x/modx/sequence/1/goto_position'
||
settings
.
url
.
match
(
/event$/
)
||
settings
.
url
.
match
(
/
6002x\/
modx\/problem\/.+\/problem_(check|reset|show|save)$/
)
settings
.
url
.
match
(
/modx\/problem\/.+\/problem_(check|reset|show|save)$/
)
# do nothing
else
throw
"External request attempted for
#{
settings
.
url
}
, which is not defined."
...
...
lms/static/coffee/spec/modules/problem_spec.coffee
View file @
e7f5a808
...
...
@@ -13,6 +13,7 @@ describe 'Problem', ->
spyOn
(
$
.
fn
,
'load'
).
andCallFake
(
url
,
callback
)
->
$
(
@
).
html
readFixtures
(
'problem_content.html'
)
callback
()
jasmine
.
stubRequests
()
describe
'constructor'
,
->
beforeEach
->
...
...
@@ -21,12 +22,6 @@ describe 'Problem', ->
it
'set the element'
,
->
expect
(
@
problem
.
element
).
toBe
'#problem_1'
it
'set the content url'
,
->
expect
(
@
problem
.
content_url
).
toEqual
'/problem/url/problem_get?id=1'
it
'render the content'
,
->
expect
(
$
.
fn
.
load
).
toHaveBeenCalledWith
@
problem
.
content_url
,
@
problem
.
bind
describe
'bind'
,
->
beforeEach
->
spyOn
window
,
'update_schematics'
...
...
@@ -77,12 +72,19 @@ describe 'Problem', ->
expect
(
@
problem
.
bind
).
toHaveBeenCalled
()
describe
'with no content given'
,
->
beforeEach
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
html
:
"Hello World"
@
problem
.
render
()
it
'load the content via ajax'
,
->
expect
(
$
.
fn
.
load
).
toHaveBeenCalledWith
@
problem
.
content_url
,
@
bind
expect
(
@
problem
.
element
.
html
()).
toEqual
'Hello World'
it
're-bind the content'
,
->
expect
(
@
problem
.
bind
).
toHaveBeenCalled
()
describe
'check'
,
->
beforeEach
->
jasmine
.
stubRequests
()
@
problem
=
new
Problem
1
,
'/problem/url/'
@
problem
.
answers
=
'foo=1&bar=2'
...
...
@@ -116,7 +118,6 @@ describe 'Problem', ->
describe
'reset'
,
->
beforeEach
->
jasmine
.
stubRequests
()
@
problem
=
new
Problem
1
,
'/problem/url/'
it
'log the problem_reset event'
,
->
...
...
@@ -130,13 +131,13 @@ describe 'Problem', ->
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/problem/1/problem_reset'
,
{
id
:
1
},
jasmine
.
any
(
Function
)
it
'render the returned content'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
(
"Reset!"
)
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
answers
,
callback
)
->
callback
html
:
"Reset!"
@
problem
.
reset
()
expect
(
@
problem
.
element
.
html
()).
toEqual
'Reset!'
describe
'show'
,
->
beforeEach
->
jasmine
.
stubRequests
()
@
problem
=
new
Problem
1
,
'/problem/url/'
@
problem
.
element
.
prepend
'<div id="answer_1_1" /><div id="answer_1_2" />'
...
...
@@ -154,18 +155,19 @@ describe 'Problem', ->
expect
(
$
.
postWithPrefix
).
toHaveBeenCalledWith
'/modx/problem/1/problem_show'
,
jasmine
.
any
(
Function
)
it
'show the answers'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
'1_1'
:
'One'
,
'1_2'
:
'Two'
)
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
answers
:
'1_1'
:
'One'
,
'1_2'
:
'Two'
@
problem
.
show
()
expect
(
$
(
'#answer_1_1'
)).
toHaveHtml
'One'
expect
(
$
(
'#answer_1_2'
)).
toHaveHtml
'Two'
it
'toggle the show answer button'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
({})
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
answers
:
{})
@
problem
.
show
()
expect
(
$
(
'.show'
)).
toHaveValue
'Hide Answer'
it
'add the showed class to element'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
({})
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
answers
:
{})
@
problem
.
show
()
expect
(
@
problem
.
element
).
toHaveClass
'showed'
...
...
@@ -179,7 +181,8 @@ describe 'Problem', ->
'''
it
'set the correct_answer attribute on the choice'
,
->
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
(
'1_1'
:
[
2
,
3
])
spyOn
(
$
,
'postWithPrefix'
).
andCallFake
(
url
,
callback
)
->
callback
answers
:
'1_1'
:
[
2
,
3
]
@
problem
.
show
()
expect
(
$
(
'label[for="input_1_1_1"]'
)).
not
.
toHaveAttr
'correct_answer'
,
'true'
expect
(
$
(
'label[for="input_1_1_2"]'
)).
toHaveAttr
'correct_answer'
,
'true'
...
...
@@ -214,7 +217,6 @@ describe 'Problem', ->
describe
'save'
,
->
beforeEach
->
jasmine
.
stubRequests
()
@
problem
=
new
Problem
1
,
'/problem/url/'
@
problem
.
answers
=
'foo=1&bar=2'
...
...
lms/static/coffee/src/modules/problem.coffee
View file @
e7f5a808
class
@
Problem
constructor
:
(
@
id
,
url
)
->
@
element
=
$
(
"#problem_
#{
id
}
"
)
@
content_url
=
"
#{
url
}
problem_get?id=
#{
@
id
}
"
@
render
()
$
:
(
selector
)
->
...
...
@@ -27,10 +26,9 @@ class @Problem
@
element
.
html
(
content
)
@
bind
()
else
$
.
postWithPrefix
"/modx/problem/
#{
@
id
}
/problem_get"
,
''
,
(
response
)
=>
$
.
postWithPrefix
"/modx/problem/
#{
@
id
}
/problem_get"
,
(
response
)
=>
@
element
.
html
(
response
.
html
)
@
bind
()
check
:
=>
Logger
.
log
'problem_check'
,
@
answers
...
...
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