diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 6ecbb9aa..5b68c433 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -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 diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index 1d72f158..27e814d7 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -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 \ No newline at end of file diff --git a/app/helpers/libraries_helper.rb b/app/helpers/libraries_helper.rb new file mode 100644 index 00000000..433effd7 --- /dev/null +++ b/app/helpers/libraries_helper.rb @@ -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 \ No newline at end of file diff --git a/app/models/competition.rb b/app/models/competition.rb index 96747b0b..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 + :min_num, :max_num, :enroll_end_time, :sub_title, :published_at has_many :competition_modules, :dependent => :destroy has_many :competition_stages, :dependent => :destroy diff --git a/app/models/library.rb b/app/models/library.rb index 63df5c91..2ff3c4c4 100644 --- a/app/models/library.rb +++ b/app/models/library.rb @@ -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 diff --git a/app/models/library_library_tag.rb b/app/models/library_library_tag.rb new file mode 100644 index 00000000..490daf08 --- /dev/null +++ b/app/models/library_library_tag.rb @@ -0,0 +1,4 @@ +class LibraryLibraryTag < ActiveRecord::Base + belongs_to :library + belongs_to :library_tag +end \ No newline at end of file diff --git a/app/models/library_tag.rb b/app/models/library_tag.rb new file mode 100644 index 00000000..2e356812 --- /dev/null +++ b/app/models/library_tag.rb @@ -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 \ No newline at end of file diff --git a/app/models/shixun.rb b/app/models/shixun.rb index fe9a00b1..0d201ed3 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -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 diff --git a/app/services/libraries/save_service.rb b/app/services/libraries/save_service.rb index db244836..393d3911 100644 --- a/app/services/libraries/save_service.rb +++ b/app/services/libraries/save_service.rb @@ -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 diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 6ab6d3f6..d60de29c 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -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 diff --git a/app/views/attachments/_from_libraries.html.erb b/app/views/attachments/_from_libraries.html.erb index a6fe347d..5d4d30bc 100644 --- a/app/views/attachments/_from_libraries.html.erb +++ b/app/views/attachments/_from_libraries.html.erb @@ -1,6 +1,6 @@ -
+
  • - 上传附件 + 上传附件

    从我的电脑选择要上传的文档:按住CTRL可以上传多份文档

    上传出现错误,请检查您的网络环境,并刷新页面重新上传。
    @@ -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') %> <%= number_to_human_size attachment.filesize %> - <%= link_to(''.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= link_to(''.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 %> @@ -24,7 +24,7 @@ <%= 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(''.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(''.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}" %> <% end %> diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 80456091..1247e9cc 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -7,9 +7,11 @@ <% end%> <% if options[:length] %> - <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%> + + <%= link_to_short_attachment attachment,:download => true,:length => options[:length] -%> <% else %> - <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true, :length => 32 -%> + + <%= link_to_short_attachment attachment,:download => true, :length => 32 -%> <% end %> <%if is_float%> diff --git a/app/views/competition_teams/show.html.erb b/app/views/competition_teams/show.html.erb index 31937688..129fa32a 100644 --- a/app/views/competition_teams/show.html.erb +++ b/app/views/competition_teams/show.html.erb @@ -11,8 +11,8 @@ 创建者 名称 学习人数 - fork版的学习人数 - 有效作品数 + fork版的学习人数 + 有效作品数 经验值 @@ -38,7 +38,7 @@ <%= 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, '--') %> + <%= @myshixun_count_map.fetch(shixun.id, '--') %> -- <% end %> @@ -65,7 +65,7 @@ 名称 学生数量 发布的实训作业数量 - 有效作品数 + 有效作品数 经验值 @@ -82,11 +82,13 @@ <%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> - <%= course.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, '--') %> + <%= @course_myshixun_map.fetch(course.id, '--') %> -- <% end %> diff --git a/app/views/competitions/_header.html.erb b/app/views/competitions/_header.html.erb index 4017f82b..b6790839 100644 --- a/app/views/competitions/_header.html.erb +++ b/app/views/competitions/_header.html.erb @@ -46,7 +46,7 @@ 排行榜
  • <% when '报名' %> -
  • +
  • 报名
  • <% else %> diff --git a/app/views/competitions/_qg_second_competition.html.erb b/app/views/competitions/_qg_second_competition.html.erb index aa45d32e..e3973c7c 100644 --- a/app/views/competitions/_qg_second_competition.html.erb +++ b/app/views/competitions/_qg_second_competition.html.erb @@ -5,10 +5,10 @@ <% index += 1 %> <% @competition.competition_stages.each_with_index do |stage, i| %> -
    +
    " style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
    <% stage.competition_stage_sections.each do |section| %> -
      +

        <%= section.name %> <%= format_time section.start_time %> ~ <%= com_end_time section.end_time %> diff --git a/app/views/competitions/_qg_second_opensource.html.erb b/app/views/competitions/_qg_second_opensource.html.erb new file mode 100644 index 00000000..b7e878e9 --- /dev/null +++ b/app/views/competitions/_qg_second_opensource.html.erb @@ -0,0 +1,71 @@ +<% index = 0 %> +

        +<% index += 1 %> +
        +<% index += 1 %> + +<% @competition.competition_stages.each_with_index do |stage, i| %> +
        + <% + first_section = stage.competition_stage_sections[0] + second_section = stage.competition_stage_sections[1] + %> +
        +
          +

          + + <%= first_section.try(:name) %> + <%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %>~<%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %> + + + <%= second_section.try(:name) %> + <%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %>~<%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %> + +

          +
        • + <% 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);" + %> + <%= entry.name %> + <% end %> +
        • +
        +
        +
        +<% index += 1 %> +<% end %> + +
        +<% index += 1 %> +
        +<% index += 1 %> +
        + + \ No newline at end of file diff --git a/app/views/competitions/_team_list.html.erb b/app/views/competitions/_team_list.html.erb index 5e75b3a4..ba445c7b 100644 --- a/app/views/competitions/_team_list.html.erb +++ b/app/views/competitions/_team_list.html.erb @@ -5,7 +5,15 @@ <% @teams.each do |team| %>
      • <%= 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 => "用户头像" %> - <%= @maximum_staff > 1 ? team.name : team.user.show_name %> + + <% if @competition.identifier == 'gcc-course-2019' %> + <%= link_to competition_team_path(id: team.id) do %> + <%= @maximum_staff > 1 ? team.name : team.user.show_name %> + <% end %> + <% else %> + <%= @maximum_staff > 1 ? team.name : team.user.show_name %> + <% end %> + <% if @maximum_staff > 1 %> <% team.teachers.each do |teacher| %> diff --git a/app/views/competitions/enroll.html.erb b/app/views/competitions/enroll.html.erb index 746251f1..69bedd2f 100644 --- a/app/views/competitions/enroll.html.erb +++ b/app/views/competitions/enroll.html.erb @@ -1,5 +1,5 @@
        -
        +

        <%= @competition.name %>

        <% if @maximum_staff > 1 %> @@ -67,7 +67,7 @@
        <% @is_enroll.each do |team| %>
      • - + <%= 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 => "用户头像" %> <%= team.name %> @@ -84,22 +84,22 @@ <% end %> - 邀请码: + 邀请码: <% if @competition.enroll_end_time.present? && @competition.enroll_end_time < Time.now %> <% if User.current.admin? || User.current == team.user %> - + <% end %> <% else %> <% if User.current.admin? || User.current == team.user %> - + <% else %> 退出 <% 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 %>
      • <% end %> diff --git a/app/views/competitions/index.html.erb b/app/views/competitions/index.html.erb index 19627026..b95bec63 100644 --- a/app/views/competitions/index.html.erb +++ b/app/views/competitions/index.html.erb @@ -69,13 +69,14 @@
    <% elsif competition.published_at.present? %> + <% url = admin_or_business? ? competition_path(competition) : 'javascript:void(0)' %>
    <% end %> <% end %> @@ -91,3 +97,14 @@ <%= render :partial => "welcome/no_data" %> <% end %>
    + diff --git a/app/views/competitions/show.html.erb b/app/views/competitions/show.html.erb index 0df98a24..28200db3 100644 --- a/app/views/competitions/show.html.erb +++ b/app/views/competitions/show.html.erb @@ -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 %>
    \ No newline at end of file diff --git a/app/views/libraries/_form.html.erb b/app/views/libraries/_form.html.erb index b3ed4721..0bb1c30a 100644 --- a/app/views/libraries/_form.html.erb +++ b/app/views/libraries/_form.html.erb @@ -1,10 +1,12 @@

    上传教学案例

    <%= 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(',') %>
    -
    +
    标题
  • <%= f.text_field :title, placeholder: '例如:软件工程教学案例', class: 'greyInput winput-300-35 mr20 fl' %> @@ -12,23 +14,28 @@
  • 简明扼要介绍文档/视频所包含的主要的内容
    -
    -
    +
    描述 -
    +
    <%= f.text_area :content %>

    请输入描述内容

    - -
    +
    + 标签 +
      + <% LibraryTag.where(nil).each do |tag| %> +
    • <%= tag.name %>
    • + <% end %> +
    +
    +
    <%= render partial: 'attachments/from_libraries', locals: { container: @library } %> -

    请上传附件

    +

    请上传附件

    @@ -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); + }) }); \ No newline at end of file diff --git a/app/views/libraries/_library_list.html.erb b/app/views/libraries/_library_list.html.erb index 63314d65..7ae5031c 100644 --- a/app/views/libraries/_library_list.html.erb +++ b/app/views/libraries/_library_list.html.erb @@ -4,7 +4,10 @@
  • <%= link_to image_tag(url_to_avatar(library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(library.user) %>
    -

    <%= link_to library.title, library_path(library) %>

    +

    + <%= link_to library.title, library_path(library),:class => "task-hide font-16 library_l_name" %> + <%= show_library_tags(library) %> +

    <%= link_to library.user.show_real_name, user_path(library.user) %> <%= library.visited_count || 0 %> 浏览 diff --git a/app/views/libraries/index.html.erb b/app/views/libraries/index.html.erb index cc34dc81..8e52e85b 100644 --- a/app/views/libraries/index.html.erb +++ b/app/views/libraries/index.html.erb @@ -5,8 +5,8 @@ 教学案例 <%= link_to '新建', new_library_path, class: 'fr color-blue font-16 mt3' %>

    -
    -
      +
      +
      • <%= link_to '全部', libraries_path(search: params[:search]), remote: true %>
      • @@ -14,7 +14,7 @@ <%= link_to '我的', libraries_path(search: params[:search], type: 'mine'), remote: true %>
      -
      +
      <%= hidden_field_tag(:type, params[:type]) %> diff --git a/app/views/libraries/show.html.erb b/app/views/libraries/show.html.erb index f857a8ec..f8d45050 100644 --- a/app/views/libraries/show.html.erb +++ b/app/views/libraries/show.html.erb @@ -7,14 +7,17 @@ 详情

      - <%= @library.title %> + + <%= @library.title %> + + <%= show_library_tags(@library) %> <% if admin_or_self %> <% if @library.pending? %> - 草稿 + 草稿 <% elsif @library.processing? %> - 审核中 + 审核中 <% elsif @library.refused? %> - 未通过 + 未通过 <% end %> <% end %> <%= link_to('返回', libraries_path, class: 'fr color-grey-9 mt5') %> @@ -40,20 +43,19 @@

      <% end %>
      -

      - 详情 - <% 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 %> -

      -
      +
      <%= link_to image_tag(url_to_avatar(@library.user), width: 50, height: 50, class: 'radius mr15 mt3'), user_path(@library.user) %>
      -
    • <%= @library.user.show_real_name %>
    • +
    • + <%= @library.user.show_real_name %> + <% 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 %> +
    • <%= @library.user.school_name %> <%= @library.user.identity %> @@ -72,7 +74,7 @@
      -
      +
      <%= render partial: 'attachments/links', locals: { attachments: @library.attachments, options: {} } %>
      diff --git a/app/views/users/picture_show.js.erb b/app/views/users/picture_show.js.erb index a41c1ed7..290d0d04 100644 --- a/app/views/users/picture_show.js.erb +++ b/app/views/users/picture_show.js.erb @@ -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 %> \ No newline at end of file +$("#picture_display").html('<%= j (render :partial => 'games/picture_display') %>'); +$("#picture_display").show(); \ No newline at end of file diff --git a/db/migrate/20190705071020_create_library_tags.rb b/db/migrate/20190705071020_create_library_tags.rb new file mode 100644 index 00000000..62b94c01 --- /dev/null +++ b/db/migrate/20190705071020_create_library_tags.rb @@ -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 diff --git a/db/migrate/20190705071810_create_library_library_tags.rb b/db/migrate/20190705071810_create_library_library_tags.rb new file mode 100644 index 00000000..3839fc19 --- /dev/null +++ b/db/migrate/20190705071810_create_library_library_tags.rb @@ -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 diff --git a/public/images/educoder/competition/qg/qg_open_1.png b/public/images/educoder/competition/qg/qg_open_1.png new file mode 100644 index 00000000..c4048d03 Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_1.png differ diff --git a/public/images/educoder/competition/qg/qg_open_2.png b/public/images/educoder/competition/qg/qg_open_2.png new file mode 100644 index 00000000..833f2af5 Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_2.png differ diff --git a/public/images/educoder/competition/qg/qg_open_3.png b/public/images/educoder/competition/qg/qg_open_3.png new file mode 100644 index 00000000..ed4ea26b Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_3.png differ diff --git a/public/images/educoder/competition/qg/qg_open_4.png b/public/images/educoder/competition/qg/qg_open_4.png new file mode 100644 index 00000000..f1bf7308 Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_4.png differ diff --git a/public/images/educoder/competition/qg/qg_open_5.png b/public/images/educoder/competition/qg/qg_open_5.png new file mode 100644 index 00000000..a1bfd8f1 Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_5.png differ diff --git a/public/images/educoder/competition/qg/qg_open_6.png b/public/images/educoder/competition/qg/qg_open_6.png new file mode 100644 index 00000000..3d101c2a Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_6.png differ diff --git a/public/images/educoder/competition/qg/qg_open_7.png b/public/images/educoder/competition/qg/qg_open_7.png new file mode 100644 index 00000000..0fe71207 Binary files /dev/null and b/public/images/educoder/competition/qg/qg_open_7.png differ diff --git a/public/images/educoder/teach_ex.png b/public/images/educoder/teach_ex.png index a3e65c73..e5ec5139 100644 Binary files a/public/images/educoder/teach_ex.png and b/public/images/educoder/teach_ex.png differ diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 5477c679..0275558c 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -114,7 +114,7 @@ function addFile(inputEl, file, eagerUpload,btnId) { fileSpan.append( $('').attr({ - 'class': 'fa fa-folder mr5 color-blue fl mt7', + 'class': 'iconfont icon-fujian mr5 color-green fl font-14', 'aria-hidden': true }), $('', { diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 13639287..48e0034f 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -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{ diff --git a/public/stylesheets/educoder/edu-main.css b/public/stylesheets/educoder/edu-main.css index 881f7ed9..f9248d58 100644 --- a/public/stylesheets/educoder/edu-main.css +++ b/public/stylesheets/educoder/edu-main.css @@ -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} diff --git a/spec/factories/shixun_infos.rb b/spec/factories/shixun_infos.rb new file mode 100644 index 00000000..35c80a06 --- /dev/null +++ b/spec/factories/shixun_infos.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :shixun_info do + + end +end diff --git a/spec/models/shixun_info_spec.rb b/spec/models/shixun_info_spec.rb new file mode 100644 index 00000000..988bdeae --- /dev/null +++ b/spec/models/shixun_info_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ShixunInfo, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end