diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index a47745171..4036d637e 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -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 :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 :toggleCourse, only: [:finishcourse, :restartcourse]
@@ -99,13 +99,13 @@ class CoursesController < ApplicationController
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)
+ 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)
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
+ @course.course_infos << course
end
respond_to do |format|
format.html {
@@ -381,12 +381,28 @@ class CoursesController < ApplicationController
# documents
@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|
format.html{render :layout => 'base_courses'}
format.api
end
end
+ #判断指定用户是否为课程教师
+ def isCourseTeacher(id)
+ result = false
+ if @teachers && @teachers.find_by_user_id(id) != nil
+ result = true
+ end
+ result
+ end
+
def feedback
page = params[:page]
# Find the page of the requested reply
diff --git a/app/models/course.rb b/app/models/course.rb
index e47fb52c2..6200c1942 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -21,10 +21,10 @@ class Course < ActiveRecord::Base
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :homework_for_courses, :dependent => :destroy
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_nested_set :order => 'name', :dependent => :destroy
+ #acts_as_nested_set :order => 'name', :dependent => :destroy
acts_as_attachable :view_permission => :view_files,
:delete_permission => :manage_files
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index 64eba20e1..8a6f51498 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -16,7 +16,7 @@
- <%= h(e.project) if @project.nil? || @project.id != e.project.id %>
+ <%= h(e.course) if @course.nil? || @course.id != e.course.id %>
<% 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) %>)
@@ -26,7 +26,7 @@
<%= l(:label_new_activity) %>
- <%= 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 %>
|
@@ -59,10 +59,10 @@
- <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @project.name %> ! |
+ <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @course.name %> ! |
- <%= l :label_update_time %>: <%= format_time(@project.created_on) %>
+ | <%= l :label_update_time %>: <%= format_time(@course.created_on) %>
| |
diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb
index 9259f1cbe..37576613a 100644
--- a/lib/redmine/activity/fetcher.rb
+++ b/lib/redmine/activity/fetcher.rb
@@ -47,7 +47,7 @@ module Redmine
if @project
@event_types = @event_types.select {|o| @project.self_and_descendants.detect {|p| @user.allowed_to?("view_#{o}".to_sym, p)}}
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
@event_types
end