增加《导入student_for_course数据》

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-31 17:02:55 +08:00
parent fc7447ba6b
commit c1705bd65b
5 changed files with 24 additions and 4 deletions

1
0) Normal file
View File

@ -0,0 +1 @@
终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)? 终止批处理操作吗(Y/N)?

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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