parent
fb36a0d5ba
commit
0d99644fa7
|
@ -6,7 +6,7 @@ class CoursesController < ApplicationController
|
||||||
menu_item l(:label_sort_by_influence), :only => :index
|
menu_item l(:label_sort_by_influence), :only => :index
|
||||||
|
|
||||||
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 => [:view_homework_attaches] #:new,:create]
|
#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]
|
||||||
|
@ -66,6 +66,13 @@ class CoursesController < ApplicationController
|
||||||
return courses
|
return courses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def settings
|
||||||
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@issue_category ||= IssueCategory.new
|
||||||
|
@member ||= @courses.members.new
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if User.current.user_extensions.identity
|
if User.current.user_extensions.identity
|
||||||
@course = Course.new
|
@course = Course.new
|
||||||
|
@ -80,6 +87,7 @@ class CoursesController < ApplicationController
|
||||||
@course.setup_time = params[:setup_time]
|
@course.setup_time = params[:setup_time]
|
||||||
@course.endup_time = params[:endup_time]
|
@course.endup_time = params[:endup_time]
|
||||||
@course.class_period = params[:class_period]
|
@course.class_period = params[:class_period]
|
||||||
|
@course.description = params[:description]
|
||||||
end
|
end
|
||||||
|
|
||||||
@issue_custom_fields = IssueCustomField.sorted.all
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@ -91,7 +99,7 @@ class CoursesController < ApplicationController
|
||||||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
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])
|
m = Member.new(:user => User.current, :roles => [r])
|
||||||
#course = ProjectInfo.new(:user_id => User.current.id, :course_id => @course.id)
|
#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)
|
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||||
if params[:course][:is_public] == '1'
|
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)
|
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||||
end
|
end
|
||||||
|
|
|
@ -200,19 +200,19 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||||
@memberships = []
|
@memberships = []
|
||||||
membership.collect { |e|
|
membership.collect { |e|
|
||||||
@memberships.push(e) if(e.project.project_type == 1)
|
@memberships.push(e)
|
||||||
}
|
}
|
||||||
## 判断课程是否过期 [需封装]
|
## 判断课程是否过期 [需封装]
|
||||||
@memberships_doing = []
|
@memberships_doing = []
|
||||||
@memberships_done = []
|
@memberships_done = []
|
||||||
now_time = Time.now.year
|
now_time = Time.now.year
|
||||||
@memberships.map { |e|
|
@memberships.map { |e|
|
||||||
end_time = e.project.course_extra.get_time.year
|
end_time = e.course.get_time.year
|
||||||
isDone = course_endTime_timeout?(e.project)
|
isDone = course_endTime_timeout?(e.course)
|
||||||
if isDone
|
if isDone
|
||||||
@memberships_done.push e
|
@memberships_done.push e
|
||||||
else
|
else
|
||||||
|
|
|
@ -182,7 +182,7 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
||||||
def course_endTime_timeout? project
|
def course_endTime_timeout? project
|
||||||
end_time_str = Course.find_by_extra(project.try(:identifier)).try(:endup_time)
|
end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time)
|
||||||
begin
|
begin
|
||||||
cTime = Time.parse(end_time_str.to_s)
|
cTime = Time.parse(end_time_str.to_s)
|
||||||
rescue TypeError,ArgumentError
|
rescue TypeError,ArgumentError
|
||||||
|
|
|
@ -10,6 +10,14 @@ class Course < ActiveRecord::Base
|
||||||
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
||||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
||||||
has_many :bid
|
has_many :bid
|
||||||
|
|
||||||
|
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||||
|
has_many :memberships, :class_name => 'Member'
|
||||||
|
has_many :member_principals, :class_name => 'Member',
|
||||||
|
:include => :principal,
|
||||||
|
: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
|
||||||
|
|
||||||
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*$/
|
||||||
safe_attributes 'extra',
|
safe_attributes 'extra',
|
||||||
|
@ -21,7 +29,8 @@ class Course < ActiveRecord::Base
|
||||||
'tea_id',
|
'tea_id',
|
||||||
'password',
|
'password',
|
||||||
'term',
|
'term',
|
||||||
'password'
|
'password',
|
||||||
|
'description'
|
||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
|
|
||||||
|
@ -49,6 +58,9 @@ class Course < ActiveRecord::Base
|
||||||
errors[:extra].blank? && !(new_record? || extra.blank?)
|
errors[:extra].blank? && !(new_record? || extra.blank?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archived?
|
||||||
|
self.status == STATUS_ARCHIVED
|
||||||
|
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)
|
||||||
|
|
|
@ -54,6 +54,7 @@ class MemberRole < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_role_to_subprojects
|
def add_role_to_subprojects
|
||||||
|
if member.project
|
||||||
member.project.children.each do |subproject|
|
member.project.children.each do |subproject|
|
||||||
if subproject.inherit_members?
|
if subproject.inherit_members?
|
||||||
child_member = Member.find_or_new(subproject.id, member.user_id)
|
child_member = Member.find_or_new(subproject.id, member.user_id)
|
||||||
|
@ -62,6 +63,7 @@ class MemberRole < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def remove_inherited_roles
|
def remove_inherited_roles
|
||||||
MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
|
MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Principal < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
||||||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
||||||
|
has_many :coursememberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :course, :roles ], :conditions => "#{Course.table_name}.status<>#{Course::STATUS_ARCHIVED}", :order => "#{Course.table_name}.name"
|
||||||
has_many :projects, :through => :memberships
|
has_many :projects, :through => :memberships
|
||||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
|
|
||||||
|
|
|
@ -292,14 +292,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 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="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>
|
<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 -->
|
|
||||||
<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:-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>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
<div class="content_frame">
|
<div class="content_frame">
|
||||||
<ul class="user_project_sort">
|
<ul class="user_course_sort">
|
||||||
<% for membership in memberships %>
|
<% for membership in memberships %>
|
||||||
<li>
|
<li>
|
||||||
<table width="660" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px;font-size:14px;">
|
<table width="660" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px;font-size:14px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top" width="50"><%= image_tag(url_to_avatar(membership.project), :class => 'avatar') %></td>
|
<td colspan="2" valign="top" width="50"><%= image_tag(url_to_avatar(membership.course), :class => 'avatar') %></td>
|
||||||
<td>
|
<td>
|
||||||
<table width="580" border="0">
|
<table width="580" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top">
|
<td colspan="2" valign="top">
|
||||||
<span><%= link_to_project(membership.project) %></span>
|
<span><%= link_to_course(membership.course) %></span>
|
||||||
<span style="float: right">
|
<span style="float: right">
|
||||||
<%= render :partial => 'courses/set_course_time', :locals => {:project => membership.project} %>
|
<%= render :partial => 'courses/set_course_time', :locals => {:course => membership.course} %>
|
||||||
<% if User.current == @user %>
|
<% if User.current == @user %>
|
||||||
<% (membership.roles).each do |role| %>
|
<% (membership.roles).each do |role| %>
|
||||||
<% unless (role == Role.find(9) || role == Role.find(3)) %>
|
<% unless (role == Role.find(9) || role == Role.find(3)) %>
|
||||||
<%= join_in_course(membership.project, User.current) %>
|
<%= join_in_course(membership.course, User.current) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= l(:label_x_base_courses_member, :count => membership.project.members.count) %>
|
<%= l(:label_x_base_courses_member, :count => membership.course.members.count) %>
|
||||||
(<%= "#{membership.project.members.count}" %>)
|
(<%= "#{membership.course.members.count}" %>)
|
||||||
<%= l(:label_homework) %>
|
<%= l(:label_homework) %>
|
||||||
(<span class=""><%= link_to (membership.project.homeworks.count), {:controller => 'projects', :action => 'homework', :id => membership.project.identifier} %></span>)
|
(<span class=""><%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.identifier} %></span>)
|
||||||
|
|
||||||
<%= l(:label_course_news) %>
|
<%= l(:label_course_news) %>
|
||||||
(<span style="color: #ed8924"><%= link_to (membership.project.news.count), {:controller => 'news', :action => 'index', :project_id => membership.project.identifier} %></span>)
|
(<span style="color: #ed8924"><%= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.identifier} %></span>)
|
||||||
</span></td>
|
</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" width="580">
|
<td colspan="2" width="580">
|
||||||
<p class="font_description">
|
<p class="font_description">
|
||||||
<%= membership.project.description %>
|
<%= membership.course.description %>
|
||||||
</p></td>
|
</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<% @course = Course.find_by_extra(membership.project.identifier) %>
|
<% @course = Course.find_by_extra(membership.course.extra) %>
|
||||||
<% unless (@course.nil? || @course.teacher.nil? || @course.teacher.name.nil?) %>
|
<% unless (@course.nil? || @course.teacher.nil? || @course.teacher.name.nil?) %>
|
||||||
<span class="font-lighter" style="float: left"><%= l(:label_main_teacher) %>
|
<span class="font-lighter" style="float: left"><%= l(:label_main_teacher) %>
|
||||||
: <%= link_to(@course.teacher.realname, user_path(@course.teacher)) %></span>
|
: <%= link_to(@course.teacher.realname, user_path(@course.teacher)) %></span>
|
||||||
|
|
|
@ -547,7 +547,7 @@ RedmineApp::Application.routes.draw do
|
||||||
# 课程路由设置
|
# 课程路由设置
|
||||||
resources :courses do
|
resources :courses do
|
||||||
member do
|
member do
|
||||||
# 之前在项目
|
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||||
post 'finishcourse'
|
post 'finishcourse'
|
||||||
post 'restartcourse'
|
post 'restartcourse'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue