From 1fadbcee22165f2f24eb0f35952e584358046129 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 16 Jan 2017 14:45:33 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=BF=87=E6=BB=A4=E4=BB=A3=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2d34bcbd2..b7d3e1849 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2023,31 +2023,28 @@ class UsersController < ApplicationController reorder("#{MessageAll.table_name}.created_at desc") @unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).count - # 用户待完成的作业 + my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course). where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" + # 用户待完成的作业 homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'") homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") @unfinished_homework_count = homeworks.count - student_works.count # 用户待完成的测验 exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") - exercise_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")" - exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}") + exercise_users = ExerciseUser.where(:user_id => @user.id, :exercise_id => exercises.map{|ex| ex.id}) @unfinished_test_count = exercises.count - exercise_users.count # 用户待完成的问卷 polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") - poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")" - poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") + poll_users = PollUser.where(:user_id => @user.id, :poll_id => polls.map{|poll| poll.id}) @unfinished_poll_count = polls.count - poll_users.count # 用户待匿评的作品 - homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)") - homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" + homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status = 2") student_work_scores = @user.student_works_scores.where("reviewer_role = 3") anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") - unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")" - @anonymous_evaluation_count = StudentWork.where("student_works.id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").count + @anonymous_evaluation_count = StudentWork.where(:id => unfinished_evaluations.map{|ev| ev.student_work_id}, :homework_common_id => homeworks.map{|hw| hw.id}).count # 待评阅的作业 暂不做 # @unreview_homework = 1 From 9ccef856001f87e87f8f713a48e16d99e79c891d Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 16 Jan 2017 16:34:51 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/controllers/words_controller.rb | 10 ++++- app/views/courses/_course_jours_list.html.erb | 17 ++++++++ app/views/courses/feedback.html.erb | 39 ++++++++++++------- .../users/_course_journalsformessage.html.erb | 14 +++++++ app/views/words/destroy.js.erb | 12 +++--- config/routes.rb | 2 +- public/javascripts/contest.js | 1 + public/javascripts/course.js | 32 +++++++++++++++ 9 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 app/views/courses/_course_jours_list.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2ad7d71c1..7166a7c94 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1151,6 +1151,7 @@ class CoursesController < ApplicationController page = params[:page] # Find the page of the requested reply @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jour_count = @jours.count @limit = 10 if params[:r] && page.nil? offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 587d14c9c..38ec4270b 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -95,6 +95,14 @@ class WordsController < ApplicationController @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count @user_activity_id = params[:user_activity_id] if params[:user_activity_id] @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] + unless @activity + if params[:user_activity_id] == params[:activity_id] + redirect_to course_feedback_path(@course) + else + redirect_to course_path(@course) + end + return + end elsif @journal_destroyed.jour_type == "Principal" @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @@ -282,7 +290,7 @@ class WordsController < ApplicationController # add by nwb def leave_course_message user = User.current - message = params[:new_form][:course_message] + message = params[:new_form][:content] feedback = Course.add_new_jour(user, message, params[:id]) if(feedback.errors.empty?) if params[:asset_id] diff --git a/app/views/courses/_course_jours_list.html.erb b/app/views/courses/_course_jours_list.html.erb new file mode 100644 index 000000000..94e464445 --- /dev/null +++ b/app/views/courses/_course_jours_list.html.erb @@ -0,0 +1,17 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> +<% end %> + +<%if jours %> + <% jours.each do |jour|%> + + <%= render :partial => 'users/course_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id, :is_course => 1} %> + <%end%> +<% end%> +<% if (jours.count + page * 10) < count %> + <%= link_to "点击展开更多",course_feedback_path(@course.id, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end %> \ No newline at end of file diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb index 3b2d3030c..1d71ff40f 100644 --- a/app/views/courses/feedback.html.erb +++ b/app/views/courses/feedback.html.erb @@ -1,15 +1,28 @@ -<% reply_allow = JournalsForMessage.create_by_user? User.current %> - -
+
+
+
班级留言
+
+
-
-

<%= l(:label_contest_userresponse) %>

