From ae5ced6a51d5b16afaaa905950bfd5d68b1b13ce Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 4 Jun 2014 17:39:11 +0800 Subject: [PATCH 01/46] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=88=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 19 +++++++++++++++++++ config/settings.yml | 1 + lib/redmine.rb | 24 ++++++++++++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9f6fb26c9..8d2ccfb50 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -454,6 +454,25 @@ zh: permission_manage_subtasks: 管理子任务 permission_view_journals_for_messages: 查看留言 permission_view_courses: 查看课程列表 + permission_new_course: 新建课程 + permission_configure_course: 配置课程 + permission_close_course: 关闭/重开课程 + permission_new_assignment: 新建任务 + permission_edit_assignment: 编辑任务 + permission_delete_assignment: 删除任务 + permission_new_placeholder: 新建占位 + permission_edit_placeholder: 编辑占位 + permission_delete_placeholder: 删除占位 + permission_commit_content: 提交内容 + permission_new_course_notify: 发布课程通知 + permission_edit_course_notify: 编辑课程通知 + permission_delete_course_notify: 删除课程通知 + permission_view_assignment: 查看任务 + permission_view_placeholder: 查看占位 + permission_view_course_messages: 查看留言 + permission_view_real_name: 查看真名 + + project_module_issue_tracking: 问题跟踪 project_module_time_tracking: 时间跟踪 diff --git a/config/settings.yml b/config/settings.yml index fbaba502f..f2c64a97c 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -172,6 +172,7 @@ default_projects_modules: - boards - calendar - gantt + - course default_projects_tracker_ids: serialized: true default: diff --git a/lib/redmine.rb b/lib/redmine.rb index 7b83c7cb6..5c96ce926 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -179,13 +179,25 @@ Redmine::AccessControl.map do |map| end #课程权限模块 - map.project_module :course do + map.project_module :course do |map| map.permission :view_courses,{:projects => [:course]},:read => true - end - - #作业模块权限 - map.project_module :bids do |map| - map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true + #map.permission :new_course, {}, :read => true + #map.permission :configure_course,{},:read => true + #map.permission :close_course,{},:read => true + map.permission :new_assignment,{:projects => [:new_homework]},:read => true + map.permission :edit_assignment,{:bids => [:edit]},:read => true + map.permission :delete_assignment,{:bids => [:homework_destroy]},:read => true + map.permission :new_placeholder,{:homework_attach => [:new]},:read => true + map.permission :edit_placeholder,{},:read => true + map.permission :delete_placeholder,{},:read => true + map.permission :commit_content,{},:read => true + #map.permission :new_course_notify,{},:read => true + #map.permission :edit_course_notify,{},:read => true + #map.permission :delete_course_notify,{},:read => true + map.permission :view_assignment,{},:read => true + map.permission :view_placeholder,{},:read => true + map.permission :view_course_messages,{},:read => true + map.permission :view_real_name,{},:read => true end map.project_module :boards do |map| From cb03669085596ba2e4c10c08b220754f32b4dbbe Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 5 Jun 2014 15:00:38 +0800 Subject: [PATCH 02/46] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=99=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index bb7a2424f..ed6cdd25a 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -70,7 +70,12 @@ class Mailer < ActionMailer::Base end mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} " - else + elsif journals_for_message.jour.class.to_s.to_sym == :Bid + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 8e2288a362824a6ce38a6ac7c98fbd8116139fed Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 5 Jun 2014 15:57:40 +0800 Subject: [PATCH 03/46] =?UTF-8?q?1.=E5=B0=81=E8=A3=85=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=B9=B3=E5=9D=87=E8=AF=84=E5=88=86=E6=96=B9?= =?UTF-8?q?=E6=B3=95=202.=E4=BC=98=E5=8C=96=E4=BD=9C=E4=B8=9A=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=95=8C=E9=9D=A2=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- app/helpers/courses_helper.rb | 11 +++++++++++ app/views/bids/_homework_list.html.erb | 19 ++----------------- app/views/layouts/base_homework.html.erb | 16 ++++++++-------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index c0df0699c..923225606 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -412,7 +412,7 @@ class BidsController < ApplicationController #增加作业按评分排序, @homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score - FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC") + FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC",:include => [:attachments]) if params[:student_id].present? @temp = [] @homework_list.each do |pro| diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index fb0a269e6..326ea8739 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -168,4 +168,15 @@ module CoursesHelper seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count seem_count > 0 end + + #获取指定作业的平均评分 + def homework_score homework + stars_reates = homework.rates(:quality) + sum = 0 + stars_reates.each do |star_reates| + sum = sum + star_reates.stars + end + stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count + format("%.2f", sum * 1.0 / stars_reates_count) + end end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 48f1c150d..a7d65ea43 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -43,14 +43,6 @@ <% else %> <% homework_filename = attachment.filename %> <% end %> - <% end %> <% else %> <% homework_filename = homework.name %> @@ -83,13 +75,7 @@ 作业评分: - <% stars_reates = homework.rates(:quality) %> - <% sum = 0 %> - <% stars_reates.each do |star_reates| %> - <% sum = sum + star_reates.stars %> - <% end %> - <% stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count %> - <%= format("%.2f", sum * 1.0 / stars_reates_count) %> + <%= homework_score homework %> <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> @@ -104,8 +90,7 @@ <% end %> - <% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && - (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %> + <% if (User.current == homework.user) || is_teacher %> <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> <%= link_to(l(:label_bid_respond_delete), homework, method: :delete, :confirm => l(:text_are_you_sure)) %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 81a8b0861..62c7d482d 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -22,27 +22,27 @@ <% course = Course.find_by_extra(project.identifier) %>
-
- <%= render :partial => 'layouts/base_header'%> +
+ <%= render :partial => 'layouts/base_header'%>
-
+
- + - -
高校课程实践社区 <%= l(:label_user_location) %> :
<%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > +

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > + <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > <%=link_to(@bid.name, respond_path(@bid)) %>

+
- +