project_pack
hjm 6 years ago
commit 094deb13cb

@ -17,21 +17,27 @@ class CompetitionTeamsController < ApplicationController
@team_user_ids = @team.team_members.pluck(:user_id)
shixuns = Shixun.where(user_id: @team_user_ids, status: 2)
shixuns = Shixun.where(user_id: @team_user_ids, status: 2).where('shixuns.created_at > ?', Time.parse('2018-06-01'))
shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2')
shixuns = shixuns.joins('left join myshixuns on myshixuns.shixun_id = shixuns.id and exists(select 1 from games where games.myshixun_id = myshixuns.id and games.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)
@myshixun_count_map = Myshixun.where(shixun_id: @shixuns.map(&:id))
.where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)')
.group('shixun_id').count
course_ids = Course.joins('join members on members.course_id = courses.id')
shixun_ids = @shixuns.map(&:id)
@myshixun_count_map = get_valid_myshixun_count(shixun_ids)
# 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 }
# todo使用新版course_members
course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01'))
.joins('join members on members.course_id = courses.id')
.joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)')
.where(members: { user_id: @team_user_ids }).pluck(:id)
courses = Course.where(id: course_ids).joins(:shixun_homework_commons)
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')
.group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0')
@course_myshixun_map = Myshixun.joins(student_works: :homework_common)
.where(homework_commons: { course_id: @courses.map(&:id) })
@ -147,7 +153,7 @@ class CompetitionTeamsController < ApplicationController
# 新增加的成员
ids = new_member_ids - team_member_ids
raise @message unless check_member_enroll_limited?(@competition, ids) # 有成员已经加入其他战队,并且只能一次报名
raise @message unless check_member_enroll_limited?(@competition, ids - [@team.user_id]) # 有成员已经加入其他战队,并且只能一次报名; 减去创建者
ids.each do |user_id|
next if user_id.to_i == @team.user_id
@ -164,7 +170,7 @@ class CompetitionTeamsController < ApplicationController
# 新增加的老师
ids = new_teacher_ids - teacher_ids
raise @message unless check_teacher_enroll_limited?(@competition, ids) # 有老师已经加入其他战队,并且只能一次报名
raise @message unless check_teacher_enroll_limited?(@competition, ids - [@team.user_id]) # 有老师已经加入其他战队,并且只能一次报名;减去创建者
ids.each do |user_id|
next if user_id.to_i == @team.user_id
@ -321,4 +327,10 @@ class CompetitionTeamsController < ApplicationController
true
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
end

@ -2,6 +2,7 @@ class LibrariesController < ApplicationController
layout 'base_library'
before_filter :require_login, :except => [:index]
after_filter :increment_visit_count, only: [:show, :create, :edit, :update]
def index
libraries = Library.where(nil)
@ -25,7 +26,6 @@ class LibrariesController < ApplicationController
return render_403 unless admin_or_self? || @library.published?
@library_applies = @library.library_applies.where(status: :refused).order('created_at desc')
@library.increment_visited_count!
end
def new
@ -39,10 +39,10 @@ class LibrariesController < ApplicationController
Libraries::SubmitService.new(@library).call
redirect_to publish_success_libraries_path
else
flash[:message] = '保存成功'
redirect_to edit_library_path(id: @library.id)
redirect_to library_path(id: @library.id)
end
rescue ActiveRecord::RecordInvalid => _
rescue ActiveRecord::RecordInvalid => e
flash[:message] = e.record.errors.full_messages.join(',')
render 'new'
rescue Libraries::SubmitService::Error => ex
flash[:message] = ex.message
@ -63,10 +63,10 @@ class LibrariesController < ApplicationController
Libraries::SubmitService.new(@library).call
redirect_to publish_success_libraries_path
else
flash[:message] = '保存成功'
redirect_to edit_library_path(id: @library.id)
redirect_to library_path(id: @library.id)
end
rescue ActiveRecord::RecordInvalid => _
rescue ActiveRecord::RecordInvalid => e
flash[:message] = e.record.errors.full_messages.join(',')
render 'edit'
rescue Libraries::SubmitService::Error => ex
flash[:message] = ex.message
@ -110,6 +110,7 @@ class LibrariesController < ApplicationController
def form_params
@_form_params ||= begin
hash = params[:library].presence || {}
hash[:tag_ids] = params[:tag_ids].to_s.split(',')
hash[:attachment_ids] = (params[:attachments].presence || []).values.map{|h| h[:attachment_id]}
hash
end
@ -122,4 +123,8 @@ class LibrariesController < ApplicationController
def admin_or_self?
current_library.user_id == current_user.id || admin_or_business?
end
def increment_visit_count
@library.increment_visited_count! if @library && @library.id
end
end

