From c1705bd65bea3b34db6e46ce684919351c10ceec Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Wed, 31 Dec 2014 17:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E3=80=8A=E5=AF=BC=E5=85=A5st?= =?UTF-8?q?udent=5Ffor=5Fcourse=E6=95=B0=E6=8D=AE=E3=80=8B=20Signed-off-by?= =?UTF-8?q?:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0) | 1 + app/controllers/courses_controller.rb | 8 ++++++-- ...141231020031_add_data_to_student_for_course.rb | 2 +- ...31085350_add_data_to_student_for_course_new.rb | 15 +++++++++++++++ db/schema.rb | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 0) create mode 100644 db/migrate/20141231085350_add_data_to_student_for_course_new.rb diff --git a/0) b/0) new file mode 100644 index 000000000..70d77d63e --- /dev/null +++ b/0) @@ -0,0 +1 @@ +终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)? \ No newline at end of file diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index eb7246fda..1a8506b12 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -330,6 +330,7 @@ class CoursesController < ApplicationController def member ## 鏈夎鑹插弬鏁扮殑鎵嶆槸璇剧▼锛屾病鏈夌殑灏辨槸椤圭洰 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) + @render_file = 'member_list' @score_sort_by = "desc" @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @@ -346,11 +347,12 @@ class CoursesController < ApplicationController @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @all_members = student_homework_score(0,page, 10,"desc") - + @members = paginateHelper_for_members @all_members, 10 end + respond_to do |format| if params[:page] format.js @@ -377,6 +379,7 @@ class CoursesController < ApplicationController end def member_score_sort + # @teachers= searchTeacherAndAssistant(@course) @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' # @role = params[:role] @@ -502,7 +505,7 @@ class CoursesController < ApplicationController per_page_option = 10 if @school_id == "0" or @school_id.nil? @courses_all = Course.active.visible. - joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id") else @courses_all = Course.active.visible. joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). @@ -1004,4 +1007,5 @@ GROUP BY members.user_id ORDER BY score #{score_sort_by}" book.write xls_report xls_report.string end + end diff --git a/db/migrate/20141231020031_add_data_to_student_for_course.rb b/db/migrate/20141231020031_add_data_to_student_for_course.rb index a507f907c..6d86efa65 100644 --- a/db/migrate/20141231020031_add_data_to_student_for_course.rb +++ b/db/migrate/20141231020031_add_data_to_student_for_course.rb @@ -3,7 +3,7 @@ class AddDataToStudentForCourse < ActiveRecord::Migration Course.all.each do |course| course.members.each do |m| - if m && m.user && m.user.allowed_to?(:student,course) && StudentsForCourse.find_by_student_id(m.user_id).nil? + if m && m.user && m.user.allowed_to?(:student,course) && StudentsForCourse.find_by_student_id(m.user).nil? StudentsForCourse.create(:student_id => m.user_id, :course_id => course.id) end end diff --git a/db/migrate/20141231085350_add_data_to_student_for_course_new.rb b/db/migrate/20141231085350_add_data_to_student_for_course_new.rb new file mode 100644 index 000000000..76552aa13 --- /dev/null +++ b/db/migrate/20141231085350_add_data_to_student_for_course_new.rb @@ -0,0 +1,15 @@ +class AddDataToStudentForCourseNew < ActiveRecord::Migration + def change + Course.all.each do |course| + + course.members.each do |m| + if m && m.user && m.user.allowed_to?(:as_student,course) && + StudentsForCourse.where(:student_id => m.user_id, :course_id => course.id).first.nil? + student = StudentsForCourse.new(:student_id => m.user_id, :course_id => course.id) + student.save! + end + + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index cdd827442..04a2e54c8 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 => 20141231020031) do +ActiveRecord::Schema.define(:version => 20141231085350) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false