From fbfa0aa113d887ea37304089786d38d0ee645458 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Oct 2017 09:45:48 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=A2=98=E5=9C=A8=E6=9C=89=E5=BF=85=E5=A1=AB=E9=A1=B9=E6=9C=AA?= =?UTF-8?q?=E5=A1=AB=E6=97=B6=E8=BF=9B=E8=A1=8C=E4=BF=9D=E5=AD=98=EF=BC=8C?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E5=AE=9A=E4=BD=8D=E5=88=B0=E6=9C=AA=E5=A1=AB?= =?UTF-8?q?=E9=A1=B9=E5=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/challenges/_single_or_multiple_question.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/challenges/_single_or_multiple_question.html.erb b/app/views/challenges/_single_or_multiple_question.html.erb index e0c883739..e066ccea3 100644 --- a/app/views/challenges/_single_or_multiple_question.html.erb +++ b/app/views/challenges/_single_or_multiple_question.html.erb @@ -349,6 +349,7 @@ var lens = contents.length; for(var i = 0; i < lens; i++){ if($(contents[i]).val().trim() == ""){ + $(contents[i]).focus(); return true; } } @@ -358,6 +359,7 @@ // 判断选择题选择答案的个数 function judge_choice_answer(){ var answer = document.getElementsByName("choice[answer][]"); + var contents = document.getElementsByName("question[cnt][]"); var lens = answer.length; var num = 0; for(var i= 0; i < lens; i++){ @@ -365,6 +367,7 @@ num += 1; } } + $(contents[0]).focus(); return num; } @@ -438,6 +441,7 @@ if(st == "1"){ if(judge_choice_contents()) { error.html("选项内容不能为空").show(); + }else if(choice_num() < 2){ error.html("单选题选项不能少于2个").show(); }else if(judge_choice_answer() == 0){ From 12159940342bb72bda42641a9d082072229c0861 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Oct 2017 11:07:21 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=A2=98tpi=E9=A1=B5=E9=9D=A2=E4=B9=9F=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=9C=89=E8=AF=84=E6=B5=8B=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 2 +- app/views/games/_game_choose_results.html.erb | 34 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index d8422beaa..ba639a7bf 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -88,7 +88,7 @@ class GamesController < ApplicationController # @praise 判断是否点赞 # @tread 判断是否踩 # git_repository_url @myshixun, "Myshixun" - # @st 0 实践任务 1 多选任务 2 单选任务 + # @st 0 实践任务 1 选择题任务 def show # 展示全部实训 @is_subject = params[:is_subject] diff --git a/app/views/games/_game_choose_results.html.erb b/app/views/games/_game_choose_results.html.erb index f212f1f3f..3ab0f6e29 100644 --- a/app/views/games/_game_choose_results.html.erb +++ b/app/views/games/_game_choose_results.html.erb @@ -1,7 +1,10 @@ @@ -60,4 +63,33 @@ +
+
+
+
+
+ <% unless @game.choose_correct_num == nil %> + <% if @game.choose_correct_num != game_challenge.challenge_chooses.count %> +

+ <%= @game.choose_correct_num %>/<%= game_challenge.challenge_chooses.count %>共有<%= game_challenge.challenge_chooses.count %>题,其中有<%= game_challenge.challenge_chooses.count - @game.choose_correct_num %>题结果不匹配。 +

+ <% else %> +

+ <%= game_challenge.challenge_chooses.count %>/<%= game_challenge.challenge_chooses.count %> 全部通过 +

+ <% end %> + <% end %> +
+
+
    +
  • 选择题:<%= @game.choose_correct_num.nil? ? 0 : @game.choose_correct_num %>/<%= game_challenge.challenge_chooses.count %>
  • +
  • 经验值:+ <%= @final_score %>
  • +
  • 金币:+ <%= @final_score %>
  • +