@ -0,0 +1,17 @@
module LibrariesHelper
def show_library_tags(library)
html = ''
library.library_tags.each do |tag|
html += content_tag(:span, tag.name, class: "edu-filter-btn fl cdefault mt3 ml10 " + library_tag_class(tag))
end
raw html
end
def library_tag_class(tag)
case tag.name
when '优秀案例' then 'edu-activity-red'
when '入库案例' then 'edu-activity-blue'
end
end
end

@ -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
:min_num, :max_num, :enroll_end_time, :sub_title, :published_at
has_many :competition_modules, :dependent => :destroy
has_many :competition_stages, :dependent => :destroy

@ -5,6 +5,8 @@ class Library < ActiveRecord::Base
has_many :library_applies, dependent: :delete_all
has_many :attachments, as: :container
has_many :library_library_tags, dependent: :delete_all
has_many :library_tags, through: :library_library_tags
attr_accessible :title, :content

@ -0,0 +1,4 @@
class LibraryLibraryTag < ActiveRecord::Base
belongs_to :library
belongs_to :library_tag
end

@ -0,0 +1,6 @@
class LibraryTag < ActiveRecord::Base
has_many :library_library_tags, dependent: :delete_all
has_many :libraries, through: :library_library_tags
validates :name, presence: true, uniqueness: true
end

@ -66,18 +66,6 @@ class Shixun < ActiveRecord::Base
#scope :visible, -> { where(status: -1) }
after_create :send_tiding
def description
self.has_attribute?(:description) ? self[:description] : ""
end
def propaedeutics
self.has_attribute?(:propaedeutics) ? self[:propaedeutics] : ""
end
def evaluate_script
self.has_attribute?(:evaluate_script) ? self[:evaluate_script] : ""
end
def should_compile?
self.mirror_repositories.published_main_mirror.first.try(:should_compile)
end

@ -23,6 +23,19 @@ class Libraries::SaveService
library.assign_attributes(params)
library.save!
new_tag_ids = LibraryTag.where(id: params[:tag_ids].presence || []).pluck(:id)
old_tag_ids = library.library_library_tags.pluck(:library_tag_id)
# 删除标签
destroy_ids = old_tag_ids - new_tag_ids
library.library_library_tags.where(library_tag_id: destroy_ids).delete_all
# 创建标签
created_ids = new_tag_ids - old_tag_ids
created_ids.each do |id|
library.library_library_tags.create!(library_tag_id: id)
end
Attachment.where(id: attachment_ids).update_all(container_id: library.id, container_type: 'Library')
end

@ -360,7 +360,7 @@ class UsersService
g = Gitlab.client
g.edit_user(@current_user.gid, :password => params[:new_password])
rescue Exception => e
logger.error "change users password failed! ===> #{e}"
Rails.logger.error "change users password failed! ===> #{e}"
end
end
end

