Merge branch 'dev_aliyun' into develop

dev_aliyun
daiao 5 years ago
commit 0d58021a16

@ -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
@ -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,

@ -18,9 +18,18 @@ class CompetitionTeamsController < ApplicationController
def shixun_detail
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
@records = CompetitionCourseRecord.where(type: 'CompetitionCourseShixunRecord', competition_team_id: @team.id)
return
end
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')
@ -48,9 +57,17 @@ class CompetitionTeamsController < ApplicationController
def course_detail
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
@records = CompetitionCourseRecord.where(type: 'CompetitionCourseCourseRecord', competition_team_id: @team.id)
return
end
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')

@ -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
@ -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)
@ -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

@ -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
@ -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

@ -0,0 +1,3 @@
class CompetitionCourseCourseRecord < CompetitionCourseRecord
end

@ -0,0 +1,6 @@
class CompetitionCourseRecord < ActiveRecord::Base
belongs_to :competition
belongs_to :competition_team
serialize :snapshot, JSON
end

@ -0,0 +1,2 @@
class CompetitionCourseShixunRecord < CompetitionCourseRecord
end

@ -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

@ -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表
@ -139,7 +139,8 @@ class Course < ActiveRecord::Base
'choose_group_allow',
'credit',
'homepage_show',
'show_unit'
'show_unit',
'email_notify'
acts_as_customizable

@ -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

@ -15,38 +15,75 @@
<%
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']
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
total_course_score += record.score.to_i
%>
<tr>
<td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to course_path(course), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 480px;"><%= course.name %></span>
<% end %>
</td>
<td width="10%"><%= course.students.count %></td>
<td width="15%"><%= record.snapshot['shixun_homework_count'].to_i || '--' %></td>
<td width="10%"><%= record.snapshot['valid_myshixun_count'].to_i %></td>
<td width="15%"><%= record.score.to_i.zero? ? '--' : record.score.to_i %></td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @records.size %></th>
<th width="10%"><%= total_members_count %></th>
<th width="15%"><%= total_shixun_homework_count %></th>
<th width="10%"><%= total_valid_homework_count %></th>
<th width="15%"><%= total_course_score %></th>
</tr>
</tfoot>
<% else %>
<% @courses.each do |course| %>
<%
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)
total_course_score += score
%>
<tr>
<td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to course_path(course), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 480px;"><%= course.name %></span>
<% end %>
</td>
<td width="10%"><%= course.members_count %></td>
<td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0)
total_course_score += score
%>
<tr>
<td width="10%"><%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to course_path(course), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 480px;"><%= course.name %></span>
<% end %>
</td>
<td width="10%"><%= course.students.count %></td>
<td width="15%"><%= course['shixun_homework_count'].presence || '--' %></td>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @courses.size %></th>
<th width="10%"><%= total_members_count %></th>
<th width="15%"><%= total_shixun_homework_count %></th>
<th width="10%"><%= @course_myshixun_map.values.reduce(:+) || 0 %></th>
<th width="15%"><%= total_course_score %></th>
</tr>
</tfoot>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @courses.size %></th>
<th width="10%"><%= total_members_count %></th>
<th width="15%"><%= total_shixun_homework_count %></th>
<th width="10%"><%= @course_myshixun_map.values.reduce(:+) || 0 %></th>
<th width="15%"><%= total_course_score %></th>
</tr>
</tfoot>
</table>