+
+
+
+
+
+
\ No newline at end of file From cd6486671f58b238686df15a8a5eec17d782b4fb Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 9 Oct 2017 14:38:54 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=97=E8=A1=A8=E6=8C=89=E7=85=A7=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=80=92=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 14 +++++++------- app/helpers/application_helper.rb | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 6e56e44c6..26f89d0e3 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -31,22 +31,22 @@ class HomeworkCommonController < ApplicationController end if @order.blank? if @is_teacher - @homework_commons = @homework_commons.order("created_at desc") + @homework_commons = @homework_commons.order("publish_time desc") else - @homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("created_at desc") + @homework_commons = @homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc") end else case @order when '1' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and end_time > '#{Time.now}'").order("homework_commons.publish_time desc") when '3' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.evaluation_end > '#{Time.now}'").order("homework_commons.publish_time desc") when '4' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and homework_detail_manuals.appeal_time > '#{Time.now}')").order("homework_commons.publish_time desc") when '5' - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("(homework_detail_manuals.comment_status = #{@order} and archive_time > '#{Time.now}')").order("homework_commons.publish_time desc") else - @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.created_at desc") + @homework_commons = @homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status = #{@order}").order("homework_commons.publish_time desc") end end @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 78c0920a3..93f500d9d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4833,15 +4833,15 @@ def get_hw_index(hw,is_teacher,type=0) homework_commons = hw.course.homework_commons if is_teacher if type != 0 - homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("created_at asc") + homeworks = homework_commons.where("homework_commons.homework_type = #{type}").order("publish_time desc") else - homeworks = homework_commons.order("created_at asc") + homeworks = homework_commons.order("publish_time desc") end else if type != 0 - homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("created_at asc") + homeworks = homework_commons.where("homework_commons.homework_type = #{type} and publish_time <= '#{Time.now}'").order("publish_time desc") else - homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("created_at asc") + homeworks = homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time desc") end end hw_ids = homeworks.map{|hw| hw.id} if !homeworks.blank? From 75a279952d9acfbd0624aeff5d815e6d4448513e Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 9 Oct 2017 15:16:26 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=8D=E5=88=B6=E5=90=88=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 37 +++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 2fb901d77..eae0690ac 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -610,23 +610,28 @@ class ShixunsController < ApplicationController gshixun = g.edit_project(gshixun.id, new_shixun.identifier, new_shixun.identifier) raise "实训复制失败" if (gshixun.try(:name) != new_shixun.identifier || gshixun.try(:path) != new_shixun.identifier) new_shixun.update_column(:gpid, gshixun.id) + # 同步复制者至gitlab,必须要求用户绑定了邮箱 + ShixunMember.create!(:user_id => User.current.id, :shixun_id => new_shixun.try(:id), :role => 1) + s = Trustie::Gitlab::Sync.new + gid = User.current.try(:gid) + u = g.add_team_member(gshixun.id, gid, 40) # 3代表角色master - # 同步复制合作者,合作者加入到gitlab - unless User.current.manager_of_shixun?(@shixun) - ShixunMember.create!(:user_id => User.current.id, :shixun_id => new_shixun.try(:id), :role => 1) - end - @shixun.shixun_members.each do |shixun_member| - if ShixunMember.where(:shixun_id => new_shixun.try(:id), :user_id => shixun_member.user_id).blank? - ShixunMember.create!(:user_id => shixun_member.try(:user_id), :shixun_id => new_shixun.try(:id), - :role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2)) - end - s = Trustie::Gitlab::Sync.new - gid = User.find(shixun_member.user_id).try(:gid) - u = s.g.add_team_member(gshixun.id, gid, 40) # 3代表角色master - if u.blank? - raise("同步Gitlab数据失败") - end - end + # # 同步复制合作者,合作者加入到gitlab + # unless User.current.manager_of_shixun?(@shixun) + # ShixunMember.create!(:user_id => User.current.id, :shixun_id => new_shixun.try(:id), :role => 1) + # end + # @shixun.shixun_members.each do |shixun_member| + # if ShixunMember.where(:shixun_id => new_shixun.try(:id), :user_id => shixun_member.user_id).blank? + # ShixunMember.create!(:user_id => shixun_member.try(:user_id), :shixun_id => new_shixun.try(:id), + # :role => (shixun_member.try(:user_id) == User.current.id ? 1 : 2)) + # end + # s = Trustie::Gitlab::Sync.new + # gid = User.find(shixun_member.user_id).try(:gid) + # u = s.g.add_team_member(gshixun.id, gid, 40) # 3代表角色master + # if u.blank? + # raise("同步Gitlab数据失败") + # end + # end # 同步复制关卡 if @shixun.challenges.present? @shixun.challenges.each do |challenge| From 028d5e087cdda3b348a68735c861d6be2ede1b4c Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 9 Oct 2017 15:59:39 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=80=E5=B9=B6=E5=88=A0=E9=99=A4gitlab?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index eae0690ac..6299519b0 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -791,6 +791,8 @@ class ShixunsController < ApplicationController return end Subject.where(:id => @shixun.stage_shixuns.map(&:subject_id)).destroy_all + g = Gitlab.client + g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present? @shixun.destroy respond_to do |format| format.html{ redirect_to shixuns_managements_path } From 9739f2bdae1529d84db183f72a3d344491084184 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 9 Oct 2017 16:22:55 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E8=B5=84=E6=96=99?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=97=B6=EF=BC=8C=E5=90=8C=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E5=90=8C=E5=AD=A6=E5=8F=B7=E4=B8=8D=E8=83=BD=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 16 ++++++++++++++++ config/routes.rb | 1 + public/javascripts/edu/account.js | 22 +++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index f31ff8eb5..f2ae14598 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -536,6 +536,21 @@ class AccountController < ApplicationController redirect_to professional_certification_account_path end + # 修改资料时判断学号是否已使用 + def check_user_student_id + data = {result:0, account:""} + if params[:student_id] && params[:school_id] + if UserExtensions.where("student_id = '#{params[:student_id]}' and school_id = #{params[:school_id]} and user_id != #{User.current.id}").count > 0 + user = User.where(:id => UserExtensions.where("student_id = '#{params[:student_id]}' and school_id = #{params[:school_id]} and user_id != #{User.current.id}").map(&:user_id)).first + data[:account] = user.mail.blank? ? user.user_phone : user.user_mail + else + data[:result] = 1 + end + end + render :json => data + end + + # 实名认证时判断学号是否已使用 def check_student_id data = {result:0, account:""} if params[:student_id] && params[:school_id] @@ -555,6 +570,7 @@ class AccountController < ApplicationController render :json => data end + # 实名认证时判断证件号码是否已使用 def check_id_number data = {result:0, account:""} if params[:id_number] diff --git a/config/routes.rb b/config/routes.rb index 3a15cc9bb..a648ddf6d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -832,6 +832,7 @@ RedmineApp::Application.routes.draw do match 'account/apply_auth', :to => 'account#apply_auth', :via => :post, :as => "apply_auth_account" match 'account/apply_pro_certification', :to => 'account#apply_pro_certification', :via => :post, :as => "apply_pro_certification_account" match 'account/check_student_id', :to => 'account#check_student_id', :via => :post + match 'account/check_user_student_id', :to => 'account#check_user_student_id', :via => :post match 'account/cancel_pro_apply', :to => 'account#cancel_pro_apply', :via => :get, :as => "cancel_pro_apply_account" match 'account/check_id_number', :to => 'account#check_id_number', :via => :post match 'account/codepedia_login', :to => 'account#codepedia_login', :via => [:get, :post] diff --git a/public/javascripts/edu/account.js b/public/javascripts/edu/account.js index ad58a5737..0abbc0119 100644 --- a/public/javascripts/edu/account.js +++ b/public/javascripts/edu/account.js @@ -246,7 +246,23 @@ function my_account_form_submit() { $("#school_name_hint").hide(); } - $('#my_account_form').submit(); + if($("#user_student_id").parent().is(":visible") == true && $("#user_student_id").val() != ""){ + $.ajax({ + url: '/account/check_user_student_id', + type: 'post', + data: {student_id:$("#user_student_id").val(), school_id:$("input[name='occupation']").val()}, + success: function(data){ + if(data.result == 0){ + notice_box("该学号已被另一个账号(" + data.account + ")使用"); + } + else if (data.result == 1){ + $('#my_account_form').submit(); + } + } + }); + } else{ + $('#my_account_form').submit(); + } } //申请单位 @@ -728,7 +744,7 @@ function submit_pro_certification(){ data: {student_id:$("#user_student_id").val(), school_id:$("input[name='occupation']").val()}, success: function(data){ if(data.result == 0){ - notice_box("该学号已被另一个账号用于(" + data.account + ")认证"); + notice_box("该学号已被另一个账号(" + data.account + ")用于认证"); } else if (data.result == 1){ $('#my_pro_certification_form').submit(); @@ -772,7 +788,7 @@ function submit_user_auth(){ success: function(data){ if(data.result == 0){ $("#user_auth_submit_a").removeAttr("disabled"); - notice_box("该证件号码已被另一个账号用于(" + data.account + ")认证"); + notice_box("该证件号码已被另一个账号(" + data.account + ")用于认证"); } else if (data.result == 1){ $('#my_user_auth_form').submit(); From 13d4ddb76d85187ef17e00b8704e66dfa3e987d8 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 10 Oct 2017 10:20:53 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E7=9A=84=E6=97=B6=E5=80=99=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E2=80=9C=E6=8A=80=E8=83=BD=E6=A0=87=E7=AD=BE=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 28 +++++++++++++++++-------- app/views/shixuns/_monitor_tip.html.erb | 5 ++++- app/views/shixuns/publish.js.erb | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 6299519b0..a5f3a9782 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -367,16 +367,26 @@ class ShixunsController < ApplicationController # jenkins回调脚本 # gameID 及实训ID def publish + @status = 0 + @position = "" begin - @shixun.update_attributes!(:status => 1) - apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first - if apply && apply.status == 0 - @status = 0 - else - ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => User.current.id, :status => 0) - notes = User.current.show_name.to_s + " 申请发布实训:#{@shixun.name}" - JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0) - @status = 1 + @shixun.challenges.each do |challenge| + if challenge.challenge_tags.count == 0 + @status = 2 + @position = (@position == "" ? @position : (@position + ",")) + challenge.position.to_s + "关" + end + end + if @status == 0 + @shixun.update_attributes!(:status => 1) + apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first + if apply && apply.status == 0 + @status = 0 + else + ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => User.current.id, :status => 0) + notes = User.current.show_name.to_s + " 申请发布实训:#{@shixun.name}" + JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0) + @status = 1 + end end rescue Exception => e @jenkin_error = true diff --git a/app/views/shixuns/_monitor_tip.html.erb b/app/views/shixuns/_monitor_tip.html.erb index bb427fb4e..aceb016f1 100644 --- a/app/views/shixuns/_monitor_tip.html.erb +++ b/app/views/shixuns/_monitor_tip.html.erb @@ -8,9 +8,12 @@ <% if result %> <% if @status == 0 %> 已发布过申请,请等待管理员审核 - <% else %> + <% elsif @status == 1 %> 发布申请已提交,请等待管理员的审核
• 我们将在1-2个工作日内完成审核 + <% else %> + 每一个关卡至少需要一个技能标签
+ 第<%= @position %>尚未设置技能标签,请补充 <% end %> <% else %> 实训云平台繁忙(繁忙等级:80) diff --git a/app/views/shixuns/publish.js.erb b/app/views/shixuns/publish.js.erb index b4099d3ae..90ccba95a 100644 --- a/app/views/shixuns/publish.js.erb +++ b/app/views/shixuns/publish.js.erb @@ -1,4 +1,4 @@ -<% unless @status && @status = 1 %> +<% unless @status && @status == 1 %> $("#apply_publish_shixun").attr("data-option", 1); $("#apply_publish_shixun").removeClass("disabled-grey-bg"); <% end %> From 485a10ef702812cc650518e3ef9777ca9007072e Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 10 Oct 2017 10:38:11 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/stages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/stages_controller.rb b/app/controllers/stages_controller.rb index d653d33a3..e5812e398 100644 --- a/app/controllers/stages_controller.rb +++ b/app/controllers/stages_controller.rb @@ -39,7 +39,7 @@ class StagesController < ApplicationController @stage.name = params[:stage_name] @stage.description = params[:stage_des] ActiveRecord::Base.transaction do - if @stage.save && params[:shixun_id] + if @stage.save begin @stage.stage_shixuns.destroy_all params[:shixun_id].each do |shixun_id| From ea08271e9cec5c2d1f733bc7871a2ab05eabde1d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 10 Oct 2017 14:29:08 +0800 Subject: [PATCH 09/23] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercises_list.html.erb | 30 +++++++++++++++---- .../_homework_index_list.html.erb | 5 ++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb index ed1030a52..6f4a971f4 100644 --- a/app/views/exercise/_exercises_list.html.erb +++ b/app/views/exercise/_exercises_list.html.erb @@ -16,13 +16,31 @@

