增加《导入student_for_course数据》
Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
parent
fc7447ba6b
commit
c1705bd65b
|
@ -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'
|
||||
|
@ -351,6 +352,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue