迁移课程作业数据

This commit is contained in:
nwb 2014-06-04 16:58:26 +08:00
parent 0d99644fa7
commit 69e366d841
3 changed files with 15 additions and 4 deletions

View File

@ -17,6 +17,12 @@ class Course < ActiveRecord::Base
:include => :principal, :include => :principal,
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
has_many :users, :through => :members has_many :users, :through => :members
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :homework_for_courses, :dependent => :destroy
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
has_many :student, :through => :students_for_courses, :source => :user
validates_presence_of :password, :term 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, :message => "class period can only digital!", :with =>/^[1-9]\d*$/

View File

@ -1,11 +1,11 @@
<% <%
id = "finish_course_#{project.id}" id = "finish_course_#{course.id}"
display = (project.course_extra.teacher.id == User.current.id || User.current.admin?) display = (course.teacher.id == User.current.id || User.current.admin?)
%> %>
<% if display #如果课程已结束%> <% if display #如果课程已结束%>
<% linkPath = course_endTime_timeout?(project) ? restartcourse_project_path(project) : finishcourse_project_path(project, format: :js) %> <% linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) %>
<% desc = course_endTime_timeout?(project) ? '重启' : '关闭' %> <% desc = course_endTime_timeout?(course) ? '重启' : '关闭' %>
<%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %> <%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
<% else %> <% else %>

View File

@ -0,0 +1,5 @@
class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration
def change
rename_column(:homework_for_courses, :project_id, :course_id)
end
end