parent
4404222437
commit
fb36a0d5ba
|
@ -5,9 +5,8 @@ class CoursesController < ApplicationController
|
||||||
menu_item l(:label_sort_by_active), :only => :index
|
menu_item l(:label_sort_by_active), :only => :index
|
||||||
menu_item l(:label_sort_by_influence), :only => :index
|
menu_item l(:label_sort_by_influence), :only => :index
|
||||||
|
|
||||||
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
|
|
||||||
before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||||
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
before_filter :authorize_global, :only => [:view_homework_attaches] #:new,:create]
|
||||||
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||||
|
|
||||||
before_filter :require_login, :only => [:join, :unjoin]
|
before_filter :require_login, :only => [:join, :unjoin]
|
||||||
|
@ -67,6 +66,63 @@ class CoursesController < ApplicationController
|
||||||
return courses
|
return courses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
if User.current.user_extensions.identity
|
||||||
|
@course = Course.new
|
||||||
|
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
||||||
|
@course.safe_attributes = params[:course]
|
||||||
|
@course.tea_id = User.current.id
|
||||||
|
# added by bai
|
||||||
|
@course.term = params[:term]
|
||||||
|
@course.time = params[:time]
|
||||||
|
#@course.school_id = params[:occupation]
|
||||||
|
@course.school_id = User.current.user_extensions.school_id
|
||||||
|
@course.setup_time = params[:setup_time]
|
||||||
|
@course.endup_time = params[:endup_time]
|
||||||
|
@course.class_period = params[:class_period]
|
||||||
|
end
|
||||||
|
|
||||||
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
|
||||||
|
if User.current.user_extensions.identity == 0
|
||||||
|
if @course.save
|
||||||
|
unless User.current.admin?
|
||||||
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||||
|
m = Member.new(:user => User.current, :roles => [r])
|
||||||
|
#course = ProjectInfo.new(:user_id => User.current.id, :course_id => @course.id)
|
||||||
|
user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||||
|
if params[:course][:is_public] == '1'
|
||||||
|
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||||
|
end
|
||||||
|
@course.members << m
|
||||||
|
#@course.course_infos << course
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
if params[:continue]
|
||||||
|
redirect_to new_course_path(attrs, :course => '0')
|
||||||
|
elsif params[:course_continue]
|
||||||
|
redirect_to new_course_path(:course => '1')
|
||||||
|
else
|
||||||
|
redirect_to settings_course_path(@course, :course_type => 1)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@course.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'new', :layout => 'base' } #Added by young
|
||||||
|
format.api { render_validation_errors(@course) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@course_type = params[:course_type] ||= params[:course]
|
@course_type = params[:course_type] ||= params[:course]
|
||||||
@issue_custom_fields = IssueCustomField.sorted.all
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@ -237,8 +293,6 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def index1
|
def index1
|
||||||
|
|
||||||
per_page_option = 10
|
per_page_option = 10
|
||||||
|
|
|
@ -23,6 +23,8 @@ class Course < ActiveRecord::Base
|
||||||
'term',
|
'term',
|
||||||
'password'
|
'password'
|
||||||
|
|
||||||
|
acts_as_customizable
|
||||||
|
|
||||||
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
||||||
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||||
scope :all_public, lambda { where(:is_public => true) }
|
scope :all_public, lambda { where(:is_public => true) }
|
||||||
|
@ -43,6 +45,11 @@ class Course < ActiveRecord::Base
|
||||||
user.allowed_to?(:view_course, self)
|
user.allowed_to?(:view_course, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def extra_frozen?
|
||||||
|
errors[:extra].blank? && !(new_record? || extra.blank?)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.visible_condition(user, options={})
|
def self.visible_condition(user, options={})
|
||||||
allowed_to_condition(user, :view_course, options)
|
allowed_to_condition(user, :view_course, options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,21 +17,21 @@
|
||||||
|
|
||||||
|
|
||||||
<% object = [] %>
|
<% object = [] %>
|
||||||
<% object << 'project' %>
|
<% object << 'course' %>
|
||||||
<% object << 'course' %>
|
<% object << 'course' %>
|
||||||
<%= error_messages_for object %>
|
<%= error_messages_for object %>
|
||||||
|
|
||||||
|
|
||||||
<!--[form:project]-->
|
<!--[form:course]-->
|
||||||
<% unless @project.new_record? %>
|
<% unless @course.new_record? %>
|
||||||
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %></p>
|
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- <p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
|
<!-- <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", > * </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" > * </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 %>
|
<!-- <p><%= f.text_field :extra, :required => true, :size => 60, :style => "width:488px;", :disabled => @course.extra_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
|
||||||
<% unless @project.identifier_frozen? %>
|
<% unless @course.extra_frozen? %>
|
||||||
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
|
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_course_identifier_info).html_safe %></em>
|
||||||
<% end %></p> -->
|
<% end %></p> -->
|
||||||
|
|
||||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||||
|
@ -294,46 +294,33 @@
|
||||||
|
|
||||||
<!-- added by huang -->
|
<!-- 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;"><%= 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>
|
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||||
<% end %>
|
<% 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> -->
|
<!-- <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 -->
|
<!--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="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| %>
|
<% @course.custom_field_values.each do |value| %>
|
||||||
<p><%= custom_field_tag_with_label :project, value %></p>
|
<p><%= custom_field_tag_with_label :course, value %></p>
|
||||||
<% end %>
|
<% 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 %>
|
<% content_for :header_tags do %>
|
||||||
<%= javascript_include_tag 'project_identifier' %>
|
<%= javascript_include_tag 'course_identifier' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% 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 %>
|
<% else %>
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
<!--teacher could create the course directly-->
|
<!--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>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% 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
|
28
db/schema.rb
28
db/schema.rb
|
@ -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 => 20140527060344) do
|
ActiveRecord::Schema.define(:version => 20140604071624) 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
|
||||||
|
@ -116,6 +116,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
|
||||||
t.integer "messages_count", :default => 0, :null => false
|
t.integer "messages_count", :default => 0, :null => false
|
||||||
t.integer "last_message_id"
|
t.integer "last_message_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
|
t.integer "course_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
|
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
|
t.datetime "updated_on", :null => false
|
||||||
end
|
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|
|
create_table "courses", :force => true do |t|
|
||||||
t.integer "tea_id"
|
t.integer "tea_id"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -234,6 +245,13 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
|
||||||
t.string "endup_time"
|
t.string "endup_time"
|
||||||
t.string "class_period"
|
t.string "class_period"
|
||||||
t.integer "school_id"
|
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
|
end
|
||||||
|
|
||||||
create_table "custom_fields", :force => true do |t|
|
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|
|
create_table "enabled_modules", :force => true do |t|
|
||||||
t.integer "project_id"
|
t.integer "project_id"
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
t.integer "course_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id"
|
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|
|
create_table "members", :force => true do |t|
|
||||||
t.integer "user_id", :default => 0, :null => false
|
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.datetime "created_on"
|
||||||
t.boolean "mail_notification", :default => false, :null => false
|
t.boolean "mail_notification", :default => false, :null => false
|
||||||
|
t.integer "course_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "members", ["project_id"], :name => "index_members_on_project_id"
|
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"
|
add_index "members", ["user_id"], :name => "index_members_on_user_id"
|
||||||
|
|
||||||
create_table "memos", :force => true do |t|
|
create_table "memos", :force => true do |t|
|
||||||
|
@ -690,7 +710,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "relative_memos", :force => true do |t|
|
create_table "relative_memos", :force => true do |t|
|
||||||
t.integer "osp_id", :null => false
|
t.integer "osp_id"
|
||||||
t.integer "parent_id"
|
t.integer "parent_id"
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :null => false
|
t.text "content", :null => false
|
||||||
|
|
Loading…
Reference in New Issue