@ -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
%>
<tr>
<td width="10%"><%= record.username %></td>
<td width="40%" class="edu-txt-left">
<%= link_to shixun_path(shixun['identifier']), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 410px;"><%= shixun['name'] %></span>
<% end %>
<% if shixun['fork_from'].blank? %>
<span class="connectTag ml10">原创</span>
<% end %>
</td>
<td width="10%"><%= record.snapshot['myshixuns_count'].to_i.zero? ? '--' : record.snapshot['myshixuns_count'].to_i %></td>
<td width="15%"><%= record.snapshot['forked_myshixun_count'].to_i.zero? ? '--' : record.snapshot['forked_myshixun_count'].to_i %></td>
<td width="10%"><%= record.snapshot['valid_myshixun_count'].to_i.zero? ? '--' : record.snapshot['valid_myshixun_count'].to_i %></td>
<td width="15%"><%= record.score.zero? ? '--' : record.score %></td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @records.size %></th>
<th width="10%"><%= total_myshixun_count %></th>
<th width="15%"><%= total_forked_myshixun_count %></th>
<th width="10%"><%= total_valid_myshixun_count %></th>
<th width="15%"><%= total_shixun_score %></th>
</tr>
</tfoot>
<% 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
%>
<tr>
<td width="10%"><%= shixun.creator.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to shixun_path(shixun), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 410px;"><%= shixun.name %></span>
<% end %>
<% if shixun.fork_from.blank? %>
<span class="connectTag ml10">原创</span>
<% end %>
</td>
<td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td>
<td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
total_shixun_score += score
%>
<tr>
<td width="10%"><%= shixun.creator.show_real_name %></td>
<td width="40%" class="edu-txt-left">
<%= link_to shixun_path(shixun), target: '_blank' do %>
<span class="task-hide fl" style="max-width: 410px;"><%= shixun.name %></span>
<% end %>
<% if shixun.fork_from.blank? %>
<span class="connectTag ml10">原创</span>
<% end %>
</td>
<td width="10%"><%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %></td>
<td width="15%"><%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %></td>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%"><%= score.zero? ? '--' : score %></td>
</tr>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @shixuns.size %></th>
<th width="10%"><%= total_myshixun_count %></th>
<th width="15%"><%= total_forked_myshixun_count %></th>
<th width="10%"><%= @myshixun_count_map.values.reduce(:+) %></th>
<th width="15%"><%= total_shixun_score %></th>
</tr>
</tfoot>
<% end %>
</tbody>
<tfoot class="tfootLastPart">
<tr class="color-orange font-16">
<th width="10%" class="color-grey-6">合计</th>
<th width="40%" class="edu-txt-left"><%= @shixuns.size %></th>
<th width="10%"><%= total_myshixun_count %></th>
<th width="15%"><%= total_forked_myshixun_count %></th>
<th width="10%"><%= @myshixun_count_map.values.reduce(:+) %></th>
<th width="15%"><%= total_shixun_score %></th>
</tr>
</tfoot>
</table>

@ -14,7 +14,7 @@
<ul class="team-ranking inline mb10">
<li class="edu-txt-left">当前排名 <%= rank.rank == 0 ? "--" : rank.rank %></li>
<li class="edu-txt-left task-hide"><%= rank.name %></li>
<% if @competition.identifier != "gcc-annotation-2018" %>
<% if @competition.identifier != "gcc-annotation-2018" && @competition.identifier != "gcc-course-2019" %>
<li class="color-grey-9"><%= rank.rank == 0 ? "--" : com_spend_time(rank.s_spend_time) %></li>
<% end %>
<li class="color-orange-tip"><%= rank.rank == 0 ? "--" : "#{rank.s_score}分" %></li>
@ -44,7 +44,7 @@
<% @records.each_with_index do |record, index| %>
<% record_user = record.user %>
<div class="rankingList-line clearfix">
<% if @competition.identifier == "gcc-annotation-2018" %>
<% if @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-course-2019" %>
<li class="with40">
<% if index == 0 %>
<img src="/images/educoder/competition/1.png" class="fl ranking-img">

@ -1,9 +1,11 @@
<% 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" %>
<div class="competion-ranking">
<div class="ranking-nav edu-txt-center clearfix">
<div class="inline">
<% if @competition.identifier == "gcc-annotation-2018" %>
<li class="active"><a href="<%= charts_competition_path(@competition) %>" data-remote="true">开源标注正赛排行榜</a></li>
<% elsif @competition.identifier == "gcc-course-2019" %>
<li class="active"><a href="<%= charts_competition_path(@competition) %>" data-remote="true">排行榜</a></li>
<% else %>
<% if @max_min_stage.count == 1 %>
<li class="active"><a href="<%= charts_competition_path(@competition) %>" data-remote="true">排行榜</a></li>

