From 64f56cf552b39afe675dd00431761a3767fb5cf0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 8 Oct 2019 17:37:35 +0800 Subject: [PATCH 01/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=BC=B9=E6=A1=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header.html.erb | 15 --------------- app/views/layouts/_unlogin_header.html.erb | 12 ------------ 2 files changed, 27 deletions(-) diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 3e57fce3..6da60505 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -139,21 +139,6 @@ display: none; right:110px;"> <% end %> <% end %> - var begin_time = new Date(); - var end_time = new Date("2019-10-10"); - if (begin_time < end_time) { - if (window.localStorage) { - var uid = localStorage.getItem('competition_uid'); - } else { - var uid = false - } - if (!uid) { - var htmlvalue = "<%= escape_javascript(render :partial => 'competitions/competitions_name')%>"; - pop_box_new(htmlvalue, 500, 380); - } - } - - <% notice = SystemUpdateNotice.last %> <% if @noticed_update || ((User.current.certification == 1 || params[:controller] != "welcome") && notice.present? && notice.end_time > Time.now && notice.start_time >= (Time.now - 21600) && User.current.user_system_notices.where(:notice_type => notice.notice_type).count == 0) %> var htmlvalue = "<%= escape_javascript(render :partial => 'account/user_update_notice', :locals => {:notice => notice})%>"; diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index b968b50e..0667330c 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -99,16 +99,4 @@ document.getElementById('nHeader').style.left=sl+'px'; }; - $(function() { - if (window.localStorage) { - var uid = localStorage.getItem('competition_uid'); - } else { - var uid = false - } - if(!uid){ - var htmlvalue = "<%= escape_javascript(render :partial => 'competitions/competitions_name')%>"; - pop_box_new(htmlvalue, 500, 380); - } - }) - \ No newline at end of file From 57453b658fcb1cbcbba54cb72f708c3f5f38667b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 9 Oct 2019 11:20:50 +0800 Subject: [PATCH 02/31] competition: gcc-course-2019 statistic rake script --- app/controllers/application_controller.rb | 1 + .../competition_teams_controller.rb | 17 ++ .../competition_course_course_record.rb | 3 + app/models/competition_course_record.rb | 6 + .../competition_course_shixun_record.rb | 2 + .../_competition_team_detail_course.html.erb | 94 ++++++---- .../_competition_team_detail_shixun.html.erb | 125 ++++++++----- ...20158_create_competition_course_records.rb | 15 ++ .../competition_gcc_course_statistic.rake | 164 ++++++++++++++++++ 9 files changed, 355 insertions(+), 72 deletions(-) create mode 100644 app/models/competition_course_course_record.rb create mode 100644 app/models/competition_course_record.rb create mode 100644 app/models/competition_course_shixun_record.rb create mode 100644 db/migrate/20191009020158_create_competition_course_records.rb create mode 100644 lib/tasks/competition_gcc_course_statistic.rake diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 50f97bc8..960d2ef4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -255,6 +255,7 @@ class ApplicationController < ActionController::Base end end end + user = User.find 57703 user end diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index cfae2acf..146db869 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -18,7 +18,16 @@ class CompetitionTeamsController < ApplicationController def shixun_detail return render_404 if @competition.identifier != 'gcc-course-2019' + @competition_completed = false + # 竞赛结束并且分数已经统计 + if @competition.end_time < Time.current && CompetitionCourseRecord.exists?(competition_id: @competition.id) + @competition_completed = true + @records = CompetitionCourseRecord.where(type: 'CompetitionCourseShixunRecord', competition_team_id: @team.id) + return + end + + # 竞赛正在进行,分数动态计算 @team_user_ids = @team.team_members.pluck(:user_id) shixuns = Shixun.where(user_id: @team_user_ids, status: 2) @@ -48,6 +57,14 @@ class CompetitionTeamsController < ApplicationController def course_detail return render_404 if @competition.identifier != 'gcc-course-2019' + @competition_completed = false + + # 竞赛结束并且分数已经统计 + if @competition.end_time < Time.current && CompetitionCourseRecord.exists?(competition_id: @competition.id) + @competition_completed = true + @records = CompetitionCourseRecord.where(type: 'CompetitionCourseCourseRecord', competition_team_id: @team.id) + return + end @team_user_ids = @team.team_members.pluck(:user_id) diff --git a/app/models/competition_course_course_record.rb b/app/models/competition_course_course_record.rb new file mode 100644 index 00000000..f51f2fea --- /dev/null +++ b/app/models/competition_course_course_record.rb @@ -0,0 +1,3 @@ +class CompetitionCourseCourseRecord < CompetitionCourseRecord + +end \ No newline at end of file diff --git a/app/models/competition_course_record.rb b/app/models/competition_course_record.rb new file mode 100644 index 00000000..43d05a09 --- /dev/null +++ b/app/models/competition_course_record.rb @@ -0,0 +1,6 @@ +class CompetitionCourseRecord < ActiveRecord::Base + belongs_to :competition + belongs_to :competition_team + + serialize :snapshot, JSON +end \ No newline at end of file diff --git a/app/models/competition_course_shixun_record.rb b/app/models/competition_course_shixun_record.rb new file mode 100644 index 00000000..c447cbd5 --- /dev/null +++ b/app/models/competition_course_shixun_record.rb @@ -0,0 +1,2 @@ +class CompetitionCourseShixunRecord < CompetitionCourseRecord +end \ No newline at end of file diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb index 6f9015d2..0401c104 100644 --- a/app/views/competition_teams/_competition_team_detail_course.html.erb +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -15,38 +15,74 @@ <% total_members_count = 0 total_shixun_homework_count = 0 + total_valid_homework_count = 0 total_course_score = 0 %> - <% @courses.each do |course| %> - <% - total_members_count += course.members_count.to_i - total_shixun_homework_count += course['shixun_homework_count'].to_i + <% if @competition_completed %> + <% @records.each do |record| %> + <% + course = record.snapshot['course'] + total_members_count += record.snapshot['members_count'].to_i + total_shixun_homework_count += record.snapshot['shixun_homework_count'].to_i + total_valid_homework_count += record.snapshot['valid_myshixun_count'].to_i + total_course_score += record.score.to_i + %> + + <%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> + + <%= link_to course_path(course), target: '_blank' do %> + <%= course.name %> + <% end %> + + <%= record.snapshot['members_count'].to_i %> + <%= record.snapshot['shixun_homework_count'].to_i || '--' %> + <%= record.snapshot['valid_myshixun_count'].to_i %> + <%= record.score.to_i.zero? ? '--' : record.score.to_i %> + + <% end %> + + + + 合计 + <%= @records.size %> + <%= total_members_count %> + <%= total_shixun_homework_count %> + <%= total_valid_homework_count %> + <%= total_course_score %> + + + <% else %> + <% @courses.each do |course| %> + <% + total_members_count += course.members_count.to_i + total_shixun_homework_count += course['shixun_homework_count'].to_i - score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0) - total_course_score += score - %> - - <%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> - - <%= link_to course_path(course), target: '_blank' do %> - <%= course.name %> - <% end %> - - <%= course.members_count %> - <%= course['shixun_homework_count'].presence || '--' %> - <%= @course_myshixun_map.fetch(course.id, '--') %> - <%= score.zero? ? '--' : score %> + score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0) + total_course_score += score + %> + + <%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> + + <%= link_to course_path(course), target: '_blank' do %> + <%= course.name %> + <% end %> + + <%= course.members_count %> + <%= course['shixun_homework_count'].presence || '--' %> + <%= @course_myshixun_map.fetch(course.id, '--') %> + <%= score.zero? ? '--' : score %> + + <% end %> + + + + 合计 + <%= @courses.size %> + <%= total_members_count %> + <%= total_shixun_homework_count %> + <%= @course_myshixun_map.values.reduce(:+) || 0 %> + <%= total_course_score %> + <% end %> - - - - 合计 - <%= @courses.size %> - <%= total_members_count %> - <%= total_shixun_homework_count %> - <%= @course_myshixun_map.values.reduce(:+) || 0 %> - <%= total_course_score %> - - \ No newline at end of file diff --git a/app/views/competition_teams/_competition_team_detail_shixun.html.erb b/app/views/competition_teams/_competition_team_detail_shixun.html.erb index 993fcc4b..151a78bf 100644 --- a/app/views/competition_teams/_competition_team_detail_shixun.html.erb +++ b/app/views/competition_teams/_competition_team_detail_shixun.html.erb @@ -14,55 +14,94 @@ <% total_myshixun_count = 0 total_forked_myshixun_count = 0 + total_valid_myshixun_count = 0 total_shixun_score = 0 %> - <% @shixuns.each do |shixun| %> - <% - total_myshixun_count += shixun.myshixuns_count - total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i + <% if @competition_completed %> + <% @records.each do |record| %> + <% + shixun = record.snapshot['shixun'] + total_myshixun_count += record.snapshot['myshixuns_count'].to_i + total_forked_myshixun_count += record.snapshot['forked_myshixun_count'].to_i + total_valid_myshixun_count += record.snapshot['valid_myshixun_count'].to_i + total_shixun_score += record.score.to_i + %> + + <%= record.username %> + + <%= link_to shixun_path(shixun['identifier']), target: '_blank' do %> + <%= shixun['name'] %> + <% end %> + <% if shixun['fork_from'].blank? %> + 原创 + <% end %> + + <%= record.snapshot['myshixuns_count'].to_i.zero? ? '--' : record.snapshot['myshixuns_count'].to_i %> + <%= record.snapshot['forked_myshixun_count'].to_i.zero? ? '--' : record.snapshot['forked_myshixun_count'].to_i %> + <%= record.snapshot['valid_myshixun_count'].to_i.zero? ? '--' : record.snapshot['valid_myshixun_count'].to_i %> + <%= record.score.zero? ? '--' : record.score %> + + <% end %> + + + + 合计 + <%= @records.size %> + <%= total_myshixun_count %> + <%= total_forked_myshixun_count %> + <%= total_valid_myshixun_count %> + <%= total_shixun_score %> + + + <% else %> + <% @shixuns.each do |shixun| %> + <% + total_myshixun_count += shixun.myshixuns_count + total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i - valid_course_count = @course_count_map.fetch(shixun.id, 0) - valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0) - score = - if shixun.fork_from.blank? - 500 + 50 * valid_course_count + 10 * valid_student_count - else - 100 + 10 * valid_course_count + 5 * valid_student_count - end + valid_course_count = @course_count_map.fetch(shixun.id, 0) + valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0) + score = + if shixun.fork_from.blank? + 500 + 50 * valid_course_count + 10 * valid_student_count + else + 100 + 10 * valid_course_count + 5 * valid_student_count + end - @forked_shixun_map.each do |shixun_id, fork_from_id| - next if fork_from_id != shixun.id + @forked_shixun_map.each do |shixun_id, fork_from_id| + next if fork_from_id != shixun.id - score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0) - end + score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0) + end - total_shixun_score += score - %> - - <%= shixun.creator.show_real_name %> - - <%= link_to shixun_path(shixun), target: '_blank' do %> - <%= shixun.name %> - <% end %> - <% if shixun.fork_from.blank? %> - 原创 - <% end %> - - <%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %> - <%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %> - <%= @myshixun_count_map.fetch(shixun.id, '--') %> - <%= score.zero? ? '--' : score %> + total_shixun_score += score + %> + + <%= shixun.creator.show_real_name %> + + <%= link_to shixun_path(shixun), target: '_blank' do %> + <%= shixun.name %> + <% end %> + <% if shixun.fork_from.blank? %> + 原创 + <% end %> + + <%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %> + <%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %> + <%= @myshixun_count_map.fetch(shixun.id, '--') %> + <%= score.zero? ? '--' : score %> + + <% end %> + + + + 合计 + <%= @shixuns.size %> + <%= total_myshixun_count %> + <%= total_forked_myshixun_count %> + <%= @myshixun_count_map.values.reduce(:+) %> + <%= total_shixun_score %> + <% end %> - - - - 合计 - <%= @shixuns.size %> - <%= total_myshixun_count %> - <%= total_forked_myshixun_count %> - <%= @myshixun_count_map.values.reduce(:+) %> - <%= total_shixun_score %> - - \ No newline at end of file diff --git a/db/migrate/20191009020158_create_competition_course_records.rb b/db/migrate/20191009020158_create_competition_course_records.rb new file mode 100644 index 00000000..e2846c9a --- /dev/null +++ b/db/migrate/20191009020158_create_competition_course_records.rb @@ -0,0 +1,15 @@ +class CreateCompetitionCourseRecords < ActiveRecord::Migration + def change + create_table :competition_course_records do |t| + t.references :competition + t.references :competition_team + + t.string :type + t.integer :user_id + t.string :username + + t.integer :score + t.text :snapshot + end + end +end diff --git a/lib/tasks/competition_gcc_course_statistic.rake b/lib/tasks/competition_gcc_course_statistic.rake new file mode 100644 index 00000000..192c2975 --- /dev/null +++ b/lib/tasks/competition_gcc_course_statistic.rake @@ -0,0 +1,164 @@ + +namespace :competition do + desc "statistic gcc_course competition score" + task :gcc_course_statistic, [:competition_id] => :environment do |_, args| + competition = Competition.find args[:competition_id] + custom_logger("Start Statistic Competition Score: #{competition.id}|#{competition.identifier}|#{competition.name} ~") + + custom_logger("Clear Old Competition Scores ~") + CompetitionScore.where(competition_id: competition.id).delete_all + CompetitionCourseRecord.where(competition_id: competition.id).delete_all + custom_logger("Clear Old Competition Scores Completed!") + + competition.competition_teams.each do |team| + custom_logger("Start Statistic Competition Team: #{team.id}|#{team.name} ~") + team_user_ids = team.team_members.pluck(:user_id) + total_score = 0 + + # =========== Shixun =========== + shixuns = Shixun.where(user_id: team_user_ids, status: 2) + .where('shixuns.created_at > ? && shixuns.created_at <= ?', Time.parse('2018-06-01'), competition.end_time) + shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') + shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count') + shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator) + + shixun_ids = shixuns.map(&:id) + myshixun_count_map = get_valid_myshixun_count(shixun_ids) + original_myshixun_count_map = myshixun_count_map.clone + # forked shixun valid myshixun count + forked_shixun_map = Shixun.where(status: 2, fork_from: shixun_ids).select('id, fork_from') + forked_shixun_map = forked_shixun_map.each_with_object({}) { |sx, obj| obj[sx.id] = sx.fork_from } + forked_myshixun_count_map = get_valid_myshixun_count(forked_shixun_map.keys) + forked_myshixun_count_map.each { |k, v| myshixun_count_map[forked_shixun_map[k]] += v } + + course_count_map = get_valid_course_count(shixun_ids) + forked_map = get_valid_course_count(forked_shixun_map.keys) + forked_course_count_map = {} + forked_map.each do |forked_id, course_count| + forked_course_count_map[forked_shixun_map[forked_id]] ||= 0 + forked_course_count_map[forked_shixun_map[forked_id]] += course_count + end + + custom_logger("Start Shixun Score ~") + shixuns.each do |shixun| + valid_course_count = course_count_map.fetch(shixun.id, 0) + valid_student_count = original_myshixun_count_map.fetch(shixun.id, 0) + score = + if shixun.fork_from.blank? + 500 + 50 * valid_course_count + 10 * valid_student_count + else + 100 + 10 * valid_course_count + 5 * valid_student_count + end + + forked_shixun_map.each do |shixun_id, fork_from_id| + next if fork_from_id != shixun.id + + score += 100 + 10 * forked_map.fetch(shixun_id, 0) + 5 * forked_myshixun_count_map.fetch(shixun_id, 0) + end + + total_score += score + + attr = { + competition_id: competition.id, + competition_team_id: team.id, + user_id: shixun.creator.id, + username: shixun.creator.show_real_name, + score: score, + snapshot: { + shixun: shixun.as_json(only: [:id, :name, :identifier, :fork_from])['shixun'], + myshixuns_count: shixun.myshixuns_count.to_i, + forked_myshixun_count: shixun['forked_myshixun_count'].to_i, + valid_myshixun_count: myshixun_count_map.fetch(shixun.id, 0), + } + } + CompetitionCourseShixunRecord.create(attr) + end + custom_logger("Shixun Score Completed!") + + + # =========== Course =========== + student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql + subquery = StudentWork.where('homework_common_id = hcs.id') + .select('sum(compelete_status !=0 ) as finish, count(*) as total') + .having('total != 0 and finish >= (total / 2)').to_sql + course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) + .where('courses.created_at <= ?', competition.end_time) + .where("(#{student_count_subquery}) >= 3") + .where("exists(select 1 from homework_commons hcs where hcs.course_id = courses.id and hcs.publish_time is not null and hcs.publish_time < NOW() and hcs.homework_type = 4 and exists(#{subquery}))") + .joins('join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)') + .where(course_members: { user_id: team_user_ids }).pluck(:id) + courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()') + courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count') + .group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0') + + course_ids = courses.map(&:id) + course_myshixun_map = Myshixun.joins(student_works: :homework_common) + .where(homework_commons: { course_id: course_ids }) + .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') + .group('homework_commons.course_id').count + course_shixun_count_map = get_valid_shixun_count(course_ids) + + custom_logger("Start Course Score ~") + courses.each do |course| + user = course.teachers.where(user_id: team_user_ids).first.user + + score = 500 + 5 * course_shixun_count_map.fetch(course.id, 0) * course_myshixun_map.fetch(course.id, 0) + total_score += score + + attr = { + competition_id: competition.id, + competition_team_id: team.id, + user_id: user.id, + username: user.show_real_name, + score: score, + snapshot: { + course: course.as_json(only: [:id, :name]), + members_count: course.members_count.to_i, + shixun_homework_count: course['shixun_homework_count'].to_i, + valid_myshixun_count: course_myshixun_map.fetch(course.id, 0), + } + } + CompetitionCourseCourseRecord.create(attr) + end + custom_logger("Course Score Completed!") + + custom_logger('Create Competition Score ~') + CompetitionScore.create(user_id: team.user_id, competition_team_id: team.id, competition_id: competition.id, score: total_score) + + custom_logger("Statistic Competition Team: #{team.id}|#{team.name} Completed!") + end + end + + def custom_logger(msg) + Rails.logger.info(msg) + p msg + end + + def get_valid_myshixun_count(ids) + Myshixun.where(shixun_id: ids) + .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') + .group('shixun_id').count + end + + def get_valid_course_count(ids) + percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()') + .select('sum(compelete_status !=0 ) as finish, count(*) as total') + .having('total != 0 and finish >= (total / 2)').to_sql + + Course.joins(shixun_homework_commons: :homework_commons_shixuns) + .where('shixun_id in (?)', ids) + .where("exists (#{percentage_sql})") + .group('shixun_id').count + end + + def get_valid_shixun_count(ids) + percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()') + .select('sum(compelete_status !=0 ) as finish, count(*) as total') + .having('total != 0 and finish >= (total / 2)').to_sql + Shixun.joins(homework_commons_shixuns: :homework_common) + .where(homework_commons: { homework_type: 4 }) + .where('course_id in (?)', ids) + .where("exists (#{percentage_sql})") + .group('course_id').count + end +end From 434008157ef730f5426b166a48714e59e1c7ad60 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 9 Oct 2019 11:30:12 +0800 Subject: [PATCH 03/31] fix --- app/controllers/application_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 960d2ef4..50f97bc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -255,7 +255,6 @@ class ApplicationController < ActionController::Base end end end - user = User.find 57703 user end From c0f465ff99b49a457bff6921ea05f571a6346866 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Oct 2019 14:46:13 +0800 Subject: [PATCH 04/31] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=87=8C=E7=A8=8B?= =?UTF-8?q?=E7=A2=91=E5=90=8D=E7=A7=B0=E6=98=BE=E7=A4=BA=E5=A4=AA=E7=9F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/versions/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index 5b66e5bc..4cfd9432 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -71,7 +71,7 @@ #<%= issue.id %> <%= issue.subject %> <%= issue.tracker %> - " class="new_roadmap_info_name" target="_blank"> + " style="max-width: 200px" title="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> <%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %> <%= format_time issue.updated_on %> From dd5d3f9a513b7f3180319ee006f94af88cddedc3 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Oct 2019 14:54:31 +0800 Subject: [PATCH 05/31] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=87=8C=E7=A8=8B?= =?UTF-8?q?=E7=A2=91=E5=90=8D=E7=A7=B0=E6=98=BE=E7=A4=BAtitle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/versions/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index 4cfd9432..b8db3bdf 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -71,7 +71,7 @@ #<%= issue.id %> <%= issue.subject %> <%= issue.tracker %> - " style="max-width: 200px" title="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> + " style="max-width: 200px" data-tip-down="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> <%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %> <%= format_time issue.updated_on %> From 67f5a07753f3515d84801c92a1b61ae5e0acf404 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Oct 2019 15:11:59 +0800 Subject: [PATCH 06/31] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=87=8C=E7=A8=8B?= =?UTF-8?q?=E7=A2=91=E6=8C=87=E6=B4=BE=E7=9D=80=E5=B1=85=E4=B8=AD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/versions/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index b8db3bdf..58547a36 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -69,9 +69,9 @@ <% @issues.each do |issue| %> #<%= issue.id %> - <%= issue.subject %> + <%= issue.subject %> <%= issue.tracker %> - " style="max-width: 200px" data-tip-down="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> + " style="max-width: 200px;text-align: center;" data-tip-down="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> <%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %> <%= format_time issue.updated_on %> From a3c081860e6676ca39027038d04d5ae8689417f8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Oct 2019 15:14:20 +0800 Subject: [PATCH 07/31] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=87=8C=E7=A8=8B?= =?UTF-8?q?=E7=A2=91=E6=8C=87=E6=B4=BE=E7=9D=80=E5=B1=85=E4=B8=AD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/versions/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index 58547a36..0abc6b79 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -69,9 +69,9 @@ <% @issues.each do |issue| %> #<%= issue.id %> - <%= issue.subject %> + <%= issue.subject %> <%= issue.tracker %> - " style="max-width: 200px;text-align: center;" data-tip-down="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> + " style="max-width: 200px;text-align: center;margin-left: 0px;" data-tip-down="<%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %>" class="new_roadmap_info_name" target="_blank"> <%= User.find(issue.try(:assigned_to_id)).nil? ? "" : User.find(issue.try(:assigned_to_id)).show_name %> <%= format_time issue.updated_on %> From a79bc50c5af40e0924a65196df9be32240fb3912 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 9 Oct 2019 17:06:42 +0800 Subject: [PATCH 08/31] =?UTF-8?q?=E5=AD=A6=E9=99=A2=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=9A=84=E5=AD=A6=E7=94=9F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/colleges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 5f1f094c..fab83063 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -128,7 +128,7 @@ class CollegesController < ApplicationController # 在线课堂 def course_statistics @courses = Course.find_by_sql("SELECT c.id, (select concat(lastname,firstname) from users u where u.id=c.tea_id) as username, - (select count(sfc.id) from students_for_courses sfc where c.id=sfc.course_id group by c.id) as student_count, + (select count(cm.id) from course_members cm where c.id=cm.course_id and cm.role=4 group by c.id) as student_count, (select count(hc.id) from homework_commons hc where c.id=hc.course_id and hc.homework_type=4 group by c.id) as hcm_count, (select count(hc.id) from homework_commons hc where c.id=hc.course_id and hc.homework_type in (1,3) group by c.id) as hcm_nonshixun_count, (select count(e.id) from exercises e where c.id=e.course_id group by c.id) as exercises_count, From 591cea9e9cdd92da7647913740914bbb751d7323 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 9 Oct 2019 17:13:06 +0800 Subject: [PATCH 09/31] tiaoz --- app/controllers/colleges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index fab83063..cc4e6c9a 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -85,7 +85,7 @@ class CollegesController < ApplicationController homeworks = HomeworkCommon.where(:homework_type => 4, :course_id => course_ids.map(&:id)) un_shixun_work_count = homeworks.where("publish_time > '#{Time.now}' or publish_time is null").count shixun_work_count = homeworks.size - un_shixun_work_count - student_count = StudentsForCourse.where(:course_id => course_ids.map(&:id)).count + student_count = CourseMember.where(:course_id => course_ids.map(&:id), :role => 4).count myshixun_ids = StudentWork.select("myshixun_id").where("homework_common_id in (#{homeworks.map(&:id).join(',').strip == "" ? -1 : homeworks.map(&:id).join(',')}) and myshixun_id is not null") complete_myshixun = Myshixun.select("id").where(:status => 1, :id => myshixun_ids.map(&:myshixun_id)).size all_myshixun = Myshixun.select("id").where(:id => myshixun_ids.map(&:myshixun_id)).size From b120e0fde55aa2b17568f13573f4a1f14abaf935 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 18 Oct 2019 14:09:46 +0800 Subject: [PATCH 10/31] =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition_team.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition_team.rb b/app/models/competition_team.rb index a8f48b3e..a7d89546 100644 --- a/app/models/competition_team.rb +++ b/app/models/competition_team.rb @@ -5,7 +5,7 @@ class CompetitionTeam < ActiveRecord::Base has_many :team_members, :dependent => :destroy has_many :members, conditions: 'team_members.is_teacher = 0', class_name: 'TeamMember' - has_many :teachers, conditions: 'team_members.is_teacher = 1', class_name: 'TeamMember' + has_many :teachers, conditions: 'team_members.is_teacher = 1', class_name: 'TeamMember', :order => "team_members.role ASC" has_many :competition_scores, :dependent => :destroy # team_type 0:组队 1:个人 # attr_accessible :invite_code, :name, :team_type From e6055191f97fce0935c16ed51d1ccb42205a57d8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 19 Oct 2019 16:03:43 +0800 Subject: [PATCH 11/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=95=B0=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_competition_team_detail_course.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb index 0401c104..49f3e7e4 100644 --- a/app/views/competition_teams/_competition_team_detail_course.html.erb +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -22,7 +22,7 @@ <% @records.each do |record| %> <% course = record.snapshot['course'] - total_members_count += record.snapshot['members_count'].to_i + total_members_count += course.students.count total_shixun_homework_count += record.snapshot['shixun_homework_count'].to_i total_valid_homework_count += record.snapshot['valid_myshixun_count'].to_i total_course_score += record.score.to_i @@ -34,7 +34,7 @@ <%= course.name %> <% end %> - <%= record.snapshot['members_count'].to_i %> + <%= course.students.count %> <%= record.snapshot['shixun_homework_count'].to_i || '--' %> <%= record.snapshot['valid_myshixun_count'].to_i %> <%= record.score.to_i.zero? ? '--' : record.score.to_i %> @@ -67,7 +67,7 @@ <%= course.name %> <% end %> - <%= course.members_count %> + <%= course.students.count %> <%= course['shixun_homework_count'].presence || '--' %> <%= @course_myshixun_map.fetch(course.id, '--') %> <%= score.zero? ? '--' : score %> From 7d5070aee6654ea2fc009213cefdcf61b7bed9cf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 19 Oct 2019 16:17:23 +0800 Subject: [PATCH 12/31] tiaoz --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 7ccf067b..4e8f4eb6 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -2,7 +2,7 @@ class Competition < ActiveRecord::Base # status 0:下架, 1:上架 attr_accessible :end_time, :identifier, :name, :online_time, :start_time, :status, :visits, :competition_lists_count, - :min_num, :max_num, :enroll_end_time, :sub_title, :published_at + :min_num, :max_num, :enroll_end_time, :sub_title, :published_at, :rate has_many :competition_modules, :dependent => :destroy has_many :competition_stages, :dependent => :destroy From 6276d1c528a02494a60576a919452b1357c90213 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 19 Oct 2019 16:26:21 +0800 Subject: [PATCH 13/31] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competitions_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 3b438e06..4cbb8d14 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -749,7 +749,7 @@ class CompetitionsController < ApplicationController # rate 关卡经验值与分数的比值 # challenge_count 每个实训的关卡数 # 对三个实训的所有关卡循环: 找到在比赛时间内通关的最低耗时 - def chart_exp_score_pre user_ids, s_time, e_time, challenges, rate, challenge_count + def chart_exp_score_pre user_ids, s_time, e_time, challenges, s_rate, challenge_count total_score = 0 total_time = 0 length = challenge_count #每个实训的关卡数 @@ -758,7 +758,7 @@ class CompetitionsController < ApplicationController time = 0 challenges.where(:position => i).each do |challenge| Game.where(:challenge_id => challenge.id, :user_id => user_ids, :status => 2).select{|game| game.open_time >= s_time && game.end_time <= e_time }.each do |game| - game_score = challenge.score * rate + game_score = challenge.score * s_rate cost_time = (game.end_time.to_i - s_time.to_i) > 0 ? (game.end_time.to_i - s_time.to_i) : 0 if score < game_score score = game_score From e53cc859d179b0a5b14b5bd3b81dfb1836a9b367 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 19 Oct 2019 16:31:15 +0800 Subject: [PATCH 14/31] tiaoz --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 4e8f4eb6..7ccf067b 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -2,7 +2,7 @@ class Competition < ActiveRecord::Base # status 0:下架, 1:上架 attr_accessible :end_time, :identifier, :name, :online_time, :start_time, :status, :visits, :competition_lists_count, - :min_num, :max_num, :enroll_end_time, :sub_title, :published_at, :rate + :min_num, :max_num, :enroll_end_time, :sub_title, :published_at has_many :competition_modules, :dependent => :destroy has_many :competition_stages, :dependent => :destroy From 5937497a1cfa71a04d38a44be239105705b8d347 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 19 Oct 2019 16:40:40 +0800 Subject: [PATCH 15/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=80=BB=E6=95=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../competition_teams/_competition_team_detail_course.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb index 49f3e7e4..806092a3 100644 --- a/app/views/competition_teams/_competition_team_detail_course.html.erb +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -54,7 +54,7 @@ <% else %> <% @courses.each do |course| %> <% - total_members_count += course.members_count.to_i + total_members_count += course.students.count total_shixun_homework_count += course['shixun_homework_count'].to_i score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0) From 56f1b9b056410f7ebc2cc7f642c63930627877b3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 09:21:13 +0800 Subject: [PATCH 16/31] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E6=95=99=E5=AD=A6?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E6=8E=92=E8=A1=8C=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competitions_controller.rb | 4 ++-- app/views/competitions/_chartList.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 4cbb8d14..08de34b8 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -305,7 +305,7 @@ class CompetitionsController < ApplicationController end records_length = 97 @records = @records[0..records_length] - elsif @competition.identifier == "gcc-annotation-2018" + elsif @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-course-2019" @records = @competition.competition_teams.includes(:user => [:user_extensions => [:school]]) @records.each do |team| team[:s_score] = team.competition_scores.where(:competition_id => @competition.id).first.try(:score).to_f.try(:round, 3) @@ -494,7 +494,7 @@ class CompetitionsController < ApplicationController sheet1[count_row,10] = com_spend_time team[:s_spend_time].to_i count_row += 1 end - elsif @competition.identifier == "gcc-annotation-2018" + elsif @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-course-2019" records = @competition.competition_teams records.each do |team| team[:s_score] = team.competition_scores.where(:competition_id => @competition.id).first.try(:score).to_f.try(:round, 3) diff --git a/app/views/competitions/_chartList.html.erb b/app/views/competitions/_chartList.html.erb index dcf66550..ee7587e6 100644 --- a/app/views/competitions/_chartList.html.erb +++ b/app/views/competitions/_chartList.html.erb @@ -44,7 +44,7 @@ <% @records.each_with_index do |record, index| %> <% record_user = record.user %>
- <% if @competition.identifier == "gcc-annotation-2018" %> + <% if @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-course-2019" %>
  • <% if index == 0 %> From 5eefbc5afa5e698f5da7d0a1c85e70830e64b083 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 15:22:54 +0800 Subject: [PATCH 17/31] =?UTF-8?q?=E6=88=98=E9=98=9F=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../competition_teams/_competition_team_detail_course.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb index 806092a3..8ae95954 100644 --- a/app/views/competition_teams/_competition_team_detail_course.html.erb +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -22,6 +22,7 @@ <% @records.each do |record| %> <% course = record.snapshot['course'] + course = Course.find(course["id"]) total_members_count += course.students.count total_shixun_homework_count += record.snapshot['shixun_homework_count'].to_i total_valid_homework_count += record.snapshot['valid_myshixun_count'].to_i From 74fd3f316dd3c8d91b687abdcebe8969458a7096 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 17:57:28 +0800 Subject: [PATCH 18/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=88=98=E9=98=9F?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../competition_teams/_competition_team_detail_course.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb index 8ae95954..fe931a2a 100644 --- a/app/views/competition_teams/_competition_team_detail_course.html.erb +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -22,7 +22,7 @@ <% @records.each do |record| %> <% course = record.snapshot['course'] - course = Course.find(course["id"]) + course = Course.find(course["course"]["id"]) total_members_count += course.students.count total_shixun_homework_count += record.snapshot['shixun_homework_count'].to_i total_valid_homework_count += record.snapshot['valid_myshixun_count'].to_i From d028eabf49eaf337a53abe1ab73b5221a4723945 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 17:59:38 +0800 Subject: [PATCH 19/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=88=98=E9=98=9F?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competition_teams_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 146db869..9c39cf44 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -20,6 +20,9 @@ class CompetitionTeamsController < ApplicationController return render_404 if @competition.identifier != 'gcc-course-2019' @competition_completed = false + # 竞赛正在进行,分数动态计算 + @team_user_ids = @team.team_members.pluck(:user_id) + # 竞赛结束并且分数已经统计 if @competition.end_time < Time.current && CompetitionCourseRecord.exists?(competition_id: @competition.id) @competition_completed = true @@ -27,9 +30,6 @@ class CompetitionTeamsController < ApplicationController return end - # 竞赛正在进行,分数动态计算 - @team_user_ids = @team.team_members.pluck(:user_id) - shixuns = Shixun.where(user_id: @team_user_ids, status: 2) .where('shixuns.created_at > ? && shixuns.created_at <= ?', Time.parse('2018-06-01'), @competition.end_time) shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') From cf4668e3b8e6e016a8b9ae445c3716e11213d36e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 18:01:33 +0800 Subject: [PATCH 20/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=88=98=E9=98=9F?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competition_teams_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 9c39cf44..c3a44fd8 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -59,6 +59,8 @@ class CompetitionTeamsController < ApplicationController return render_404 if @competition.identifier != 'gcc-course-2019' @competition_completed = false + @team_user_ids = @team.team_members.pluck(:user_id) + # 竞赛结束并且分数已经统计 if @competition.end_time < Time.current && CompetitionCourseRecord.exists?(competition_id: @competition.id) @competition_completed = true @@ -66,8 +68,6 @@ class CompetitionTeamsController < ApplicationController return end - @team_user_ids = @team.team_members.pluck(:user_id) - student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql subquery = StudentWork.where('homework_common_id = hcs.id') .select('sum(compelete_status !=0 ) as finish, count(*) as total') From 8513370063cc6ca55806d6365576035e922522c1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 21 Oct 2019 18:07:35 +0800 Subject: [PATCH 21/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=88=98=E9=98=9F?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/competitions_controller.rb | 2 +- app/views/competitions/charts.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 08de34b8..6cb547c7 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -188,7 +188,7 @@ class CompetitionsController < ApplicationController end end end - if @competition.identifier == "gcc-annotation-2018" + if @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-course-2019" @rule_content = @competition.chart_rules.first else @rule_content = @competition.chart_rules.where(:competition_stage_id => @stage.try(:id)).first diff --git a/app/views/competitions/charts.html.erb b/app/views/competitions/charts.html.erb index 5fdbafff..37828fb1 100644 --- a/app/views/competitions/charts.html.erb +++ b/app/views/competitions/charts.html.erb @@ -1,4 +1,4 @@ -<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-task-2019" %> +<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-task-2019" || @competition.identifier == "gcc-course-2019" %>
    From 9b591f8fc02b05af858d26bf3e5daeb2933c115e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 22 Oct 2019 09:56:25 +0800 Subject: [PATCH 22/31] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/competitions/charts.html.erb | 2 ++ lib/tasks/competition_gcc_course_statistic.rake | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/competitions/charts.html.erb b/app/views/competitions/charts.html.erb index 37828fb1..86b20033 100644 --- a/app/views/competitions/charts.html.erb +++ b/app/views/competitions/charts.html.erb @@ -4,6 +4,8 @@
    <% if @competition.identifier == "gcc-annotation-2018" %>
  • 开源标注正赛排行榜
  • + <% elsif @competition.identifier == "gcc-course-2019" %> +
  • 排行榜
  • <% else %> <% if @max_min_stage.count == 1 %>
  • 排行榜
  • diff --git a/lib/tasks/competition_gcc_course_statistic.rake b/lib/tasks/competition_gcc_course_statistic.rake index 192c2975..f212a365 100644 --- a/lib/tasks/competition_gcc_course_statistic.rake +++ b/lib/tasks/competition_gcc_course_statistic.rake @@ -17,7 +17,7 @@ namespace :competition do # =========== Shixun =========== shixuns = Shixun.where(user_id: team_user_ids, status: 2) - .where('shixuns.created_at > ? && shixuns.created_at <= ?', Time.parse('2018-06-01'), competition.end_time) + .where('shixuns.created_at > ? && shixuns.created_at <= ?', Time.parse('2018-06-01'), Time.now) shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count') shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator) @@ -82,7 +82,7 @@ namespace :competition do .select('sum(compelete_status !=0 ) as finish, count(*) as total') .having('total != 0 and finish >= (total / 2)').to_sql course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) - .where('courses.created_at <= ?', competition.end_time) + .where('courses.created_at <= ?', Time.now) .where("(#{student_count_subquery}) >= 3") .where("exists(select 1 from homework_commons hcs where hcs.course_id = courses.id and hcs.publish_time is not null and hcs.publish_time < NOW() and hcs.homework_type = 4 and exists(#{subquery}))") .joins('join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)') From 275218cf04e0a67fbaec312aac1004a34a5aee8b Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 22 Oct 2019 14:14:43 +0800 Subject: [PATCH 23/31] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/competitions/_chartList.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competitions/_chartList.html.erb b/app/views/competitions/_chartList.html.erb index ee7587e6..6bfb5582 100644 --- a/app/views/competitions/_chartList.html.erb +++ b/app/views/competitions/_chartList.html.erb @@ -14,7 +14,7 @@
    • 当前排名 <%= rank.rank == 0 ? "--" : rank.rank %>
    • <%= rank.name %>
    • - <% if @competition.identifier != "gcc-annotation-2018" %> + <% if @competition.identifier != "gcc-annotation-2018" && @competition.identifier == "gcc-course-2019" %>
    • <%= rank.rank == 0 ? "--" : com_spend_time(rank.s_spend_time) %>
    • <% end %>
    • <%= rank.rank == 0 ? "--" : "#{rank.s_score}分" %>
    • From a6365c76ea948718ea3141e73d7ed87cbe8a4182 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 22 Oct 2019 14:17:24 +0800 Subject: [PATCH 24/31] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/competitions/_chartList.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/competitions/_chartList.html.erb b/app/views/competitions/_chartList.html.erb index 6bfb5582..169b70e4 100644 --- a/app/views/competitions/_chartList.html.erb +++ b/app/views/competitions/_chartList.html.erb @@ -14,7 +14,7 @@
      • 当前排名 <%= rank.rank == 0 ? "--" : rank.rank %>
      • <%= rank.name %>
      • - <% if @competition.identifier != "gcc-annotation-2018" && @competition.identifier == "gcc-course-2019" %> + <% if @competition.identifier != "gcc-annotation-2018" && @competition.identifier != "gcc-course-2019" %>
      • <%= rank.rank == 0 ? "--" : com_spend_time(rank.s_spend_time) %>
      • <% end %>
      • <%= rank.rank == 0 ? "--" : "#{rank.s_score}分" %>
      • From b2b4d7e7c77c7aa11123f5e3ed3dcc9aac72de1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 22 Oct 2019 14:54:41 +0800 Subject: [PATCH 25/31] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header.html.erb | 2 +- app/views/layouts/_unlogin_header.html.erb | 2 +- public/react/src/modules/tpm/NewHeader.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 6da60505..19915869 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -22,7 +22,7 @@ <% end %>
      • "> <%= link_to "在线竞赛", competitions_path %> - +
      • "><%= link_to "教学案例", libraries_path %>
      • diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 0667330c..6ee75008 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -24,7 +24,7 @@ <% end %>
      • "> <%= link_to "在线竞赛", competitions_path %> - +
      • "><%= link_to "教学案例", libraries_path %>
      • diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index e4cfd6cf..2377198e 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -398,7 +398,7 @@ class NewHeader extends Component {
      • 在线竞赛 - + {/**/}
      • 教学案例
      • From 7e01c32481df25652f7a4f708b12757910dfff94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Tue, 22 Oct 2019 18:14:14 +0800 Subject: [PATCH 26/31] b --- .../ec/ecCompletion_calculation/ecCompletion_calculation.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/ec/ecCompletion_calculation/ecCompletion_calculation.js b/public/react/src/modules/ec/ecCompletion_calculation/ecCompletion_calculation.js index 63dc7a7c..e1dee2b5 100644 --- a/public/react/src/modules/ec/ecCompletion_calculation/ecCompletion_calculation.js +++ b/public/react/src/modules/ec/ecCompletion_calculation/ecCompletion_calculation.js @@ -684,7 +684,9 @@ class EcCompletionCalculation extends Component { // }) } { - Spintype===false?
      • 1200?(113*(total_rate_data+4.5))+63:1200+"px"}}> + Spintype===false?
      • 5 ? (180 * total_rate_data+226+16) : 1200 + "px"}} + // style={{width: 113*(total_rate_data+4)>1200?(113*(total_rate_data+4.5))+63:1200+"px"}} + > {/*{k+1}*/} 平均分 {/*{i.student_scores.name}*/} From 2fe3f5741b966106683471b2d1ca52f588b2dc7b Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 30 Oct 2019 15:42:59 +0800 Subject: [PATCH 27/31] =?UTF-8?q?=E9=A1=B9=E7=9B=AEissue=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journal.rb | 8 ++++---- public/javascripts/create_kindeditor.js | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/models/journal.rb b/app/models/journal.rb index 41d81de1..3f6e2563 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -72,10 +72,10 @@ class Journal < ActiveRecord::Base where("(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes, *args)}))", false) } - def save(*args) - # Do not save an empty journal - (details.empty? && notes.blank?) ? false : super - end + # def save(*args) + # # Do not save an empty journal + # (details.empty? && notes.blank?) ? false : super + # end # Returns the new status if the journal contains a status change, otherwise nil def new_status diff --git a/public/javascripts/create_kindeditor.js b/public/javascripts/create_kindeditor.js index fdd493d8..0ac14179 100644 --- a/public/javascripts/create_kindeditor.js +++ b/public/javascripts/create_kindeditor.js @@ -36,7 +36,8 @@ function sd_create_editor(params){ } //params.toolbar_container.hide(); $('#reply_image_' + id).addClass('imageFuzzy'); - if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){ + // /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())) + if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html()) && $(".upload_filename").length == 0 ){ params.submit_btn.hide(); params.toolbar_container.hide(); this.resize("100%", null); @@ -209,13 +210,17 @@ function sd_check_editor_form_field(params){ if(params.content.html()!=params.textarea.html() || params.issubmit==true){ params.textarea.html(params.content.html()); params.content.sync(); - if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.textarea.html())){ - params.contentmsg.html('内容不能为空'); + if( + (params.content.isEmpty() && $(".upload_filename").length == 0) + || + (/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.textarea.html())&& $(".upload_filename").length == 0)){ + params.contentmsg.html('请填写评论内容或者上传附件!'); params.contentmsg.css({color:'#ff0000'}); - }else{ - params.contentmsg.html('填写正确'); - params.contentmsg.css({color:'#008000'}); } + // else{ + // params.contentmsg.html('填写正确'); + // params.contentmsg.css({color:'#008000'}); + // } params.contentmsg.show(); } } @@ -281,6 +286,7 @@ function sd_create_editor_from_data(id){ }); params.submit_btn.click(function () { var tContents = $("#comment_news_" + id).val(); + console.log("tcontrnet"+tContents); if(tContents != undefined){ var beforeImage = tContents.split(""); From f1c54bdee2cb3fc23d89cac38f90db805605297d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 4 Nov 2019 16:39:58 +0800 Subject: [PATCH 28/31] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 10 ++++++++++ .../managements/_classroom_classment_list.html.erb | 11 +++++++++++ .../managements/course_board_email_notify.js.erb | 0 config/routes.rb | 1 + 4 files changed, 22 insertions(+) create mode 100644 app/views/managements/course_board_email_notify.js.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index df14dd53..06a09f93 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2210,6 +2210,16 @@ end end end + + # 讨论区邮件通知 + def course_board_email_notify + if params[:course_id] + course = Course.find params[:course_id] + course.update_attributes(:email_notify => !course.email_notify) + end + end + + # 课程实训 def class_shixuns @menu_type = 4 diff --git a/app/views/managements/_classroom_classment_list.html.erb b/app/views/managements/_classroom_classment_list.html.erb index 2b9c98cb..9321c495 100644 --- a/app/views/managements/_classroom_classment_list.html.erb +++ b/app/views/managements/_classroom_classment_list.html.erb @@ -40,6 +40,8 @@ <%= course.is_hidden ? "显示" : "隐藏" %> class="ml-3 mr5 magic-checkbox" id="join_course_role_<%= course.id %>"> + class="ml-3 mr5 magic-checkbox" id="email_notify_<%= course.id %>"> + <% end %> @@ -74,4 +76,13 @@ dateType: "script" }); }) + $("input[name='email_notify']").click(function(){ + var course_id = $(this).val(); + $.ajax({ + url:"<%= course_board_email_notify_managements_path %>", + data: {course_id: course_id}, + type: 'post', + dateType: "script" + }); + }) diff --git a/app/views/managements/course_board_email_notify.js.erb b/app/views/managements/course_board_email_notify.js.erb new file mode 100644 index 00000000..e69de29b diff --git a/config/routes.rb b/config/routes.rb index ef6d561c..49f180bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -625,6 +625,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'update_shixun_hidden' get 'update_subject_hidden' post 'course_homepage_show' + post 'course_board_email_notify' post 'shixun_homepage_show' post 'update_shixun_task_pass' post 'update_shixun_code_hidden' From 7cb079359c39e11e6d4d5616f8cb39dbf0dbaae5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 7 Nov 2019 10:58:01 +0800 Subject: [PATCH 29/31] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index 796ea3c9..ff56ed80 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -139,7 +139,8 @@ class Course < ActiveRecord::Base 'choose_group_allow', 'credit', 'homepage_show', - 'show_unit' + 'show_unit', + 'email_notify' acts_as_customizable From 5ba6e70e1efc398015755984d2c18d052b1d0113 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 7 Nov 2019 11:01:19 +0800 Subject: [PATCH 30/31] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index ff56ed80..ac073a44 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -26,7 +26,7 @@ class Course < ActiveRecord::Base attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public, :description,:class_period, :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, - :choose_group_allow, :is_end, :homepage_show, :course_list_id, :teacher_list, :student_list, :is_hidden + :choose_group_allow, :is_end, :homepage_show, :course_list_id, :teacher_list, :student_list, :is_hidden, :email_notify #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 From ad61dc8ceeeb8db7fcdcb00a6bd135145b7fb5eb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 13 Nov 2019 09:35:40 +0800 Subject: [PATCH 31/31] =?UTF-8?q?=E5=BC=95=E6=B5=81=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 06a09f93..b19bbaf9 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -29,7 +29,7 @@ class ManagementsController < ApplicationController end def user_agents - @user_agents = UserAgent.where("user_agents.key is not order by action_status, register_status") + @user_agents = UserAgent.where("user_agents.key is not null order by action_status, register_status") @agents_count = @user_agents.count limit = 20 @agents_pages = Paginator.new @agents_count, limit, params['page'] || 1