From f3d439a35901bc78454d981c2f2a8520a58f4f1b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jun 2017 14:10:28 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/challenges_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/challenges_helper.rb b/app/helpers/challenges_helper.rb index 6a9004d90..425155726 100644 --- a/app/helpers/challenges_helper.rb +++ b/app/helpers/challenges_helper.rb @@ -14,8 +14,8 @@ module ChallengesHelper def find_game_status challenge_id game = Game.where(:challenge_id => challenge_id, :user_id => User.current.id).first - case game.status - when 0 + case game.try(:status) + when 0,nil "".html_safe when 1 "评测中" From 48ec5c6f81fdf49e1b6ddd1ec672284a2e271c0b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 30 Jun 2017 14:39:56 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E2=80=9C=E8=AF=BE=E5=A0=82=E6=95=99?= =?UTF-8?q?=E5=AD=A6=E2=80=9D=E9=A6=96=E9=A1=B5=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 20 ++++++---------- app/helpers/application_helper.rb | 21 +++++++++++++++++ app/helpers/courses_helper.rb | 20 ---------------- app/views/courses/_courseList.html.erb | 16 ++++++------- app/views/courses/index.html.erb | 23 +++++++++++++++---- app/views/games/_game_show.html.erb | 2 +- .../users/_my_homepage_shixuns_list.html.erb | 2 +- public/stylesheets/css/edu-common.css | 3 +++ 8 files changed, 59 insertions(+), 48 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 6e3229087..ccf9383dd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -42,21 +42,15 @@ class CoursesController < ApplicationController # def index @user = User.current - sy_courses = @user.courses.visible.not_deleted - syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" - syllabus_members = SyllabusMember.where("user_id = #{@user.id}") - syllabus_member_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|syl_mem| syl_mem.syllabus_id}.join(',') + ")" - @search = params[:search].nil? ? '' : params[:search] @select = params[:select].nil? ? '' : params[:select] - # 我发布的课程 - create_syllabuses = Syllabus.where("user_id = #{@user.id} and title like '%#{@search}%'").order("created_at desc") - # 我参与的课程 - join_syllabuses = Syllabus.where("(id in #{syllabus_ids} or id in #{syllabus_member_ids}) and user_id != #{@user.id} and title like '%#{@search}%'").order("created_at desc") - # 我的所有课程 - all_syllabuses = Syllabus.where("title like '%#{@search}%'").order("created_at desc") - - @syllabus_count = Syllabus.all.count + # 全部课堂 + all_syllabuses = Course.where("is_end = 0 and name like '%#{@search}%'").order("created_at desc") + # 我参与的课堂 + join_syllabuses = @user.courses.where("tea_id != #{@user.id} and name like '%#{@search}%'").order("created_at desc") + # 我创建的课堂 + create_syllabuses = Course.where(:tea_id => @user.id).where("is_end = 0 and name like '%#{@search}%'").order("created_at desc") + @syllabus_count = all_syllabuses.count @join_syllabuses_count = join_syllabuses.count @create_syllabuses_count = create_syllabuses.count # 页面筛选的课程 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3303d6083..9568aab1c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4870,6 +4870,27 @@ def sy_homeworks syllabus homeworks end +# 可以查看到资源库的资源 +def visable_attachemnts_incourse course + return[] unless course + result = [] + course.attachments.each do |attachment| + if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || User.current.allowed_to?(:as_teacher,course) || (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? + result << attachment + end + end + result +end + +def visable_course_homework course + if User.current.admin? || User.current.allowed_to?(:as_teacher,course) + homework_num = course.homework_commons.count + else + homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count + end + homework_num +end + #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 9d9415e0e..ae3497878 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -833,26 +833,6 @@ module CoursesHelper link.html_safe end - # 可以查看到资源库的资源 - def visable_attachemnts_incourse course - return[] unless course - result = [] - course.attachments.each do |attachment| - if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || User.current.allowed_to?(:as_teacher,course) || (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? - result << attachment - end - end - result - end - - def visable_course_homework course - if User.current.admin? || User.current.allowed_to?(:as_teacher,course) - homework_num = course.homework_commons.count - else - homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count - end - homework_num - end def zh_course_role role if role == "TeachingAsistant" diff --git a/app/views/courses/_courseList.html.erb b/app/views/courses/_courseList.html.erb index 4f8a7fc41..a3dfe4c9c 100644 --- a/app/views/courses/_courseList.html.erb +++ b/app/views/courses/_courseList.html.erb @@ -1,18 +1,18 @@ <% if @syllabuses.count > 0 %> <% @syllabuses.each do | sy | %> + <% sy_author = User.find(sy.tea_id) %>
- +

- <%= sy.title %> + <%= sy.name %>

- <%= link_to image_tag(url_to_avatar(sy.user), :width => "60", :height => "60", :class => "panel-warp-img mr10 fl", :alt => "用户"), user_path(sy.user), :target => '_blank' %> - <%= link_to sy.user.show_name, user_path(sy.user), :class => 'task-index-name task-hide fl', :target => '_blank' %> + <%= link_to image_tag(url_to_avatar(sy_author), :width => "60", :height => "60", :class => "panel-warp-img mr10 fl", :alt => "用户"), user_path(sy_author), :target => '_blank' %> + <%= link_to sy_author.show_name, user_path(sy_author), :class => 'task-index-name task-hide fl', :target => '_blank' %>

- <% sy_author = User.find(sy.user_id) %> <% if !sy_author.user_extensions.school_id.blank? && sy_author.user_extensions.school %> <%= sy_author.user_extensions.school.name %> <% end %> @@ -25,10 +25,10 @@

