创建课程修改

This commit is contained in:
nwb 2014-06-05 16:41:05 +08:00
parent c1f9f389b7
commit ebe771db88
4 changed files with 26 additions and 10 deletions

View File

@ -7,7 +7,7 @@ class CoursesController < ApplicationController
before_filter :find_course, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] before_filter :find_course, :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 => [: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 :toggleCourse, only: [:finishcourse, :restartcourse] before_filter :toggleCourse, only: [:finishcourse, :restartcourse]
@ -99,13 +99,13 @@ class CoursesController < ApplicationController
unless User.current.admin? unless User.current.admin?
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 = CourseInfos.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
@course.members << m @course.members << m
#@course.course_infos << course @course.course_infos << course
end end
respond_to do |format| respond_to do |format|
format.html { format.html {
@ -381,12 +381,28 @@ class CoursesController < ApplicationController
# documents # documents
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
# #
@teachers= searchTeacherAndAssistant(@course)
@canShowRealName = isCourseTeacher(User.current.id)
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
end
respond_to do |format| respond_to do |format|
format.html{render :layout => 'base_courses'} format.html{render :layout => 'base_courses'}
format.api format.api
end end
end end
#判断指定用户是否为课程教师
def isCourseTeacher(id)
result = false
if @teachers && @teachers.find_by_user_id(id) != nil
result = true
end
result
end
def feedback def feedback
page = params[:page] page = params[:page]
# Find the page of the requested reply # Find the page of the requested reply

View File

@ -21,10 +21,10 @@ class Course < ActiveRecord::Base
has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :homework_for_courses, :dependent => :destroy has_many :homework_for_courses, :dependent => :destroy
has_many :student, :through => :students_for_courses, :source => :user has_many :student, :through => :students_for_courses, :source => :user
has_many :course_infos, :dependent => :destroy has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
acts_as_taggable acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy #acts_as_nested_set :order => 'name', :dependent => :destroy
acts_as_attachable :view_permission => :view_files, acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files :delete_permission => :manage_files

View File

@ -16,7 +16,7 @@
<table width="580px" border="0"> <table width="580px" border="0">
<tr> <tr>
<td colspan="2" valign="top"> <td colspan="2" valign="top">
<strong> <%= h(e.project) if @project.nil? || @project.id != e.project.id %></strong> <strong> <%= h(e.course) if @course.nil? || @course.id != e.course.id %></strong>
<span class="font_lighter"> <span class="font_lighter">
<% if @canShowRealName %> <% if @canShowRealName %>
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>) <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>)
@ -26,7 +26,7 @@
<%= l(:label_new_activity) %> </span> <%= l(:label_new_activity) %> </span>
<%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(course)) ? course_files_path(e.container) : e.event_url %>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -59,10 +59,10 @@
<td colspan="2"> <td colspan="2">
<table width="580"> <table width="580">
<tr> <tr>
<td > <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @project.name %><strong> !</strong></td> <td > <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @course.name %><strong> !</strong></td>
</tr> </tr>
<tr> <tr>
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@project.created_on) %> <td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@course.created_on) %>
</table></td> </table></td>
</tr> </tr>
</table> </table>

View File

@ -47,7 +47,7 @@ module Redmine
if @project if @project
@event_types = @event_types.select {|o| @project.self_and_descendants.detect {|p| @user.allowed_to?("view_#{o}".to_sym, p)}} @event_types = @event_types.select {|o| @project.self_and_descendants.detect {|p| @user.allowed_to?("view_#{o}".to_sym, p)}}
else else
@event_types = @event_types.select {|o| @course.self_and_descendants.detect {|p| @user.allowed_to?("view_#{o}".to_sym, p)}} if @course @event_types = @event_types.select {|o| @user.allowed_to?("view_#{o}".to_sym,@course)} if @course
end end
@event_types @event_types
end end