From 952b9baf1b448544c5e8e2fa4f6b7288bd04fd90 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:07:04 +1300 Subject: [PATCH 01/15] Output problem ids in problem set endpoints --- app/models/problem_set.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/models/problem_set.rb b/app/models/problem_set.rb index b1f473b5..90afbf6e 100644 --- a/app/models/problem_set.rb +++ b/app/models/problem_set.rb @@ -36,4 +36,16 @@ def for_group_user? u_id def total_weighting problem_associations.sum(:weighting) end + + def to_xml(opts={}) + opts[:only] ||= [:id, :name, :owner_id, :created_at, :updated_at] + + super(opts) do |xml| + xml.problems do + problems.each do |problem| + xml.tag!('id', problem.id, :type => ActiveSupport::XmlMini::TYPE_NAMES[problem.id.class.name]) + end + end + end + end end From 8b06df38b4a928274fa34d40c688290c279762d8 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:17:49 +1300 Subject: [PATCH 02/15] Implement GET /groups/:id.xml; include count attribute on association nodes --- app/controllers/groups_controller.rb | 9 ++++++--- app/models/group.rb | 25 +++++++++++++++++++++++++ app/models/problem_set.rb | 6 +++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 6165b184..0c27db5d 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -59,7 +59,10 @@ def show @group = Group.find(params[:id]) if policy(@group).access? @problem_set_associations = @group.problem_set_associations - render :layout => "group" + respond_to do |format| + format.html { render :layout => "group" } + format.xml { render :xml => @group } + end else redirect_to info_group_path(@group) end @@ -73,8 +76,8 @@ def contests format.html { render :layout => "group" } end end - - def info + + def info @group = Group.find(params[:id]) authorize @group, :show? respond_to do |format| diff --git a/app/models/group.rb b/app/models/group.rb index 0ac34b37..6791575b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -54,5 +54,30 @@ def apply!(current_user, user = nil) def invite!(user, current_user) Request.create(:requester => current_user, :subject => self, :verb => :invite, :target => user, :requestee => user) end + + def to_xml(opts={}) + # No sensitive data + super(opts) do |xml| + xml.contests 'count' => contests.count do + contests.each do |contest| + ActiveSupport::XmlMini.to_tag( + 'id', + contest.id, + {:builder => xml}, + ) + end + end + + xml.problem_sets 'count' => problem_sets.count do + problem_sets.each do |problem_set| + ActiveSupport::XmlMini.to_tag( + 'id', + problem_set.id, + {:builder => xml}, + ) + end + end + end + end end diff --git a/app/models/problem_set.rb b/app/models/problem_set.rb index 90afbf6e..d8cc5a42 100644 --- a/app/models/problem_set.rb +++ b/app/models/problem_set.rb @@ -43,7 +43,11 @@ def to_xml(opts={}) super(opts) do |xml| xml.problems do problems.each do |problem| - xml.tag!('id', problem.id, :type => ActiveSupport::XmlMini::TYPE_NAMES[problem.id.class.name]) + ActiveSuppoprt::XmlMini.to_tag( + 'id', + problem.id, + {:builder => xml}, + ) end end end From 745263755303851676c7966935d9628be85dd287 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:28:01 +1300 Subject: [PATCH 03/15] Write a helper for serializing lists of document ids in order to reduce code duplication --- app/models/group.rb | 21 ++------------------- app/models/problem_set.rb | 10 +--------- app/services/xml_util.rb | 13 +++++++++++++ 3 files changed, 16 insertions(+), 28 deletions(-) create mode 100644 app/services/xml_util.rb diff --git a/app/models/group.rb b/app/models/group.rb index 6791575b..f4bcf234 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -58,25 +58,8 @@ def invite!(user, current_user) def to_xml(opts={}) # No sensitive data super(opts) do |xml| - xml.contests 'count' => contests.count do - contests.each do |contest| - ActiveSupport::XmlMini.to_tag( - 'id', - contest.id, - {:builder => xml}, - ) - end - end - - xml.problem_sets 'count' => problem_sets.count do - problem_sets.each do |problem_set| - ActiveSupport::XmlMini.to_tag( - 'id', - problem_set.id, - {:builder => xml}, - ) - end - end + XmlUtil.serialize_id_list xml, 'contests', contests + XmlUtil.serialize_id_list xml, 'problem-sets', problem_sets end end end diff --git a/app/models/problem_set.rb b/app/models/problem_set.rb index d8cc5a42..37b0a52e 100644 --- a/app/models/problem_set.rb +++ b/app/models/problem_set.rb @@ -41,15 +41,7 @@ def to_xml(opts={}) opts[:only] ||= [:id, :name, :owner_id, :created_at, :updated_at] super(opts) do |xml| - xml.problems do - problems.each do |problem| - ActiveSuppoprt::XmlMini.to_tag( - 'id', - problem.id, - {:builder => xml}, - ) - end - end + XmlUtil.serialize_id_list xml, 'problems', problems end end end diff --git a/app/services/xml_util.rb b/app/services/xml_util.rb new file mode 100644 index 00000000..611d9983 --- /dev/null +++ b/app/services/xml_util.rb @@ -0,0 +1,13 @@ +module XmlUtil + def self.serialize_id_list builder, name, docs + builder.tag!(name, 'count' => docs.count) do + docs.each do |doc| + ActiveSupport::XmlMini.to_tag( + 'id', + doc.id, + {:builder => builder}, + ) + end + end + end +end From bcebec22c7af015e6ff26b21f88ab5af57f42a1e Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:38:02 +1300 Subject: [PATCH 04/15] Expose GET /problems/:id.xml --- app/controllers/problems_controller.rb | 5 +++-- app/models/problem.rb | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index b345ac7f..28879d43 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -73,6 +73,7 @@ def show respond_to do |format| format.html { render :layout => "problem" } + format.xml { render :xml => @problem } end if user_signed_in? @@ -115,7 +116,7 @@ def submissions start_time = current_user.contest_relations.joins(:contest => {:problem_set => :problems}).where{(started_at <= DateTime.now) & (finish_at > DateTime.now) & (contest.problem_set.problems.id == my{params[:id]})}.minimum(:started_at) @submissions = @problem.submission_history(current_user,start_time) end - + respond_to do |format| format.html { render :layout => "problem" } end @@ -225,7 +226,7 @@ def create def update @problem = Problem.find(params[:id]) authorize @problem, :update? - + @problem.assign_attributes(permitted_params) respond_to do |format| if validate(@problem) && @problem.save diff --git a/app/models/problem.rb b/app/models/problem.rb index 9c92cfc9..165e5db3 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -72,7 +72,7 @@ def get_highest_scoring_submission(user, from = DateTime.new(1), to = DateTime.n def get_score(user, from = DateTime.new(1), to = DateTime.now) subs = self.submissions.find(:all, :limit => 1, :order => "score DESC", :conditions => ["created_at between ? and ? and user_id = ?", from, to, user]) scores = subs.map {|s| s.score} - return scores.max + return scores.max end def submission_history(user, from = DateTime.new(1), to = DateTime.now) @@ -108,4 +108,14 @@ def weighted_score return nil if self.points.nil? self.points * self.weighting / self.maximum_points end + + def to_xml(opts={}) + super(opts) do |xml| + XmlUtil.serialize_id_list xml, 'contests', contests + XmlUtil.serialize_id_list xml, 'groups', groups + XmlUtil.serialize_id_list xml, 'problem-sets', problem_sets + + # TODO: Possibly nice to include submission ids here if user is an admin? + end + end end From a24a188f2cac282d88ca82a5a60b19e80d3f0bd9 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 18:39:14 +1300 Subject: [PATCH 05/15] Forgot to output groups & contests in problem set endpoints --- app/models/problem_set.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/problem_set.rb b/app/models/problem_set.rb index 37b0a52e..2f274836 100644 --- a/app/models/problem_set.rb +++ b/app/models/problem_set.rb @@ -41,6 +41,8 @@ def to_xml(opts={}) opts[:only] ||= [:id, :name, :owner_id, :created_at, :updated_at] super(opts) do |xml| + XmlUtil.serialize_id_list xml, 'contests', contests + XmlUtil.serialize_id_list xml, 'groups', groups XmlUtil.serialize_id_list xml, 'problems', problems end end From 2a8316f94f5ceb497604465e3adac1cd0e5b8d4a Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 19:05:38 +1300 Subject: [PATCH 06/15] Expose GET /accounts/requests.xml --- app/controllers/accounts/requests_controller.rb | 11 +++++++++++ app/models/request.rb | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/controllers/accounts/requests_controller.rb b/app/controllers/accounts/requests_controller.rb index 642f9366..f25101ab 100644 --- a/app/controllers/accounts/requests_controller.rb +++ b/app/controllers/accounts/requests_controller.rb @@ -6,5 +6,16 @@ class Accounts::RequestsController < ApplicationController def index @pending_requests = current_user.requests.pending @requests = current_user.requests.closed + + respond_to do |format| + format.html + + # Return all requests in the XML, sorted by creation date + format.xml { + render :xml => (@pending_requests + @requests).sort do |a, b| + a.created_at <=> b.created_at + end + } + end end end diff --git a/app/models/request.rb b/app/models/request.rb index b4b2e6b3..7cf3e72b 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -1,6 +1,6 @@ class Request < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection - + belongs_to :requester, :class_name => :User # entity that initiated request belongs_to :subject, :polymorphic => true # subject controlled by requester # verb # action applying subject to target @@ -42,4 +42,18 @@ def cancel! self.status = STATUS[:cancelled] self.save end + + def to_xml(opts={}) + if self.expired_at == Float::INFINITY then + # `expired_at` has the value Float::INFINITY when the request hasn't expired, + # and the XML formatter explodes when it encounters that value. Adding :expired_at + # to opts[:exclude] is the obvious solution, but for reasons unknown to me it does + # not appear to work as expected. Changing `expired_at` to some other value (which isn't + # a datetime) will result in an empty tag being emitted with a `nil="true"` attribute + # which seems like the best solution after just omitting the tag entirely.` + self.expired_at = 0 + end + + super(opts) + end end From 1610e6d1ee90f90e4ddf8e60763f11ce069d133f Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 19:05:56 +1300 Subject: [PATCH 07/15] `XmlUtil.serialize_id_list`: Ensure a `type` attribute gets added to the root node of the list --- app/services/xml_util.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/xml_util.rb b/app/services/xml_util.rb index 611d9983..3b88a952 100644 --- a/app/services/xml_util.rb +++ b/app/services/xml_util.rb @@ -1,6 +1,8 @@ module XmlUtil def self.serialize_id_list builder, name, docs - builder.tag!(name, 'count' => docs.count) do + array_type = ActiveSupport::XmlMini::TYPE_NAMES['Array'] + + builder.tag!(name, 'count' => docs.count, 'type' => array_type) do docs.each do |doc| ActiveSupport::XmlMini.to_tag( 'id', From fb3c2dc6faf2e61c7451b3dd321fbd35cb40a801 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 20:38:11 +1300 Subject: [PATCH 08/15] Output sample cases when serializing problems; hide some admin stats --- app/models/problem.rb | 8 ++++++++ app/services/xml_util.rb | 22 ++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/models/problem.rb b/app/models/problem.rb index 165e5db3..b8a4bd73 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -110,11 +110,19 @@ def weighted_score end def to_xml(opts={}) + # hide e.g. test submission stats + opts[:only] ||= [:id, :name, :statement, :input, :output, :memory_limit, :time_limit, :owner_id, :created_at, :updated_at] + super(opts) do |xml| XmlUtil.serialize_id_list xml, 'contests', contests XmlUtil.serialize_id_list xml, 'groups', groups XmlUtil.serialize_id_list xml, 'problem-sets', problem_sets + XmlUtil.serialize_list xml, 'sample-cases', sample_cases do |sample| + XmlUtil.tag xml, 'input', sample.input + XmlUtil.tag xml, 'output', sample.output + end + # TODO: Possibly nice to include submission ids here if user is an admin? end end diff --git a/app/services/xml_util.rb b/app/services/xml_util.rb index 3b88a952..d6f4b455 100644 --- a/app/services/xml_util.rb +++ b/app/services/xml_util.rb @@ -1,15 +1,21 @@ module XmlUtil + def self.serialize_list builder, name, docs + array_type = ActiveSupport::XmlMini::TYPE_NAMES['Array'] + builder.tag!(name, 'count' => docs.count, 'type' => array_type) do + docs.each do |doc| yield doc end + end + end + def self.serialize_id_list builder, name, docs array_type = ActiveSupport::XmlMini::TYPE_NAMES['Array'] - builder.tag!(name, 'count' => docs.count, 'type' => array_type) do - docs.each do |doc| - ActiveSupport::XmlMini.to_tag( - 'id', - doc.id, - {:builder => builder}, - ) - end + XmlUtil.serialize_list builder, name, docs do |doc| + XmlUtil.tag builder, 'id', doc.id end end + + # Wrapper around ActiveSupport's to_tag method as the original is pretty long + def self.tag builder, name, value + ActiveSupport::XmlMini.to_tag(name, value, {:builder => builder}) + end end From 3074c8d5d4f109acbd32819ec727be452d60f937 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 20:38:45 +1300 Subject: [PATCH 09/15] Allow listing all problems in the system --- app/controllers/problems_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb index 28879d43..1440a9cc 100644 --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -50,6 +50,7 @@ def index respond_to do |format| format.html # index.html.erb + format.xml { render :xml => @problems } end end From edfeb9e93df83d2bb22db5a10905a8aa7c71b5f4 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 21:37:11 +1300 Subject: [PATCH 10/15] Hide judge data --- app/models/submission.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 644c04ab..72881bca 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -1,6 +1,6 @@ class Submission < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection - + belongs_to :user belongs_to :problem has_many :contest_scores @@ -9,7 +9,7 @@ class Submission < ActiveRecord::Base def user_problem_relation UserProblemRelation.where(:user_id => user_id, :problem_id => problem_id).first_or_create! end - + validates :source, :presence => true validate do |submission| errors.add :language_id, "Invalid language specified" if submission.language.nil? @@ -199,5 +199,11 @@ def update_test_messages end end + def to_xml(opts={}) + # hiding e.g. judge log + opts[:only] ||= [:id, :source, :score, :user_id, :problem_id, :created_at, :updated_at, :input, :output, :language_id, :judged_at, :evaluation, :points, :maximum_points] + + super(opts) + end end From f2b15b5a51b9005d8293fdfed842734b57ee30cf Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 21:37:42 +1300 Subject: [PATCH 11/15] Most of GET /contests/:id.xml -- need to include scoreboard in future --- app/controllers/contests_controller.rb | 14 +++++++++-- app/models/contest.rb | 35 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 3d8a37e0..68e239d9 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -1,3 +1,5 @@ +require 'builder' + class ContestsController < ApplicationController def permitted_params @_permitted_params ||= begin @@ -18,7 +20,7 @@ def index authorize Contest.new, :manage? @contests = Contest.order("end_time DESC") end - + respond_to do |format| format.html # index.html.erb end @@ -42,6 +44,11 @@ def browse else raise Pundit::NotAuthorizedError end + + respond_to do |format| + format.html + format.xml { render :xml => @contests.to_xml(:user => current_user) } + end end # GET /contests/1 @@ -61,7 +68,10 @@ def show @contest_message = "You have not started this contest." end - render :layout => 'contest' + respond_to do |format| + format.html { render :layout => 'contest' } + format.xml { render :xml => @contest.to_xml(:user => current_user) } + end end def info diff --git a/app/models/contest.rb b/app/models/contest.rb index 9edd6d23..684a8cc0 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -117,7 +117,7 @@ def status return "Running" if is_running? return finalized? ? "Finalized" : "Preliminary" end - + def status_text(user_id) return "The contest has ended." if ended? @@ -166,4 +166,37 @@ def max_extra_time (duration*3600).to_i end + def to_xml(opts={}) + super(opts) do |xml| + + if opts[:user] then + policy = Pundit.policy(opts[:user], self) + + has_contestants = policy.contestants? + has_scoreboard = policy.scoreboard? + + if policy.contestants? then + XmlUtil.serialize_id_list xml, 'contestants', contestants + end + + if policy.scoreboard? then + # TODO: Include scoreboard info + + XmlUtil.serialize_list xml, 'problems', problem_set.problems do |problem| + association = problem_associations.find {|i| i.problem_id == problem.id} + xml.id( + problem.id, + 'type' => ActiveSupport::XmlMini::TYPE_NAMES[association.weighting.class.name], + 'weighting' => association.weighting, + ) + end + end + + if policy.manage? then + XmlUtil.serialize_id_list xml, 'groups', groups + XmlUtil.serialize_id_list xml, 'registrants', registrants + end + end + end + end end From d63c62eb14affb9d648810525a3c960ce5d199d6 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 21:39:03 +1300 Subject: [PATCH 12/15] Wrap each sample case in a tag --- app/models/problem.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/problem.rb b/app/models/problem.rb index b8a4bd73..67a57519 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -119,8 +119,10 @@ def to_xml(opts={}) XmlUtil.serialize_id_list xml, 'problem-sets', problem_sets XmlUtil.serialize_list xml, 'sample-cases', sample_cases do |sample| - XmlUtil.tag xml, 'input', sample.input - XmlUtil.tag xml, 'output', sample.output + xml.tag! 'sample-case' do + XmlUtil.tag xml, 'input', sample.input + XmlUtil.tag xml, 'output', sample.output + end end # TODO: Possibly nice to include submission ids here if user is an admin? From 9f7b0c4e76bb5292f488531312e4f677605eadfe Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 21:53:51 +1300 Subject: [PATCH 13/15] Include groups & solved problems in user response when auth'ed as staff --- app/controllers/user_controller.rb | 4 ++-- app/models/user.rb | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d8de9ddf..de2bea53 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -21,13 +21,13 @@ def visible_attributes def show @user = User.find(params[:id]) authorize @user, :show? - @solved_problems = @user.user_problem_relations.where(ranked_score: 100).joins(:problem).select([:problem_id, :ranked_submission_id, {problem: :name}]).order("problems.name") + @solved_problems = @user.solved_problems @user_presenter = UserPresenter.new(@user).permit!(*visible_attributes) respond_to do |format| format.html - format.xml {render :xml => @user } + format.xml {render :xml => @user, :user => current_user } end end diff --git a/app/models/user.rb b/app/models/user.rb index c50b77c0..6e1a0456 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -173,6 +173,10 @@ def school=(value) end end + def solved_problems + self.user_problem_relations.where(ranked_score: 100).joins(:problem).select([:problem_id, :ranked_submission_id, {problem: :name}]).order("problems.name") + end + def estimated_year_level(on_this_date = DateTime.now) if school_graduation.nil? || school_graduation <= on_this_date nil @@ -187,4 +191,25 @@ def estimated_year_level(on_this_date = DateTime.now) end end + def to_xml(opts={}) + default_fields = [:id, :created_at, :updated_at, :brownie_points, :username, :avatar] + if opts[:user] then + if Pundit.policy(opts[:user], self).inspect? then + default_fields.append(:email) + default_fields.append(:name) + end + end + opts[:only] ||= default_fields + + super(opts) do |xml| + if opts[:user] then + if Pundit.policy(opts[:user], self).inspect? then + XmlUtil.serialize_id_list xml, 'groups', groups + XmlUtil.serialize_list xml, 'solved-problems', solved_problems do |association| + XmlUtil.tag xml, 'id', association.problem_id + end + end + end + end + end end From fee0f93ceabed2533273b3be15c034e85f653f28 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 23:05:06 +1300 Subject: [PATCH 14/15] Hide points on submissions --- app/models/submission.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 72881bca..e80cf841 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -201,7 +201,7 @@ def update_test_messages def to_xml(opts={}) # hiding e.g. judge log - opts[:only] ||= [:id, :source, :score, :user_id, :problem_id, :created_at, :updated_at, :input, :output, :language_id, :judged_at, :evaluation, :points, :maximum_points] + opts[:only] ||= [:id, :source, :score, :user_id, :problem_id, :created_at, :updated_at, :input, :output, :language_id, :judged_at, :evaluation] super(opts) end From e0b660a828ced196e0ecccd50d128fa79b801b77 Mon Sep 17 00:00:00 2001 From: Sophia Willows <20146550+sophiabits@users.noreply.github.com> Date: Sun, 30 Jan 2022 23:08:17 +1300 Subject: [PATCH 15/15] Don't include startcode in contest xml doc --- app/models/contest.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/contest.rb b/app/models/contest.rb index 684a8cc0..332f02be 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -167,8 +167,9 @@ def max_extra_time end def to_xml(opts={}) - super(opts) do |xml| + opts[:exclude] ||= [:startcode] + super(opts) do |xml| if opts[:user] then policy = Pundit.policy(opts[:user], self)