Commit 9fce2faf by ichuang

Merge pull request #100 from MITx/ps-fix-histogram

Fix histogram and sequence navigation bug

looks good, works in my tests. thanks.
parents 3bfe8112 b4ed14f4
......@@ -11,7 +11,7 @@ describe 'Histogram', ->
describe 'calculate', ->
beforeEach ->
@histogram = new Histogram(1, [[1, 1], [2, 2], [3, 3]])
@histogram = new Histogram(1, [[null, 1], [1, 1], [2, 2], [3, 3]])
it 'store the correct value for data', ->
expect(@histogram.data).toEqual [[1, Math.log(2)], [2, Math.log(3)], [3, Math.log(4)]]
......
......@@ -24,7 +24,6 @@ describe 'Sequence', ->
expect(titles).toEqual ['Video 1', 'Video 2', 'Sample Problem']
it 'bind the page events', ->
expect(@sequence.element).toHandleWith 'contentChanged', @sequence.toggleArrows
expect($('#sequence-list a')).toHandleWith 'click', @sequence.goto
it 'render the active sequence content', ->
......@@ -76,6 +75,7 @@ describe 'Sequence', ->
spyOn $, 'postWithPrefix'
@sequence = new Sequence '1', @items, 'sequence'
spyOnEvent @sequence.element, 'contentChanged'
spyOn(@sequence, 'toggleArrows').andCallThrough()
describe 'with a different position than the current one', ->
beforeEach ->
......@@ -105,6 +105,9 @@ describe 'Sequence', ->
it 'update the position', ->
expect(@sequence.position).toEqual 1
it 're-update the arrows', ->
expect(@sequence.toggleArrows).toHaveBeenCalled()
it 'trigger contentChanged event', ->
expect('contentChanged').toHaveBeenTriggeredOn @sequence.element
......
......@@ -8,6 +8,7 @@ class @Histogram
calculate: ->
for [score, count] in @rawData
continue if score == null
log_count = Math.log(count + 1)
@data.push [score, log_count]
@xTicks.push [score, score.toString()]
......
......@@ -9,7 +9,6 @@ class @Sequence
$(selector, @element)
bind: ->
@element.bind 'contentChanged', @toggleArrows
@$('#sequence-list a').click @goto
buildNavigation: ->
......@@ -43,6 +42,7 @@ class @Sequence
MathJax.Hub.Queue(["Typeset", MathJax.Hub])
@position = new_position
@toggleArrows()
@element.trigger 'contentChanged'
goto: (event) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment