From afd02d90a5438419b2b4829aab47c9a61bbbd40c Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 27 Oct 2015 09:58:19 +0800 Subject: [PATCH 01/29] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E7=9A=84=E4=BD=9C=E4=B8=9A=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E4=BD=9C=E4=B8=9A=E9=99=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/new.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 09544d004..072c26185 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -59,6 +59,10 @@
<%= @homework.description.html_safe %>
+
+ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @homework.attachments} %> +
+
From b1284cbf5508d0bab08044bcae8d296d3388559a Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 28 Oct 2015 10:17:45 +0800 Subject: [PATCH 02/29] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=92=8C=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 7 +- app/controllers/student_work_controller.rb | 16 ++-- .../_set_evalutation_att.html.erb | 4 +- .../homework_common/score_rule_set.js.erb | 2 +- .../start_evaluation_set.js.erb | 6 +- .../student_work/_set_score_rule.html.erb | 75 +++---------------- .../_set_score_rule_detail.html.erb | 61 +++++++++++++++ app/views/student_work/set_score_rule.js.erb | 8 ++ app/views/users/_course_homework.html.erb | 17 +++-- .../users/_user_homework_detail.html.erb | 2 +- app/views/users/show.html.erb | 1 + 11 files changed, 112 insertions(+), 87 deletions(-) create mode 100644 app/views/student_work/_set_score_rule_detail.html.erb create mode 100644 app/views/student_work/set_score_rule.js.erb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 7793ef097..55807886b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -217,7 +217,12 @@ class HomeworkCommonController < ApplicationController #评分设置 def score_rule_set - + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] end private diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 529c5ea72..2f828669c 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -456,14 +456,14 @@ class StudentWorkController < ApplicationController student_work.save end end - respond_to do |format| - format.html{ - if params[:student_path] - redirect_to student_work_index_url(:homework => @homework.id) - else - redirect_to user_homeworks_user_path(User.current.id) - end - } + if params[:student_path] + redirect_to student_work_index_url(:homework => @homework.id) + else + @user_activity_id = params[:user_activity_id] + @is_in_course = params[:is_in_course] + respond_to do |format| + format.js + end end end diff --git a/app/views/homework_common/_set_evalutation_att.html.erb b/app/views/homework_common/_set_evalutation_att.html.erb index 01d9351ee..d51713e9a 100644 --- a/app/views/homework_common/_set_evalutation_att.html.erb +++ b/app/views/homework_common/_set_evalutation_att.html.erb @@ -7,7 +7,7 @@ 开启匿评
- <%= calendar_for('evaluation_start_time')%> + <%#= calendar_for('evaluation_start_time')%>

@@ -18,7 +18,7 @@ 关闭匿评
- <%= calendar_for('evaluation_end_time')%> + <%#= calendar_for('evaluation_end_time')%>

diff --git a/app/views/homework_common/score_rule_set.js.erb b/app/views/homework_common/score_rule_set.js.erb index 5ff42dff7..a3afb0c9a 100644 --- a/app/views/homework_common/score_rule_set.js.erb +++ b/app/views/homework_common/score_rule_set.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework, :student_path => false, :user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:remote=>true}) %>'); showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + diff --git a/app/views/homework_common/start_evaluation_set.js.erb b/app/views/homework_common/start_evaluation_set.js.erb index 9d494f908..aac4ecd66 100644 --- a/app/views/homework_common/start_evaluation_set.js.erb +++ b/app/views/homework_common/start_evaluation_set.js.erb @@ -1,6 +1,10 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'homework_common/set_evalutation_att') %>'); +var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); -$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); \ No newline at end of file +$('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); +$(function() { $('#evaluation_start_time').datepicker(datepickerOptions); + $('#evaluation_end_time').datepicker(datepickerOptions); +}); \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb index 508b89a1c..26e3b06cb 100644 --- a/app/views/student_work/_set_score_rule.html.erb +++ b/app/views/student_work/_set_score_rule.html.erb @@ -1,66 +1,9 @@ -<%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id},:method => "post") do |f|%> - <% if student_path %> - <%=hidden_field_tag 'student_path', params[:student_path], :value => student_path %> - <% end %> -
- 评分设置 -
- 迟交扣分 - -
-
- 缺评扣分 - -
- - <% if homework.homework_type == 2%> -
- 系统评分 - <%= select_tag :sy_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "markPercentage"} %> -
- - - <% else%> - - <% end%> - -
- 教辅评分 - <%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> -
-
- 学生匿评 - -
-
- 教师优先 - /> - 教师评分为最终评分 -
-
-
- 确定 -
-
- 取消 -
-
-
-
-<% end%> +<% if student_path%> + <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:student_path => student_path},:method => "post") do |f|%> + <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> + <% end%> +<% else %> + <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course},:method => "post",:remote => true) do |f|%> + <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> + <% end%> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule_detail.html.erb b/app/views/student_work/_set_score_rule_detail.html.erb new file mode 100644 index 000000000..f49bb2c69 --- /dev/null +++ b/app/views/student_work/_set_score_rule_detail.html.erb @@ -0,0 +1,61 @@ +
+ 评分设置 +
+ 迟交扣分 + +
+
+ 缺评扣分 + +
+ + <% if homework.homework_type == 2%> +
+ 系统评分 + <%= select_tag :sy_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "markPercentage"} %> +
+ + + <% else%> + + <% end%> + +
+ 教辅评分 + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> +
+
+ 学生匿评 + +
+
+ 教师优先 + /> + 教师评分为最终评分 +
+
+
+ 确定 +
+
+ 取消 +
+
+
+
\ No newline at end of file diff --git a/app/views/student_work/set_score_rule.js.erb b/app/views/student_work/set_score_rule.js.erb new file mode 100644 index 000000000..ff3a0e7ed --- /dev/null +++ b/app/views/student_work/set_score_rule.js.erb @@ -0,0 +1,8 @@ +clickCanel(); +<% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else %> + $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 70494192d..aa0344800 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -56,28 +56,31 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %>
- <%# if is_teacher%> - + <% end%>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 4570f365c..25f14ab31 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -69,7 +69,7 @@ <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
  • - <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) %> + <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course),:class => "postOptionLink", :remote => true) %>
  • <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true) if homework_common.homework_detail_manual.comment_status == 1%> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index fc87bd3a0..2805c4379 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,3 +1,4 @@ +
    最新动态
    From bd350536eb9911c2cd0120677f01e82177ee6c28 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 28 Oct 2015 10:30:31 +0800 Subject: [PATCH 03/29] =?UTF-8?q?=E5=BC=B9=E5=87=BA=E2=80=9C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=AF=BE=E7=A8=8B=E2=80=9D=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=E5=90=8E=E9=9A=90=E8=97=8F"=E5=8A=A0=E5=85=A5/=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E8=AF=BE=E7=A8=8B"=E7=9A=84=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/join_private_courses.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/courses/join_private_courses.js.erb b/app/views/courses/join_private_courses.js.erb index 8a1680030..0c44770bd 100644 --- a/app/views/courses/join_private_courses.js.erb +++ b/app/views/courses/join_private_courses.js.erb @@ -1,3 +1,4 @@ +$('#topnav_course_menu').hide(); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>'); showModal('ajax-modal', '540px'); $('#ajax-modal').css('height','390px'); From 788e900d4afa91882fa9801116c70fc7dab0d50f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 28 Oct 2015 10:58:37 +0800 Subject: [PATCH 04/29] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=8D=9A=E5=AE=A2?= =?UTF-8?q?=E5=8F=91=E5=8D=9A=E6=96=87=E4=B9=9F=E8=A6=81=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8A=A8=E6=80=81=20=E4=B8=AA=E4=BA=BA=E5=8D=9A=E5=AE=A2=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=AE=BE=E7=BD=AE=E8=8F=9C=E5=8D=95=E8=A6=81?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=9C=A8=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=8F=B3=E4=B8=8A=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 3 + app/controllers/users_controller.rb | 13 ++- app/models/blog_comment.rb | 28 ++++- app/views/blog_comments/reply.js.erb | 7 +- app/views/blogs/_article.html.erb | 33 +++++- app/views/users/_user_activities.html.erb | 7 ++ app/views/users/_user_blog.html.erb | 119 ++++++++++++++++++++ 7 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 app/views/users/_user_blog.html.erb diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 95790a68d..f9cb3c3ad 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -89,6 +89,9 @@ class BlogCommentsController < ApplicationController #回复 def reply + if params[:in_user_center] + @in_user_center = true + end @article = BlogComment.find(params[:id]).root @quote = params[:quote][:quote] @blogComment = BlogComment.new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6d049783e..175c8ce51 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -949,10 +949,19 @@ class UsersController < ApplicationController when "current_user" @user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10) else - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) + blog_ids = "("+@user.blog.id.to_s+","+User.watched_by(@user.id).map{|u| u.blog.id}.join(',')+")" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) end else - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) + # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) + blog_ids = "("+@user.blog.id.to_s+","+User.watched_by(@user.id).map{|u| u.blog.id}.join(',')+")" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) end # @user_activities = paginateHelper @user_activities,500 @type = params[:type] diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 92970b663..9bb28ddd8 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -7,7 +7,8 @@ class BlogComment < ActiveRecord::Base acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" acts_as_attachable belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' - + # 虚拟关联 + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act acts_as_watchable validates_presence_of :title, :content @@ -15,6 +16,31 @@ class BlogComment < ActiveRecord::Base #validate :cannot_reply_to_locked_comment, :on => :create safe_attributes 'title', 'content',"sticky", "locked" + after_save :add_user_activity + before_destroy :destroy_user_activity + + #在个人动态里面增加当前动态 + def add_user_activity + if self.parent_id.nil? #只有发博文才插入动态 + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Blog" + user_activity.container_id = self.blog_id + user_activity.user_id = self.author_id + user_activity.save + end + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end def deleted_attach_able_by? user (user && user.logged? && (self.author == user) ) || user.admin? end diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index 7ebe4d077..f8ed4bb24 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -1,2 +1,7 @@ +<% if @in_user_center%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 943d21852..33a3201c0 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,10 +1,36 @@ -
    -
    +
    +
    <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
    -
    + <% if activity.author.id == User.current.id%> + + <%end%> +
    <% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% else %> @@ -13,6 +39,7 @@ TO <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
    +
  • <%= time_tag(ma.created_at).html_safe %>
  • From ac82910aa5f30c6084270b75d8df2cf04cb033a3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 29 Oct 2015 11:53:52 +0800 Subject: [PATCH 20/29] =?UTF-8?q?=E5=A4=A7=E7=BA=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 21 +++++++++++++++ app/models/blog_comment.rb | 9 +++++++ .../courses/_course_outlines_list.html.erb | 27 +++++++++++-------- app/views/courses/course_outline.js.erb | 2 +- app/views/courses/set_course_outline.js.erb | 1 + app/views/layouts/base_courses.html.erb | 27 ++++++++++++++++--- config/routes.rb | 1 + 7 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 app/views/courses/set_course_outline.js.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1113de159..1216599a1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -713,7 +713,28 @@ class CoursesController < ApplicationController #从课程创建的老师那里选择课程大纲 def course_outline + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles + respond_to do |format| + format.js + end + end + + #根据关键字搜索,查找方法一样的,但返回内容不一样 + def search_course_outline + @article_title = params[:title] + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles.like(@article_title) + render :json=>@blog_articles.to_json + end + #设置或者更改课程的大纲 + def set_course_outline + @course.outline = params[:outline_id] + @course.save + respond_to do |format| + format.js + end end #删除课程 diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 9bb28ddd8..27da33121 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -19,6 +19,15 @@ class BlogComment < ActiveRecord::Base after_save :add_user_activity before_destroy :destroy_user_activity + scope :like, lambda {|arg| + if arg.blank? + where(nil) + else + pattern = "%#{arg.to_s.strip.downcase}%" + where(" LOWER(title) LIKE :p ", :p => pattern) + end + } + #在个人动态里面增加当前动态 def add_user_activity if self.parent_id.nil? #只有发博文才插入动态 diff --git a/app/views/courses/_course_outlines_list.html.erb b/app/views/courses/_course_outlines_list.html.erb index cb7c52cfb..b8a8bfd2a 100644 --- a/app/views/courses/_course_outlines_list.html.erb +++ b/app/views/courses/_course_outlines_list.html.erb @@ -8,19 +8,24 @@ - + + <%= form_tag(url_for(:controller=>'courses',:action=>'set_course_outline',:id=>course.id),:method=>'post',:remote=>'true') do %>
    -
      -
    • - -
    • -
    • 博客一
    • -
    -
    发布时间:2015-05-11
    - + <% unless articles.blank? %> + <% articles.each do |article|%> +
      +
    • + +
    • +
    • <%= article.title%>
    • +
    +
    发布时间:<%= format_date(article.created_at)%>
    + <% end %> + <% end %>
    +<% end %> diff --git a/app/views/courses/course_outline.js.erb b/app/views/courses/course_outline.js.erb index 300ba6466..f747661b8 100644 --- a/app/views/courses/course_outline.js.erb +++ b/app/views/courses/course_outline.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list') %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list',:locals => {:articles=>@blog_articles,:course=>@course}) %>'); showModal('ajax-modal', '300px'); //$('#ajax-modal').css('height','250px'); $('#ajax-modal').css('padding-top','0px'); diff --git a/app/views/courses/set_course_outline.js.erb b/app/views/courses/set_course_outline.js.erb new file mode 100644 index 000000000..ad3b78189 --- /dev/null +++ b/app/views/courses/set_course_outline.js.erb @@ -0,0 +1 @@ +hideModal(); \ 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 4e9868efe..43f754097 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -63,7 +63,7 @@ <%= l(:field_is_private)%>
    <% end %> - <%if @course.tea_id == User.current.id && @course.outline == 0%> + <%if @course.tea_id == User.current.id %> 设置大纲 @@ -172,6 +172,7 @@ <%= call_hook :view_layouts_base_body_bottom %> @@ -40,7 +33,7 @@ <%= text_field_tag 'course_password', nil, :style=>'width:300px;'%>
    - + 确  定 From 16206d8c0aa6adb1db3fb744935881174dc09557 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 29 Oct 2015 16:48:54 +0800 Subject: [PATCH 26/29] =?UTF-8?q?=E9=9A=90=E8=97=8F=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E9=97=AD/=E5=BC=80=E5=90=AF=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/helpers/courses_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f9fb31969..a5acc4523 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -628,10 +628,10 @@ module CoursesHelper #重启、关闭课程按钮 def set_course_time course - id = "finish_course_#{course.id}" - linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) - desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed) - link_to "#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a" + # id = "finish_course_#{course.id}" + # linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) + # desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed) + # link_to "#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a" end #加入课程、退出课程按钮 From 578bb2537dfa47ede7771b404af7aa0294a59521 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 29 Oct 2015 17:09:03 +0800 Subject: [PATCH 27/29] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=A4=A7=E7=BA=B2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 24 ++- app/controllers/courses_controller.rb | 7 + .../_simple_ke_reply_form.html.erb | 3 + app/views/blog_comments/quote.js.erb | 2 +- app/views/courses/set_course_outline.js.erb | 6 +- .../courses/show_course_outline.html.erb | 160 ++++++++++++++++++ app/views/layouts/base_courses.html.erb | 50 ++++-- config/routes.rb | 1 + public/stylesheets/courses.css | 9 + 9 files changed, 243 insertions(+), 19 deletions(-) create mode 100644 app/views/courses/show_course_outline.html.erb diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 14a0a3536..42f1e2f20 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -60,10 +60,16 @@ class BlogCommentsController < ApplicationController @article.children.delete @article.delete redirect_to user_blogs_path(:user_id=>User.current) - else - root = @article.root - @article.delete - redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + else#如果是回复被删, + if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + @article.delete + redirect_to show_course_outline_course_path(:id=>params[:course_id]) + else + root = @article.root + @article.delete + redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + end + end end @@ -81,6 +87,7 @@ class BlogCommentsController < ApplicationController @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " @temp = BlogComment.new + @course_id = params[:course_id] @temp.content = "
    #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}
    #{@blogComment.content.html_safe}
    ".html_safe respond_to do | format| format.js @@ -114,7 +121,14 @@ class BlogCommentsController < ApplicationController #@article.save # redirect_to user_blogs_path(:user_id=>params[:user_id]) respond_to do |format| - format.html { redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)} + format.html { + if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + redirect_to show_course_outline_course_path(:id=>params[:course_id]) + else + redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article) + end + + } format.js end rescue Exception => e #如果上面的代码执行发生异常就捕获 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1216599a1..3c211b361 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -737,6 +737,13 @@ class CoursesController < ApplicationController end end + #显示课程大纲 + def show_course_outline + @article = BlogComment.find(@course.outline) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end #删除课程 #删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到 def destroy diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb index fa7ff0c4a..d65dd3faa 100644 --- a/app/views/blog_comments/_simple_ke_reply_form.html.erb +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -17,6 +17,9 @@
    <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + <% if course_id%> + + <% end %>
    diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb index 4d16745ca..088b2cf67 100644 --- a/app/views/blog_comments/quote.js.erb +++ b/app/views/blog_comments/quote.js.erb @@ -1,5 +1,5 @@ if($("#reply_message_<%= @blogComment.id%>").length > 0) { - $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject}) %>"); + $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'blog_comments/simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject,:course_id=>@course_id}) %>"); $(function(){ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); diff --git a/app/views/courses/set_course_outline.js.erb b/app/views/courses/set_course_outline.js.erb index ad3b78189..febcb0b1f 100644 --- a/app/views/courses/set_course_outline.js.erb +++ b/app/views/courses/set_course_outline.js.erb @@ -1 +1,5 @@ -hideModal(); \ No newline at end of file +hideModal(); +<%if @course.tea_id == User.current.id && @course.outline == 0 %> +<% else %> + $("#course_outline_bar").html('
    ') +<%end %> diff --git a/app/views/courses/show_course_outline.html.erb b/app/views/courses/show_course_outline.html.erb new file mode 100644 index 000000000..ff503d983 --- /dev/null +++ b/app/views/courses/show_course_outline.html.erb @@ -0,0 +1,160 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> +
    +
    + <% if @article.author.id == User.current.id%> + + + + + + + [设置大纲] + + <%end%> + +
    + +
    + <% if @article.try(:author).try(:realname) == ' ' %> + <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @article.created_on)%>
    +
    +
    + <%= @article.content.html_safe%> +
    +
    +
    + <%#= link_to_attachments_course @topic, :author => false %> + <% if @article.attachments.any?%> + <% options = {:author => true, :deletable => false} %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> + <% end %> +
    +
    +
    +
    +
    + <% count=0 %> + <% if @article.parent %> + <% count=@article.parent.children.count%> + <% else %> + <% count=@article.children.count%> + <% end %> +
    + <% unless count == 0 %> +
    +
    回复(<%=count %>)
    +
    + +
    +
    + <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@article.locked? && User.current.logged?%> +
    + +
    +
    + <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + + <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% 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 43f754097..d7e7bba90 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -54,21 +54,47 @@
    + + + + + + + + + + + + + + + + + + +
    - - <%= @course.name %> - - <% if @course.is_public == 0%> - + +
    + + <%= @course.name %> + + <% if @course.is_public == 0%> + + <%= l(:field_is_private)%> - <% end %> - <%if @course.tea_id == User.current.id %> - - 设置大纲 - - <% end %> -
    + <% end %> + + <%if @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %> + + <% elsif @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%> + + <% elsif @course.tea_id != User.current.id %> + <%end %> + +
    +
    <%= l(:label_account_identity_teacher)%>(<%= course_teacher_link teacher_num %>) diff --git a/config/routes.rb b/config/routes.rb index 3811bd43f..5be734dee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -792,6 +792,7 @@ RedmineApp::Application.routes.draw do get 'course_outline' post 'search_course_outline' post 'set_course_outline' + get 'show_course_outline' end collection do match 'join_private_courses', :via => [:get, :post] diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 9fe75db34..744f1e07a 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1099,3 +1099,12 @@ a.postRouteLink:hover {text-decoration:underline;} .blogRow {width:280px; height:15px; line-height:15px;} .blogSearchBox {border:1px solid #e6e6e6; height:25px; background-color:#ffffff; margin-top:8px; margin-bottom:8px;}/*width:280px;*/ .blogSearchContent {border:none; outline:none; background-color:#ffffff; width:216px; height:25px; padding-left:10px; display:inline-block; float:left;} + +/*课程大纲图标样式20151028Tim*/ +.syllabusIcon {background:url("../images/course/syllabus.png") 0px 0px no-repeat; width: 17px; height: 16px; display: inline-block;} +.syllabusSetting {background:url("../images/course/syllabus.png") 0px -16px no-repeat; width: 20px; height: 16px; display: inline-block;} + +.syllabusSettingIcon {background:url(../images/course/syllabus_setting.png) 0px 0px no-repeat; width:20px; height:20px;} +.syllabusSettingIcon:hover {cursor: pointer} + +.pic_files{display:block; background:url(../images/public_icon.png) 0px -578px no-repeat; width:20px; height:15px;} From 070166e7c7e0b7cce7d2fd8eb28b787231060288 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 29 Oct 2015 17:26:37 +0800 Subject: [PATCH 28/29] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=82=B9=E5=87=BB=E9=80=80=E5=87=BA=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=8C=E6=89=A7=E8=A1=8C=E6=93=8D=E4=BD=9C=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=88=B7=E6=96=B0=E5=BD=93=E5=89=8D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E9=80=80=E5=87=BA=E5=8F=98=E6=88=90=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_set_join.js.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index 33caf5273..dbdf3d7f3 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -23,4 +23,6 @@ <% else %> alert("未知错误,请稍后再试"); <% end %> +<% else %> + location.reload(); <% end %> From 57f37acecc449522542e156bfbdec5a9b6026d27 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 29 Oct 2015 17:28:23 +0800 Subject: [PATCH 29/29] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=83=85=E5=86=B5?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=20=E6=8F=90=E4=BA=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 4 ++- app/views/repositories/_revisions.html.erb | 30 +++++++++++----------- app/views/repositories/show.html.erb | 10 +------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 72314cad9..f41dbe6c7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -283,7 +283,9 @@ update def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry - @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) + g = Gitlab.client + @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") + #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) render :layout => 'base_projects' diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 3da718484..fe60f8933 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -1,35 +1,35 @@ - <%= form_tag( {:controller => 'repositories', :action => 'diff', :id => project, :repository_id => @repository.identifier_param, :path => to_path_param(path)}, :method => :get ) do %> - - - - - - - - + + + + + + + + <% show_diff = revisions.size > 1 %> <% line_num = 1 %> <% revisions.each do |changeset| %> - - - - - + + + + + <% line_num += 1 %> <% end %>
    #<%= l(:label_date) %><%= l(:field_author) %><%= l(:field_comments) %>
    <%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked',true);") if show_diff && (line_num < revisions.size) %><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %><%= format_time(changeset.committed_on) %><%= h truncate(changeset.author.to_s, :length => 30) %><%= textilizable(truncate_at_line_break(changeset.comments)) %><%= h truncate(changeset.id.to_s, :length => 20) %><%= format_time(changeset.created_at) %><%= h truncate(changeset.author_name.to_s, :length => 30) %><%= textilizable(truncate_at_line_break(changeset.message)) %>

    - <%= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %> + <%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>

    + <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 132d915f2..7f9f675d2 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -59,15 +59,7 @@ <%= render_properties(@properties) %> -<% if authorize_for('repositories', 'revisions') %> - <% if @changesets && !@changesets.empty? %> - <% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) - sep = '' %> - <% if @repository.supports_all_revisions? && @path.blank? %> - <%= link_to l(:label_view_all_revisions_commits), :action => 'revisions', :id => @project, :repository_id => @repository.identifier_param %> - <% end %> | - <% end %> -<% end %> + 如何提交代码 <% content_for :header_tags do %>