+
@@ -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 eed1a07bd2..9a6efd9389 100644
--- a/lms/static/coffee/spec/helper.coffee
+++ b/lms/static/coffee/spec/helper.coffee
@@ -1,14 +1,14 @@
jasmine.getFixtures().fixturesPath = "/_jasmine/fixtures/"
jasmine.stubbedMetadata =
- abc123:
- id: 'abc123'
- duration: 100
- def456:
- id: 'def456'
+ slowerSpeedYoutubeId:
+ id: 'slowerSpeedYoutubeId'
+ duration: 300
+ normalSpeedYoutubeId:
+ id: 'normalSpeedYoutubeId'
duration: 200
bogus:
- duration: 300
+ duration: 100
jasmine.stubbedCaption =
start: [0, 10000, 20000, 30000]
@@ -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."
@@ -49,10 +49,10 @@ jasmine.stubVideoPlayer = (context, enableParts, createPlayer=true) ->
loadFixtures 'video.html'
jasmine.stubRequests()
YT.Player = undefined
- context.video = new Video 'example', '.75:abc123,1.0:def456'
+ context.video = new Video 'example', '.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
jasmine.stubYoutubePlayer()
if createPlayer
- return new VideoPlayer context.video
+ return new VideoPlayer(video: context.video)
spyOn(window, 'onunload')
diff --git a/lms/static/coffee/spec/logger_spec.coffee b/lms/static/coffee/spec/logger_spec.coffee
index bfad742de3..33f924362a 100644
--- a/lms/static/coffee/spec/logger_spec.coffee
+++ b/lms/static/coffee/spec/logger_spec.coffee
@@ -25,7 +25,7 @@ describe 'Logger', ->
it 'send a request to log event', ->
spyOn($, 'ajax')
- $(window).trigger('onunload')
+ window.onunload()
expect($.ajax).toHaveBeenCalledWith
url: "#{Courseware.prefix}/event",
data:
diff --git a/lms/static/coffee/spec/modules/problem_spec.coffee b/lms/static/coffee/spec/modules/problem_spec.coffee
index 7537cd3493..107930c3b1 100644
--- a/lms/static/coffee/spec/modules/problem_spec.coffee
+++ b/lms/static/coffee/spec/modules/problem_spec.coffee
@@ -17,16 +17,16 @@ 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.element).toBe '#problem_1'
+ expect(@problem.el).toBe '#problem_1'
describe 'bind', ->
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'
@@ -69,7 +69,7 @@ describe 'Problem', ->
@problem.render 'Hello World'
it 'render the content', ->
- expect(@problem.element.html()).toEqual 'Hello World'
+ expect(@problem.el.html()).toEqual 'Hello World'
it 're-bind the content', ->
expect(@problem.bind).toHaveBeenCalled()
@@ -81,14 +81,14 @@ describe 'Problem', ->
@problem.render()
it 'load the content via ajax', ->
- expect(@problem.element.html()).toEqual 'Hello World'
+ expect(@problem.el.html()).toEqual 'Hello World'
it 're-bind the content', ->
expect(@problem.bind).toHaveBeenCalled()
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,19 +98,19 @@ 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', ->
spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) -> callback(success: 'correct', contents: 'Correct!')
@problem.check()
- expect(@problem.element.html()).toEqual 'Correct!'
+ expect(@problem.el.html()).toEqual 'Correct!'
describe 'when the response is incorrect', ->
it 'call render with returned content', ->
spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) -> callback(success: 'incorrect', contents: 'Correct!')
@problem.check()
- expect(@problem.element.html()).toEqual 'Correct!'
+ expect(@problem.el.html()).toEqual 'Correct!'
describe 'when the response is undetermined', ->
it 'alert the response', ->
@@ -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,22 +131,22 @@ 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) ->
callback html: "Reset!"
@problem.reset()
- expect(@problem.element.html()).toEqual 'Reset!'
+ expect(@problem.el.html()).toEqual 'Reset!'
describe 'show', ->
beforeEach ->
- @problem = new Problem 1, '/problem/url/'
- @problem.element.prepend '
'
+ @problem = new Problem 1, "problem_1", "/problem/url/"
+ @problem.el.prepend '
'
describe 'when the answer has not yet shown', ->
beforeEach ->
- @problem.element.removeClass 'showed'
+ @problem.el.removeClass 'showed'
it 'log the problem_show event', ->
@problem.show()
@@ -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) ->
@@ -172,11 +172,11 @@ describe 'Problem', ->
it 'add the showed class to element', ->
spyOn($, 'postWithPrefix').andCallFake (url, callback) -> callback(answers: {})
@problem.show()
- expect(@problem.element).toHaveClass 'showed'
+ expect(@problem.el).toHaveClass 'showed'
describe 'multiple choice question', ->
beforeEach ->
- @problem.element.prepend '''
+ @problem.el.prepend '''
@@ -194,8 +194,8 @@ describe 'Problem', ->
describe 'when the answers are alreay shown', ->
beforeEach ->
- @problem.element.addClass 'showed'
- @problem.element.prepend '''
+ @problem.el.addClass 'showed'
+ @problem.el.prepend '''
'''
- it 'bind to player speedChange event', ->
- expect($(@player)).toHandleWith 'speedChange', @speedControl.onSpeedChange
-
it 'bind to change video speed link', ->
expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed
@@ -29,7 +26,7 @@ describe 'VideoSpeedControl', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn true
$('.speeds').removeClass 'open'
- @speedControl = new VideoSpeedControl @player, @video.speeds
+ @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'open the speed toggle on click', ->
$('.speeds').click()
@@ -41,7 +38,7 @@ describe 'VideoSpeedControl', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn false
$('.speeds').removeClass 'open'
- @speedControl = new VideoSpeedControl @player, @video.speeds
+ @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'open the speed toggle on hover', ->
$('.speeds').mouseenter()
@@ -59,31 +56,31 @@ describe 'VideoSpeedControl', ->
describe 'changeVideoSpeed', ->
beforeEach ->
- @speedControl = new VideoSpeedControl @player, @video.speeds
+ @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
@video.setSpeed '1.0'
describe 'when new speed is the same', ->
beforeEach ->
- spyOnEvent @player, 'speedChange'
+ spyOnEvent @speedControl, 'speedChange'
$('li[data-speed="1.0"] a').click()
it 'does not trigger speedChange event', ->
- expect('speedChange').not.toHaveBeenTriggeredOn @player
+ expect('speedChange').not.toHaveBeenTriggeredOn @speedControl
describe 'when new speed is not the same', ->
beforeEach ->
@newSpeed = null
- $(@player).bind 'speedChange', (event, newSpeed) => @newSpeed = newSpeed
- spyOnEvent @player, 'speedChange'
+ $(@speedControl).bind 'speedChange', (event, newSpeed) => @newSpeed = newSpeed
+ spyOnEvent @speedControl, 'speedChange'
$('li[data-speed="0.75"] a').click()
- it 'trigger player speedChange event', ->
- expect('speedChange').toHaveBeenTriggeredOn @player
+ it 'trigger speedChange event', ->
+ expect('speedChange').toHaveBeenTriggeredOn @speedControl
expect(@newSpeed).toEqual 0.75
describe 'onSpeedChange', ->
beforeEach ->
- @speedControl = new VideoSpeedControl @player, @video.speeds
+ @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
$('li[data-speed="1.0"] a').addClass 'active'
@speedControl.setSpeed '0.75'
diff --git a/lms/static/coffee/spec/modules/video/video_volume_control_spec.coffee b/lms/static/coffee/spec/modules/video/video_volume_control_spec.coffee
index cbdef03ef0..a2b14afa55 100644
--- a/lms/static/coffee/spec/modules/video/video_volume_control_spec.coffee
+++ b/lms/static/coffee/spec/modules/video/video_volume_control_spec.coffee
@@ -1,15 +1,15 @@
describe 'VideoVolumeControl', ->
beforeEach ->
- @player = jasmine.stubVideoPlayer @
+ jasmine.stubVideoPlayer @
$('.volume').remove()
describe 'constructor', ->
beforeEach ->
spyOn($.fn, 'slider')
- @volumeControl = new VideoVolumeControl @player
+ @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
- it 'initialize previousVolume to 100', ->
- expect(@volumeControl.previousVolume).toEqual 100
+ it 'initialize currentVolume to 100', ->
+ expect(@volumeControl.currentVolume).toEqual 100
it 'render the volume control', ->
expect($('.secondary-controls').html()).toContain """
@@ -32,7 +32,6 @@ describe 'VideoVolumeControl', ->
slide: @volumeControl.onChange
it 'bind the volume control', ->
- expect($(@player)).toHandleWith 'ready', @volumeControl.onReady
expect($('.volume>a')).toHandleWith 'click', @volumeControl.toggleMute
expect($('.volume')).not.toHaveClass 'open'
@@ -41,27 +40,19 @@ describe 'VideoVolumeControl', ->
$('.volume').mouseleave()
expect($('.volume')).not.toHaveClass 'open'
- describe 'onReady', ->
- beforeEach ->
- @volumeControl = new VideoVolumeControl @player
- spyOn $.fn, 'slider'
- spyOn(@player, 'volume').andReturn 60
- @volumeControl.onReady()
-
- it 'set the max value of the slider', ->
- expect($.fn.slider).toHaveBeenCalledWith 'option', 'max', 60
-
describe 'onChange', ->
beforeEach ->
- spyOn @player, 'volume'
- @volumeControl = new VideoVolumeControl @player
+ spyOnEvent @volumeControl, 'volumeChange'
+ @newVolume = undefined
+ @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
+ $(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
describe 'when the new volume is more than 0', ->
beforeEach ->
@volumeControl.onChange undefined, value: 60
it 'set the player volume', ->
- expect(@player.volume).toHaveBeenCalledWith 60
+ expect(@newVolume).toEqual 60
it 'remote muted class', ->
expect($('.volume')).not.toHaveClass 'muted'
@@ -71,32 +62,33 @@ describe 'VideoVolumeControl', ->
@volumeControl.onChange undefined, value: 0
it 'set the player volume', ->
- expect(@player.volume).toHaveBeenCalledWith 0
+ expect(@newVolume).toEqual 0
it 'add muted class', ->
expect($('.volume')).toHaveClass 'muted'
describe 'toggleMute', ->
beforeEach ->
- spyOn @player, 'volume'
- @volumeControl = new VideoVolumeControl @player
+ @newVolume = undefined
+ @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
+ $(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
describe 'when the current volume is more than 0', ->
beforeEach ->
- @player.volume.andReturn 60
+ @volumeControl.currentVolume = 60
@volumeControl.toggleMute()
it 'save the previous volume', ->
expect(@volumeControl.previousVolume).toEqual 60
it 'set the player volume', ->
- expect(@player.volume).toHaveBeenCalledWith 0
+ expect(@newVolume).toEqual 0
describe 'when the current volume is 0', ->
beforeEach ->
- @player.volume.andReturn 0
+ @volumeControl.currentVolume = 0
@volumeControl.previousVolume = 60
@volumeControl.toggleMute()
it 'set the player volume to previous volume', ->
- expect(@player.volume).toHaveBeenCalledWith 60
+ expect(@newVolume).toEqual 60
diff --git a/lms/static/coffee/spec/modules/video_spec.coffee b/lms/static/coffee/spec/modules/video_spec.coffee
index 134b38caff..67399b2ce3 100644
--- a/lms/static/coffee/spec/modules/video_spec.coffee
+++ b/lms/static/coffee/spec/modules/video_spec.coffee
@@ -3,6 +3,10 @@ describe 'Video', ->
loadFixtures 'video.html'
jasmine.stubRequests()
+ @videosDefinition = '.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
+ @slowerSpeedYoutubeId = 'slowerSpeedYoutubeId'
+ @normalSpeedYoutubeId = 'normalSpeedYoutubeId'
+
afterEach ->
window.player = undefined
window.onYouTubePlayerAPIReady = undefined
@@ -15,26 +19,26 @@ describe 'Video', ->
describe 'by default', ->
beforeEach ->
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
it 'reset the current video player', ->
expect(window.player).toBeNull()
it 'set the elements', ->
- expect(@video.element).toBe '#video_example'
+ expect(@video.el).toBe '#video_example'
it 'parse the videos', ->
expect(@video.videos).toEqual
- '0.75': 'abc123'
- '1.0': 'def456'
+ '0.75': @slowerSpeedYoutubeId
+ '1.0': @normalSpeedYoutubeId
it 'fetch the video metadata', ->
expect(@video.metadata).toEqual
- abc123:
- id: 'abc123'
- duration: 100
- def456:
- id: 'def456'
+ slowerSpeedYoutubeId:
+ id: @slowerSpeedYoutubeId
+ duration: 300
+ normalSpeedYoutubeId:
+ id: @normalSpeedYoutubeId
duration: 200
it 'parse available video speeds', ->
@@ -51,20 +55,20 @@ describe 'Video', ->
@originalYT = window.YT
window.YT = { Player: true }
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
afterEach ->
window.YT = @originalYT
it 'create the Video Player', ->
- expect(window.VideoPlayer).toHaveBeenCalledWith @video
+ expect(window.VideoPlayer).toHaveBeenCalledWith(video: @video)
expect(@video.player).toEqual @stubVideoPlayer
describe 'when the Youtube API is not ready', ->
beforeEach ->
@originalYT = window.YT
window.YT = {}
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
afterEach ->
window.YT = @originalYT
@@ -77,33 +81,33 @@ describe 'Video', ->
@originalYT = window.YT
window.YT = {}
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
window.onYouTubePlayerAPIReady()
afterEach ->
window.YT = @originalYT
it 'create the Video Player for all video elements', ->
- expect(window.VideoPlayer).toHaveBeenCalledWith @video
+ expect(window.VideoPlayer).toHaveBeenCalledWith(video: @video)
expect(@video.player).toEqual @stubVideoPlayer
describe 'youtubeId', ->
beforeEach ->
$.cookie.andReturn '1.0'
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
describe 'with speed', ->
it 'return the video id for given speed', ->
- expect(@video.youtubeId('0.75')).toEqual 'abc123'
- expect(@video.youtubeId('1.0')).toEqual 'def456'
+ expect(@video.youtubeId('0.75')).toEqual @slowerSpeedYoutubeId
+ expect(@video.youtubeId('1.0')).toEqual @normalSpeedYoutubeId
describe 'without speed', ->
it 'return the video id for current speed', ->
- expect(@video.youtubeId()).toEqual 'def456'
+ expect(@video.youtubeId()).toEqual @normalSpeedYoutubeId
describe 'setSpeed', ->
beforeEach ->
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
describe 'when new speed is available', ->
beforeEach ->
@@ -124,7 +128,22 @@ describe 'Video', ->
describe 'getDuration', ->
beforeEach ->
- @video = new Video 'example', '.75:abc123,1.0:def456'
+ @video = new Video 'example', @videosDefinition
it 'return duration for current video', ->
expect(@video.getDuration()).toEqual 200
+
+ describe 'log', ->
+ beforeEach ->
+ @video = new Video 'example', @videosDefinition
+ @video.setSpeed '1.0'
+ spyOn Logger, 'log'
+ @video.player = { currentTime: 25 }
+ @video.log 'someEvent'
+
+ it 'call the logger with valid parameters', ->
+ expect(Logger.log).toHaveBeenCalledWith 'someEvent',
+ id: 'example'
+ code: @normalSpeedYoutubeId
+ currentTime: 25
+ speed: '1.0'
diff --git a/lms/static/coffee/src/_subview.coffee b/lms/static/coffee/src/_subview.coffee
new file mode 100644
index 0000000000..2e14289843
--- /dev/null
+++ b/lms/static/coffee/src/_subview.coffee
@@ -0,0 +1,14 @@
+class @Subview
+ constructor: (options) ->
+ $.each options, (key, value) =>
+ @[key] = value
+ @initialize()
+ @render()
+ @bind()
+
+ $: (selector) ->
+ $(selector, @el)
+
+ initialize: ->
+ render: ->
+ bind: ->
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/main.coffee b/lms/static/coffee/src/main.coffee
index 7fe23689c5..b8047df2a3 100644
--- a/lms/static/coffee/src/main.coffee
+++ b/lms/static/coffee/src/main.coffee
@@ -24,8 +24,8 @@ $ ->
# Preserved for backward compatibility
window.submit_circuit = (circuit_id) ->
- $("input.schematic").each (index, element) ->
- element.schematic.update_value()
+ $("input.schematic").each (index, el) ->
+ el.schematic.update_value()
schematic_value $("#schematic_#{circuit_id}").attr("value")
$.postWithPrefix "/save_circuit/#{circuit_id}", schematic: schematic_value, (data) ->
diff --git a/lms/static/coffee/src/modules/problem.coffee b/lms/static/coffee/src/modules/problem.coffee
index 85186a2903..c2ebd0d590 100644
--- a/lms/static/coffee/src/modules/problem.coffee
+++ b/lms/static/coffee/src/modules/problem.coffee
@@ -1,10 +1,10 @@
class @Problem
constructor: (@id, @element_id, url) ->
- @element = $("##{element_id}")
+ @el = $("##{@element_id}")
@render()
$: (selector) ->
- $(selector, @element)
+ $(selector, @el)
bind: =>
MathJax.Hub.Queue ["Typeset", MathJax.Hub]
@@ -18,16 +18,16 @@ class @Problem
updateProgress: (response) =>
if response.progress_changed
- @element.attr progress: response.progress_status
- @element.trigger('progressChanged')
+ @el.attr progress: response.progress_status
+ @el.trigger('progressChanged')
render: (content) ->
if content
- @element.html(content)
+ @el.html(content)
@bind()
else
$.postWithPrefix "/modx/#{@id}/problem_get", (response) =>
- @element.html(response.html)
+ @el.html(response.html)
@bind()
check: =>
@@ -47,7 +47,7 @@ class @Problem
@updateProgress response
show: =>
- if !@element.hasClass 'showed'
+ if !@el.hasClass 'showed'
Logger.log 'problem_show', problem: @id
$.postWithPrefix "/modx/#{@id}/problem_show", (response) =>
answers = response.answers
@@ -59,12 +59,12 @@ class @Problem
@$("#answer_#{key}, #solution_#{key}").html(value)
MathJax.Hub.Queue ["Typeset", MathJax.Hub]
@$('.show').val 'Hide Answer'
- @element.addClass 'showed'
+ @el.addClass 'showed'
@updateProgress response
else
@$('[id^=answer_], [id^=solution_]').text ''
@$('[correct_answer]').attr correct_answer: null
- @element.removeClass 'showed'
+ @el.removeClass 'showed'
@$('.show').val 'Show Answer'
save: =>
diff --git a/lms/static/coffee/src/modules/sequence.coffee b/lms/static/coffee/src/modules/sequence.coffee
index 2c979f0853..958fbd17cf 100644
--- a/lms/static/coffee/src/modules/sequence.coffee
+++ b/lms/static/coffee/src/modules/sequence.coffee
@@ -1,13 +1,13 @@
class @Sequence
constructor: (@id, @element_id, @elements, @tag, position) ->
- @element = $("#sequence_#{@element_id}")
+ @el = $("##{@element_id}")
@buildNavigation()
@initProgress()
@bind()
@render position
$: (selector) ->
- $(selector, @element)
+ $(selector, @el)
bind: ->
@$('#sequence-list a').click @goto
@@ -57,7 +57,7 @@ class @Sequence
when 'none' then element.addClass('progress-none')
when 'in_progress' then element.addClass('progress-some')
when 'done' then element.addClass('progress-done')
-
+
buildNavigation: ->
$.each @elements, (index, item) =>
link = $('