增加《导入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
|
def member
|
||||||
## 有角色参数的才是课程,没有的就是项目
|
## 有角色参数的才是课程,没有的就是项目
|
||||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||||
|
|
||||||
@render_file = 'member_list'
|
@render_file = 'member_list'
|
||||||
@score_sort_by = "desc"
|
@score_sort_by = "desc"
|
||||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||||
|
@ -346,11 +347,12 @@ class CoursesController < ApplicationController
|
||||||
@subPage_title = l :label_student_list
|
@subPage_title = l :label_student_list
|
||||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||||
@all_members = student_homework_score(0,page, 10,"desc")
|
@all_members = student_homework_score(0,page, 10,"desc")
|
||||||
|
|
||||||
@members = paginateHelper_for_members @all_members, 10
|
@members = paginateHelper_for_members @all_members, 10
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if params[:page]
|
if params[:page]
|
||||||
format.js
|
format.js
|
||||||
|
@ -377,6 +379,7 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_score_sort
|
def member_score_sort
|
||||||
|
|
||||||
# @teachers= searchTeacherAndAssistant(@course)
|
# @teachers= searchTeacherAndAssistant(@course)
|
||||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||||
# @role = params[:role]
|
# @role = params[:role]
|
||||||
|
@ -502,7 +505,7 @@ class CoursesController < ApplicationController
|
||||||
per_page_option = 10
|
per_page_option = 10
|
||||||
if @school_id == "0" or @school_id.nil?
|
if @school_id == "0" or @school_id.nil?
|
||||||
@courses_all = Course.active.visible.
|
@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
|
else
|
||||||
@courses_all = Course.active.visible.
|
@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").
|
||||||
|
@ -1004,4 +1007,5 @@ GROUP BY members.user_id ORDER BY score #{score_sort_by}"
|
||||||
book.write xls_report
|
book.write xls_report
|
||||||
xls_report.string
|
xls_report.string
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ class AddDataToStudentForCourse < ActiveRecord::Migration
|
||||||
Course.all.each do |course|
|
Course.all.each do |course|
|
||||||
|
|
||||||
course.members.each do |m|
|
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)
|
StudentsForCourse.create(:student_id => m.user_id, :course_id => course.id)
|
||||||
end
|
end
|
||||||
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.
|
# 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|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
|
Loading…
Reference in New Issue