+
+
<%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %> +
+ <%= form_for('new_form',:url => leave_course_message_path(@course.id), :html =>{:id => "course_feedback_new"}, :method => "post") do |f|%> + <%= render :partial => "users/jour_form", :locals => {:f => f, :object => @course} %> + + 留言 + 取消 + <% end %> +
+
+ <%=render :partial => "course_jours_list", :locals => {:jours =>@jours, :page => 0, :count => @jour_count} %> +
+
- - -<%= render :partial => 'courses_jours', - :locals => { :contest => @contest, :journals => @jour, :state => false} -%> - -<% html_title(l(:label_course_feedback)) -%> -
\ No newline at end of file + \ No newline at end of file diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index 6604f344b..02ae4a80c 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -36,6 +36,20 @@ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+ <% if defined?(is_course) && is_course == 1 && (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher, course))%> +
+ +
+ <% end%>
diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index f53a21935..49a8dc966 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -28,12 +28,12 @@ <% else %> $('#course_jour_count').html("<%= @jours_count %>"); <% end %> - <% elsif @contest && @jours_count%> - <% if @user_activity_id %> - $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); - sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); - <% end %> - <% elsif @user && @jours_count%> + <% elsif @contest && @jours_count%> + <% if @user_activity_id %> + $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_journal_post_reply', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); + <% end %> + <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> $("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/homework_post_reply', :locals => {:activity => @homework, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>"); diff --git a/config/routes.rb b/config/routes.rb index c3a41703f..dd49df318 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1405,7 +1405,7 @@ RedmineApp::Application.routes.draw do end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' match '/courses/search', :via => [:get, :post] - match 'words/:id/leave_course_message', :to => 'words#leave_course_message' + match 'words/:id/leave_course_message', :to => 'words#leave_course_message', :as => "leave_course_message" match 'workflows', :to => 'workflows#index', :via => :get diff --git a/public/javascripts/contest.js b/public/javascripts/contest.js index bc1fda130..414af8cc0 100644 --- a/public/javascripts/contest.js +++ b/public/javascripts/contest.js @@ -158,6 +158,7 @@ function jourReplyVerify() { if (jour_content_editor.isEmpty()) { $("#jour_content_span").text("留言不能为空"); $("#jour_content_span").css('color', '#ff0000'); + $("#jour_content_span").show(); $("#submit_feedback_user").one('click',function() { contest_jour_submit(); }); diff --git a/public/javascripts/course.js b/public/javascripts/course.js index aeb92c6c9..e42821cc6 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1606,3 +1606,35 @@ function submit_course_feedback() { function show_more_tool(){ $('#navContentCourse').css('display', 'block'); } + +//留言 +function course_jour_submit(){ + if(jourReplyVerify()){ + jour_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值 + $("#course_feedback_new").submit(); + } +} + +function jourReplyVerify() { + var content = jour_content_editor.html();//$.trim($("#message_content").val()); + if (jour_content_editor.isEmpty()) { + $("#jour_content_span").text("留言不能为空"); + $("#jour_content_span").show(); + $("#jour_content_span").css('color', '#ff0000'); + $("#submit_feedback_user").one('click',function() { + course_jour_submit(); + }); + return false; + } + else { + $("#jour_content_span").text("填写正确"); + $("#jour_content_span").css('color', '#008000'); + return true; + } +} + +function cancel_jour_submit(){ + jour_content_editor.html(""); + $("#jour_content_span").text(""); + $("#jour_content_span").hide(); +} \ No newline at end of file From 39c65fb6ae2a8342013795b6d639427587663a1f Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 16 Jan 2017 16:57:03 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=85=B7=E4=BD=93=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A=E4=BF=A1=E6=81=AF=E9=A1=B5=EF=BC=8C?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=B8=8D=E5=BA=94=E8=AF=A5=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9C=81=E7=95=A5=E5=8F=B7=EF=BC=8C=E5=9B=A0=E4=B8=BA=E5=AE=83?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9C=80=E7=BB=86=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E4=BA=86=EF=BC=8C=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=85=A8=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_homework_post_brief.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/student_work/_homework_post_brief.html.erb b/app/views/student_work/_homework_post_brief.html.erb index 12fba5d71..0419db665 100644 --- a/app/views/student_work/_homework_post_brief.html.erb +++ b/app/views/student_work/_homework_post_brief.html.erb @@ -5,11 +5,10 @@
<%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%>
- <% else%> -

- <%= l(:label_no_data) %> -

+
+

没有数据可以显示!

<% end %> -
-
-
    -
  • - 基本信息 -
  • -
  • - 成员 -
  • -
  • - 组织 -
  • -
  • - 讨论区设置 -
  • -
-
-
-
    - <%= labelled_form_for @course do |f| %> -
  • - <%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %> -
  • -
  • - - <%=@course.syllabus.title %> - <%#= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:210px'} %> - -
  • -
  • - - -
    - -
  • -
    -
  • - - - -
  • -
    -
  • - - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"edit_time"} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"edit_term"} %> -
  • -
    -
  • - - <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"edit_end_time"} %> - <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"edit_end_term"} %> - -
  • -
    - - - - - - -
  • - - id="course_is_public" name="course[is_public]" type="checkbox"> - (选中后对所有用户可见,否则仅对本班级成员可见) -
    -
  • -
  • - - id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> - (选中后对所有用户可见,否则仅对本班级成员可见) -
    -
  • -
  • - - id="course_publish_resource" name="course[publish_resource]" type="checkbox" style="margin-left: 1px;"/> - (选中后允许学生上传班级资源,否则不允许) -
    -
  • -
  • - 提交 - <%= link_to l(:button_cancel), course_path(@course), :class => "grey_btn fl c_white ml10" %> -
    -
  • - <% end %> -
