- if
+
错误信息:
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index a1f328721..6fbc00be0 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -55,9 +55,9 @@
:
<% if @homework.homework_type == 2%>
- <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => "// 这是一个C语言的样例程序\n// 功能:输入两个整数,输出两者之和\n// 测试:老师可以给出以下测试集:\n// 输入1和2,输出3\n// 输入3和4,输出7\n// 那么下面这段代码将得到满分\n\n// 注意:编程作业采用命令行传参方式\n// 程序的所有输入都通过argv传入\n// 否则您的程序将被判错\n\n#include //引用必须头文件\n\nint main(int argc, char** argv) {\n\tint a = atoi(argv[1]); //将第一个输入转成整型\n\tint b = atoi(argv[2]); //将第二个输入转换为整型\n\tprintf('%d',a+b); //输出a+b\n\treturn 0;\n}"%>
+ <%= f.text_area "description", :class => "w620 hwork_txt h350", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => stantard_code%>
<% else %>
- <%= f.text_area "description", :class => "w620 hwork_txt h350", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
+ <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
<% end%>
From ba84e19048648813cd5350e6ccc4b5458f357686 Mon Sep 17 00:00:00 2001
From: huang
Date: Tue, 4 Aug 2015 17:06:19 +0800
Subject: [PATCH 15/31] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=BA=95=E9=83=A8?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/_base_footer_public.html.erb | 10 ++++++----
app/views/layouts/base_courses.html.erb | 2 +-
app/views/layouts/base_projects.html.erb | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/views/layouts/_base_footer_public.html.erb b/app/views/layouts/_base_footer_public.html.erb
index d4fc3e7e5..dba26f1f6 100644
--- a/app/views/layouts/_base_footer_public.html.erb
+++ b/app/views/layouts/_base_footer_public.html.erb
@@ -6,10 +6,12 @@
<%= l(:label_recruitment_information)%> |
<%= l(:label_surpport_group)%> |
<%= l(:label_forums)%> |
- <%= l(:label_language)%>
- 中文
- 英文
-
+ <%= l(:label_language)%>
+
+ 中文
+ 英文
+
+
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index fb29439a8..7a32cb67d 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -180,7 +180,7 @@
- <%= render :partial => 'layouts/base_footer_public' %>
+ <%= render :partial => 'layouts/new_footer' %>
<%= render :partial => 'layouts/new_feedback' %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 74b876391..74c13cc8e 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -173,7 +173,7 @@
- <%= render :partial => 'layouts/base_footer_public'%>
+ <%= render :partial => 'layouts/new_footer'%>
From 69adc98fe4e7a23134b9f304df9f4b4d10733ae8 Mon Sep 17 00:00:00 2001
From: huang
Date: Tue, 4 Aug 2015 17:26:03 +0800
Subject: [PATCH 16/31] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?=
=?UTF-8?q?=E5=B7=A6=E4=BE=A7=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=AD=A3=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/base_users_new.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb
index 18d0a1f5b..0513f49ce 100644
--- a/app/views/layouts/base_users_new.html.erb
+++ b/app/views/layouts/base_users_new.html.erb
@@ -169,7 +169,7 @@
-
diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css
index 78538c07f..7389dff8a 100644
--- a/public/stylesheets/public_new.css
+++ b/public/stylesheets/public_new.css
@@ -436,12 +436,12 @@ a:hover.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;}
div.ke-statusbar{height:1px; border-top:none;}
/*底部*/
-#Footer{background-color:#ffffff; margin-bottom:10px; padding-bottom:15px; color:#666666;}
-.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}
-.footerAbout{ width:585px; margin:0 auto;height:35px; line-height:35px; border-bottom:1px solid #efefef; }
-.languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;}
-.departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;}
-.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}
-a.f_grey {color:#666666;}
-a.f_grey:hover {color:#000000;}
+/*#Footer{background-color:#ffffff; margin-bottom:10px; padding-bottom:15px; color:#666666;}*/
+/*.footerAboutContainer {width:auto; border-bottom:1px solid #efefef;}*/
+/*.footerAbout{ width:585px; margin:0 auto;height:35px; line-height:35px; border-bottom:1px solid #efefef; }*/
+/*.languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;}*/
+/*.departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;}*/
+/*.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}*/
+/*a.f_grey {color:#666666;}*/
+/*a.f_grey:hover {color:#000000;}*/
From bc6b6b05364848102caaf98c2d038b84dda01339 Mon Sep 17 00:00:00 2001
From: huang
Date: Tue, 4 Aug 2015 18:24:06 +0800
Subject: [PATCH 20/31] =?UTF-8?q?=E5=BA=95=E9=83=A8=E5=9B=BD=E9=99=85?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/locales/zh.yml | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index b40359f46..c47976275 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -2058,22 +2058,22 @@ zh:
lable_unset: 未设置
label_chose_group: 请选择分班
- label_hosted_organization: 主办单位
- label_hosted_by: 国防科学技术大学并行与分布处理国家重点实验室
- label_sponsor: 计算机科学与技术系
- label_partners: 合作单位
- label_co_organizer_NUDT: 国防科学技术大学计算机学院
- label_co_organizer_EECS: 北京大学
- label_co_organizer_BHU: 北京航空航天大学
- label_co_organizer_CAS: 中国科学院软件研究所
- label_co_organizer_InforS: 中创软件
- label_rights_reserved: Copyright 2007~2015, All Rights Riserved
- label_about_us: 关于我们
- label_contact_us: 联系我们
- label_recruitment_information: 招聘信息
- label_surpport_group: 帮助中心
- label_forums: 论坛反馈
- label_language: 语言
- label_license: 湘ICP备09019772
+# label_hosted_organization: 主办单位
+# label_hosted_by: 国防科学技术大学并行与分布处理国家重点实验室
+# label_sponsor: 计算机科学与技术系
+# label_partners: 合作单位
+# label_co_organizer_NUDT: 国防科学技术大学计算机学院
+# label_co_organizer_EECS: 北京大学
+# label_co_organizer_BHU: 北京航空航天大学
+# label_co_organizer_CAS: 中国科学院软件研究所
+# label_co_organizer_InforS: 中创软件
+# label_rights_reserved: Copyright 2007~2015, All Rights Riserved
+# label_about_us: 关于我们
+# label_contact_us: 联系我们
+# label_recruitment_information: 招聘信息
+# label_surpport_group: 帮助中心
+# label_forums: 论坛反馈
+# label_language: 语言
+# label_license: 湘ICP备09019772
From 5d82f3336e9a0392dc5990c04704dc7e5f2923b8 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Mon, 10 Aug 2015 09:12:26 +0800
Subject: [PATCH 21/31] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E8=80=85?=
=?UTF-8?q?=E6=98=AF=E6=88=91=EF=BC=8C=E4=BD=86=E6=98=AF=E9=97=AE=E5=8D=B7?=
=?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=BB=96=E8=AF=BE=E7=A8=8B=E9=87=8C=E7=9A=84?=
=?UTF-8?q?=E9=97=AE=E5=8D=B7=EF=BC=8C=E5=8F=AF=E4=BB=A5=E5=A4=9A=E9=80=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/poll_controller.rb | 62 ++++++++++++++++++++++++++++++
app/helpers/poll_helper.rb | 9 +++++
app/views/poll/_poll.html.erb | 1 +
app/views/poll/_poll_list.html.erb | 14 ++-----
app/views/poll/index.html.erb | 5 +++
config/routes.rb | 3 ++
public/stylesheets/polls.css | 2 +-
7 files changed, 85 insertions(+), 11 deletions(-)
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index dda5b81b2..b376a9acd 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -410,6 +410,68 @@ class PollController < ApplicationController
end
end
+ # 将其他地方的问卷导出来
+ def other_poll
+ # 查作者是我,且不在当前课程内的问卷 进行导入
+ @polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
+ @polls_group_id = params[:polls_group_id]
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ # 将问卷导入本课程
+ def import_other_poll
+ course_id = params[:course_id]
+ @course = Course.find(course_id)
+ params[:polls].each_with_index do |p,i|
+ poll = Poll.find(p)
+ option = {
+ :polls_name => poll.polls_name,
+ :polls_type => 'Course',
+ :polls_group_id => course_id,
+ :polls_status => 1,
+ :user_id => User.current.id,
+ :published_at => Time.now,
+ :closed_at => Time.now,
+ :show_result => 1,
+ :polls_description => poll.polls_description
+ }
+ @poll = Poll.create option
+
+ poll.poll_questions.each do | q|
+ #question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
+ option = {
+ :is_necessary => q[:is_necessary],
+ :question_title => q[:question_title],
+ :question_type => q[:question_type] || 1,
+ :question_number => q[:question_number]
+ }
+ @poll_questions = @poll.poll_questions.new option
+
+ for i in 1..q.poll_answers.count
+ answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text]
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ @poll_questions.poll_answers.new question_option
+ end
+ end
+ @poll.save
+ end
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course)
+ if @is_teacher
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
+ else
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
+ end
+ @polls = paginateHelper polls,20 #分页
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_poll_and_course
@poll = Poll.find params[:id]
diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb
index 3156f1b3a..0baad37ee 100644
--- a/app/helpers/poll_helper.rb
+++ b/app/helpers/poll_helper.rb
@@ -74,4 +74,13 @@ module PollHelper
end
end
+ #带勾选框的问卷列表
+ def poll_check_box_tags(name,polls,current_poll)
+ s = ''
+ polls.each do |poll|
+ s << "#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name} [#{ h Course.find(poll.polls_group_id).name}] "
+ end
+ s.html_safe
+ end
+
end
\ No newline at end of file
diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb
index 180fed0f0..b4d944220 100644
--- a/app/views/poll/_poll.html.erb
+++ b/app/views/poll/_poll.html.erb
@@ -41,6 +41,7 @@
导出
<% elsif poll.polls_status == 2 || poll.polls_status == 3 %>
<%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%>
+
<% end%>
diff --git a/app/views/poll/_poll_list.html.erb b/app/views/poll/_poll_list.html.erb
index becfc32a5..fb8b765a3 100644
--- a/app/views/poll/_poll_list.html.erb
+++ b/app/views/poll/_poll_list.html.erb
@@ -3,20 +3,14 @@
(<%= @obj_count%>)
<% if @is_teacher%>
+ <%= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%>
<%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %>
<% end%>
-
- <% @polls.each do |poll|%>
-
- <%= render :partial => 'poll', :locals => {:poll => poll} %>
-
-
- <% end%>
+
+
+ <%= render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count} %>
-
- <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
-
\ No newline at end of file
diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb
index bede915b4..92a42cbac 100644
--- a/app/views/poll/index.html.erb
+++ b/app/views/poll/index.html.erb
@@ -80,6 +80,11 @@
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
+
+ function closeModal()
+ {
+ hideModal($("#popbox_upload"));
+ }
<%= render :partial => 'poll_list'%>
diff --git a/config/routes.rb b/config/routes.rb
index 5af5ea3d7..9a14b4599 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -83,10 +83,13 @@ RedmineApp::Application.routes.draw do
get 'close_poll'
get 'export_poll'
get 'import_poll'
+
end
collection do
delete 'delete_poll_question'
post 'update_poll_question'
+ get 'other_poll'
+ post 'import_other_poll'
end
end
diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css
index 83fa5089b..97faa0f57 100644
--- a/public/stylesheets/polls.css
+++ b/public/stylesheets/polls.css
@@ -130,7 +130,7 @@ a:hover.btn_de{ background:#ff5d31;}
a.btn_pu{ border:1px solid #3cb761; color:#3cb761; }
a:hover.btn_pu{ background:#3cb761;}
.pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; height:19px; padding-top:3px; }
-.polls_title_w { width:300px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
+.polls_title_w { width:280px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.polls_title_st { max-width:530px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.polls_de_grey{ color:#b1b1b1; margin-top:3px;}
.ml5{ margin-left:5px;}
From 44f22feefd93b3e85745724bdb9cf950b74cd179 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Mon, 10 Aug 2015 09:13:38 +0800
Subject: [PATCH 22/31] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E8=80=85?=
=?UTF-8?q?=E6=98=AF=E6=88=91=EF=BC=8C=E4=BD=86=E6=98=AF=E9=97=AE=E5=8D=B7?=
=?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=BB=96=E8=AF=BE=E7=A8=8B=E9=87=8C=E7=9A=84?=
=?UTF-8?q?=E9=97=AE=E5=8D=B7=EF=BC=8C=E5=8F=AF=E4=BB=A5=E5=A4=9A=E9=80=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/poll/_other_poll.html.erb | 27 +++++++++++++++++++++++++
app/views/poll/_polls_list.html.erb | 10 +++++++++
app/views/poll/import_other_poll.js.erb | 1 +
app/views/poll/other_poll.js.erb | 9 +++++++++
4 files changed, 47 insertions(+)
create mode 100644 app/views/poll/_other_poll.html.erb
create mode 100644 app/views/poll/_polls_list.html.erb
create mode 100644 app/views/poll/import_other_poll.js.erb
create mode 100644 app/views/poll/other_poll.js.erb
diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb
new file mode 100644
index 000000000..c899f0d47
--- /dev/null
+++ b/app/views/poll/_other_poll.html.erb
@@ -0,0 +1,27 @@
+
+
+
将以下问卷导入本课程
+
+
+ <%= form_tag import_other_poll_poll_index_path,
+ method: :post,
+ remote: true,
+ id: "relation_file_form" do %>
+
+ <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%>
+
导 入
+
取 消
+ <% end -%>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/poll/_polls_list.html.erb b/app/views/poll/_polls_list.html.erb
new file mode 100644
index 000000000..c096f396d
--- /dev/null
+++ b/app/views/poll/_polls_list.html.erb
@@ -0,0 +1,10 @@
+<% polls.each do |poll|%>
+
+ <%= render :partial => 'poll', :locals => {:poll => poll} %>
+
+
+<% end%>
+
+
+ <%= pagination_links_full obj_pages, obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
\ No newline at end of file
diff --git a/app/views/poll/import_other_poll.js.erb b/app/views/poll/import_other_poll.js.erb
new file mode 100644
index 000000000..f60cea1c5
--- /dev/null
+++ b/app/views/poll/import_other_poll.js.erb
@@ -0,0 +1 @@
+$('#polls_list').html('<%= escape_javascript(render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count}) %>
');
\ No newline at end of file
diff --git a/app/views/poll/other_poll.js.erb b/app/views/poll/other_poll.js.erb
new file mode 100644
index 000000000..34f53b73e
--- /dev/null
+++ b/app/views/poll/other_poll.js.erb
@@ -0,0 +1,9 @@
+
+$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>');
+
+
+showModal('ajax-modal', '513px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("
");
+$('#ajax-modal').parent().css("top","").css("left","");
+$('#ajax-modal').parent().addClass("popbox_polls");
\ No newline at end of file
From a282d8155199abc66ae6cdc28372a999d7253311 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Mon, 10 Aug 2015 15:31:23 +0800
Subject: [PATCH 23/31] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E6=88=96=E8=80=85=E5=B7=B2=E7=BB=8F=E5=8A=A0=E5=85=A5=E7=9A=84?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=90=8E=E8=BF=9B?=
=?UTF-8?q?=E8=A1=8C=E8=B7=B3=E8=BD=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 11 ++++++++---
app/views/courses/_set_join.js.erb | 2 ++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 1623979f0..d9980e286 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -39,9 +39,14 @@ class CoursesController < ApplicationController
else
@state = 5 #未登录
end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
- end
+ # if @state == 1 || @state == 3
+ # respond_to course_path(course.id)
+ # else
+ respond_to do |format|
+ format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
+ end
+ #end
+
rescue Exception => e
@state = 4 #已经加入了课程
respond_to do |format|
diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb
index 0542f2a0c..5476e7ff0 100644
--- a/app/views/courses/_set_join.js.erb
+++ b/app/views/courses/_set_join.js.erb
@@ -6,12 +6,14 @@
alert("加入成功");
hideModal($("#popbox02"));
$("#try_join_course_link").replaceWith("
'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品 ");
+ window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
<% elsif @state == 1 %>
alert("密码错误");
<% elsif @state == 2 %>
alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)");
<% elsif @state == 3 %>
alert("您已经加入了课程");
+ window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>"
<% elsif @state == 4 %>
alert("您加入的课程不存在");
<% elsif @state == 5 %>
From 82747a769089149d2ca8fb6a5a8608cc398cf6e1 Mon Sep 17 00:00:00 2001
From: huang
Date: Mon, 10 Aug 2015 16:12:13 +0800
Subject: [PATCH 24/31] =?UTF-8?q?=E7=95=99=E8=A8=80=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 8 +++++---
app/models/user.rb | 5 +++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0c5b441d4..39a467d53 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -262,9 +262,11 @@ class UsersController < ApplicationController
# modified by fq
def user_newfeedback
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- jours.update_all(:is_readed => true, :status => false)
- jours.each do |journal|
- fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
+ if User.current == @user
+ jours.update_all(:is_readed => true, :status => false)
+ jours.each do |journal|
+ fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
+ end
end
@jour = paginateHelper jours,10
@state = false
diff --git a/app/models/user.rb b/app/models/user.rb
index 2271adc18..1cd0675c8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -291,9 +291,10 @@ class User < Principal
name
end
## end
-
+
+ # 查询用户未读过的记录
def count_new_jour
- count = self.new_jours.count
+ count = self.journals_for_messages.where("status=?", 1).count
end
#added by nie
From d43ded4f8bcdcb66abb52254e21559a56106ef6c Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Tue, 11 Aug 2015 11:30:17 +0800
Subject: [PATCH 25/31] =?UTF-8?q?1.=E6=B2=A1=E6=9C=89=E5=8F=AF=E5=AF=BC?=
=?UTF-8?q?=E5=85=A5=E7=9A=84=E9=97=AE=E5=8D=B7=E6=8F=90=E7=A4=BA=202.?=
=?UTF-8?q?=E6=95=99=E8=BE=85=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=AF=BC=E5=85=A5?=
=?UTF-8?q?=E8=80=81=E5=B8=88=E7=9A=84=E9=97=AE=E5=8D=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 10 +++++-----
app/controllers/poll_controller.rb | 9 ++++++---
app/helpers/poll_helper.rb | 2 +-
app/views/poll/_other_poll.html.erb | 4 ++--
app/views/poll/other_poll.js.erb | 16 ++++++++++------
5 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 19c1214e2..7b81d12db 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -177,11 +177,11 @@ class FilesController < ApplicationController
def index
@flag = params[:flag] || false
#sort_init 'filename', 'asc'
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
+ # sort_init 'created_on', 'desc'
+ # sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ # 'filename' => "#{Attachment.table_name}.filename",
+ # 'size' => "#{Attachment.table_name}.filesize",
+ # 'downloads' => "#{Attachment.table_name}.downloads"
sort = ""
@sort = ""
@order = ""
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index b376a9acd..edf8c2259 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -1,3 +1,4 @@
+#encoding utf-8
class PollController < ApplicationController
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll]
before_filter :find_container, :only => [:new,:create, :index]
@@ -412,8 +413,10 @@ class PollController < ApplicationController
# 将其他地方的问卷导出来
def other_poll
- # 查作者是我,且不在当前课程内的问卷 进行导入
- @polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
+ # 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入
+ tea_ids = '('
+ tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
+ @polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
@polls_group_id = params[:polls_group_id]
respond_to do |format|
format.js
@@ -427,7 +430,7 @@ class PollController < ApplicationController
params[:polls].each_with_index do |p,i|
poll = Poll.find(p)
option = {
- :polls_name => poll.polls_name,
+ :polls_name => poll.polls_name || l(:label_poll_new),
:polls_type => 'Course',
:polls_group_id => course_id,
:polls_status => 1,
diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb
index 0baad37ee..22ee21936 100644
--- a/app/helpers/poll_helper.rb
+++ b/app/helpers/poll_helper.rb
@@ -78,7 +78,7 @@ module PollHelper
def poll_check_box_tags(name,polls,current_poll)
s = ''
polls.each do |poll|
- s << "#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name} [#{ h Course.find(poll.polls_group_id).name}] "
+ s << "#{ check_box_tag name, poll.id, false, :id => nil } #{h poll.polls_name.blank? ? l(:label_poll_new) : poll.polls_name } [#{ h Course.find(poll.polls_group_id).name}] "
end
s.html_safe
end
diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb
index c899f0d47..850d821fd 100644
--- a/app/views/poll/_other_poll.html.erb
+++ b/app/views/poll/_other_poll.html.erb
@@ -1,6 +1,6 @@
-
将以下问卷导入本课程
+
选择问卷导入本课程
<%= form_tag import_other_poll_poll_index_path,
@@ -8,7 +8,7 @@
remote: true,
id: "relation_file_form" do %>
- <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%>
+ <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses',:style=> 'width: 300px;')%>
导 入
取 消
<% end -%>
diff --git a/app/views/poll/other_poll.js.erb b/app/views/poll/other_poll.js.erb
index 34f53b73e..eee4ed4a1 100644
--- a/app/views/poll/other_poll.js.erb
+++ b/app/views/poll/other_poll.js.erb
@@ -1,9 +1,13 @@
-$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>');
+<% if @polls.empty? %>
+ alert('您目前还没有自己新建的问卷');
+<% else %>
+ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>');
-showModal('ajax-modal', '513px');
-$('#ajax-modal').siblings().remove();
-$('#ajax-modal').before("
");
-$('#ajax-modal').parent().css("top","").css("left","");
-$('#ajax-modal').parent().addClass("popbox_polls");
\ No newline at end of file
+ showModal('ajax-modal', '513px');
+ $('#ajax-modal').siblings().remove();
+ $('#ajax-modal').before("
");
+ $('#ajax-modal').parent().css("top","").css("left","");
+ $('#ajax-modal').parent().addClass("popbox_polls");
+<% end %>
\ No newline at end of file
From 477db5841bd1678bcab255857daec1a54bc1047e Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Tue, 11 Aug 2015 14:32:01 +0800
Subject: [PATCH 26/31] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=97=AE=E5=8D=B7=E7=9A=84=E6=97=B6=E5=80=99?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/poll/_other_poll.html.erb | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb
index 850d821fd..40ecbc569 100644
--- a/app/views/poll/_other_poll.html.erb
+++ b/app/views/poll/_other_poll.html.erb
@@ -19,9 +19,19 @@
\ No newline at end of file
From fbcd19b54ff7b098aaa0c8135d9fb2515a1a220d Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Tue, 11 Aug 2015 15:00:40 +0800
Subject: [PATCH 27/31] =?UTF-8?q?1.=E7=BC=96=E8=BE=91=E5=88=86=E7=8F=AD?=
=?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E7=BC=96=E8=BE=91=E6=A1=86=E9=87=8C?=
=?UTF-8?q?=E8=A6=81=E6=9C=89=E9=BB=98=E8=AE=A4=E6=98=AF=E5=8E=9F=E6=9D=A5?=
=?UTF-8?q?=E7=9A=84=E8=AF=A5=E7=8F=AD=E7=BA=A7=E5=90=8D=E5=AD=97=202.?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5=E6=90=9C=E7=B4=A2=E8=BE=93?=
=?UTF-8?q?=E5=85=A5=E7=A9=BA=E6=A0=BC=E4=BB=8D=E7=84=B6=E8=BF=94=E5=9B=9E?=
=?UTF-8?q?=E6=89=80=E6=9C=89=E7=9A=84=E9=80=9A=E7=9F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/news_controller.rb | 2 +-
app/views/courses/_new_groups_name.html.erb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 185e7128e..1a8e75b54 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -72,7 +72,7 @@ class NewsController < ApplicationController
@news_count = scope.count
@q = params[:subject]
- if params[:subject].nil?
+ if params[:subject].nil? || params[:subject].blank?
scope_order = scope.all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC")
else
diff --git a/app/views/courses/_new_groups_name.html.erb b/app/views/courses/_new_groups_name.html.erb
index fc2c5a62d..6ffbb6dd2 100644
--- a/app/views/courses/_new_groups_name.html.erb
+++ b/app/views/courses/_new_groups_name.html.erb
@@ -21,7 +21,7 @@
<% end%>
-
+
<% end %>
From 465af5e2d33b9a6ac09fa168f2301a602ed60714 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Tue, 11 Aug 2015 15:54:05 +0800
Subject: [PATCH 28/31] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E5=86=85=E7=9B=B8=E5=85=B3=E6=B4=BB=E5=8A=A8=E6=97=B6=E5=8A=A8?=
=?UTF-8?q?=E6=80=81=E7=9A=84=E6=B7=BB=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/attachment.rb | 12 ++++++++++--
app/models/course_activity.rb | 7 +++++++
app/models/homework_common.rb | 12 +++++++++++-
app/models/journals_for_message.rb | 11 ++++++++++-
app/models/message.rb | 11 ++++++++++-
app/models/news.rb | 11 ++++++++++-
app/models/poll.rb | 10 +++++++++-
.../20150811065543_add_course_activities.rb | 15 +++++++++++++++
db/schema.rb | 11 ++++++++++-
9 files changed, 92 insertions(+), 8 deletions(-)
create mode 100644 app/models/course_activity.rb
create mode 100644 db/migrate/20150811065543_add_course_activities.rb
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index f999e27d6..f7fb9b1aa 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
include UserScoreHelper
@@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base
cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
- before_save :files_to_final_location
- after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
+ before_save :files_to_final_location,:act_as_course_activity
+ after_create :office_conver, :be_user_score,:act_as_forge_activity
after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score
@@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.container_type == "Course" && self.course_acts.empty?
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
+ end
+ end
end
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
new file mode 100644
index 000000000..1b05e876d
--- /dev/null
+++ b/app/models/course_activity.rb
@@ -0,0 +1,7 @@
+class CourseActivity < ActiveRecord::Base
+ attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
+ # 虚拟关联
+ belongs_to :act ,:polymorphic => true
+ belongs_to :course
+ belongs_to :user
+end
diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb
index 291c14563..5fe01db96 100644
--- a/app/models/homework_common.rb
+++ b/app/models/homework_common.rb
@@ -13,17 +13,27 @@ class HomeworkCommon < ActiveRecord::Base
has_many :student_works, :dependent => :destroy
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
acts_as_attachable
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
- after_create :act_as_activity, :send_mail
+ after_create :act_as_activity, :send_mail, :act_as_course_activity
after_destroy :delete_kindeditor_assets
def act_as_activity
self.acts << Activity.new(:user_id => self.user_id)
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
+ end
+ end
+
#删除对应的图片
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index b15c9b2d1..bcae58174 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base
acts_as_attachable
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour?
- after_create :act_as_activity #huang
+ after_create :act_as_activity, :act_as_course_activity
after_create :reset_counters!
after_destroy :reset_counters!
after_save :be_user_score
@@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,7
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.jour_type == 'Course'
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
+ end
+ end
end
diff --git a/app/models/message.rb b/app/models/message.rb
index 15d358789..de5cc3f9b 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -32,6 +32,8 @@ class Message < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@@ -68,7 +70,7 @@ class Message < ActiveRecord::Base
after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
- after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail
+ after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail
#before_save :be_user_score
scope :visible, lambda {|*args|
@@ -185,6 +187,13 @@ class Message < ActiveRecord::Base
:project_id => self.board.project.id)
end
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
+ end
+ end
#更新用户分数 -by zjc
def be_user_score
diff --git a/app/models/news.rb b/app/models/news.rb
index 7d33d760e..e5c1d192a 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -28,6 +28,8 @@ class News < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@@ -49,7 +51,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
- after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail
+ after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail
after_destroy :delete_kindeditor_assets
@@ -121,6 +123,13 @@ class News < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
+ end
+ end
+
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 64e9df79a..34a381246 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -8,7 +8,9 @@ class Poll < ActiveRecord::Base
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
# 添加课程的poll动态
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
- after_create :act_as_activity
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
+ after_create :act_as_activity, :act_as_course_activity
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
@@ -27,4 +29,10 @@ class Poll < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.user_id)
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.polls_type == "Course"
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
+ end
+ end
end
diff --git a/db/migrate/20150811065543_add_course_activities.rb b/db/migrate/20150811065543_add_course_activities.rb
new file mode 100644
index 000000000..03ec7e354
--- /dev/null
+++ b/db/migrate/20150811065543_add_course_activities.rb
@@ -0,0 +1,15 @@
+class AddCourseActivities < ActiveRecord::Migration
+ def up
+ create_table :course_activities do |t|
+ t.integer :user_id
+ t.integer :course_id
+ t.integer :course_act_id
+ t.string :course_act_type
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :course_activities
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 30ca29d12..ac1bb987c 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 => 20150801034945) do
+ActiveRecord::Schema.define(:version => 20150811065543) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -324,6 +324,15 @@ ActiveRecord::Schema.define(:version => 20150801034945) do
t.datetime "updated_on", :null => false
end
+ create_table "course_activities", :force => true do |t|
+ t.integer "user_id"
+ t.integer "course_id"
+ t.integer "course_act_id"
+ t.string "course_act_type"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "course_attachments", :force => true do |t|
t.string "filename"
t.string "disk_filename"
From ce763088647626e57072d37503696ca58c40c509 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Tue, 11 Aug 2015 17:02:52 +0800
Subject: [PATCH 29/31] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=EF=BC=8C=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E7=9A=84=E8=BF=81?=
=?UTF-8?q?=E7=A7=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/course_activity.rb | 2 +-
.../20150811080754_course_activities.rb | 39 +++++++++++++++++++
...50811083234_update_course_activity_time.rb | 22 +++++++++++
db/schema.rb | 2 +-
4 files changed, 63 insertions(+), 2 deletions(-)
create mode 100644 db/migrate/20150811080754_course_activities.rb
create mode 100644 db/migrate/20150811083234_update_course_activity_time.rb
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
index 1b05e876d..02b6dacf1 100644
--- a/app/models/course_activity.rb
+++ b/app/models/course_activity.rb
@@ -1,7 +1,7 @@
class CourseActivity < ActiveRecord::Base
attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
# 虚拟关联
- belongs_to :act ,:polymorphic => true
+ belongs_to :course_act ,:polymorphic => true
belongs_to :course
belongs_to :user
end
diff --git a/db/migrate/20150811080754_course_activities.rb b/db/migrate/20150811080754_course_activities.rb
new file mode 100644
index 000000000..bdb8e19c0
--- /dev/null
+++ b/db/migrate/20150811080754_course_activities.rb
@@ -0,0 +1,39 @@
+#encoding=UTF-8
+class CourseActivities < ActiveRecord::Migration
+ def up
+ Course.all.each do |course|
+ transaction do
+ #作业
+ course.homework_commons.each do |homework_common|
+ homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id)
+ end
+ #通知
+ course.news.each do |new|
+ new.course_acts << CourseActivity.new(:user_id => new.author_id,:course_id => course.id)
+ end
+ #资源
+ course.attachments.each do |attachment|
+ attachment.course_acts << CourseActivity.new(:user_id => attachment.author_id,:course_id => course.id)
+ end
+ #讨论区
+ if course.boards.first
+ course.boards.first.messages.each do |message|
+ message.course_acts << CourseActivity.new(:user_id => message.author_id,:course_id => course.id)
+ end
+ end
+ #留言
+ course.journals_for_messages.each do |jour|
+ jour.course_acts << CourseActivity.new(:user_id => jour.user_id,:course_id => course.id)
+ end
+ #问卷
+ Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll|
+ poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => course.id)
+ end
+ end
+ end
+ end
+
+ def down
+ CourseActivity.destroy_all
+ end
+end
diff --git a/db/migrate/20150811083234_update_course_activity_time.rb b/db/migrate/20150811083234_update_course_activity_time.rb
new file mode 100644
index 000000000..9ba8140d8
--- /dev/null
+++ b/db/migrate/20150811083234_update_course_activity_time.rb
@@ -0,0 +1,22 @@
+class UpdateCourseActivityTime < ActiveRecord::Migration
+ def up
+ count = CourseActivity.all.count / 10 + 1
+ transaction do
+ for i in 1 ... count do i
+ CourseActivity.page(i).per(10).each do |activity|
+ if activity.course_act
+ if activity.course_act.respond_to?("created_at")
+ activity.created_at = activity.course_act.created_at
+ elsif activity.course_act.respond_to?("created_on")
+ activity.created_at = activity.course_act.created_on
+ end
+ activity.save
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ac1bb987c..1488ca365 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 => 20150811065543) do
+ActiveRecord::Schema.define(:version => 20150811083234) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
From 053587bd53713880e75cfa26a9204529f2faf01b Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Tue, 11 Aug 2015 17:11:10 +0800
Subject: [PATCH 30/31] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B=E5=88=9B=E5=BB=BA=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E7=9A=84=E5=8A=A8=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/course.rb | 9 ++++++++-
db/migrate/20150811080754_course_activities.rb | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/models/course.rb b/app/models/course.rb
index 6d71ad967..a56ea5949 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -33,6 +33,8 @@ class Course < ActiveRecord::Base
has_many :student_works, :through => :homework_commons, :dependent => :destroy
has_many :course_groups, :dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy
@@ -44,7 +46,7 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
- after_create :create_board_sync
+ after_create :create_board_sync, :act_as_course_activity
before_destroy :delete_all_members
safe_attributes 'extra',
@@ -310,6 +312,11 @@ class Course < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
+ end
+
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
#def name
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
diff --git a/db/migrate/20150811080754_course_activities.rb b/db/migrate/20150811080754_course_activities.rb
index bdb8e19c0..a4cae915d 100644
--- a/db/migrate/20150811080754_course_activities.rb
+++ b/db/migrate/20150811080754_course_activities.rb
@@ -3,6 +3,7 @@ class CourseActivities < ActiveRecord::Migration
def up
Course.all.each do |course|
transaction do
+ course.course_acts << CourseActivity.new(:user_id => course.tea_id,:course_id => course.id)
#作业
course.homework_commons.each do |homework_common|
homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id)
From 2f77adfe9cdb3f194bbd3475f2d466e77dd9a0e7 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Wed, 12 Aug 2015 16:24:27 +0800
Subject: [PATCH 31/31] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E5=85=AC=E5=85=B1=E8=A1=A8=E7=9A=84=E5=AE=8C=E6=88=90=EF=BC=8C?=
=?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E8=A1=A8?=
=?UTF-8?q?=E7=9A=84=E4=B8=8E=E6=88=91=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=EF=BC=8C=E5=8A=A8=E6=80=81=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 89 +-------------------
app/helpers/courses_helper.rb | 53 ++++++++++++
app/models/course.rb | 2 +
app/views/courses/show.html.erb | 104 +++++++-----------------
app/views/layouts/base_courses.html.erb | 2 +-
public/stylesheets/courses.css | 2 +-
6 files changed, 89 insertions(+), 163 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index d9980e286..aa66dd7a0 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -663,92 +663,9 @@ class CoursesController < ApplicationController
end
def show
- if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
- return
- end
- @users_by_role = @course.users_by_role
- if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
- @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
- end
- @key = User.current.rss_key
- #新增内容
- @days = Setting.activity_days_default.to_i
- if params[:from]
- begin; @date_to = params[:from].to_date + 1; rescue; end
- end
- has = {
- "show_course_files" => true,
- "show_course_news" => true,
- "show_course_messages" => true,
- #"show_course_journals_for_messages" => true,
- # "show_bids" => true,
- # "show_homeworks" => true,
- "show_polls" => true
- }
- @date_to ||= Date.today + 1
- @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
- @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
- if @author.nil?
- # 显示老师和助教的活动
- # @authors = searchTeacherAndAssistant(@course)
- @authors = course_all_member(@course)
- events = []
- key = "course_events_#{@course.id}".to_sym
- if Rails.env.production? && Setting.course_cahce_enabled?
- events = Rails.cache.read(key) || []
- end
- if events.empty?
- @authors.each do |author|
- @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
- :with_subprojects => false,
- :author => author.user)
-
- @activity.scope_select {|t| has["show_#{t}"]}
- # modify by nwb
- # 添加私密性判断
- if User.current.member_of_course?(@course)|| User.current.admin?
- events += @activity.events(@days, @course.created_at)
- else
- events += @activity.events(@days, @course.created_at, :is_public => 1)
- end
- end
- Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
- end
- else
- # @author = @course.teacher
- @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
- :with_subprojects => false,
- :author => @author)
-
- @activity.scope_select {|t| has["show_#{t}"]}
- # modify by nwb
- # 添加私密性判断
- if User.current.member_of_course?(@course)|| User.current.admin?
- events = @activity.events(@days, @course.created_at)
- else
- events = @activity.events(@days, @course.created_at, :is_public => 1)
- end
- end
-
- # 无新动态时,显示老动态
- if events.count == 0
- if User.current.member_of_course?(@course)|| User.current.admin?
- events = @activity.events
- else
- events = @activity.events(:is_public => 1)
- end
- end
- @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
- if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
- @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
- end
-
- sorted_events = sort_activity_events_course(events)
- events = paginateHelper sorted_events,10
- @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
- # documents
-
-
+ course_activities = @course.course_activities.order("created_at desc")
+ @canShowRealName = User.current.member_of_course? @course
+ @course_activities = paginateHelper course_activities,10
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 597d5749c..da7a34a98 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -676,4 +676,57 @@ module CoursesHelper
end
result
end
+
+ #生成课程相关动态的链接
+ def course_activity_link activity
+ # activity = CourseActivity.first
+ title = ""
+ url = ""
+ case activity.course_act_type
+ when "Course"
+ title = activity.course_act.name
+ url = course_path activity.course
+ when "HomeworkCommon"
+ title = "作业 " + activity.course_act.name
+ url = student_work_index_path(:homework => activity.course_act.id)
+ when "News"
+ title = "通知公告 " + activity.course_act.title
+ url = course_news_index_path(activity.course)
+ when "Attachment"
+ title = "课件 " + activity.course_act.filename
+ url = course_files_path(activity.course)
+ when "Message"
+ title = "课程讨论区 " + activity.course_act.subject
+ url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
+ when "JournalsForMessage"
+ title = "留言 " + activity.course_act.notes
+ url = course_feedback_path(activity.course)
+ when "Poll"
+ title = "问卷 " + activity.course_act.polls_name
+ url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id)
+ end
+ link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
+ end
+
+ #课程动态的描述
+ def course_activity_desc activity
+ desc = ""
+ case activity.course_act_type
+ when "Course"
+ desc = ""
+ when "HomeworkCommon"
+ desc = activity.course_act.description
+ when "News"
+ desc = activity.course_act.description
+ when "Attachment"
+ desc = ""
+ when "Message"
+ desc = activity.course_act.content
+ when "JournalsForMessage"
+ desc = ""
+ when "Poll"
+ desc = activity.course_act.polls_description
+ end
+ desc.html_safe
+ end
end
diff --git a/app/models/course.rb b/app/models/course.rb
index a56ea5949..89990dd48 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -36,6 +36,8 @@ class Course < ActiveRecord::Base
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
+ has_many :course_activities
+
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy
acts_as_attachable :view_permission => :view_course_files,
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index 654c25a42..7159c3c83 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -1,83 +1,37 @@
-<% if @events_by_day != nil && @events_by_day.size >0 %>
- <% @events_by_day.keys.sort.reverse.each do |day| %>
- <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
-
-
- <%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %>
-
-
- <%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %>
- <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %>
-
-
<%= l(:label_new_activity) %>:
- <%
- link = (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) :
- (e.event_type.eql?("bid") ? homework_course_path(@course) :
- (e.event_type.eql?("message") || e.event_type.eql?("reply") ?
- course_boards_path(@course,:topic_id => e.id,:parent_id=>(e.parent_id ? e.parent_id : e.id)) : e.event_url))
- %>
- <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
- :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
- 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
- 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
- <%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
-
- <%end%>
-
-
<%= e.event_description.html_safe %>
-
-
- <%= l :label_activity_time %> : <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %>
-
- <%= link_to_attachments_course(e) if e.class.to_s == "News" %>
-
-
-
- <% end%>
- <% end%>
-<% elsif @controller_name=='ActivityNotifys' %>
-
<%= l(:label_no_data) %>
-<% end%>
-<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
-
-
- <%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %>
-
-
- <%= link_to_user_header(@user,false,:class => 'problem_name c_orange fl') %>
- <%= link_to_user_header("(#{@user})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName %>
-
<%= l(:label_user_create_project) %>:
- <%= link_to @course.name,course_path(@course),:class => "problem_tit c_dblue fl fb"%>
-
-
-
- <%= l :label_create_time %> : <%= format_time(@course.created_at) %>
-
-
-
-
+<%@course_activities.each do |activity|%>
+
+
+ <%= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %>
+
+
+ <%= link_to_user_header(activity.user,false,:class => 'problem_name c_orange fl') %>
+
+
<%= activity.course_act_type == "Course" ? "创建了课程" : l(:label_new_activity) %>:
+ <%#= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
+ :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
+ 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
+ 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
+ <%#if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
+
+ <%#end%>
+ <%= link_to course_activity_link activity%>
+
+
+ <%= course_activity_desc activity%>
+
+
+ <%= l :label_activity_time %> : <%= format_time(activity.created_at) %>
+
+ <%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %>
+
+
+
<% end%>
+
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 7a32cb67d..3242d79e9 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -113,7 +113,7 @@
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
- <%= link_to "(#{course_activity_count @course})", course_path(@course), :class => "subnav_num c_orange"%>
+ <%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 921e79c7e..1393431d7 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -55,7 +55,7 @@ a:hover.problem_pic{border:1px solid #64bdd9;}
.problem_txt{ width:610px; margin-left:10px; color:#777777;word-break: break-all;word-wrap: break-word;}
a.problem_name{ color:#ff5722;max-width:60px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
a:hover.problem_name{ color:#d33503;}
-a.problem_tit{ color:#0781b4; max-width:410px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
+a.problem_tit{ color:#0781b4; max-width:410px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;vertical-align: top;}
a.pro_mes_w{ height:20px; float:right;display:block; color:#999999;}
a:hover.problem_tit{ color:#09658c; }
.problem_main{ border-bottom:1px dashed #d4d4d4; padding-bottom:10px; margin-bottom:10px;}