创建于<%=time_from_now exercise.created_at %> 更新于<%=time_from_now exercise.updated_at %> - <%= exercise.exercise_users.where("commit_status = 1").count %>已答 - <%= exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count %>未答 - <%# count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %> - <%= un_commit_num exercise %>未评 - <%= ex_curr_status[:time] %> - <% if exercise.try(:exercise_status) == 0 && exercise.publish_time %> + <% if exercise.try(:exercise_status) > 1 %> + <% if @is_teacher %> + + <%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise, :ex_status => ['1']), :class => "color-orange05 mr3", :target =>"_blank" %> + 已答 + + <%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise, :ex_status => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %> + 未答 + <%# count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %> + + <%= link_to un_commit_num(exercise), student_exercise_list_exercise_path(exercise, :ex_comment => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %> + 未评 + <% else %> + + <%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %> + 已答 + + <%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %> + 未答 + <% end %> + <% end %> + <% if exercise.try(:exercise_status) == 1 && exercise.publish_time %> 将于 <%= format_time(exercise.publish_time).to_s %> 发布 + <% else %> + <%= ex_curr_status[:time] %> <% end %>

diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb index 4013d1c29..4b957b505 100644 --- a/app/views/homework_common/_homework_index_list.html.erb +++ b/app/views/homework_common/_homework_index_list.html.erb @@ -53,10 +53,11 @@ <% end %> <% end %> - <%= homework_curr_status[:time] %> <% if homework_common.homework_detail_manual.try(:comment_status) == 0 && homework_common.publish_time %> 将于 <%= format_time(homework_common.publish_time).to_s %> 发布 - <% end %> + <% else %> + <%= homework_curr_status[:time] %> + <% end %>

