liam-m / flippd

A lightweight VLE for the "flipped classroom"
1 stars 0 forks source link

Small refactors to main.rb #15

Open Lixquid opened 8 years ago

Lixquid commented 8 years ago

Small things that can be done on final/q1-refactor:

liam-m commented 8 years ago

Looking at this code, it took me a bit to understand what it means:

    if params[ ( "q" + index.to_s ).to_sym ].nil?
      answer = params[ ( "q" + index.to_s ).to_sym ].to_i
      @results[ index ] = [
        false, # Correct?
        false, # Selected Answer
        question[ "correct_answer" ], # Actual correct answer
        false
      ]
      @submission_error = "Please answer all questions"
    else
      answer = params[ ( "q" + index.to_s ).to_sym ].to_i
      @results[ index ] = [
        answer == question[ "correct_answer" ], # Correct?
        answer, # Selected Answer
        question[ "correct_answer" ], # Actual correct answer
        true
      ]
    end

Maybe add a comment to the if explaining that the question key (e.g. q0) isn't in params as it wasn't completed? Or some other refactoring could probably help with the clarity

liam-m commented 8 years ago

Also discussed:

liam-m commented 8 years ago

@Lixquid Are all of these done?