@ -1,6 +1,6 @@
<div class="librariesField">
<div class="librariesField pointer" onclick="$('#_file').click();">
<li>
<a href="javascript:void(0)" class="color-blue font-18" onclick="$('#_file').click();" data-tip-down="请选择文件上传">上传附件</a>
<a href="javascript:void(0)" class="color-blue font-18" data-tip-down="请选择文件上传">上传附件</a>
<!--<p class="color-grey-c">(单个文件<%#= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>以内)</p>-->
<p class="color-grey-c mt7">从我的电脑选择要上传的文档按住CTRL可以上传多份文档</p>
<div id="network_issue" class="fl ml10 color-red none">上传出现错误,请检查您的网络环境,并刷新页面重新上传。</div>
@ -14,7 +14,7 @@
<% size = judge_Chinese_num attachment.filename %>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden color-grey fl', :size => size, :style => 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;font-family: Consolas;', :readonly => 'readonly') %>
<span class="color-grey mr10 fl"><%= number_to_human_size attachment.filesize %></span>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt1') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<%= hidden_field_tag "attachments[p#{i}][attachment_id]", attachment.id %>
</span>
@ -24,7 +24,7 @@
<label class="panel-form-label fl">&nbsp;</label>
<i class="iconfont icon-fujian mr5 color-green fl font-14" aria-hidden="true"></i>
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'hidden atta_input readonly color-grey fl', :style => 'border:none; max-width:980px;', :readonly => 'readonly') %>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt2') unless attachment.id.nil? %>
<%= link_to('<i class="fa fa-trash-o mr5"></i>'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload fl mt1') unless attachment.id.nil? %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>

@ -7,9 +7,11 @@
<% end%>
<span title="<%= attachment.filename%>" id = "attachment_">
<% if options[:length] %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%>
<i class="iconfont icon-fujian color-green font-14 mr10 fl lineh-20 mt3"></i>
<%= link_to_short_attachment attachment,:download => true,:length => options[:length] -%>
<% else %>
<%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true, :length => 32 -%>
<i class="iconfont icon-fujian color-green font-14 mr10 fl lineh-20 mt3"></i>
<%= link_to_short_attachment attachment,:download => true, :length => 32 -%>
<% end %>
</span>
<%if is_float%>

@ -11,8 +11,8 @@
<th width="10%">创建者</th>
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学习人数</th>
<th width="15%">fork版的学习人数</th>
<th width="10%">有效作品数</th>
<th width="15%" data-tip-down="fork该实训产生的新实训学习总人数">fork版的学习人数</th>
<th width="10%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
@ -38,7 +38,7 @@
</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>
<th width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></th>
<td width="10%"><%= @myshixun_count_map.fetch(shixun.id, '--') %></td>
<td width="15%">--</td>
</tr>
<% end %>
@ -65,7 +65,7 @@
<th width="40%" class="edu-txt-left">名称</th>
<th width="10%">学生数量</th>
<th width="15%">发布的实训作业数量</th>
<th width="10%">有效作品数</th>
<th width="10%" data-tip-down="至少完成了1个关卡">有效作品数</th>
<th width="15%">经验值</th>
</tr>
</thead>
@ -82,11 +82,13 @@
<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">
<span class="task-hide fl" style="max-width: 480px;"><%= course.name %></span>
<%= 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>
<th width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></th>
<td width="10%"><%= @course_myshixun_map.fetch(course.id, '--') %></td>
<td width="15%">--</td>
</tr>
<% end %>

@ -46,7 +46,7 @@
<a href="<%= charts_competition_path(@competition) %>" >排行榜</a>
</li>
<% when '报名' %>
<li class="<%= params[:action] == 'enroll' || params[:action] == 'show' ? 'active' : '' %>">
<li class="<%= params[:action] == 'enroll' || (params[:controller] == 'competition_teams' && params[:action] == 'show') ? 'active' : '' %>">
<a href="<%= enroll_competition_path(@competition) %>">报名</a>
</li>
<% else %>

@ -5,10 +5,10 @@
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="second_3" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
<div class="<%= i == 0 ? "second_3_small" :"second_3" %>" style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
<div class="enter_panel">
<% stage.competition_stage_sections.each do |section| %>
<ul class="mb40">
<ul class="mb30">
<p class="mb30 font-22 enter_title">
<span class="mr20 font-bd"><%= section.name %></span>
<span><%= format_time section.start_time %> ~ <%= com_end_time section.end_time %></span>

@ -0,0 +1,71 @@
<% index = 0 %>
<div class="openSource_1" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_2" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="openSource_<%= index + 1 %>" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<%
first_section = stage.competition_stage_sections[0]
second_section = stage.competition_stage_sections[1]
%>
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd"><%= first_section.try(:name) %></span>
<span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %>~<%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd"><%= second_section.try(:name) %></span>
<span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %>~<%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span>
</span>
</p>
<li class="inline enter_btn mt20">
<% is_start = Time.now > first_section.start_time %>
<% first_section.competition_entries.each_with_index do |entry, j| %>
<%
competition_url = User.current.logged? ? "#{entry.url}?eid=#{User.current.id}" : "#{entry.url}"
btn_url = is_start ? "#{competition_url}" : "javascript:void(0);"
%>
<a class="li-1 <%= is_start ? 'active' : '' %>"
href="javascript:void(0);"
data-url="<%= btn_url %>"><%= entry.name %></a>
<% end %>
</li>
</ul>
</div>
</div>
<% index += 1 %>
<% end %>
<div class="openSource_5" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_6" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<script>
$(function(){
var userLogged = <%= @user.present? && @user.logged? %>;
var userEnrolled = <%= @enrolled %>;
$(".enter_btn .li-1.active").on("click", function(){
var url = $(this).data("url");
if (!userLogged) {
location.href = "<%= signin_url(back_url: competition_path(id: params[:id])) %>";
return;
}
if (!userEnrolled) {
sure_box_redirect_without_newtab_btn("<%= enroll_competition_path(id: params[:id]) %>", "完成报名后即可参赛", "我要报名");
return;
}
var newTab = window.open("_blank");
newTab.location = url;
})
})
</script>

@ -5,7 +5,15 @@
<% @teams.each do |team| %>
<li class="clearfix">
<%= link_to image_tag(url_to_avatar(team.user), :width => "40", :height => "40", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to competition_team_path(id: team.id) do %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% end %>
<% else %>
<span class="fl task-hide mr20 mt10" style="width: 130px;" data-tip-down="<%= @maximum_staff > 1 ? team.name : team.user.show_name %>"><%= @maximum_staff > 1 ? team.name : team.user.show_name %></span>
<% end %>
<% if @maximum_staff > 1 %>
<span class="fl mr40 mt10" style="width: 270px;">
<% team.teachers.each do |teacher| %>

@ -1,5 +1,5 @@
<div class="enroll-b">
<div class="enroll-t" style="background:url('/images/educoder/competition/anon.png') no-repeat top center;">
<div class="enroll-t" style="background:url('/images/educoder/competition/anon.png') no-repeat top center;">
<div class="educontent edu-txt-center">
<p class="main_title"><%= @competition.name %></p>
<% if @maximum_staff > 1 %>
@ -67,7 +67,7 @@
<div class="clearfix mt30 pr88">
<% @is_enroll.each do |team| %>
<li class="clearfix joinTeamInfo">
<span class="fl mr20 ml35">
<span class="fl mr20 ml20">
<%= link_to image_tag(url_to_avatar(team.user), :width => "48", :height => "48", :class => "radius fl mr10"), user_path(team.user), :title => team.user.show_name, :target => "_blank", :alt => "用户头像" %>
<span class="fl task-hide mt12 font-16" style="width: 140px;"><span data-tip-down="<%= team.name %>"><%= team.name %></span></span>
</span>
@ -84,22 +84,22 @@
<% end %>
</span>
</span>
<span class="fl mr40 mt13 font-16">邀请码:<label class="color-orange"><%= team.invite_code %></label></span>
<span class="fl mr10 mt13 font-16">邀请码:<label class="color-orange"><%= team.invite_code %></label></span>
<% if @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %>
<% if User.current.admin? || User.current == team.user %>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr20" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr10" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<% end %>
<% else %>
<% if User.current.admin? || User.current == team.user %>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr20" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<a href="<%= edit_competition_team_path(team) %>" data-remote="true" class="fl mt13 mr10" data-tip-down="编辑"><i class="iconfont icon-bianjidaibeijing color-blue fl"></i></a>
<a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认删除战队')" data-tip-down="删除"><i class="iconfont icon-shanchu color-grey-c font-15"></i></a>
<% else %>
<a href="javascript:void(0)" class="font-16 color-grey-c fl mt12" onclick="delete_confirm_box('<%= exit_team_competition_team_path(team) %>', '是否确认退出战队')">退出</a>
<% end %>
<% end %>
<%= link_to '进入大赛', competition_path(@competition), class: 'enrollOperation' %>
<% if @competition.identifier == 'gcc-course-2019' %>
<%= link_to '战队详情', competition_team_path(id: team.id), class: 'fl mt13 ml10' %>
<%= link_to '战队详情', competition_team_path(id: team.id), class: 'enrollOperation' %>
<% end %>
</li>
<% end %>

@ -69,13 +69,14 @@
</div>
</div>
<% elsif competition.published_at.present? %>
<% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
<div class="competitionsList-item mb20">
<div class="edu-back-white">
<a href="javascript:void(0)" class="competition-Img">
<a href="<%= url %>" class="competition-Img">
<%= image_tag(url_to_avatar(competition), :width => "100%", :height => "100%") %>
</a>
<div class="pt20 pl20 mb10 clearfix">
<a href="javascript:void(0)" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<a href="<%= url %>" style="max-width: 400px;" class="font-16 task-hide fl"><%= [competition.name, competition.sub_title.presence].compact.join('——') %></a>
<div class="fr status-orange">
<img src="/images/educoder/competition/home/orange.png" class="fl">
<span class="status-tag fl">即将发布</span>
@ -83,6 +84,11 @@
</div>
<p class="color-grey-B3 clearfix pl20 pr20 pb20"></p>
</div>
<div class="competitionsList-item-tip strongNone">
<div class="color-white font-26">
<p>即将发布</p><p>敬请期待</p>
</div>
</div>
</div>
<% end %>
<% end %>
@ -91,3 +97,14 @@
<%= render :partial => "welcome/no_data" %>
<% end %>
</div>
<script>
$(function(){
<% unless admin_or_business? %>
$(".competitionsList-item").hover(function(){
$(this).find(".competitionsList-item-tip").removeClass("strongNone");
},function(){
$(this).find(".competitionsList-item-tip").addClass("strongNone");
});
<% end %>
})
</script>

@ -13,5 +13,7 @@
<%= render :partial => "gq_second_code_competition" %>
<% elsif @competition.identifier == "gcc-course-2019" %>
<%= render :partial => "qg_second_course_competition" %>
<% elsif @competition.identifier == "gcc-project-2019" %>
<%= render :partial => "qg_second_opensource" %>
<% end %>
</div>

@ -1,10 +1,12 @@
<p class="lineh-25 font-22 mb20">上传教学案例</p>
<div class="library-form-container">
<%= form_for(@library) do |f| %>
<% tag_ids = @library.library_tags.map(&:id) %>
<%= hidden_field_tag :apply_publish, false %>
<%= hidden_field_tag :tag_ids, tag_ids.join(',') %>
<div class="edu-back-white">
<div class="padding30">
<div class="clearfix mb20">
<div class="clearfix">
<span class="upload_Title">标题</span>
<li class="fl">
<%= f.text_field :title, placeholder: '例如:软件工程教学案例', class: 'greyInput winput-300-35 mr20 fl' %>
@ -12,23 +14,28 @@
</li>
<span class="color-grey-c font-12 fl mt6">简明扼要介绍文档/视频所包含的主要的内容</span>
</div>
</div>
<div class="padding30 bor-top-greyE">
<div class="clearfix df">
<div class="clearfix">
<span class="upload_Title">描述</span>
<div class="flex1">
<div class="fl" style="width: 1078px">
<div id="libraries_description" style="margin:0px">
<%= f.text_area :content %>
</div>
<p style="height:22px;line-height:22px;"><span class="color-red none" id="des_notice">请输入描述内容</span></p>
</div>
</div>
<div>
<div class="clearfix mb20">
<span class="upload_Title">标签</span>
<ul class="fl libraries_tab">
<% LibraryTag.where(nil).each do |tag| %>
<li class="<%= tag_ids.include?(tag.id) ? 'active' : '' %>" data-id="<%= tag.id %>"><%= tag.name %></li>
<% end %>
</ul>
</div>
<div style="padding-left: 62px">
<%= render partial: 'attachments/from_libraries', locals: { container: @library } %>
<p s
tyle="height:22px;line-height:22px;"><span class="color-red none" id="file_notice">请上传附件</span></p>
<p style="height:22px;line-height:22px;"><span class="color-red none" id="file_notice">请上传附件</span></p>
</div>
</div>
<div class="padding30 bor-top-greyE">
@ -61,12 +68,12 @@
/* ------------------------------- 描述md ------------------------------*/
editormd("libraries_description", {
width: "100%",
height: 210,
height: 400,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
watch:false,
watch:true,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
@ -121,5 +128,19 @@
submitForm();
});
$('.submit-btn').on('click', submitForm);
$(".libraries_tab").on("click","li",function(){
if($(this).hasClass("active")){
$(this).removeClass("active")
}else{
$(this).addClass("active")
}
var ids = [];
$('.libraries_tab li.active').each(function(){
ids.push($(this).data('id'))
})
console.log('ids', ids)
$('#tag_ids').val(ids);
})
});
</script>

