Commit be92ad04 by Prem Sichanugrist

Handle the case where histogram score can be null

This will leave out the student that never attempt the question and
fixes the error with histogram rendering.
parent f031d16d
......@@ -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)]]
......
......@@ -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()]
......
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