app/models/user.rb
def available_problems
    # first, we check if this is normal mode
    if not GraderConfiguration.multicontests?

      #if this is a normal mode
      #we show problem based on problem_group, if the config said so
      if GraderConfiguration.use_problem_group?
        return available_problems_in_group
      else
        return Problem.available_problems
      end
    else
      #this is multi contest mode
      contest_problems = []
      pin = {}
      contests.enabled.each do |contest|
        contest.problems.available.each do |problem|
          if not pin.has_key? problem.id
            contest_problems << problem
          end
          pin[problem.id] = true
        end
      end
      other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
      return contest_problems + other_avaiable_problems
    end
  end
#get a list of available problem
get a list of available problem
get a list of available problem
def available_problems
    if not GraderConfiguration.multicontests?
      if GraderConfiguration.use_problem_group?
        return available_problems_in_group
      else
        return Problem.available_problems
      end
    else
      contest_problems = []
      pin = {}
      contests.enabled.each do |contest|
        contest.problems.available.each do |problem|
          if not pin.has_key? problem.id
            contest_problems << problem
          end
          pin[problem.id] = true
        end
      end
      other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
      return contest_problems + other_avaiable_problems
    end
  end
def available_problems if not GraderConfiguration . multicontests? if GraderConfiguration . use_problem_group? return available_problems_in_group else return Problem . available_problems end else contest_problems = [ ] pin = { } contests . enabled . each do | contest | contest . problems . available . each do | problem | if not pin . has_key? problem . id contest_problems << problem end pin [ problem . id ] = true end end other_avaiable_problems = Problem . available . find_all { | p | pin [ p . id ] == nil and p . contests . length == 0 } return contest_problems + other_avaiable_problems end end
get a list of available problem
get a list of available problem
# first, we check if this is normal mode #if this is a normal mode #we show problem based on problem_group, if the config said so #this is multi contest mode