@ -4,7 +4,10 @@
<li class="library_list_item">
<%= link_to image_tag(url_to_avatar(library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(library.user) %>
<div class="flex1">
<p class="task-hide font-16 mb15 lineh-20"><%= link_to library.title, library_path(library) %></p>
<p class="clearfix mb15 lineh-20">
<%= link_to library.title, library_path(library),:class => "task-hide font-16 library_l_name" %>
<%= show_library_tags(library) %>
</p>
<p class="clearfix lineh-20">
<span class="color-grey-3 mr20"><%= link_to library.user.show_real_name, user_path(library.user) %></span>
<span class="color-grey-c mr20"><%= library.visited_count || 0 %> 浏览</span>

@ -5,8 +5,8 @@
<span class="font-18 fl color-grey-3">教学案例</span>
<%= link_to '新建', new_library_path, class: 'fr color-blue font-16 mt3' %>
</p>
<div class="clearfix pt20 pl30 pr30">
<ul class="fl library_nav">
<div class="clearfix pl30 pr30">
<ul class="fl library_nav mt20">
<li class="<%= params[:type] == 'mine' ? '' : 'active' %>">
<%= link_to '全部', libraries_path(search: params[:search]), remote: true %>
</li>
@ -14,7 +14,7 @@
<%= link_to '我的', libraries_path(search: params[:search], type: 'mine'), remote: true %>
</li>
</ul>
<div class="edu-position fr">
<div class="edu-position fr mt12">
<%= hidden_field_tag(:type, params[:type]) %>
<input class="winput-300-35 panel-box-sizing" placeholder="输入教学案例标题、编号进行检索" type="text" id="search_name">
<a href="javascript:void(0);" class="edu-btn-search font-16 color-grey" id="search"><i class="fa fa-search"></i></a>

@ -7,14 +7,17 @@
<span class="color-grey-3">详情</span>
</p>
<p class="lineh-25 mb20 clearfix">
<span class="font-22 fl mr10 task-hide" style="max-width: 800px"><%= @library.title %></span>
<span class="font-22 fl mr10 task-hide" style="max-width: 800px">
<%= @library.title %>
</span>
<%= show_library_tags(@library) %>
<% if admin_or_self %>
<% if @library.pending? %>
<span class="fl edu-filter-btn edu-activity-green mt5">草稿</span>
<span class="fl edu-filter-btn edu-activity-green mt3 ml10">草稿</span>
<% elsif @library.processing? %>
<span class="fl edu-filter-btn edu-activity-green mt5">审核中</span>
<span class="fl edu-filter-btn edu-activity-green mt3 ml10">审核中</span>
<% elsif @library.refused? %>
<span class="fl edu-filter-btn edu-activity-orange mt5">未通过</span>
<span class="fl edu-filter-btn edu-activity-orange mt3 ml10">未通过</span>
<% end %>
<% end %>
<%= link_to('返回', libraries_path, class: 'fr color-grey-9 mt5') %>
@ -40,20 +43,19 @@
</div>
<% end %>
<div class="padding30">
<p class="mb10 clearfix">
<span class="color-grey-6 font-16 mr10">详情</span>
<% if admin_or_business? || @library.user_id == User.current.id && @library.pending? %>
<%= link_to '删除', 'javascript:void(0);', data: { id: @library.id },
class: 'white-btn edu-blueline-btn fr ml20 delete-btn' %>
<% end %>
<% if admin_or_self %>
<%= link_to '编辑', edit_library_path(id: @library.id), class: 'white-btn edu-blueline-btn fr' %>
<% end %>
</p>
<div class="df mb20">
<div class="df">
<%= link_to image_tag(url_to_avatar(@library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(@library.user) %>
<div class="flex1">
<li class="font-16"><%= @library.user.show_real_name %></li>
<li class="clearfix">
<span class="font-16 fl"><%= @library.user.show_real_name %></span>
<% if admin_or_business? || @library.user_id == User.current.id && @library.pending? %>
<%= link_to '删除', 'javascript:void(0);', data: { id: @library.id },
class: 'white-btn edu-blueline-btn fr ml20 delete-btn' %>
<% end %>
<% if admin_or_self %>
<%= link_to '编辑', edit_library_path(id: @library.id), class: 'white-btn edu-blueline-btn fr' %>
<% end %>
</li>
<li class="clearfix">
<span class="fl color-grey-9 mr20"><%= @library.user.school_name %></span>
<span class="fl color-grey-9"><%= @library.user.identity %></span>
@ -72,7 +74,7 @@
<div class="break_full_word new_li" id="labraries_editorMd_content" style="box-sizing: border-box">
<textarea style="display:none;"><%= @library.content %></textarea>
</div>
<div class="mt10">
<div class="mt10 pl20">
<%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>
</div>
</div>

@ -1,5 +1,3 @@
console.log("<%= @user_picture.present? %>")
<% if @user_picture.present? %>
$("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>');
$("#picture_display").show();
<% end %>
$("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>');
$("#picture_display").show();

@ -0,0 +1,9 @@
class CreateLibraryTags < ActiveRecord::Migration
def change
create_table :library_tags do |t|
t.string :name
end
execute "insert into library_tags(name) values('优秀案例'),('入库案例')"
end
end

@ -0,0 +1,8 @@
class CreateLibraryLibraryTags < ActiveRecord::Migration
def change
create_table :library_library_tags do |t|
t.references :library
t.references :library_tag
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 KiB

After

Width:  |  Height:  |  Size: 177 KiB

@ -114,7 +114,7 @@ function addFile(inputEl, file, eagerUpload,btnId) {
fileSpan.append(
$('<i></i>').attr({
'class': 'fa fa-folder mr5 color-blue fl mt7',
'class': 'iconfont icon-fujian mr5 color-green fl font-14',
'aria-hidden': true
}),
$('<input>', {

@ -628,6 +628,7 @@ p .activity-item:first-child{border-top: 1px solid #eee;}
.enterTo span.f-cart{width: 246px;text-align: center;color: #29BD8B;font-size: 20px;line-height: 20px;float: left;display: block;font-weight: bold;margin-right: 20px;}
.enterTo span.d-cart{box-sizing:border-box;width: 246px;text-align: center;color: #989898;font-size: 16px;line-height: 22px;float: left;display: block;margin-right: 20px;}
.partGame.largepart .partborder .enterTo a:last-child,.enterTo span.f-cart:last-child,.enterTo span.d-cart:last-child{margin-right:0px;}
/*.partTime.active .time{color:#ff3232; }*/
.partTime.active .enterTo a{cursor: pointer;background-color: #29bd8b;box-shadow: 0px 10px 10px rgba(41,189,139,0.2)}
a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;box-shadow: none!important;font-size: 14px!important;text-align: left;line-height: 20px;height: 20px;padding-bottom: 1px;border-bottom: 1px solid #418ccd;width: auto!important;border-radius: 0px;}
@ -643,7 +644,8 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;
/*第二次竞赛-全国*/
.second_1{min-height: 832px;}
.second_2{min-height: 446px;}
.second_3{min-height: 595px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_3{min-height: 766px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_3_small{min-height: 595px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_4{min-height: 610px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_5{min-height: 617px;padding-top: 190px;box-sizing: border-box;position: relative}
.second_6{min-height: 1053px;}
@ -659,6 +661,15 @@ a.enterLink{cursor: pointer;color: #418CCD!important;background: none!important;
.second_code_6{min-height: 1060px;}
.second_code_7{min-height: 1116px;}
.second_code_8{min-height: 711px;}
/*开源创新竞赛*/
.openSource_1{min-height: 803px;}
.openSource_2{min-height: 427px;}
.openSource_3{min-height: 524px;padding-top: 190px;box-sizing: border-box;position: relative}
.openSource_4{min-height: 526px;padding-top: 190px;box-sizing: border-box;position: relative}
.openSource_5{min-height: 1061px;}
.openSource_6{min-height: 1090px;}
.openSource_7{min-height: 683px;}
.challenge_title{
color: #41ABEF;font-size: 30px;font-weight: bold;text-align: center;letter-spacing: 1px;line-height: 60px;margin-bottom: 20px;
}
@ -843,6 +854,18 @@ table.tBodyScroll thead th{
.joinTeamInfo{background-image:url('/images/educoder/competition/enroll-item.png');height:202px;width: 934px;padding: 10px 35px;box-sizing: border-box;margin: 0px auto;padding-top: 60px;}
.joinTeamInfo span,.joinTeamInfo a{line-height: 30px;}
.enrollOperation{
float: left;
padding: 0px 8px;
border-radius: 27px;
background: #459be5;
color: #fff!important;
font-size: 12px!important;
height: 20px;
line-height: 19px!important;
margin-top: 18px;
margin-left: 10px;
}
/*弹框*/
.c-l-box{background: rgba(139,163,183,0.08);height: 226px;overflow-y: auto;width: 100%;padding: 20px 20px 0px 20px;box-sizing: border-box;}
.c-l-box li,.c-r-box li{margin-bottom: 15px;line-height: 25px;}
@ -875,9 +898,14 @@ table.tBodyScroll thead th{
.homePageBtn{position: absolute;width: 100%;top: 510px;}
.homeBtn{display: block;float: left;border-radius: 30px;width: 168px;height: 60px;line-height: 60px;background-color: #21B351;font-size: 30px;color: #fff!important;text-align: center}
.competitionsList-item{width: 50%;float: left;box-sizing: border-box;}
.competitionsList-item{width: 50%;float: left;box-sizing: border-box;position: relative}
.competitionsList-item:nth-of-type(odd){padding-right: 10px;}
.competitionsList-item:nth-of-type(even){padding-left: 10px;}
.competitionsList-item-tip{
position: absolute;top: 0px;left: 0px;height: 100%;background: rgba(0,0,0,0.5);right: 10px;justify-content: center;
align-items: center;display: -webkit-flex;
}
.strongNone{display: none!important;}
.competition-Img{width: 100%;height: 340px;}
.competition-Img img{border-radius: 4px 4px 0px 0px;}
.status-tag {display: block;height: 30px;line-height: 30px;color: #fff;padding: 0px 20px;}
@ -3439,16 +3467,22 @@ line-height: 16px;display: inline-block;color: rgba(65, 140, 205, 1) !important;
.library_list_item{
background: #fff;padding:30px;margin-bottom: 15px;display: flex;
}
.library_list_item .library_l_name{max-width: 900px;float: left;}
.upload_Title{
position: relative;margin-right: 30px;float: left;line-height: 35px;font-size: 16px;
position: relative;margin-right: 30px;float: left;line-height: 35px;font-size: 16px;width: 32px;
}
.upload_Title:before{
position: absolute;left: -10px;top:2px;content: '*';color: #FE4F4C;
position: absolute;left: -10px;top:2px;content: '*';color: #FE4F4C;width: 32px;
}
.librariesField{
width: 100%;background: #F2F9FF;justify-content: center;align-items: center;display: -webkit-flex;text-align: center;
height: 120px;border-radius: 4px;border:1px dashed #4cacff;
}
.libraries_tab li{
width: 120px;height: 35px;line-height: 35px;border-radius:18px;border:1px solid #4C98FF;color: #4C98FF;cursor: pointer;
margin-right: 30px;float: left;text-align: center;
}
.libraries_tab li.active{background:#4C98FF;color: #fff; }
.private_reason{overflow: hidden;max-height:163px;}
.private_reason li{margin-bottom: 10px;}
.successPage{

@ -763,6 +763,7 @@ html>body #ajax-indicator { position: fixed; }
.edu-activity-grey{background-color:#747A7F;color:#fff!important;cursor: pointer;border: 1px solid #747A7F;}/*匿评作品*/
.edu-activity-green{background-color:#29BD8B;color:#fff!important;cursor: pointer;border: 1px solid #29BD8B;}/*查看作品、查看实战、查看答题*/
.edu-activity-light-grey{background-color:#cbcbcb;color:#fff!important;cursor: pointer;border: 1px solid #cbcbcb;}/*取消关联*/
.edu-activity-red{background-color:#FC2B6A;color:#fff!important;cursor: pointer;border: 1px solid #FC2B6A;}
/*课堂设置页面*/
.course-ul-nav{width: 100%;border-bottom: 1px solid #EBEBEB;}
.course-ul-nav a{display: inline-block;padding: 20px;font-size: 18px;text-align: center;width: 94px;position: relative}

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :shixun_info do
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ShixunInfo, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save