- <% syResource = sy_resources sy %> - <% syHome = sy.homework_banks %> + <% syResource = visable_attachemnts_incourse(sy) %> + <% syHome = visable_course_homework(sy) %> <%= syResource.count %> - <%= syHome.count %> + <%= syHome %> diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 0e952345c..eb6c369bd 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -12,14 +12,18 @@

-
  • + @search) %>" class="course_filtrate fl course_filtrate_bg" data-tab="all" data-remote="true">全部课堂 + @search) %>" class="course_filtrate fl" data-tab="create" data-remote="true">我管理的 + @search) %>" class="course_filtrate fl" data-tab="join" data-remote="true">我参与的 + +
    @@ -125,4 +129,13 @@ evt.preventDefault(); } + $(".course_filtrate").live("click", function(){ + console.log($(this).attr("data-tab")); + if ($(this).hasClass("course_filtrate_bg")){ + return; + }else{ + $(".course_filtrate").removeClass("course_filtrate_bg"); + $(this).addClass("course_filtrate_bg"); + } + }) diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index acada02ce..7b901ffc3 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -132,7 +132,7 @@ function error_correction_pop(){ var htmlvalue = "<%= escape_javascript(render :partial => 'games/send_error_pop') %>"; pop_box_new(htmlvalue,460,316); - $("#popupWrap").addClass("bg_shadow"); + $("#popupWrap").addClass("user_bg_shadow"); }; // 点赞/取消点赞功能 diff --git a/app/views/users/_my_homepage_shixuns_list.html.erb b/app/views/users/_my_homepage_shixuns_list.html.erb index 9bdb19695..49f4b1548 100644 --- a/app/views/users/_my_homepage_shixuns_list.html.erb +++ b/app/views/users/_my_homepage_shixuns_list.html.erb @@ -13,7 +13,7 @@
    -
    +
      <%= pagination_links_full @shixuns_pages, @shixuns_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
    diff --git a/public/stylesheets/css/edu-common.css b/public/stylesheets/css/edu-common.css index ce59fe87d..596e34168 100644 --- a/public/stylesheets/css/edu-common.css +++ b/public/stylesheets/css/edu-common.css @@ -274,3 +274,6 @@ html>body #ajax-indicator { position: fixed; } .white_bg {background: #fff} .user_tab_type {background: #FF6610} +.course_filtrate{width: 70px;text-align: center;background: #fff;border-radius: 10px;margin-right: 10px} +.course_filtrate:hover{background: #FFDAC1; color: #FF6610;} +.course_filtrate_bg{background: #FFDAC1; color: #FF6610!important;} From ef1c513a09c325e0c61184456704cec3fb5f5ecc Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 30 Jun 2017 14:44:48 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=88=91=E5=88=9B=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=EF=BC=8C=E6=B2=A1=E6=9C=89=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=EF=BC=8C=E5=AE=9E=E8=AE=AD=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E5=8D=A1=E7=8A=B6=E6=80=81=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E6=98=AF=E9=94=81=E5=AE=9A=E8=80=8C=E4=B8=8D=E6=98=AF=E5=BE=85?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/challenges_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/challenges_helper.rb b/app/helpers/challenges_helper.rb index 425155726..dd63cc007 100644 --- a/app/helpers/challenges_helper.rb +++ b/app/helpers/challenges_helper.rb @@ -15,13 +15,13 @@ module ChallengesHelper def find_game_status challenge_id game = Game.where(:challenge_id => challenge_id, :user_id => User.current.id).first case game.try(:status) - when 0,nil + when 0 "".html_safe when 1 "评测中" when 2 "".html_safe - when 3 + when 3,nil "".html_safe end end From f72c0be759d8c01676197b0abc8a533990bf723d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 30 Jun 2017 14:53:16 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=BF=87=EF=BC=8C=E4=BD=86=E6=98=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BA=86=E2=80=9C=E5=8A=A0=E8=BD=BD=E4=B8=8A=E6=AC=A1?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E7=9A=84=E4=BB=A3=E7=A0=81=E2=80=9D=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_code_actions.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index d25a931ea..846c3a15d 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -132,10 +132,10 @@ } // 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕 pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight); + $("#reset_code_to_bengin").show(); // 显示加载上次通过的代码 } var html = "评测"; $("#code_test").html(html); // 恢复评测 - $("#reset_code_to_bengin").show(); // 显示加载上次通过的代码 } // 访问60次,即120s后后台还未改变状态即执行 if(i == 60){ From 0dba009b156dee7d14fcdd9a1502a73e8e68f5f7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jun 2017 15:17:19 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9shixun=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shixuns/_shixun_top.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index 3834166e3..7f39eb294 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -25,14 +25,14 @@ <%= link_to "开始实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> <%#= link_to_shixun_exec myshixun, @shixun, '开始实战' %> <% else %> - <%= link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :target => "_blank"%> + <%= link_to "继续实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> <% end %> <% if User.current.manager_of_shixun?(@shixun) %> 永久关闭 <% end %> <% elsif @shixun.status == 3 %> <% unless myshixun.blank? %> - <%= link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :target => "_blank"%> + <%= link_to "继续实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> <% end %> 已关闭 <% end %> From d61ac51c55493c11ca4c65560fd9685d08db4ea2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 30 Jun 2017 15:43:01 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E8=BD=AC?= =?UTF-8?q?=E5=9C=88=E7=AD=89=E5=BE=85=EF=BC=8C=E7=AA=81=E7=84=B6=E5=B0=B1?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_code_actions.html.erb | 6 ++++++ app/views/games/_repository.html.erb | 5 ++++- app/views/games/reset_new_code.js.erb | 6 ++++-- public/javascripts/edu/application.js | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 846c3a15d..1ad4aa574 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -23,6 +23,12 @@ <% end %>