<% if @is_teacher %> From c69f9c9d9fc603c5762764c6fe32941b7c746458 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 10 Oct 2017 15:59:52 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=B7=B7=E4=B9=B1=EF=BC=8Ceducoder=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=9A=84C++=E7=A8=8B=E5=BA=8F=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=9C=89=E5=A4=9A=E6=9D=A1=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- .../managements/_classroom_list.html.erb | 2 +- ...71010071751_migrate_shixun_major_course.rb | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20171010071751_migrate_shixun_major_course.rb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 7e54df3f1..7ee69d2e9 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -823,7 +823,7 @@ end @courselist= @courselist.where("name like '%#{search}%'") end end - @courselist = @courselist.order("created_at #{@sx_order}") + @courselist = @courselist.order("id #{@sx_order}") @courselist_count = @courselist.count limit = 20 @is_remote = true diff --git a/app/views/managements/_classroom_list.html.erb b/app/views/managements/_classroom_list.html.erb index 0d6192326..dc321ffa0 100644 --- a/app/views/managements/_classroom_list.html.erb +++ b/app/views/managements/_classroom_list.html.erb @@ -23,7 +23,7 @@ - <%= courselist.name %> + <%= courselist.name %> <%= courselist.courses.count %> diff --git a/db/migrate/20171010071751_migrate_shixun_major_course.rb b/db/migrate/20171010071751_migrate_shixun_major_course.rb new file mode 100644 index 000000000..40124ffa2 --- /dev/null +++ b/db/migrate/20171010071751_migrate_shixun_major_course.rb @@ -0,0 +1,19 @@ +# encoding: utf-8 +class MigrateShixunMajorCourse < ActiveRecord::Migration + def up + c_courses = CourseList.where("name = 'C++程序设计' and id != 5") + ShixunMajorCourse.where(:course_list_id => c_courses.map(&:id)).update_all(:course_list_id => 5) + c_courses.destroy_all + + c_courses = CourseList.where("id in (70, 86)") + ShixunMajorCourse.where(:course_list_id => c_courses.map(&:id)).update_all(:course_list_id => 1) + c_courses.destroy_all + + c_courses = CourseList.where("id = 84") + ShixunMajorCourse.where(:course_list_id => c_courses.map(&:id)).update_all(:course_list_id => 79) + c_courses.destroy_all + end + + def down + end +end From 268a626e7a616f42bde61da30aa5832e639f5edb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 10 Oct 2017 16:45:41 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=9A=84ke=E7=AE=80=E4=BB=8B=E5=92=8Cke=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E9=A1=BB=E7=9F=A5=EF=BC=8C=E9=83=BD=E6=94=B9=E4=B8=BAmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/subjects/edit.html.erb | 175 ++++++++++++++++------- app/views/subjects/new.html.erb | 216 +++++++++++++++++++---------- app/views/subjects/show.html.erb | 29 +++- public/javascripts/edu/base_edu.js | 12 +- 4 files changed, 296 insertions(+), 136 deletions(-) diff --git a/app/views/subjects/edit.html.erb b/app/views/subjects/edit.html.erb index 0f8baf4e9..845ad9424 100644 --- a/app/views/subjects/edit.html.erb +++ b/app/views/subjects/edit.html.erb @@ -1,6 +1,5 @@ -<% content_for :header_tags do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> -<% end %> +<%= stylesheet_link_tag '/editormd/css/editormd' %> +<%= javascript_include_tag '/editormd/editormd' %>

