diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -97,7 +97,7 @@ prepare_list_information render :action => 'list' and return end - redirect_to :action => 'list' + redirect_to edit_submission_path(@submission) end def source diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -52,6 +52,8 @@ #set up range from param @since_id = params.fetch(:from_id, 0).to_i @until_id = params.fetch(:to_id, 0).to_i + @since_id = nil if @since_id == 0 + @until_id = nil if @until_id == 0 #calculate the routine @scorearray = calculate_max_score(@problems, @users, @since_id, @until_id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -85,11 +85,10 @@ end def format_short_time(time) - now = Time.now.gmtime + now = Time.zone.now st = '' - if (time.yday != now.yday) or - (time.year != now.year) - st = time.strftime("%x ") + if (time.yday != now.yday) or (time.year != now.year) + st = time.strftime("%d/%m/%y ") end st + time.strftime("%X") end @@ -100,6 +99,10 @@ return Time.at(d).gmtime.strftime("%X") end + def format_full_time_ago(time) + st = time_ago_in_words(time) + ' ago (' + format_short_time(time) + ')' + end + def read_textfile(fname,max_size=2048) begin File.open(fname).read(max_size) diff --git a/app/models/submission.rb b/app/models/submission.rb --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -34,8 +34,8 @@ def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id) records = Submission.where(problem_id: problem_id,user_id: user_id) - records = records.where('id >= ?',since_id) if since_id > 0 - records = records.where('id <= ?',until_id) if until_id > 0 + records = records.where('id >= ?',since_id) if since_id and since_id > 0 + records = records.where('id <= ?',until_id) if until_id and until_id > 0 records.all end diff --git a/app/views/application/_submission_short.html.haml b/app/views/application/_submission_short.html.haml --- a/app/views/application/_submission_short.html.haml +++ b/app/views/application/_submission_short.html.haml @@ -1,13 +1,15 @@ - - if submission.nil? = "-" - else + %strong= "Submission ID:" + = submission.id + %br - unless submission.graded_at - = t 'main.submitted_at' - = format_short_time(submission.submitted_at.localtime) + %strong= t 'main.submitted_at:' + = format_full_time_ago(submission.submitted_at.localtime) - else - %strong= t 'main.graded_at' - = "#{format_short_time(submission.graded_at.localtime)} " + %strong= t 'main.graded_at:' + = format_full_time_ago(submission.graded_at.localtime) %br - if GraderConfiguration['ui.show_score'] %strong=t 'main.score' @@ -17,10 +19,10 @@ = submission.grader_comment = "]" %br - %strong View: - - if GraderConfiguration.show_grading_result - = link_to '[detailed result]', :action => 'result', :id => submission.id - = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} + %strong View: + - if GraderConfiguration.show_grading_result + = link_to '[detailed result]', :action => 'result', :id => submission.id + = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} if submission.graded_at = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info' = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info' diff --git a/app/views/report/max_score.html.haml b/app/views/report/max_score.html.haml --- a/app/views/report/max_score.html.haml +++ b/app/views/report/max_score.html.haml @@ -33,11 +33,11 @@ .panel-body .radio %label - = radio_button_tag 'users', 'all', true + = radio_button_tag 'users', 'all', (params[:users] == "all") All users .radio %label - = radio_button_tag 'users', 'enabled' + = radio_button_tag 'users', 'enabled', (params[:users] == "enabled") Only enabled users .row .col-md-12 diff --git a/app/views/submissions/edit.html.haml b/app/views/submissions/edit.html.haml --- a/app/views/submissions/edit.html.haml +++ b/app/views/submissions/edit.html.haml @@ -27,7 +27,7 @@ = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit', data: {confirm: "Submitting this source code for task #{@problem.long_name}?"} - # latest submission status - .panel.panel-info + .panel{class: (@submission && @submission.graded_at) ? "panel-info" : "panel-warning"} .panel-heading Latest Submission Status = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission diff --git a/config/application.rb.SAMPLE b/config/application.rb.SAMPLE --- a/config/application.rb.SAMPLE +++ b/config/application.rb.SAMPLE @@ -65,7 +65,7 @@ config.assets.precompile += ['local_jquery.js','tablesorter-theme.cafe.css'] %w( announcements submissions configurations contests contest_management graders heartbeat login main messages problems report site sites sources tasks - test user_admin users ).each do |controller| + test user_admin users testcases).each do |controller| config.assets.precompile += ["#{controller}.js", "#{controller}.css"] end end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -18,6 +18,6 @@ Rails.application.config.assets.precompile += ['local_jquery.js','tablesorter-theme.cafe.css'] %w( announcements submissions configurations contests contest_management graders heartbeat login main messages problems report site sites sources tasks groups - test user_admin users tags).each do |controller| + test user_admin users tags testcases).each do |controller| Rails.application.config.assets.precompile += ["#{controller}.js", "#{controller}.css"] end diff --git a/lib/grader_script.rb b/lib/grader_script.rb --- a/lib/grader_script.rb +++ b/lib/grader_script.rb @@ -33,6 +33,7 @@ GraderScript.call_grader "#{env} test_request -err-log &" end + #call the import problem script def self.call_import_problem(problem_name, problem_dir, time_limit=1, diff --git a/lib/testdata_importer.rb b/lib/testdata_importer.rb --- a/lib/testdata_importer.rb +++ b/lib/testdata_importer.rb @@ -8,8 +8,9 @@ @problem = problem end - def import_from_file(tempfile, - time_limit, + #Create or update problem according to the parameter + def import_from_file(tempfile, + time_limit, memory_limit, checker_name='text', import_to_db=false) @@ -52,6 +53,7 @@ return filename.slice(i..len) end + # extract an archive file located at +tempfile+ to the +raw_dir+ def extract(tempfile) testdata_filename = save_testdata_file(tempfile) ext = TestdataImporter.long_ext(tempfile.original_filename)