liam-m / flippd

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

Refactor main.rb #8

Closed liam-m closed 8 years ago

liam-m commented 9 years ago

The following code seems trivial to refactor:

@phases.each do |phase|
  phase['topics'].each do |topic|
    topic['videos'].each do |video|
      if video["id"] == params['id'].to_i
        @phase = phase
        @video = video
      end
    end
  end
end

@phases.each do |phase|
  phase['topics'].each do |topic|
    topic['videos'].each do |video|
      if video["id"] == params['id'].to_i + 1
        @next_video = video
      end
    end
  end
end

@phases.each do |phase|
  phase['topics'].each do |topic|
    topic['videos'].each do |video|
      if video["id"] == params['id'].to_i - 1
        @previous_video = video
      end
    end
  end
end
liam-m commented 9 years ago

This is done on the generic-ids branch.

liam-m commented 8 years ago

Completed in #20, also https://github.com/Lixquid/flippd/commit/22f89783f8479ef6861e2faffbd18cc47cb34132