@ -22,7 +22,7 @@
<% end %>
<li class="<%= params[:controller] == "competitions" ? " active" : "" %>">
<%= link_to "在线竞赛", competitions_path %>
<img class="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>
<!-- <img class="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>-->
</li>
<li class="<%= params[:controller] == "libraries" ? " active" : "" %>"><%= link_to "教学案例", libraries_path %></li>
<!-- <li class="<%#= params[:controller] == "project_packages" ? " active" : "" %>"><%#= link_to "众包创新", project_packages_path %></li>-->
@ -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})%>";

@ -24,7 +24,7 @@
<% end %>
<li class="<%= params[:controller] == "competitions" ? " active" : "" %>">
<%= link_to "在线竞赛", competitions_path %>
<img class="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>
<!-- <img class="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>-->
</li>
<li class="<%= params[:controller] == "libraries" ? " active" : "" %>"><%= link_to "教学案例", libraries_path %></li>
<!-- <li class="<%#= params[:controller] == "project_packages" ? " active" : "" %>"><%#= link_to "众包创新", project_packages_path %></li>-->
@ -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);
}
})
</script>

@ -40,6 +40,8 @@
<a href="<%= hidden_course_managements_path(:course_id => course.id) %>" class="mr5 fr" data-remote="true" id="hidden_course_<%= course.id %>"><%= course.is_hidden ? "显示" : "隐藏" %></a>
<input type="checkbox" name="homepage_show" value="<%= course.id %>" <%= course.homepage_show ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="join_course_role_<%= course.id %>">
<label style="top:0px;padding-left: 25px;float:right; margin-right: 10px" for="join_course_role_<%= course.id %>">首页显示</label>
<input type="checkbox" name="email_notify" value="<%= course.id %>" <%= course.email_notify ? "checked" : "" %> class="ml-3 mr5 magic-checkbox" id="email_notify_<%= course.id %>">
<label style="top:0px;padding-left: 25px;float:right; margin-right: 10px" for="email_notify_<%= course.id %>">邮件通知</label>
</td>
</tr>
<% 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"
});
})
</script>

@ -69,9 +69,9 @@
<% @issues.each do |issue| %>
<tr>
<td>#<%= issue.id %></td>
<td><a href="<%= issue_path(issue) %>" class="new_roadmap_info_title color-grey3" title="<%= issue.subject %>" target="_blank"><%= issue.subject %></a> </td>
<td><a href="<%= issue_path(issue) %>" class="new_roadmap_info_title color-grey3" data-tip-down="<%= issue.subject %>" target="_blank"><%= issue.subject %></a> </td>
<td> <%= issue.tracker %> </td>
<td><a href="<%= issue.assigned_to_id.nil? ? "" : user_path(issue.assigned_to) %>" class="new_roadmap_info_name" target="_blank">
<td><a href="<%= issue.assigned_to_id.nil? ? "" : user_path(issue.assigned_to) %>" 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 %></a>
</td>
<td><%= format_time issue.updated_on %></td>

@ -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'

@ -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

@ -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'), 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)
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 <= ?', 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)')
.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

@ -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("<img");
var afterImage = tContents.split("/>");

@ -684,7 +684,9 @@ class EcCompletionCalculation extends Component {
// })
}
{
Spintype===false?<li className={"clearfix newtarget_scoreclass lipadding10im bordereaeaea"} style={{width: 113*(total_rate_data+4)>1200?(113*(total_rate_data+4.5))+63:1200+"px"}}>
Spintype===false?<li className={"clearfix newtarget_scoreclass lipadding10im bordereaeaea"} style={{width: total_rate_data > 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"}}
>
{/*<span className="column-1 color-05101A mr16 width86">{k+1}</span>*/}
<span className="column-1 color-05101A mr16 width86">平均分</span>
{/*<span className="column-1 color-05101A ec_graduation_name mr16">{i.student_scores.name}</span>*/}

@ -398,7 +398,7 @@ class NewHeader extends Component {
<li className={`${competitions === true ? 'active' : ''}`} >
<a href="/competitions">在线竞赛</a>
<img className="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>
{/*<img className="roundedRectangles" src="/images/educoder/roundedRectangle.png"/>*/}
</li>
<li><a href="/moop_cases">教学案例</a></li>

Loading…
Cancel
Save