+
@@ -46,7 +46,7 @@ describe 'Courseware', ->
expect(window.Video).toHaveBeenCalledWith('2', '1.0:def5678')
it 'detect the problem element and convert it', ->
- expect(window.Problem).toHaveBeenCalledWith('3', '/example/url/')
+ expect(window.Problem).toHaveBeenCalledWith(3, 'problem_3', '/example/url/')
it 'detect the histrogram element and convert it', ->
expect(window.Histogram).toHaveBeenCalledWith('3', [[0, 1]])
diff --git a/lms/static/coffee/spec/helper.coffee b/lms/static/coffee/spec/helper.coffee
index c0d3d77950..33c7fdb43f 100644
--- a/lms/static/coffee/spec/helper.coffee
+++ b/lms/static/coffee/spec/helper.coffee
@@ -20,12 +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$/
+ else if settings.url.match /modx\/.+\/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(/modx\/.+\/goto_position$/) ||
settings.url.match(/event$/) ||
- settings.url.match(/modx\/problem\/.+\/problem_(check|reset|show|save)$/)
+ settings.url.match(/modx\/.+\/problem_(check|reset|show|save)$/)
# do nothing
else
throw "External request attempted for #{settings.url}, which is not defined."
diff --git a/lms/static/coffee/spec/modules/problem_spec.coffee b/lms/static/coffee/spec/modules/problem_spec.coffee
index 48d63784d6..107930c3b1 100644
--- a/lms/static/coffee/spec/modules/problem_spec.coffee
+++ b/lms/static/coffee/spec/modules/problem_spec.coffee
@@ -17,7 +17,7 @@ describe 'Problem', ->
describe 'constructor', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
it 'set the element', ->
expect(@problem.el).toBe '#problem_1'
@@ -26,7 +26,7 @@ describe 'Problem', ->
beforeEach ->
spyOn window, 'update_schematics'
MathJax.Hub.getAllJax.andReturn [@stubbedJax]
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
it 'set mathjax typeset', ->
expect(MathJax.Hub.Queue).toHaveBeenCalled()
@@ -60,7 +60,7 @@ describe 'Problem', ->
describe 'render', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@bind = @problem.bind
spyOn @problem, 'bind'
@@ -88,7 +88,7 @@ describe 'Problem', ->
describe 'check', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@problem.answers = 'foo=1&bar=2'
it 'log the problem_check event', ->
@@ -98,7 +98,7 @@ describe 'Problem', ->
it 'submit the answer for check', ->
spyOn $, 'postWithPrefix'
@problem.check()
- expect($.postWithPrefix).toHaveBeenCalledWith '/modx/problem/1/problem_check', 'foo=1&bar=2', jasmine.any(Function)
+ expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/problem_check', 'foo=1&bar=2', jasmine.any(Function)
describe 'when the response is correct', ->
it 'call render with returned content', ->
@@ -121,7 +121,7 @@ describe 'Problem', ->
describe 'reset', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
it 'log the problem_reset event', ->
@problem.answers = 'foo=1&bar=2'
@@ -131,7 +131,7 @@ describe 'Problem', ->
it 'POST to the problem reset page', ->
spyOn $, 'postWithPrefix'
@problem.reset()
- expect($.postWithPrefix).toHaveBeenCalledWith '/modx/problem/1/problem_reset', { id: 1 }, jasmine.any(Function)
+ expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/problem_reset', { id: 1 }, jasmine.any(Function)
it 'render the returned content', ->
spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) ->
@@ -141,7 +141,7 @@ describe 'Problem', ->
describe 'show', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@problem.el.prepend '
'
describe 'when the answer has not yet shown', ->
@@ -155,7 +155,7 @@ describe 'Problem', ->
it 'fetch the answers', ->
spyOn $, 'postWithPrefix'
@problem.show()
- expect($.postWithPrefix).toHaveBeenCalledWith '/modx/problem/1/problem_show', jasmine.any(Function)
+ expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/problem_show', jasmine.any(Function)
it 'show the answers', ->
spyOn($, 'postWithPrefix').andCallFake (url, callback) ->
@@ -220,7 +220,7 @@ describe 'Problem', ->
describe 'save', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@problem.answers = 'foo=1&bar=2'
it 'log the problem_save event', ->
@@ -230,7 +230,7 @@ describe 'Problem', ->
it 'POST to save problem', ->
spyOn $, 'postWithPrefix'
@problem.save()
- expect($.postWithPrefix).toHaveBeenCalledWith '/modx/problem/1/problem_save', 'foo=1&bar=2', jasmine.any(Function)
+ expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/problem_save', 'foo=1&bar=2', jasmine.any(Function)
it 'alert to the user', ->
spyOn window, 'alert'
@@ -240,7 +240,7 @@ describe 'Problem', ->
describe 'refreshMath', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
$('#input_example_1').val 'E=mc^2'
@problem.refreshMath target: $('#input_example_1').get(0)
@@ -250,7 +250,7 @@ describe 'Problem', ->
describe 'updateMathML', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@stubbedJax.root.toMathML.andReturn '
'
describe 'when there is no exception', ->
@@ -270,7 +270,7 @@ describe 'Problem', ->
describe 'refreshAnswers', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
@problem.el.html '''
diff --git a/lms/static/coffee/spec/modules/sequence_spec.coffee b/lms/static/coffee/spec/modules/sequence_spec.coffee
index 61f48c4f13..3708c76537 100644
--- a/lms/static/coffee/spec/modules/sequence_spec.coffee
+++ b/lms/static/coffee/spec/modules/sequence_spec.coffee
@@ -9,7 +9,7 @@ describe 'Sequence', ->
describe 'constructor', ->
beforeEach ->
- @sequence = new Sequence '1', @items, 'sequence', 1
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
it 'set the element', ->
expect(@sequence.el).toEqual $('#sequence_1')
@@ -31,7 +31,7 @@ describe 'Sequence', ->
describe 'toggleArrows', ->
beforeEach ->
- @sequence = new Sequence '1', @items, 'sequence', 1
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
describe 'when the first tab is active', ->
beforeEach ->
@@ -73,7 +73,7 @@ describe 'Sequence', ->
describe 'render', ->
beforeEach ->
spyOn $, 'postWithPrefix'
- @sequence = new Sequence '1', @items, 'sequence'
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence'
spyOnEvent @sequence.el, 'contentChanged'
spyOn(@sequence, 'toggleArrows').andCallThrough()
@@ -94,7 +94,7 @@ describe 'Sequence', ->
expect($('[data-element="2"]')).toHaveClass 'seq_video_visited'
it 'save the new position', ->
- expect($.postWithPrefix).toHaveBeenCalledWith '/modx/sequence/1/goto_position', position: 1
+ expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/goto_position', position: 1
it 'mark new tab as active', ->
expect($('[data-element="1"]')).toHaveClass 'seq_video_active'
@@ -120,7 +120,7 @@ describe 'Sequence', ->
describe 'goto', ->
beforeEach ->
jasmine.stubRequests()
- @sequence = new Sequence '1', @items, 'sequence', 2
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('[data-element="3"]').click()
it 'log the sequence goto event', ->
@@ -132,7 +132,7 @@ describe 'Sequence', ->
describe 'next', ->
beforeEach ->
jasmine.stubRequests()
- @sequence = new Sequence '1', @items, 'sequence', 2
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('.sequence-nav-buttons .next a').click()
it 'log the next sequence event', ->
@@ -144,7 +144,7 @@ describe 'Sequence', ->
describe 'previous', ->
beforeEach ->
jasmine.stubRequests()
- @sequence = new Sequence '1', @items, 'sequence', 2
+ @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('.sequence-nav-buttons .prev a').click()
it 'log the previous sequence event', ->
@@ -155,5 +155,5 @@ describe 'Sequence', ->
describe 'link_for', ->
it 'return a link for specific position', ->
- sequence = new Sequence '1', @items, 2
+ sequence = new Sequence '1', 'sequence_1', @items, 2
expect(sequence.link_for(2)).toBe '[data-element="2"]'
diff --git a/lms/static/coffee/src/courseware.coffee b/lms/static/coffee/src/courseware.coffee
index 4e57d13194..39c4dec2fe 100644
--- a/lms/static/coffee/src/courseware.coffee
+++ b/lms/static/coffee/src/courseware.coffee
@@ -20,7 +20,7 @@ class @Courseware
id = $(this).attr('id').replace(/video_/, '')
new Video id, $(this).data('streams')
$('.course-content .problems-wrapper').each ->
- id = $(this).attr('problem-id')
+ id = $(this).data('problem-id')
new Problem id, $(this).attr('id'), $(this).data('url')
$('.course-content .histogram').each ->
id = $(this).attr('id').replace(/histogram_/, '')
diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee
index aa86237254..c2ebd0d590 100644
--- a/lms/static/coffee/src/modules/problem.coffee
+++ b/lms/static/coffee/src/modules/problem.coffee
@@ -1,6 +1,6 @@
class @Problem
constructor: (@id, @element_id, url) ->
- @el = $("##{element_id}")
+ @el = $("##{@element_id}")
@render()
$: (selector) ->
diff --git a/lms/static/coffee/src/modules/sequence.coffee b/lms/static/coffee/src/modules/sequence.coffee
index 6d8a513a32..958fbd17cf 100644
--- a/lms/static/coffee/src/modules/sequence.coffee
+++ b/lms/static/coffee/src/modules/sequence.coffee
@@ -1,6 +1,6 @@
class @Sequence
constructor: (@id, @element_id, @elements, @tag, position) ->
- @el = $("#sequence_#{@element_id}")
+ @el = $("##{@element_id}")
@buildNavigation()
@initProgress()
@bind()
diff --git a/lms/templates/problem_ajax.html b/lms/templates/problem_ajax.html
index 6330edfac0..012e4276c3 100644
--- a/lms/templates/problem_ajax.html
+++ b/lms/templates/problem_ajax.html
@@ -1 +1 @@
-
+
diff --git a/lms/templates/seq_module.html b/lms/templates/seq_module.html
index 00221a4951..292aa1230d 100644
--- a/lms/templates/seq_module.html
+++ b/lms/templates/seq_module.html
@@ -22,7 +22,7 @@
<%block name="js_extra">
%block>