Show More
Commit Description:
fig bugs in login report
Commit Description:
fig bugs in login report
References:
File last commit:
Show/Diff file:
Action:
app/models/problem.rb | 168 lines | 4.7 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 class Problem < ActiveRecord::Base
jittat
[web] refactor problem description, some styling...
r92 belongs_to :description
Jittat Fakcharoenphol
manages users in contests
r280 has_and_belongs_to_many :contests, :uniq => true
make group_user and group_problem unique
r678
#has_and_belongs_to_many :groups
start update to 5.2
r751 has_many :groups_problems, class_name: 'GroupProblem'
make group_user and group_problem unique
r678 has_many :groups, :through => :groups_problems
start update to 5.2
r751 has_many :problems_tags, class_name: 'ProblemTag'
tag
r681 has_many :tags, through: :problems_tags
Jittat Fakcharoenphol
imports test pairs
r210 has_many :test_pairs, :dependent => :delete_all
- start adding testcases into database...
r607 has_many :testcases, :dependent => :destroy
jittat
[web] refactor problem description, some styling...
r92
add submissions to users
r738 has_many :submissions
jittat
added quick new problem...
r171 validates_presence_of :name
update models to satisfy rails 4
r618 validates_format_of :name, :with => /\A\w+\z/
jittat
added quick new problem...
r171 validates_presence_of :full_name
jittat
small refactoring in Problem.new_from_import_form_params...
r208
change find(:xxx) to correct syntax for rails 4
r619 scope :available, -> { where(available: true) }
Jittat Fakcharoenphol
shows problems availabe in contests
r278
jittat
small refactoring in Problem.new_from_import_form_params...
r208 DEFAULT_TIME_LIMIT = 1
DEFAULT_MEMORY_LIMIT = 32
Jittat Fakcharoenphol
imports task description as pdf
r271
add model solution
r855 def get_jschart_history
start = 4.month.ago.beginning_of_day
start_date = start.to_date
count = Submission.where(problem: self).where('submitted_at >= ?', start).group('DATE(submitted_at)').count
i = 0
label = []
value = []
while (start_date + i < Time.zone.now.to_date)
if (start_date+i).day == 1
#label << (start_date+i).strftime("%d %b %Y")
#label << (start_date+i).strftime("%d")
else
#label << ' '
#label << (start_date+i).strftime("%d")
end
label << (start_date+i).strftime("%d-%b")
value << (count[start_date+i] || 0)
i+=1
end
return {labels: label,datasets: [label:'sub',data: value, backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgb(75, 192, 192)']}
end
change find(:xxx) to correct syntax for rails 4
r619 def self.available_problems
available.order(date_added: :desc).order(:name)
#Problem.available.all(:order => "date_added DESC, name ASC")
pramook
initial commit...
r0 end
Jittat Fakcharoenphol
imports test pairs
r210 def self.create_from_import_form_params(params, old_problem=nil)
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 org_problem = old_problem || Problem.new
revert simple_form_for to form_tag
r758 import_params, problem = Problem.extract_params_and_check(params,
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 org_problem)
jittat
added problem import...
r204
Jittat Fakcharoenphol
uses empty? instead of length to check model validation errors when importing problems
r338 if !problem.errors.empty?
Jittat Fakcharoenphol
imports test pairs
r210 return problem, 'Error importing'
jittat
small refactoring in Problem.new_from_import_form_params...
r208 end
jittat
added problem import...
r204
jittat
small refactoring in Problem.new_from_import_form_params...
r208 problem.full_score = 100
problem.date_added = Time.new
problem.test_allowed = true
problem.output_only = false
problem.available = false
Jittat Fakcharoenphol
imports test pairs
r210
if not problem.save
return problem, 'Error importing'
end
import_to_db = params.has_key? :import_to_db
importer = TestdataImporter.new(problem)
revert simple_form_for to form_tag
r758 if not importer.import_from_file(import_params[:file],
import_params[:time_limit],
Jittat Fakcharoenphol
imports test pairs
r210 import_params[:memory_limit],
add selectable checker (for now, only 'text' and 'float') in the problem import
r402 import_params[:checker_name],
Jittat Fakcharoenphol
imports test pairs
r210 import_to_db)
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 problem.errors.add(:base,'Import error.')
Jittat Fakcharoenphol
imports test pairs
r210 end
jittat
small refactoring in Problem.new_from_import_form_params...
r208 return problem, importer.log_msg
end
Jittat Fakcharoenphol
imports task description as pdf
r271 def self.download_file_basedir
Jittat Fakcharoenphol
boots into rails 3
r318 return "#{Rails.root}/data/tasks"
Jittat Fakcharoenphol
imports task description as pdf
r271 end
add more problem stat
r457
def get_submission_stat
result = Hash.new
#total number of submission
result[:total_sub] = Submission.where(problem_id: self.id).count
add bulk manage for enablind users
r643 result[:attempted_user] = Submission.where(problem_id: self.id).group(:user_id)
result[:pass] = Submission.where(problem_id: self.id).where("points >= ?",self.full_score).count
return result
add more problem stat
r457 end
live editor using cloud9 ace for problem
r564
def long_name
"[#{name}] #{full_name}"
end
Jittat Fakcharoenphol
imports task description as pdf
r271
jittat
small refactoring in Problem.new_from_import_form_params...
r208 protected
jittat
added problem import...
r204
jittat
small refactoring in Problem.new_from_import_form_params...
r208 def self.to_i_or_default(st, default)
if st!=''
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 result = st.to_i
jittat
small refactoring in Problem.new_from_import_form_params...
r208 end
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 result ||= default
end
def self.to_f_or_default(st, default)
if st!=''
result = st.to_f
end
result ||= default
jittat
small refactoring in Problem.new_from_import_form_params...
r208 end
def self.extract_params_and_check(params, problem)
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 time_limit = Problem.to_f_or_default(params[:time_limit],
jittat
small refactoring in Problem.new_from_import_form_params...
r208 DEFAULT_TIME_LIMIT)
memory_limit = Problem.to_i_or_default(params[:memory_limit],
DEFAULT_MEMORY_LIMIT)
jittat
added problem import...
r204
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 if time_limit<=0 or time_limit >60
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 problem.errors.add(:base,'Time limit out of range.')
jittat
added problem import...
r204 end
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 if memory_limit==0 and params[:memory_limit]!='0'
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 problem.errors.add(:base,'Memory limit format errors.')
jittat
added problem import...
r204 elsif memory_limit<=0 or memory_limit >512
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 problem.errors.add(:base,'Memory limit out of range.')
jittat
added problem import...
r204 end
if params[:file]==nil or params[:file]==''
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
r347 problem.errors.add(:base,'No testdata file.')
jittat
added problem import...
r204 end
add selectable checker (for now, only 'text' and 'float') in the problem import
r402 checker_name = 'text'
if ['text','float'].include? params[:checker]
checker_name = params[:checker]
end
jittat
added problem import...
r204 file = params[:file]
Jittat Fakcharoenphol
uses empty? instead of length to check model validation errors when importing problems
r338 if !problem.errors.empty?
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 return nil, problem
jittat
added problem import...
r204 end
problem.name = params[:name]
if params[:full_name]!=''
problem.full_name = params[:full_name]
else
problem.full_name = params[:name]
end
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 return [{
:time_limit => time_limit,
:memory_limit => memory_limit,
add selectable checker (for now, only 'text' and 'float') in the problem import
r402 :file => file,
:checker_name => checker_name
Jittat Fakcharoenphol
fixed problem import from validation (thanks Witchakorn Kamolpornwijit)
r310 },
problem]
jittat
added problem import...
r204 end
pramook
initial commit...
r0 end