- <% if @course.is_delete == 1 %> -
<%=link_to "恢复该班级", renew_course_path(@course) %>
- <% else %> -
- <%=link_to "删除该班级", course_path(@course), :method => :delete, :confirm=>"确认要删除该班级吗?" %> - (友情提示:删除该班级后如果您想恢复该班级,请联系系统管理员!) -
- <% end %> + }); -
+ function g(o){ + return document.getElementById(o); + } + function HoverLi(n){ +//如果有N个标签,就将i<=N; + for(var i=1;i<=4;i++){ + g('tb_'+i).className='game-setting-nav-nomall'; + g('tbc_0'+i).className='undis'; + } + g('tb_'+n).className='game-setting-nav-hover'; + g('tbc_0'+n).className='game-dis'; + } -
-
- <%= form_tag(search_member_course_path,:id => "course_member_search_form", :method => :get, :class => "search_form_course",:remote => true) do %> - - <%= text_field_tag 'name', params[:name], :placeholder => "登录名、学号、姓名搜索", :class => "search_text fl" %> - - <%= l(:label_search)%> - -
- - <% end %> -
- -
- <%= render :partial => "course_members" %> -
-
- -
- <%= render :partial => 'courses/settings/join_org' %> -
- -
- <%= render :partial => 'courses/settings/boards_setting' %> -
-
-
- - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/courses/settings/_added_orgs.html.erb b/app/views/courses/settings/_added_orgs.html.erb index 9ac783ca0..36ca14043 100644 --- a/app/views/courses/settings/_added_orgs.html.erb +++ b/app/views/courses/settings/_added_orgs.html.erb @@ -1,12 +1,8 @@
    -
  • 名称操作
  • <% orgs.each do |org| %> -
  • - <%= org.name %> - 取消关联 - <%#= link_to "取消关联", org_course_path(:id => OrgCourse.where(:organization_id => org.id, :course_id => course_id).first.id, :course_id => course_id), - :method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %> +
  • + + 取消关联
  • <% end %>
\ No newline at end of file diff --git a/app/views/courses/settings/_boards_setting.html.erb b/app/views/courses/settings/_boards_setting.html.erb index 21115ff6e..90c1f8b46 100644 --- a/app/views/courses/settings/_boards_setting.html.erb +++ b/app/views/courses/settings/_boards_setting.html.erb @@ -1,67 +1,59 @@ <% board = @course.boards.where("parent_id is NULL").first %> -
-
    -
  • 名称
  • -
  • 状态
  • -
  • 类型
  • -
  • 操作
  • -
    -
-
    -
  • 班级讨论区
  • -
  • 默认
  • -
  • 帖子
  • -
  • 添加子栏目
  • -
    - <% count = board.children.count %> - <% board.children.reorder("position asc").each_with_index do |board, i|%> -
      -
    • -
    • - - -
    • -
    • 新增
    • -
    • 帖子
    • -
    • - 编辑 - <%= link_to('删除', {:controller => 'boards', :action => 'destroy', :id => board.id, :course_id => @course.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "linkGrey fr ml5 mr5", :title => l(:button_delete)) %> - <% if i < count - 1 %> - <%= link_to('下移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'down'},:remote => true, :method => 'post', :class => "linkGrey fr ml5 mr5", :title => '下移') %> - <% end %> - <% unless i == 0 %> - <%= link_to('上移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'up'},:remote => true, :method => 'post', :class => "linkGrey fr ml5 mr5", :title => '上移') %> - <% end %> +
      +
      + <%= form_tag url_for(:controller => 'boards', :action => 'create', :course_id => @course.id, :board_id => board.id), :id=> 'add_board_form_subboard',:remote => true do %> +
        +
      • + + + 取消 + 保存
      • + 名称不能为空
      + <% end %> -
    +
+
+ + + + + + + + + + + + + <% count = board.children.count %> + <% board.children.reorder("position asc").each_with_index do |board, i|%> + + + + + <% end %> + +
名称操作
班级讨论区添加子栏目
+ + + + <% unless i == 0 %> + <%= link_to('上移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'up'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '上移') %> + <% end %> + <% if i < count - 1 %> + <%= link_to('下移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'down'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '下移') %> + <% end %> + 编辑 + 删除 +
+
- - - + <% @roles.each do |role| %> +
  • + + <%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role), :id => "edit_member_role_#{member.id}_#{role.id}", + :disabled => member.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?}, :class => "mt6 fl h28" %> +

    <%= zh_course_role(h role) %>

    + +
  • + <% end %> + <%= hidden_field_tag 'membership[role_ids][]', '' %> + + <% end %> + + + <% unless member.user == @course.teacher %> + 编辑 + + + 删除 + <% end %> + + + <% end %> + + + \ No newline at end of file diff --git a/app/views/courses/settings/_edit.html.erb b/app/views/courses/settings/_edit.html.erb new file mode 100644 index 000000000..df1b0e73b --- /dev/null +++ b/app/views/courses/settings/_edit.html.erb @@ -0,0 +1,72 @@ +
      + <%= labelled_form_for @course do |f| %> +
    • + <%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %> +
    • +
    • + + <%=@course.syllabus.title %> + <%#= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:210px'} %> + +
    • +
    • + + +
      + +
    • +
      +
    • 正确示例:软件工程计算机系2016秋季A班
    • +
    • 错误示例:计算机系2016秋季A班
    • +
    • + + + +
    • +
      +
    • + + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"edit_time", :class => "h28 w145 mr8"} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"edit_term", :class => "h28 w145"} %> +
    • +
      +
    • + + <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"edit_end_time", :class => "h28 w145 mr8"} %> + <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"edit_end_term", :class => "h28 w145"} %> + +
    • +
      +
    • + + id="course_is_public" name="course[is_public]" type="checkbox"> + (选中后对所有用户可见,否则仅对本班级成员可见) +
      +
    • +
    • + + id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> + (选中后对所有用户可见,否则仅对本班级成员可见) +
      +
    • +
    • + + id="course_publish_resource" name="course[publish_resource]" type="checkbox" style="margin-left: 1px;"/> + (选中后允许学生上传班级资源,否则不允许) +
      +
    • +
    • + 提交 + <%= link_to l(:button_cancel), course_path(@course), :class => "grey_btn fl c_white ml10" %> +
      +
    • + <% end %> +
    +<% if @course.is_delete == 1 %> +
    <%=link_to "恢复该班级", renew_course_path(@course) %>
    +<% else %> +
    + <%=link_to "删除该班级", course_path(@course), :method => :delete, :confirm=>"确认要删除该班级吗?" %> + (友情提示:删除该班级后如果您想恢复该班级,请联系系统管理员!) +
    +<% end %> diff --git a/app/views/courses/settings/_join_org.html.erb b/app/views/courses/settings/_join_org.html.erb index 2774a6c9a..86d55d145 100644 --- a/app/views/courses/settings/_join_org.html.erb +++ b/app/views/courses/settings/_join_org.html.erb @@ -1,85 +1,84 @@ - - - - - - - <%= stylesheet_link_tag 'css/org' %> -
    -
    - 关联组织 -
    - <%= form_tag url_for(:controller => 'org_courses', :action => 'create', :course_id => @course.id), :id => 'join_orgs_for_course', :remote => true do %> - -
    -
      - 关联 - 取消 - <% end %> -
      -
      -
      - 已关联组织 -
      - <%= render :partial => 'courses/settings/added_orgs', :locals => {:orgs => @course.organizations, :course_id => params[:id]} %> -
      -
      -
      +<% if @orgs_not_in_course.empty? && @course.organizations.empty? %> +
      +

      您没有创建组织,请先 <%=link_to '新建组织', new_organization_path, :class => 'sy_btn_green', :target => '_blank' %>,再关联

      +<% else %> +
      +
      +

      关联组织

      +
      + <%= form_tag url_for(:controller => 'org_courses', :action => 'create', :course_id => @course.id), :id => 'join_orgs_for_course', :remote => true do %> + +
      +
      +
        + 关联 + 取消 + + <% end %> +
        +
        +

        已关联组织

        +
          +
          + <%= render :partial => 'courses/settings/added_orgs', :locals => {:orgs => @course.organizations, :course_id => @course.id} %> +
          +
        +
        -
        -
        - \ No newline at end of file + + $(document).ready(function(){ + $.ajax({ + url: '<%= url_for(:controller => 'courses', :action => 'search_public_orgs_not_in_course') %>'+'?page=1', + type:'get' + }); + }); + function cancel_join_orgs() { + $("#join_orgs_for_course input:checked").attr("checked", false); + } + function course_join_org(courseId) { + $.ajax({ + url: "/org_courses?" + $("#join_orgs_for_course").serialize() + "&course_id=" + courseId, + type: "post", + success: function (data) { + $.ajax({ + url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true&name=" + $("input[name='orgs']").val().trim(), + type: "get" + }); + } + }); + } + + +<% end %> \ No newline at end of file diff --git a/app/views/courses/settings/_member.html.erb b/app/views/courses/settings/_member.html.erb new file mode 100644 index 000000000..5fa67feaa --- /dev/null +++ b/app/views/courses/settings/_member.html.erb @@ -0,0 +1,67 @@ +
        + 添加成员 +
        +
        + <%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %> + +
        + <%= render_principals_for_new_course_members(@course) %> +
        +
        +
          +
        • + +
        • +
        • + +
        • +
        • + +
        • +
        +
        +
        + 取消 + 保存 + <% end %> +
        + +
        + <%= render :partial => 'courses/settings/course_member' %> +
        +
        + + \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index a437ea01f..ca451bd51 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -19,7 +19,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel'%> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%> <%= javascript_include_tag "course","avatars","header","attachments",'prettify' %> <%= yield :header_tags -%> diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 8a6500572..46c4fb392 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -9,12 +9,12 @@ <% end%> <%elsif @course%> <% if @create_member_error_messages%> - alert("<%= @create_member_error_messages%>"); + notice_box("<%= @create_member_error_messages%>"); <% else%> - $('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/settings/member') %>'); $("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>"); $("#student_number").html("<%= studentCount(@course) %>"); - alert("添加成功"); + notice_box("添加成功"); <% end%> hideOnLoad(); <%end%> diff --git a/app/views/members/destroy.js.erb b/app/views/members/destroy.js.erb index b331f15a4..842506de8 100644 --- a/app/views/members/destroy.js.erb +++ b/app/views/members/destroy.js.erb @@ -3,7 +3,7 @@ $("#project_members_number").html("<%= @project.members.count %>"); // $('#tab-content-members').html('<%#= escape_javascript(render :partial => 'projects/settings/members') %>'); <%elsif @course%> - $('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + $('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/settings/member') %>'); $("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>") $("#student_number").html("<%= studentCount(@course) %>"); <%end%> diff --git a/app/views/members/update.js.erb b/app/views/members/update.js.erb index 7c27e39fc..e2442b8dd 100644 --- a/app/views/members/update.js.erb +++ b/app/views/members/update.js.erb @@ -1,7 +1,7 @@ <%if @project%> $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); <%elsif @course%> -$('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); +$('#tbc_02').html('<%= escape_javascript(render :partial => 'courses/settings/member') %>'); $("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>") $("#student_number").html("<%= studentCount(@course) %>"); <%end%> diff --git a/app/views/org_courses/destroy.js.erb b/app/views/org_courses/destroy.js.erb index 9984f6a4c..ad2c1eb0f 100644 --- a/app/views/org_courses/destroy.js.erb +++ b/app/views/org_courses/destroy.js.erb @@ -1,4 +1,4 @@ -$("#added_orgs").html(""); -$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>'); +hideModal(); +$("#tbc_03").html('<%= escape_javascript(render :partial => "courses/settings/join_org") %>'); diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index 9a1b324a2..d79a9a828 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -217,6 +217,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .mt30{ margin-top: 30px;} .mt35 {margin-top:35px;} .mt40{ margin-top: 40px;} +.mt45{ margin-top: 45px;} .mt50{ margin-top:50px;} .mt100{ margin-top:100px;} .mb0 {margin-bottom: 0px !important;} @@ -276,6 +277,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .w270{ width: 270px;} .w280{ width:280px;} .w289{ width:289px !important;} +.w290{ width:290px !important;} .w300{ width:300px !important;} .w305{ width:305px;} .w350 {width:350px;} diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 8c0bbb8f4..29fef34e0 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -605,4 +605,28 @@ a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no- .archive_course_notice em {display:block; border-width:10px; position:absolute;top:26px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;} .archive_course_notice span {display:block; border-width:10px; position:absolute;top:26px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;} -.teacher_member_img{width:50px; height:50px; border: 1px solid #fff;-webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} \ No newline at end of file +.teacher_member_img{width:50px; height:50px; border: 1px solid #fff;-webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} + +/* 设置页的头像更换 */ +.banner-course-avatar { width: 64px; height: 62px; position: relative; overflow: hidden;} +.banner-course-inner { + display: block; + position: absolute; + left: 0; + top: 100%; + width: 100%; + height: 100%; + background: #000; + text-align: center; + opacity: 0.3; + -moz-transition: top ease 200ms; + -o-transition: top ease 200ms; + -webkit-transition: top ease 200ms; + transition: top ease 200ms; +} +a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px; top: 102px; left: 10px; color: #fff;} +.banner-course-avatar:hover .banner-course-inner { top: 0;} +.banner-course-avatar:hover .banner-course-notice { top: 20px;} + +.course_setting_org_fl {width: 49%; border-right: 1px solid #e5e5e5;} +.course_setting_org_fr {width: 49%;} \ No newline at end of file From 4ea2c41188a8b44466d1a471aee140157aab1a87 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Jan 2017 17:30:46 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8-=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=8Ctip=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_evaluation_un_group_member_work.html.erb | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/views/student_work/_evaluation_un_group_member_work.html.erb b/app/views/student_work/_evaluation_un_group_member_work.html.erb index 073e79fc4..d3aa12b86 100644 --- a/app/views/student_work/_evaluation_un_group_member_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_member_work.html.erb @@ -26,9 +26,21 @@
        - - <%= st.teaching_asistant_score.nil? ? "--" : (!score_open ? "**" : format("%.1f",st.teaching_asistant_score))%> - +
        + <% if st.teaching_asistant_score.nil? || !score_open %> + <%=st.teaching_asistant_score.nil? ? "--" : "**" %> + <% else %> + <%= format("%.1f",st.teaching_asistant_score) %> +
        + + + 现共有 +  <%= st.student_works_scores.where(:reviewer_role => 2).group_by(&:user_id).count%>  + 名助教进行了评分,<%=@homework.homework_detail_manual.ta_mode == 1 ? "平均" : "复审" %>分为 +  <%= format("%.1f",st.teaching_asistant_score)%> 分。 +
        + <% end %> +
        <% if @homework.anonymous_comment == 0 %>
        @@ -57,12 +69,14 @@ (<%= anon_count %>) -
        - 现共有 -  <%= anon_count %>  - 名学生进行了匿评,平均分为 -  <%= format("%.1f", st.student_score) %> 分。 -
        +
        + + + 现共有 +  <%= anon_count%>  + 名学生进行了匿评,平均分为 +  <%= format("%.1f",st.student_score)%> 分。 +
        <% end %> <% end %>
        @@ -73,7 +87,7 @@
        <%= score.nil? ? "--" : (!score_open ? "**" : format("%.1f",score<0 ? 0 : score))%> <% unless !score_open || score.nil?%> -
        +
        作品最终评分为 @@ -105,17 +119,10 @@ <% if User.current.allowed_to?(:as_teacher, st.homework_common.course) %>
        评分
        <% end %> - \ No newline at end of file diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 64a685f4a..fccf7a6cf 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -67,6 +67,6 @@ <% end %> <% if show_nav?(0) %>
      • - 统计 + 统计
      • <% end %> \ No newline at end of file diff --git a/app/views/courses/course_statistics.html.erb b/app/views/courses/course_statistics.html.erb new file mode 100644 index 000000000..ce3d65743 --- /dev/null +++ b/app/views/courses/course_statistics.html.erb @@ -0,0 +1,5 @@ +
        +
        +

        统计功能即将上线,届时我们一起享受教育大数据的红利吧!

        +
        +
        \ No newline at end of file diff --git a/app/views/courses/course_statistics.js.erb b/app/views/courses/course_statistics.js.erb new file mode 100644 index 000000000..e79baacb2 --- /dev/null +++ b/app/views/courses/course_statistics.js.erb @@ -0,0 +1,5 @@ +<% if !params[:tab] || params[:tab] == "activity" %> + $("#act_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'act_table')%>"); +<% else %> + +<% end %> \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ca451bd51..2dfc9c96c 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -127,7 +127,7 @@ <% statistics_count = 0 %> <% unless show_nav?(statistics_count) %>
      • - 统计 + 统计
      • <% end %> diff --git a/config/routes.rb b/config/routes.rb index dd49df318..20efb7e21 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1352,7 +1352,7 @@ RedmineApp::Application.routes.draw do get 'search_public_orgs_not_in_course' get "homework_search" get "show_comparecode" - get "statistics_course" + get "course_statistics" get "switch_role" get 'search_not_group_member' post 'add_members' diff --git a/db/schema.rb b/db/schema.rb index f638a653c..74cea0c6b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170111030006) do +ActiveRecord::Schema.define(:version => 20170119084333) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -350,16 +350,14 @@ ActiveRecord::Schema.define(:version => 20170111030006) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" - t.integer "project_id" - t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -630,6 +628,20 @@ ActiveRecord::Schema.define(:version => 20170111030006) do t.integer "container_id", :default => 0 end + create_table "course_class_post", :id => false, :force => true do |t| + t.integer "班级id", :default => 0, :null => false + t.string "班级名" + t.integer "帖子id", :default => 0, :null => false + t.integer "主贴id" + t.string "帖子标题", :default => "", :null => false + t.text "帖子内容" + t.integer "帖子用户id" + t.integer "帖子回复数", :default => 0, :null => false + t.integer "最后回帖id" + t.datetime "发帖时间", :null => false + t.datetime "帖子更新时间", :null => false + end + create_table "course_contributor_scores", :force => true do |t| t.integer "course_id" t.integer "user_id" @@ -657,6 +669,21 @@ ActiveRecord::Schema.define(:version => 20170111030006) do add_index "course_groups", ["course_id"], :name => "index_course_groups_on_course_id" + create_table "course_homework_statistics", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "committed_work_num", :default => 0 + t.integer "un_commit_work_num", :default => 0 + t.integer "late_commit_work_num", :default => 0 + t.integer "absence_evaluation_work_num", :default => 0 + t.integer "un_evaluation_work_num", :default => 0 + t.integer "appeal_num", :default => 0 + t.float "average_score", :default => 0.0 + t.float "total_score", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_infos", :force => true do |t| t.integer "course_id" t.integer "user_id" @@ -804,21 +831,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "delayed_jobs_20161218", :id => false, :force => true do |t| - t.integer "id", :default => 0, :null => false - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -944,11 +956,13 @@ ActiveRecord::Schema.define(:version => 20170111030006) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" + t.integer "question_random", :default => 0 + t.integer "choice_random", :default => 0 end create_table "first_pages", :force => true do |t| @@ -1138,23 +1152,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do t.datetime "updated_at", :null => false end - create_table "ii", :force => true do |t| - t.integer "project_id" - t.string "author_login" - t.string "rep_identifier" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sonar_version", :default => 0 - t.string "path" - t.string "branch" - t.string "language" - t.string "sonar_name" - end - - create_table "innodb_monitor", :id => false, :force => true do |t| - t.integer "a" - end - create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -2082,9 +2079,10 @@ ActiveRecord::Schema.define(:version => 20170111030006) do t.integer "score" t.text "comment" t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "appeal_status", :default => 0 + t.boolean "is_hidden", :default => false end add_index "student_works_scores", ["student_work_id"], :name => "student_work_id" diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index de910c8d7..eb2bd9073 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -629,4 +629,18 @@ a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px; .banner-course-avatar:hover .banner-course-notice { top: 20px;} .course_setting_org_fl {width: 49%; border-right: 1px solid #e5e5e5;} -.course_setting_org_fr {width: 49%;} \ No newline at end of file +.course_setting_org_fr {width: 49%;} + +/*20161222班级统计*/ +.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;} +.t-center{ text-align: center;} +.table-td-w20{ width: 18%;} +.table-td-w10{ width: 10%;} +.table-td-w30{ width: 30%;} +.new_project_title_width {font-size: 14px;color: #666; max-width: 180px;font-weight: normal;white-space: nowrap;overflow: hidden; text-overflow: ellipsis;} +.syllabus_class_property { font-size: 12px; padding: 0 5px;border-radius: 3px;line-height: 14px;} +.syllabus_class_private {color: #ff4a1b;border: 1px solid #ff4a1b;} +.syllabus_class_open { color: #7dd26c; border: 1px solid #7dd26c;} +.st_tips_box_inner{ position: absolute;line-height: 2.0;padding: 5px 10px; white-space: nowrap; background-color: #fff; left:100px; top: -5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);} +.st_tips_box_inner span { display: block; border-width: 10px;position: absolute;top: 15px; left: -18px; border-style: dashed solid dashed dashed;border-color: transparent #fff transparent transparent;font-size: 0;line-height: 0;} +.course_class_users_st_name{ display: inline-block;width:120px; overflow:hidden;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;} diff --git a/public/stylesheets/css/moduel.css b/public/stylesheets/css/moduel.css index ce5761ac7..27812018c 100644 --- a/public/stylesheets/css/moduel.css +++ b/public/stylesheets/css/moduel.css @@ -14,7 +14,7 @@ input.radio-width90{ width: 90px; } .muban_table thead tr{ height:40px; line-height:40px;} .muban_table thead tr th{ border-bottom:1px solid #e5e5e5;} .muban_table tbody tr:hover{ background:#f5f5f5;} -.muban_table tbody tr th{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; font-weight:normal; color:#888;} +.muban_table tbody tr td{ height:40px; border-bottom:1px solid #e5e5e5; font-weight:normal; color:#888;} /*模板icons 20161013byLB*/ .muban_icons_orange{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #ff4a1b;border: 1px solid #ff4a1b;} .muban_icons_blue{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #3b94d6;border: 1px solid #3b94d6;} From 2995c05b0610c5dd45f66034fb19e20a4c89c679 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Jan 2017 11:16:35 +0800 Subject: [PATCH 16/16] =?UTF-8?q?sw=5F1=E7=94=A8=E6=88=B7=E8=AE=BF?= =?UTF-8?q?=E9=97=AE875=E7=8F=AD=E7=BA=A7=E5=8D=B4=E6=8A=A5403?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/members_controller.rb | 4 +++- app/models/member.rb | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index db6aeda94..bb1dc437e 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -352,7 +352,9 @@ class MembersController < ApplicationController role_ids = attrs.delete(:role_ids) if role_ids && role_ids.include?("10") - StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id) + if StudentsForCourse.where(:student_id => @member.user_id, :course_id =>@course.id).blank? + StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id) + end else joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id) joined.each do |join| diff --git a/app/models/member.rb b/app/models/member.rb index bb336e936..2d1a25b74 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -55,6 +55,9 @@ class Member < ActiveRecord::Base if (new_role_ids.include?(7) || new_role_ids.include?(9)) && role_ids.include?(10) member_roles.where("role_id = 10").first.update_column('is_current', 0) end + if ids.include?(10) && !ids.include?(7) && !ids.include?(9) && role_ids.include?(10) + member_roles.where("role_id = 10").first.update_column('is_current', 1) + end # Add new roles if new_role_ids.include?(7) && new_role_ids.include?(10) member_roles << MemberRole.new(:role_id => 7)