@@ -9,40 +8,28 @@

- 编辑实训路径 -
+ 编辑实训路径 +
- <%= labelled_form_for @subject do |f| %> -
  • - - -
    - 请输入名称 -
  • - + <%= labelled_form_for @subject do |f| %> +
  • + + +
    + 请输入名称 +
  • + - +
  • <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> - - <%= f.kindeditor :description, :editor_id => 'subject_description_editor', - :owner_id => @subject.nil? ? 0: @subject.id, - :owner_type => OwnerTypeHelper::SUBJECT, - :local_storage_mdu => "subject_description_#{User.current.id}_#{@subject.id}", - :local_storage_id => "desc", - :width => '80%', - :height => 200, - :minHeight=>200, - :placeholder => "请在此输入实训路径的简介", - :class => 'talk_text fl', - :input_html => { :id => 'new_subject_description', - :class => 'talk_text fl', - :maxlength => 5000 } - %> +
    + +

    @@ -50,32 +37,116 @@
  • - - <%= f.kindeditor :learning_notes, :editor_id => 'subject_learning_notes_editor', - :owner_id => @subject.nil? ? 0: @subject.id, - :owner_type => OwnerTypeHelper::SUBJECT, - :local_storage_mdu => "subject_notes_#{User.current.id}_#{@subject.id}", - :local_storage_id => "notes", - :width => '80%', - :height => 200, - :minHeight=>200, - :placeholder => "请在此输入实训路径的学习须知", - :class => 'talk_text fl', - :input_html => { :id => 'new_learning_notes', - :class => 'talk_text fl', - :maxlength => 5000 } - %> +
    + +

    请输入学习须知
  • -
  • - - <%= link_to "取消", subject_path(@subject), :class => "task-btn fl mr10 ml20" %> - 保存 -
  • - <% end %> +
  • + + <%= link_to "取消", subject_path(@subject), :class => "task-btn fl mr10 ml20" %> + 保存 +
  • + <% end %> +
    - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/subjects/new.html.erb b/app/views/subjects/new.html.erb index 42b2382d2..cfa6ae8ea 100644 --- a/app/views/subjects/new.html.erb +++ b/app/views/subjects/new.html.erb @@ -1,6 +1,6 @@ -<% content_for :header_tags do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> -<% end %> +<%= stylesheet_link_tag '/editormd/css/editormd' %> +<%= javascript_include_tag '/editormd/editormd' %> +

    @@ -9,81 +9,57 @@

    - 新建实训路径 -
    + 新建实训路径 +
    - <%= labelled_form_for @subject do |f| %> -
  • - - -
    - 请输入名称 -
  • - + <%= labelled_form_for @subject do |f| %> +
  • + + +
    + 请输入名称 +
  • + - -
  • - - <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> - - <%= f.kindeditor :description, :editor_id => 'subject_description_editor', - :owner_id => @subject.nil? ? 0: @subject.id, - :owner_type => OwnerTypeHelper::SUBJECT, - :local_storage_mdu => "subject_description_#{User.current.id}", - :local_storage_id => "desc", - :width => '80%', - :height => 200, - :minHeight=>200, - :placeholder => "请在此输入实训路径的简介", - :class => 'talk_text fl', - :input_html => { :id => 'new_subject_description', - :class => 'talk_text fl', - :maxlength => 5000 } - %> -
    -

    -

    - 请输入简介 -
  • -
  • - - - <%= f.kindeditor :learning_notes, :editor_id => 'subject_learning_notes_editor', - :owner_id => @subject.nil? ? 0: @subject.id, - :owner_type => OwnerTypeHelper::SUBJECT, - :local_storage_mdu => "subject_notes_#{User.current.id}", - :local_storage_id => "notes", - :width => '80%', - :height => 200, - :minHeight=>200, - :placeholder => "请在此输入实训路径的学习须知", - :class => 'talk_text fl', - :input_html => { :id => 'new_learning_notes', - :class => 'talk_text fl', - :maxlength => 5000 } - %> - -
    -

    -

    - 请输入学习须知 -
  • - -
  • - - <%= link_to "取消", subjects_path(), :class => "task-btn fl mr10 ml20" %> - 保存 -
  • - <% end %> -
    -
    + +
  • + + <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> +
    + +
    +
    +

    +

    + 请输入简介 +
  • +
  • + +
    + +
    + +
    +

    +

    + 请输入学习须知 +
  • + +
  • + + <%= link_to "取消", subjects_path(), :class => "task-btn fl mr10 ml20" %> + 保存 +
  • + <% end %> + + \ No newline at end of file + /* ------------------------------- 简介md ------------------------------*/ + var shixun_editormd = editormd("shixun_introduction", { + width : "80%", + height : 600, + syncScrolling : "single", + //你的lib目录的路径,我这边用JSP做测试的 + path : "/editormd/lib/", + tex : true, + toolbarIcons : function() { + // Or return editormd.toolbarModes[name]; // full, simple, mini + // Using "||" set icons align right. + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + + toolbarCustomIcons : { + testIcon : "
    ", + testIcon1 : "
    " + }, + //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 + saveHTMLToTextarea : true, + autoFocus: false, + // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 + dialogMaskOpacity : 0.6, + placeholder: "请在此输入实训路径的简介", + imageUpload : true, + imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], + imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => @subject.class) %>" //url + }); + + /* --------------------------------- 学习须知 -------------------------------------- */ + var shixun_propaedeutics = editormd("shixun_propaedeutics", { + width : "80%", + height : 600, + syncScrolling : "single", + //你的lib目录的路径,我这边用JSP做测试的 + path : "/editormd/lib/", + tex : true, + toolbarIcons : function() { + // Or return editormd.toolbarModes[name]; // full, simple, mini + // Using "||" set icons align right. + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ] + }, + toolbarCustomIcons : { + testIcon : "
    ", + testIcon1 : "
    " + }, + //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 + saveHTMLToTextarea : true, + autoFocus: false, + // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 + dialogMaskOpacity : 0.6, + placeholder: "请在此输入实训路径的学习须知", + imageUpload : true, + imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], + imageUploadURL : "<%= upload_with_markdown_path(:container_id => @subject.id, :container_type => @subject.class) %>" //url + }); + window.onload = function(){ + console.log(shixun_editormd); + + $("#shixun_introduction [type=\"latex\"]").bind("click", function(){ + shixun_editormd.cm.replaceSelection("```latex"); + shixun_editormd.cm.replaceSelection("\n"); + shixun_editormd.cm.replaceSelection("\n"); + shixun_editormd.cm.replaceSelection("```"); + var __Cursor = shixun_editormd.cm.getDoc().getCursor(); + shixun_editormd.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#shixun_propaedeutics [type=\"latex\"]").bind("click", function(){ + shixun_propaedeutics.cm.replaceSelection("```latex"); + shixun_propaedeutics.cm.replaceSelection("\n"); + shixun_propaedeutics.cm.replaceSelection("\n"); + shixun_propaedeutics.cm.replaceSelection("```"); + var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor(); + shixun_propaedeutics.cm.setCursor(__Cursor.line-1, 0); + }); + + $("#shixun_introduction [type=\"inline\"]").bind("click", function(){ + shixun_editormd.cm.replaceSelection("$$$$"); + var __Cursor = shixun_editormd.cm.getDoc().getCursor(); + shixun_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2); + shixun_editormd.cm.focus(); + }); + + $("#shixun_propaedeutics [type=\"inline\"]").bind("click", function(){ + shixun_propaedeutics.cm.replaceSelection("$$$$"); + var __Cursor = shixun_propaedeutics.cm.getDoc().getCursor(); + shixun_propaedeutics.cm.setCursor(__Cursor.line, __Cursor.ch-2); + shixun_propaedeutics.cm.focus(); + }); + $("[type=\"inline\"]").attr("title", "行内公式"); + $("[type=\"latex\"]").attr("title", "多行公式"); + + }; + diff --git a/app/views/subjects/show.html.erb b/app/views/subjects/show.html.erb index 10208015c..944631c62 100644 --- a/app/views/subjects/show.html.erb +++ b/app/views/subjects/show.html.erb @@ -1,3 +1,6 @@ +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js', + '/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js'%>
    <% if !@subject.description.blank? || User.current.manager_of_subject?(@subject) %> @@ -8,8 +11,10 @@ <% end %>

    -
    -
    <%= @subject.description.blank? ? "暂未填写" : (@subject.description.html_safe) %>
    +
    +
    + +
    <% end %> @@ -142,7 +147,9 @@ <% end %>

    -
    <%= @subject.learning_notes.blank? ? "暂未填写" : @subject.learning_notes.html_safe %>
    +
    + +

    教学团队 @@ -176,6 +183,22 @@