diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7128014da..c0d7c1e25 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -5,6 +5,10 @@ class CoursesController < ApplicationController helper :members helper :words + menu_item :overview + menu_item :feedback, :only => :feedback + menu_item :homework, :only => :homework + menu_item l(:label_sort_by_time), :only => :index menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index diff --git a/app/models/course.rb b/app/models/course.rb index 7a9e411d5..2dfb6ae44 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -34,7 +34,7 @@ class Course < ActiveRecord::Base :delete_permission => :manage_files validates_presence_of :password, :term - validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ + validates_format_of :class_period, :with =>/^[1-9]\d*$/ after_save :create_board_sync before_destroy :delete_all_members @@ -199,9 +199,11 @@ class Course < ActiveRecord::Base # 删除课程所有成员 def delete_all_members - me, mr = Member.table_name, MemberRole.table_name - connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})") - Member.delete_all(['course_id = ?', id]) + if self.members && self.members.count > 0 + me, mr = Member.table_name, MemberRole.table_name + connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})") + Member.delete_all(['course_id = ?', id]) + end end def get_endup_time diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index c1de9629d..705040579 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -58,90 +58,93 @@ - - - - - - - - - - + + + + + - - - - + + + + + + + + - + <% if is_evaluation || is_teacher%> + <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> + <% end %> + +
- 作品名称:  - <% if homework.name == nil || homework.name == "" %> - <% homework_filename = homework.user.name + "提交的作业" %> - <% else %> - <% homework_filename = homework.name %> - <% end %> - - <%= link_to homework_filename , homework_attach_path(homework)%> - - - 合作成员:  - <% homework_users = homework_user_of_homework(homework,is_teacher) %> - <% if homework.users.count == 0 %> - 无 - <% else %> - <%= homework_users %> - <% end %> - - <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> - 迟交 - <% end %> -
- 开发项目:  - <% if homework.project != nil %> - <%= link_to homework.project.name,project_path(homework.project.id)%> - <% else %> - 暂无 - <% end %> - - 项目得分:  - - <% if homework.project != nil %> - <%= project_score homework.project %> - <% else %> - 0.00 - <% end %> - - -
+ 作品名称:  + <% if homework.name == nil || homework.name == "" %> + <% homework_filename = homework.user.name + "提交的作业" %> + <% else %> + <% homework_filename = homework.name %> + <% end %> + + <%= link_to homework_filename , homework_attach_path(homework)%> + + + 合作成员:  + <% homework_users = homework_user_of_homework(homework,is_teacher) %> + <% if homework.users.count == 0 %> + 无 + <% else %> + <%= homework_users %> + <% end %> + + <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> + 迟交 + <% end %> +
- 提交文件:  - <% if is_evaluation || is_teacher%> - <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> - <% else %> - 未开启互评功能作业不允许下载 - <% end %> - - - 互评得分:  - <%= student_score_for_homework(homework) %>   - <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> - <%= link_to "学生互评>>",homework_attach_path(homework) %> - <% end %> - -
+ 开发项目:  + <% if homework.project != nil %> + <%= link_to homework.project.name,project_path(homework.project.id)%> + <% else %> + 暂无 + <% end %> + + 项目得分:  + ;"> + <%= homework.project.nil? ? "N/A" : project_score(homework.project) %> + + +
+ 提交文件:  + <% if is_evaluation || is_teacher%> + <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + <% else %> + 未开启互评功能作业不允许下载 + <% end %> + + + 互评得分:  + <% student_homework_score = student_score_for_homework(homework) %> + ;"> + <% score = student_homework_score == "0.00"? "N/A" : student_homework_score %> + <%= score %> +    + <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> + <%= link_to "学生互评>>",homework_attach_path(homework) %> + <% end %> + +
- <% if is_evaluation || is_teacher%> - <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> - <% end %> - - 终评得分:  - <%= score_for_homework homework %>   - <% if is_teacher %> - <%= link_to "教师评分>>",homework_attach_path(homework) %> - <% end %> - - + 终评得分:  + <% totle_homework_score = score_for_homework(homework) %> + ;"> + <% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %> + <%= score %> +    + <% if is_teacher %> + <%= link_to "教师评分>>",homework_attach_path(homework) %> + <% end %> + +
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 2601d7c7e..ac5cc104d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -66,7 +66,6 @@ <%= link_to @course.name,course_path(@course) %> - <%= @course.name %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index ac10931dc..6fb6e71c6 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -38,7 +38,7 @@ <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index' %>

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

@@ -65,7 +65,7 @@ - <%= link_to @bid.courses.first.name.to_s, homework_course_path(@bid.courses.first) if @bid.courses.first %> + <%= link_to course.name.to_s, homework_course_path(course) if course %> @@ -211,9 +211,9 @@
  • <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show'}, :class => link_class(:respond) %>
  • - <% if User.current.member_of? @bid.courses.first %> + <% if User.current.member_of_course? course %>
  • - <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %> + <% if User.current.logged? && course && (!Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, course.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %> <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %> <% else %> <%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %> @@ -221,9 +221,9 @@ <% end %>
  • <% end %> - - + + + <%= yield %> diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 60d0f0ed3..5104cd851 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -76,7 +76,7 @@ <%= stylesheet_link_tag 'scm' %> <% end %> - <% html_title(l(:label_news_plural)) -%> + <% html_title(l(:label_course_news)) -%>