1.课程control添加create方法

2.课程model添加部分新列及相关逻辑
CourseModify
nwb 11 years ago
parent 4404222437
commit fb36a0d5ba

File diff suppressed because it is too large Load Diff

@ -23,6 +23,8 @@ class Course < ActiveRecord::Base
'term',
'password'
acts_as_customizable
scope :active, lambda { where(:status => STATUS_ACTIVE) }
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
scope :all_public, lambda { where(:is_public => true) }
@ -43,6 +45,11 @@ class Course < ActiveRecord::Base
user.allowed_to?(:view_course, self)
end
def extra_frozen?
errors[:extra].blank? && !(new_record? || extra.blank?)
end
def self.visible_condition(user, options={})
allowed_to_condition(user, :view_course, options)
end

@ -17,21 +17,21 @@
<% object = [] %>
<% object << 'project' %>
<% object << 'course' %>
<% object << 'course' %>
<%= error_messages_for object %>
<!--[form:project]-->
<% unless @project.new_record? %>
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %></p>
<!--[form:course]-->
<% unless @course.new_record? %>
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %></p>
<% end %>
<!-- <p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
<p><label for="project_name" style="font-size: 13px;" ><%=l(:label_tags_course_name)%><span class="required", > *&nbsp;&nbsp;</span></label><input id="project_name" type="text" value="<%=@project.name%>" style="width:490px;" size="60" name="project[name]"></p>
<p><label for="course_name" style="font-size: 13px;" ><%=l(:label_tags_course_name)%><span class="required" > *&nbsp;&nbsp;</span></label><input id="course_name" type="text" value="<%=@course.name%>" style="width:490px;" size="60" name="course[name]"></p>
<!-- <p><%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
<% unless @project.identifier_frozen? %>
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
<!-- <p><%= f.text_field :extra, :required => true, :size => 60, :style => "width:488px;", :disabled => @course.extra_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
<% unless @course.extra_frozen? %>
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_course_identifier_info).html_safe %></em>
<% end %></p> -->
<!-- added by bai 新增开课时间、结课时间、课时 -->
@ -294,46 +294,33 @@
<!-- added by huang -->
<!-- <p style="margin-left:-10px;"><%= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
<p style="margin-left:-10px;"><label for="project[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="project_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@project.course_extra.password if @project.course_extra %>" size="60" name="project[course][password]"></p>
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
<% end %>
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
<!--new added -->
<p style="margin-left:-20px;padding-right: 20px;"><label for="project_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="project_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="project[description]" cols="40" ><%=@project.description%></textarea></span></p>
<p style="margin-left:-20px;padding-right: 20px;"><label for="course_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" ><%=@course.description%></textarea></span></p>
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %></em></p><!-- modified by bai -->
<p style="display:none;"><%= f.text_field :project_type, :value => 1 %></p>
<p style="display:none;"><%= f.text_field :course_type, :value => 1 %></p>
<%= wikitoolbar_for 'project_description' %>
<%= wikitoolbar_for 'course_description' %>
<% @project.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :project, value %></p>
<% @course.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :course, value %></p>
<% end %>
<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
<%= call_hook(:view_courses_form, :course => @course, :form => f) %>
<!--[eoform:project]-->
<!--[eoform:course]-->
<% unless @project.identifier_frozen? %>
<% unless @course.extra_frozen? %>
<% content_for :header_tags do %>
<%= javascript_include_tag 'project_identifier' %>
<%= javascript_include_tag 'course_identifier' %>
<% end %>
<% end %>
<% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %>
<%= javascript_tag do %>
$(document).ready(function() {
$("#project_inherit_members").change(function(){
if (!$(this).is(':checked')) {
if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) {
$("#project_inherit_members").attr("checked", true);
}
}
});
});
<% end %>
<% end %>

@ -7,7 +7,7 @@
<% else %>
<p class="font_description">
<!--teacher could create the course directly-->
<%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'projects', :action => 'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %>
<%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
</p>
<% end %>
<% else %>

@ -0,0 +1,6 @@
class AddIsPublicToCourses < ActiveRecord::Migration
def change
add_column :courses, :is_public, :tinyint,:default => 1
add_column :courses, :inherit_members, :tinyint,:default => 1
end
end

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140527060344) do
ActiveRecord::Schema.define(:version => 20140604071624) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -116,6 +116,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
t.integer "messages_count", :default => 0, :null => false
t.integer "last_message_id"
t.integer "parent_id"
t.integer "course_id"
end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -217,6 +218,16 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
t.datetime "updated_on", :null => false
end
create_table "course_statuses", :force => true do |t|
t.integer "changesets_count"
t.integer "watchers_count"
t.integer "course_id"
t.float "grade", :default => 0.0
t.integer "course_ac_para", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "courses", :force => true do |t|
t.integer "tea_id"
t.string "name"
@ -224,8 +235,8 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "location"
t.string "term"
t.string "string"
@ -234,6 +245,13 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
t.string "endup_time"
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.boolean "is_public", :default => true
t.integer "inherit_members", :limit => 1, :default => 1
end
create_table "custom_fields", :force => true do |t|
@ -296,6 +314,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
create_table "enabled_modules", :force => true do |t|
t.integer "project_id"
t.string "name", :null => false
t.integer "course_id"
end
add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id"
@ -499,13 +518,14 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
create_table "members", :force => true do |t|
t.integer "user_id", :default => 0, :null => false
t.integer "project_id", :default => 0, :null => false
t.integer "project_id", :default => 0
t.datetime "created_on"
t.boolean "mail_notification", :default => false, :null => false
t.integer "course_id"
end
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"
create_table "memos", :force => true do |t|
@ -690,7 +710,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
end
create_table "relative_memos", :force => true do |t|
t.integer "osp_id", :null => false
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :null => false

Loading…
Cancel
Save