diff --git a/Gemfile b/Gemfile
index a94f1b33b..03dbb5785 100644
--- a/Gemfile
+++ b/Gemfile
@@ -51,7 +51,7 @@ gem 'elasticsearch-rails'
### profile
-# gem 'oneapm_rpm'
+gem 'oneapm_rpm'
group :development do
gem 'grape-swagger'
diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb
index bb5758e71..39b6a486a 100644
--- a/app/api/mobile/apis/blog_comments.rb
+++ b/app/api/mobile/apis/blog_comments.rb
@@ -6,10 +6,17 @@ module Mobile
resources :blog_comments do
desc "get special topic"
- get ':id' do
+ post ':id' do
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
+
blog = BlogComment.find params[:id]
- present :data, blog, with: Mobile::Entities::BlogComment,user: user
+ present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb
index caabad198..60e00280e 100644
--- a/app/api/mobile/apis/courses.rb
+++ b/app/api/mobile/apis/courses.rb
@@ -200,8 +200,13 @@ module Mobile
# course = Course.find(params[:id])
cs = CoursesService.new
course = cs.show_course(params,current_user)
- present :data, course, with: Mobile::Entities::Course,user: current_user
- { status: 0}
+
+ if course[:course][:is_delete] == 1
+ {status:-1, message: '该班级不存在或已被删除啦' }
+ else
+ present :data, course, with: Mobile::Entities::Course,user: current_user
+ present :status, 0
+ end
end
end
@@ -212,7 +217,7 @@ module Mobile
get "homeworks/:id" do
cs = CoursesService.new
homeworks = cs.homework_list params,current_user
- present :data, homeworks, with: Mobile::Entities::Homework
+ present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
present :status, 0
end
@@ -259,7 +264,7 @@ module Mobile
post ":course_id/attachments" do
cs = CoursesService.new
count = cs.course_attachments params
- present :data, count, with: Mobile::Entities::Attachment
+ present :data, count, with: Mobile::Entities::Attachment,user: current_user
present :status, 0
end
@@ -392,8 +397,8 @@ module Mobile
authenticate!
course = Course.find(params[:course_id])
- exercises = course.exercises.where("exercise_status <> 1").order("created_at desc")
- present :data,exercises,with:Mobile::Entities::Exercise
+ exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc")
+ present :data,exercises,with:Mobile::Entities::Exercise,user: current_user
present :status,0
end
diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb
index 4a6417cb4..36b558652 100644
--- a/app/api/mobile/apis/issues.rb
+++ b/app/api/mobile/apis/issues.rb
@@ -7,11 +7,17 @@ module Mobile
include IssuesHelper
desc "get special issuse"
- get ':id' do
+ post ':id' do
authenticate!
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
issue = Issue.find params[:id]
- present :data, issue, with: Mobile::Entities::Issue,user: user
+ present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb
index 5f2d01185..6ac484513 100644
--- a/app/api/mobile/apis/journal_for_messages.rb
+++ b/app/api/mobile/apis/journal_for_messages.rb
@@ -6,11 +6,18 @@ module Mobile
resources :journal_for_messages do
desc "get special journal"
- get ':id' do
+ post ':id' do
authenticate!
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
+
jour = JournalsForMessage.find params[:id]
- present :data, jour, with: Mobile::Entities::Jours,user: user
+ present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb
index bab82de8d..ceda5058f 100644
--- a/app/api/mobile/apis/messages.rb
+++ b/app/api/mobile/apis/messages.rb
@@ -6,11 +6,17 @@ module Mobile
resources :messages do
desc "get special topic"
- get ':id' do
+ post ':id' do
authenticate!
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
message = Message.find params[:id]
- present :data, message, with: Mobile::Entities::Message,user: user
+ present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb
index d42177783..6e012ca4b 100644
--- a/app/api/mobile/apis/newss.rb
+++ b/app/api/mobile/apis/newss.rb
@@ -6,11 +6,17 @@ module Mobile
resources :newss do
desc "get special news"
- get ':id' do
+ post ':id' do
authenticate!
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
news = News.find params[:id]
- present :data, news, with: Mobile::Entities::News,user: user
+ present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb
index d5823d5b4..ebfef7f2d 100644
--- a/app/api/mobile/apis/resources.rb
+++ b/app/api/mobile/apis/resources.rb
@@ -85,12 +85,26 @@ module Mobile
requires :token, type: String
requires :course_ids, type: Array[Integer]
requires :send_id, type: Integer
+ requires :send_type, type: Integer
end
post 'send' do
authenticate!
rs = ResourcesService.new
- ori, flag, save_message = rs.send_resource_to_course(current_user,params)
+
+ ori = nil
+ flag = false
+ save_message = nil
+
+ case params[:send_type]
+ when 1
+ ori, flag, save_message = rs.send_resource_to_course(current_user,params)
+ when 2
+ ori, flag, save_message = rs.send_homework_to_course(current_user,params)
+ when 3
+ ori, flag, save_message = rs.send_exercise_to_course(current_user,params)
+ end
+
if flag
present :status, 0
else
diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb
index c8377aa0d..db1e7e269 100644
--- a/app/api/mobile/apis/whomeworks.rb
+++ b/app/api/mobile/apis/whomeworks.rb
@@ -6,11 +6,17 @@ module Mobile
resources :whomeworks do
desc "get one homework"
- get ':id' do
+ post ':id' do
authenticate!
user = current_user
+
+ #0一级回复的更多 1 二级回复的更多
+ type = params[:type] || 0
+ page = params[:page] || 0
homework = HomeworkCommon.find params[:id]
- present :data, homework, with: Mobile::Entities::Whomework,user: user
+ present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page
+ present :type, type
+ present :page, page
present :status, 0
end
end
diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb
index 9e2a39a5a..2856354a1 100644
--- a/app/api/mobile/entities/activity.rb
+++ b/app/api/mobile/entities/activity.rb
@@ -25,10 +25,12 @@ module Mobile
elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
- ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
+ all_comments = []
+ ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end
+
when :subject
if ac.act_type == "HomeworkCommon"
ac.act.name unless ac.nil? || ac.act.nil?
diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb
index 49cb6bd2b..028ad633d 100644
--- a/app/api/mobile/entities/attachment.rb
+++ b/app/api/mobile/entities/attachment.rb
@@ -3,6 +3,7 @@ module Mobile
class Attachment < Grape::Entity
include Redmine::I18n
include ActionView::Helpers::NumberHelper
+ include ApplicationHelper
def self.attachment_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
@@ -22,6 +23,7 @@ module Mobile
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename
f.course.nil? ? "" : f.course.name
+
end
end
end
@@ -36,6 +38,12 @@ module Mobile
attachment_expose :file_dir
attachment_expose :attafile_size
attachment_expose :coursename #所属班级名
+ expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
+ current_user = options[:user]
+ current_user_is_teacher = false
+ current_user_is_teacher = is_course_teacher(current_user,instance.course)
+ current_user_is_teacher
+ end
end
end
end
\ No newline at end of file
diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb
index 67904d11e..3f58e901f 100644
--- a/app/api/mobile/entities/blog_comment.rb
+++ b/app/api/mobile/entities/blog_comment.rb
@@ -25,7 +25,9 @@ module Mobile
when :act_id
u.id
when :comment_count
- u.children.count
+ # u.children.count
+ all_comments = []
+ get_all_children(all_comments, u).count
end
end
end
@@ -51,7 +53,18 @@ module Mobile
blog_comment_expose :praise_count
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
- c.children.reverse
+ ##自己的父回复为空 才有子回复
+ if !opt[:children]
+ if c.parent.nil? && opt[:type] == 0
+ opt[:children] = true
+ all_comments = []
+ tStart = opt[:page]*5
+ tEnd = (opt[:page]+1)*5 - 1
+
+ all_comments = get_all_children(all_comments, c)[tStart..tEnd]
+ all_comments
+ end
+ end
end
end
expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options|
@@ -61,6 +74,63 @@ module Mobile
has_praise = obj.empty? ? false : true
has_praise
end
+
+ expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
+ parents_reply = []
+ parents_reply = get_reply_parents_no_root(parents_reply, instance)
+ parents_reply.count
+ end
+
+ expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
+ if c.is_a? (::BlogComment)
+ #取二级回复的底楼层
+ parents_reply = []
+ parents_reply = get_reply_parents_no_root(parents_reply, c)
+ if parents_reply.count > 0 && !opt[:bottom]
+ if opt[:type] == 1
+ # opt[:bottom] = true
+ # parents_reply[opt[:page]..opt[:page]]
+ else
+ opt[:bottom] = true
+ parents_reply[0..0]
+ end
+ else
+ []
+ end
+ end
+ end
+
+ expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
+ if c.is_a? (::BlogComment)
+ #取二级回复的顶楼层
+ parents_reply = []
+ parents_reply = get_reply_parents_no_root(parents_reply, c)
+ if parents_reply.count > 0 && !opt[:top]
+ if opt[:type] == 1
+ opt[:bottom] = true
+ tStart = (opt[:page]-1)*5+2
+ tEnd = (opt[:page])*5+2 - 1
+
+ if tEnd >= parents_reply.count - 1
+ tEnd = parents_reply.count - 2
+ end
+
+ if tStart <= parents_reply.count - 2
+ parents_reply = parents_reply.reverse[tStart..tEnd]
+ parents_reply.reverse
+ else
+ []
+ end
+ else
+ opt[:top] = true
+ parents_reply = parents_reply.reverse[0..1]
+ parents_reply.reverse
+ end
+ else
+ []
+ end
+ end
+ end
end
end
end
\ No newline at end of file
diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb
index 05066f8a4..ce6a2fb39 100644
--- a/app/api/mobile/entities/exercise.rb
+++ b/app/api/mobile/entities/exercise.rb
@@ -27,6 +27,14 @@ module Mobile
expose :exercise_name
expose :exercise_description
exercise_expose :coursename #所属班级名
+
+ expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
+ current_user = options[:user]
+ current_user_is_teacher = false
+ current_user_is_teacher = is_course_teacher(current_user,instance.course)
+ current_user_is_teacher
+ end
+
end
end
end
diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb
index 3f1631c96..a5b981c6d 100644
--- a/app/api/mobile/entities/homework.rb
+++ b/app/api/mobile/entities/homework.rb
@@ -98,6 +98,14 @@ module Mobile
homework_expose :coursename #所属班级名
+ expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
+ if instance[:current_user_is_teacher].nil?
+ current_user = options[:user]
+ current_user_is_teacher = false
+ current_user_is_teacher = is_course_teacher(current_user,instance.course)
+ current_user_is_teacher
+ end
+ end
end
end
end
\ No newline at end of file
diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb
index ef3d09450..b99ea03a5 100644
--- a/app/api/mobile/entities/issue.rb
+++ b/app/api/mobile/entities/issue.rb
@@ -23,7 +23,9 @@ module Mobile
when :issue_status
IssueStatus.find(issue.status_id).name
when :journals_count
- issue.journals.where("notes is not null and notes != ''").count
+ # issue.journals.where("notes is not null and notes != ''").count
+ all_comments = []
+ get_all_children(all_comments, f).count
when :project_name
issue.project.name
when :praise_count
diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb
index 15e22174c..f98d7a9ed 100644
--- a/app/api/mobile/entities/jours.rb
+++ b/app/api/mobile/entities/jours.rb
@@ -18,7 +18,9 @@ module Mobile
when :lasted_comment
time_from_now f.created_on
when :reply_count
- f.children.count
+ # f.children.count
+ all_comments = []
+ get_all_children(all_comments, f).count
when :praise_count
get_activity_praise_num(f)
when :act_type
diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb
index 051c92886..d58192378 100644
--- a/app/api/mobile/entities/message.rb
+++ b/app/api/mobile/entities/message.rb
@@ -30,6 +30,9 @@ module Mobile
'Message'
when :act_id
u.id
+ when :replies_count
+ all_comments = []
+ get_all_children(all_comments, u).count
end
end
end
diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb
index 4f973d82e..ff1452b1c 100644
--- a/app/api/mobile/entities/news.rb
+++ b/app/api/mobile/entities/news.rb
@@ -24,6 +24,9 @@ module Mobile
'News'
when :act_id
f.id
+ when :comments_count
+ all_comments = []
+ get_all_children(all_comments, f).count
end
end
elsif f.is_a?(Hash) && !f.key?(field)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b1aae9b26..d14bccc4e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -507,7 +507,8 @@ class ApplicationController < ActionController::Base
# render_404
# end
- def self.model_object(model)
+ def self.
+ model_object(model)
self.model_object = model
end
diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb
index dcab1b360..dcd549d76 100644
--- a/app/controllers/blog_comments_controller.rb
+++ b/app/controllers/blog_comments_controller.rb
@@ -144,7 +144,7 @@ class BlogCommentsController < ApplicationController
if params[:parent_id]
@blogComment.content = params[:blog_comment][:content]
parent = BlogComment.find params[:parent_id]
- @blogComment.reply_id = params[:reply_id]
+ @blogComment.reply_id = params[:id]
parent.children << @blogComment
else
@quote = params[:quote][:quote] || ""
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index ceb63d7b0..099e9404a 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -161,6 +161,7 @@ class BoardsController < ApplicationController
if @project
render :action => 'show', :layout => 'base_projects'
elsif @course
+ @left_nav_type = 2
@params=params
render :action => 'show', :layout => 'base_courses'
end
@@ -185,6 +186,7 @@ class BoardsController < ApplicationController
@board = @project.boards.build
@board.safe_attributes = params[:board]
if @project.project_type == 1
+ @left_nav_type = 2
render :layout => 'base_courses'
end
end
@@ -206,6 +208,7 @@ class BoardsController < ApplicationController
def edit
if @project.project_type == 1
+ @left_nav_type = 2
render :layout => 'base_courses'
end
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 5966b310f..9226b904c 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -19,8 +19,8 @@ class CommentsController < ApplicationController
default_search_scope :news
include ApplicationHelper
model_object News
- before_filter :find_model_object
- before_filter :find_project_from_association
+ before_filter :find_model_object, :except => [:reply, :quote]
+ before_filter :find_project_from_association, :except => [:reply, :quote]
before_filter :authorize
def create
@@ -73,7 +73,46 @@ class CommentsController < ApplicationController
def destroy
@news.comments.find(params[:comment_id]).destroy
- redirect_to news_url(@news)
+ if params[:user_activity_id]
+ @user_activity_id = params[:user_activity_id]
+ respond_to do |format|
+ format.js
+ return
+ end
+ else
+ redirect_to news_url(@news)
+ end
+ end
+
+ def quote
+ @comment = Comment.find(params[:id])
+ respond_to do | format|
+ format.js
+ end
+ end
+
+ def reply
+ comment = Comment.find(params[:id])
+ @news = News.find comment.commented_id
+ new_comment = @news.comments.build(:author_id => User.current.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
+ @user_activity_id = params[:user_activity_id]
+ if new_comment.save
+ update_course_activity(@news.class,@news.id)
+ update_user_activity(@news.class,@news.id)
+ update_org_activity(@news.class,@news.id)
+ if @user_activity_id
+ respond_to do |format|
+ format.js
+ return
+ end
+ else
+ respond_to do |format|
+ format.html {
+ redirect_to news_path(@news)
+ }
+ end
+ end
+ end
end
private
@@ -87,5 +126,4 @@ class CommentsController < ApplicationController
@news
end
-
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 665273ae0..41ea9c45e 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -301,7 +301,6 @@ class CoursesController < ApplicationController
def member
## 有角色参数的才是课程,没有的就是项目
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
-
@render_file = 'new_member_list'
@score_sort_by = "desc"
@sort_type = params[:sort_type] ? params[:sort_type] : "score"
@@ -414,6 +413,9 @@ class CoursesController < ApplicationController
end
def settings
+ #添加成员消息状态
+ join_course_messages = CourseMessage.where("user_id =? and course_message_type =? and course_id =? and status = ? and viewed =?", User.current.id, 'JoinCourse', @course.id, 1, 0)
+ join_course_messages.update_all(:viewed => true)
if User.current.allowed_to?(:as_teacher,@course)
@select_tab = params[:tab]
@issue_custom_fields = IssueCustomField.sorted.all
@@ -905,6 +907,7 @@ class CoursesController < ApplicationController
end
@type = params[:type]
+ @left_nav_type = 1
respond_to do |format|
format.js
format.html{render :layout => 'base_courses'}
@@ -936,6 +939,7 @@ class CoursesController < ApplicationController
end
@jour = paginateHelper @jours,10
@state = false
+ @left_nav_type = 6
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
@@ -1119,6 +1123,14 @@ class CoursesController < ApplicationController
end
end
+ #统计
+ def statistics_course
+ @left_nav_type = 9
+ respond_to do |format|
+ format.html {render :layout => 'base_courses'}
+ end
+ end
+
private
def update_quotes attachment
if attachment.copy_from
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index c3964c567..e3caaf9fb 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -29,6 +29,7 @@ class ExerciseController < ApplicationController
exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc")
end
@exercises = paginateHelper exercises,20 #分页
+ @left_nav_type = 8
respond_to do |format|
format.html
end
@@ -72,6 +73,7 @@ class ExerciseController < ApplicationController
end
# @percent = get_percent(@exercise,User.current)
@exercise_questions = @exercise.exercise_questions
+ @left_nav_type = 8
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
@@ -118,6 +120,7 @@ class ExerciseController < ApplicationController
end
def edit
+ @left_nav_type = 8
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@@ -159,6 +162,7 @@ class ExerciseController < ApplicationController
@exercise = Exercise.find(params[:id])
exercise_questions = @exercise.exercise_questions
@exercise_questions = paginateHelper exercise_questions, 5
+ @left_nav_type = 8
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@@ -379,6 +383,7 @@ class ExerciseController < ApplicationController
else
@exercise_users_list = []
end
+ @left_nav_type = 8
respond_to do |format|
format.html
format.xls {
@@ -566,6 +571,7 @@ class ExerciseController < ApplicationController
eu = get_exercise_user(@exercise.id, @user.id)
eu.update_attributes(:score => score)
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
+ @left_nav_type = 8
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index f06725d01..ed2b2ebfa 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -366,6 +366,7 @@ class FilesController < ApplicationController
@tag_list = attachment_tag_list @all_attachments
+ @left_nav_type = 5
render :layout => 'base_courses'
elsif params[:org_subfield_id]
if params[:sort]
@@ -445,6 +446,7 @@ class FilesController < ApplicationController
@versions = @project.versions.sort
@course_tag = @project.project_type
if @project.project_type == 1
+ @left_nav_type = 5
render :layout => 'base_courses'
end
end
@@ -812,6 +814,7 @@ class FilesController < ApplicationController
@attachtype = params[:type].to_i
@contenttype = params[:contentType].to_s
# render layout: 'base_courses'
+ @left_nav_type = 5
respond_to do |format|
format.js
format.html {
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 6724f42bb..2020915f8 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -39,6 +39,7 @@ class HomeworkCommonController < ApplicationController
end
end
+ @left_nav_type = 3
respond_to do |format|
format.js
format.html
@@ -60,6 +61,7 @@ class HomeworkCommonController < ApplicationController
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
if @is_in_course == 1 || @course_activity == 1
+ @left_nav_type = 3
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 049842e37..921d7d12b 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -432,15 +432,14 @@ class IssuesController < ApplicationController
def add_journal
if User.current.logged?
- @jour = Journal.new
- @jour.user_id = User.current.id
- @jour.notes = params[:notes]
- @jour.journalized = @issue
- @jour.save_attachments(params[:attachments])
- @jour.save
+ jour = Journal.new
+ jour.user_id = User.current.id
+ jour.notes = params[:notes]
+ jour.journalized = @issue
+ jour.save_attachments(params[:attachments])
+ jour.save
update_user_activity(@issue.class,@issue.id)
update_forge_activity(@issue.class,@issue.id)
- @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@user_activity_id = params[:user_activity_id]
if params[:issue_id]
@@ -474,7 +473,6 @@ class IssuesController < ApplicationController
def reply
@issue = Issue.find(params[:id])
@jour = Journal.find(params[:journal_id])
- @tempContent = "
#{ll(Setting.default_language, :text_user_wrote, @jour.user.realname.blank? ? @jour.user.login: @jour.user.realname)}
#{@jour.notes.html_safe}
".html_safe
respond_to do |format|
format.js
end
@@ -483,17 +481,17 @@ class IssuesController < ApplicationController
#给issue添加journ。回复内容包含 对某个被回复的journ的内容
def add_reply
if User.current.logged?
- jour = Journal.new
- jour.user_id = User.current.id
- jour.notes = params[:quote]+params[:notes]
+ jour = Journal.find(params[:journal_id])
@issue = Issue.find params[:id]
- jour.journalized = @issue
- jour.save
- update_user_activity(@issue.class,@issue.id)
- update_forge_activity(@issue.class,@issue.id)
+ new_jour = @issue.journals.build(:user_id => User.current.id, :reply_id => params[:journal_id], :notes => params[:content], :parent_id => jour.id)
+ @user_activity_id = params[:user_activity_id]
+ if new_jour.save
+ update_user_activity(@issue.class,@issue.id)
+ update_forge_activity(@issue.class,@issue.id)
- respond_to do |format|
- format.html{redirect_to issue_url(@issue)}
+ respond_to do |format|
+ format.js
+ end
end
end
end
@@ -502,8 +500,9 @@ class IssuesController < ApplicationController
def delete_journal
@issue = Issue.find(params[:id])
Journal.destroy(params[:journal_id])
- respond_to do |format|
- format.html{redirect_to issue_url(@issue)}
+ @user_activity_id = params[:user_activity_id]
+ respond_to do |format|
+ format.js
end
end
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index f5ad89832..fae350a6a 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -124,6 +124,7 @@ class MessagesController < ApplicationController
end
else
+ @left_nav_type = 2
respond_to do |format|
format.html {
layout_file = @project ? 'base_projects' : 'base_courses'
@@ -140,15 +141,15 @@ class MessagesController < ApplicationController
def reply
if params[:parent_id]
parent = Message.find params[:parent_id]
+ @topic = params[:activity_id].nil? ? parent : Message.find(params[:activity_id].to_i)
@reply = Message.new
@reply.author = User.current
@reply.board = parent.board
@reply.content = params[:content]
- @reply.subject = "RE: #{parent.subject}"
- @reply.reply_id = params[:reply_id]
+ @reply.subject = "RE: #{@topic.subject}"
+ @reply.reply_id = params[:id]
# @reply.reply_id = params[:id]
parent.children << @reply
- @topic = params[:activity_id].nil? ? parent : Message.find(params[:activity_id].to_i)
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
@is_course = params[:is_course] if params[:is_course]
@is_board = params[:is_board] if params[:is_board]
@@ -241,6 +242,7 @@ class MessagesController < ApplicationController
if @project
layout_file = 'base_projects'
elsif @course
+ @left_nav_type = 2
layout_file = 'base_courses'
elsif @org_subfield
@organization = @org_subfield.organization
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 76b229dbf..190c3852b 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -56,7 +56,7 @@ class NewsController < ApplicationController
:order => "#{News.table_name}.created_on DESC",
:offset => @page * 10,
:limit => 10)
-
+ @left_nav_type = 4
respond_to do |format|
format.html {
@news = News.new # for adding news inline
@@ -136,6 +136,7 @@ class NewsController < ApplicationController
@newss = paginateHelper @newss,@limit
#@newss = paginateHelper scope_order,10
+ @left_nav_type = 4
respond_to do |format|
format.html {
@news = News.new
@@ -176,6 +177,7 @@ class NewsController < ApplicationController
if @news.course_id
@course = Course.find(@news.course_id)
if @course
+ @left_nav_type = 4
render :layout => 'base_courses'
end
elsif @news.org_subfield_id
@@ -279,6 +281,7 @@ class NewsController < ApplicationController
@organization = @org_subfield.organization
end
if @course
+ @left_nav_type = 4
render :layout => "base_courses"
elsif @org_subfield
render :layout => 'base_org'
diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb
index 924be596e..a8a294d4d 100644
--- a/app/controllers/org_document_comments_controller.rb
+++ b/app/controllers/org_document_comments_controller.rb
@@ -1,6 +1,6 @@
class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index]
- before_filter :authorize_allowed, :only => [:create, :add_reply]
+ before_filter :authorize_allowed, :only => [:create, :add_reply, :add_reply_in_doc]
helper :attachments,:organizations
layout 'base_org'
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index e4cf31f55..ad04e68fa 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -15,6 +15,7 @@ class PollController < ApplicationController
polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
end
@polls = paginateHelper polls,20 #分页
+ @left_nav_type = 7
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@@ -25,7 +26,7 @@ class PollController < ApplicationController
def show
@poll = Poll.find params[:id]
- if @poll.polls_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)
+ if @poll.polls_status != 2 && !(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)
render_403
return
end
@@ -44,6 +45,7 @@ class PollController < ApplicationController
@percent = get_percent(@poll,User.current)
poll_questions = @poll.poll_questions
@poll_questions = paginateHelper poll_questions,5 #分页
+ @left_nav_type = 7
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
@@ -78,6 +80,7 @@ class PollController < ApplicationController
def edit
respond_to do |format|
+ @left_nav_type = 7
format.html{render :layout => 'base_courses'}
end
end
@@ -112,6 +115,7 @@ class PollController < ApplicationController
@poll = Poll.find(params[:id])
poll_questions = @poll.poll_questions
@poll_questions = paginateHelper poll_questions, 5
+ @left_nav_type = 7
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@@ -393,6 +397,7 @@ class PollController < ApplicationController
#显示某个学生某份问卷的填写结果
def poll_result
@poll_questions = paginateHelper @poll.poll_questions,5
+ @left_nav_type = 7
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 45b54cf0a..4992501c5 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -526,6 +526,7 @@ class StudentWorkController < ApplicationController
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID
@message_student_work_id = params[:student_work_id]
+ @left_nav_type = 3
respond_to do |format|
format.js
format.html
@@ -918,6 +919,7 @@ class StudentWorkController < ApplicationController
ORDER BY absence #{order}")
end
@order = order == "desc" ? "asc" : "desc"
+ @left_nav_type = 3
respond_to do |format|
format.html
end
diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb
index 291e6ca30..9c69f5259 100644
--- a/app/controllers/syllabuses_controller.rb
+++ b/app/controllers/syllabuses_controller.rb
@@ -13,7 +13,6 @@ class SyllabusesController < ApplicationController
end
def show
- #@courses = @syllabus.courses
respond_to do |format|
format.js
format.html{render :layout => 'base_syllabus'}
@@ -109,11 +108,7 @@ class SyllabusesController < ApplicationController
sort_name = "updated_on"
sort_type = @c_sort == 1 ? "asc" : "desc"
- if User.current == @syllabus.user || User.current.admin?
- @courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
- else
- @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
- end
+ @courses = @syllabus.courses.where("is_delete = ?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}")
#根据 作业+资源数排序
if @order.to_i == 2
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 5a88e90d3..5e968e854 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -94,6 +94,12 @@ class UsersController < ApplicationController
@comment = Message.find params[:comment].to_i
when 'BlogComment'
@comment = BlogComment.find params[:comment].to_i
+ when 'OrgDocumentComment'
+ @comment = OrgDocumentComment.find params[:comment].to_i
+ when 'Comment'
+ @comment = Comment.find params[:comment].to_i
+ when 'Journal'
+ @comment = Journal.find params[:comment].to_i
end
end
@@ -133,6 +139,16 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'OrgDocumentComment'
+ when 'News'
+ @reply = Comment.find params[:reply_id]
+ @user_activity_id = params[:user_activity_id]
+ @activity_id = params[:activity_id]
+ @type = 'News'
+ when 'Issue'
+ @reply = Journal.find params[:reply_id]
+ @user_activity_id = params[:user_activity_id]
+ @activity_id = params[:activity_id]
+ @type = 'Issue'
end
respond_to do |format|
format.js
@@ -709,9 +725,9 @@ class UsersController < ApplicationController
@user = User.current
@select_course = params[:select_course] ? 1 : 0
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
- visible_course = Course.where("is_public = 1 && is_delete = 0")
- visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
+ courses = @user.courses.where("is_delete = 1")
+ course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
@type = params[:type]
@limit = 15
@is_remote = true
@@ -933,6 +949,7 @@ class UsersController < ApplicationController
@student_work = StudentWork.new
end
@course = @homework.course
+ @left_nav_type = 3
respond_to do |format|
format.js
format.html {render :layout => 'base_courses'}
@@ -1549,7 +1566,11 @@ class UsersController < ApplicationController
when "current_user"
@user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10)
else
- blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
+ if @user == User.current
+ blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
+ else
+ blog_ids = "("+@user.blog.id.to_s+")"
+ end
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
@@ -1559,8 +1580,12 @@ class UsersController < ApplicationController
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
# blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
# 减少数据库交互
- watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(','))
- user_ids = "(" + @user.id.to_s + watched_user_ids + ")"
+ if @user == User.current
+ watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(','))
+ user_ids = "(" + @user.id.to_s + watched_user_ids + ")"
+ else
+ user_ids = "(" + @user.id.to_s + ")"
+ end
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}")
blog_ids = watched_user_blog_ids.empty? ? "(-1)" : "(" + watched_user_blog_ids.map { |blog| blog.id}.join(",") + ")"
@@ -3312,19 +3337,22 @@ class UsersController < ApplicationController
when 'News'
obj = News.where('id = ?', params[:id].to_i).first
@journals = obj.comments.reorder("created_on desc")
+ @type = 'News'
+ @user_activity_id = params[:div_id].to_i if params[:div_id]
when 'Syllabus'
obj = Syllabus.where('id = ?', params[:id].to_i).first
- @journals = obj.comments.reorder("created_on desc")
+ @journals = obj.journals_for_messages.reorder("created_on desc")
when 'JournalsForMessage'
obj = JournalsForMessage.where('id = ?', params[:id].to_i).first
journals = []
@journals = get_all_children(journals, obj)
@type = 'JournalsForMessage'
@user_activity_id = params[:div_id].to_i if params[:div_id]
- @allow_delete = params[:allow_delete]
when 'Issue'
obj = Issue.where('id = ?', params[:id].to_i).first
@journals = obj.journals.reorder("created_on desc")
+ @type = 'Issue'
+ @user_activity_id = params[:div_id].to_i if params[:div_id]
when 'BlogComment'
obj = BlogComment.where('id = ?', params[:id].to_i).first
@user_activity_id = params[:div_id].to_i if params[:div_id]
@@ -3334,6 +3362,7 @@ class UsersController < ApplicationController
@journals = get_all_children(comments, obj)
when 'HomeworkCommon'
obj = HomeworkCommon.where('id = ?', params[:id].to_i).first
+ @type = 'HomeworkCommon'
@journals = obj.journals_for_messages.reorder("created_on desc")
@is_in_course = params[:is_in_course].to_i if params[:is_in_course]
@course_activity = params[:course_activity].to_i if params[:course_activity]
diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb
index ea305d967..6b1e3010d 100644
--- a/app/controllers/wechats_controller.rb
+++ b/app/controllers/wechats_controller.rb
@@ -78,12 +78,7 @@ class WechatsController < ActionController::Base
end
# When user view URL in the menu button
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
- uw = user_binded?(request[:FromUserName])
- unless uw
- sendBind(request)
- else
- request.reply.text "#{request[:FromUserName]} view #{view}"
- end
+ request.reply.text "#{request[:FromUserName]} view #{view}"
end
# When user sent the imsage
@@ -147,6 +142,14 @@ class WechatsController < ActionController::Base
default_msg(request)
end
+ on :click, with: 'PROJECT' do |request, key|
+ request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
+ end
+
+ on :click, with: 'JOIN_PROJECT' do |request, key|
+ request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
+ end
+
on :click, with: 'JOIN_CLASS' do |request, key|
uw = user_binded?(request[:FromUserName])
unless uw
@@ -218,8 +221,8 @@ class WechatsController < ActionController::Base
raise CoursesService::JoinCourseError.message(status[:state])
end
- news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
- content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
+ news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
+ content: "课程名称:#{course.name}\n班级名称:#{course.name}\n任课老师:#{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} }
return request.reply.news(news) do |article, n, index| # article is return object
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
@@ -274,7 +277,7 @@ class WechatsController < ActionController::Base
user: user
)
ws = WechatService.new
- ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now))
+ ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.login, format_time(Time.now))
render :json => {status:0, msg: "绑定成功"}
rescue Exception=>e
render :json => {status: -1, msg: e.message}
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 8a871e2ea..089333160 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -44,6 +44,13 @@ module ApplicationHelper
user.nil? ? User.find(2) : user
end
+ # 历史数据(老版本库数据)处理完则可以修改该放放
+ def get_rep_identifier_by_project project
+ identifier = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier)
+ result = identifier.nil? ? Repository.where(:project_id => project.id).first.try(:identifier) : identifier
+ result
+ end
+
# 获取用户单位
# 优先获取高校信息,如果改信息不存在则获取occupation
def get_occupation_from_user user
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index d1f4bfe97..42511f218 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -35,7 +35,7 @@ module CoursesHelper
and (c.is_excellent =1 or c.excellent_option =1) and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;"
default_ids = Course.find_by_sql(sql).flatten.map { |c| c.id }
excellent_ids << default_ids.flatten
- arr_result = excellent_ids.flatten.uniq.first(5)
+ arr_result = excellent_ids.flatten.uniq.first(3)
excellent_courses = Course.find(arr_result)
return excellent_courses
end
@@ -78,18 +78,18 @@ module CoursesHelper
#生成课程老师成员链接
def course_teacher_link teacher_num
if User.current.member_of_course?(@course) || User.current.admin?
- link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue', :id => 'teacher_number'
+ link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'sy_cblue', :id => 'teacher_number'
else
- content_tag 'span',teacher_num, :class => 'info_foot_num c_blue'
+ content_tag 'span',teacher_num, :class => 'sy_cblue'
end
end
#生成课程学生列表连接
def course_student_link student_num
if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) || User.current.admin?
- link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue', :id => "student_number"
+ link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'sy_cblue', :id => "student_number"
else
- content_tag 'span',student_num, :class => 'info_foot_num c_blue'
+ content_tag 'span',student_num, :class => 'sy_cblue'
end
end
@@ -772,12 +772,12 @@ module CoursesHelper
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'
if joined
- link = link_to(text, url, :remote => true, :method => method, :class => "Blue-btn", :style => "margin_left: 0px;", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
+ link = link_to(text, url, :remote => true, :method => method, :class => "sy_btn_grey fl", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
else
- link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "Blue-btn", :style => "margin_left: 0px;")
+ link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "sy_btn_grey fl")
end
else
- link = "#{l(:label_course_join_student)}"
+ link = "#{l(:label_course_join_student)}"
end
link.html_safe
end
@@ -872,7 +872,7 @@ module CoursesHelper
desc.html_safe
end
- # 学生按作业总分排序,取前8个
+ # 学生按作业总分排序,取前3个
def hero_homework_score(course, score_sort_by)
sql_select = "SELECT members.*,(
SELECT SUM(work_score)
@@ -884,14 +884,14 @@ module CoursesHelper
FROM members
JOIN students_for_courses
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
- WHERE members.course_id = #{course.id} ORDER BY score #{score_sort_by} limit 9"
+ WHERE members.course_id = #{course.id} ORDER BY score #{score_sort_by} limit 3"
homework_scores = Member.find_by_sql(sql_select)
end
def contributor_course_scor(course_id)
ccs = CourseContributorScore.find_by_sql("SELECT * FROM `course_contributor_scores` where course_id = #{course_id} order by
(message_num*2 + message_reply_num + news_reply_num + news_num +
- resource_num*5 + journal_num + homework_journal_num ) desc limit 9;")
+ resource_num*5 + journal_num + homework_journal_num ) desc limit 3;")
end
end
diff --git a/app/helpers/wechats_helper.rb b/app/helpers/wechats_helper.rb
new file mode 100644
index 000000000..5c6b3da8c
--- /dev/null
+++ b/app/helpers/wechats_helper.rb
@@ -0,0 +1,20 @@
+#coding=utf-8
+#
+
+module WechatsHelper
+ def include_wechat_jsfile
+ if Rails.env.production?
+ javascript_include_tag '/javascripts/wechat/build/app.min.js'
+ else
+ wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")
+ srcs = Rails.application.config.wechat_srcs
+ paths = []
+ srcs.each do |src|
+ Dir.glob(wechat_path+ "/#{src}" ) do |path|
+ paths << path[File.join(Rails.root, "public").to_s.size, path.size]
+ end
+ end
+ javascript_include_tag *paths
+ end
+ end
+end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 80b52a8f4..633c9a825 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -33,10 +33,11 @@ class Comment < ActiveRecord::Base
:title=>Proc.new {|o| "RE: #{o.commented.title}" },
:url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} }
+ acts_as_tree :counter_cache => :comments_count, :order => "#{Comment.table_name}.created_on ASC"
belongs_to :commented, :polymorphic => true, :counter_cache => true,:touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :commented, :author, :comments
- safe_attributes 'comments'
+ safe_attributes 'comments','parent_id','reply_id','comments_count'
after_create :send_mail, :act_as_system_message, :act_as_student_score
after_destroy :down_course_score
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 0f88fcb7f..d2cc9e539 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -37,6 +37,7 @@ class Journal < ActiveRecord::Base
has_many :at_messages, as: :at_message, dependent: :destroy
acts_as_attachable
attr_accessor :indice
+ acts_as_tree :counter_cache => :comments_count, :order => "#{Journal.table_name}.created_on ASC"
acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" },
:description =>:notes,
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 39c77de4b..d864b6462 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -162,7 +162,7 @@ class CoursesService
raise '403'
end
end
- @comments = @news.comments
+ @comments = @news.comments.reorder("created_on desc")
@comments.reverse! if current_user.wants_comments_in_reverse_order?
{:news => @news,:comments => @comments}
@@ -335,6 +335,7 @@ class CoursesService
8, '您已经是该班级的教师了',
9, '您已经是该班级的教辅了',
10, '您已经是该班级的管理员了',
+ 11, '该班级不存在或已被删除啦',
'未知错误,请稍后再试'
]
end
@@ -348,6 +349,8 @@ class CoursesService
if course
if course_endTime_timeout? course
@state = 2
+ elsif course[:is_delete] == 1
+ @state = 11
else
if current_user.member_of_course?(course) #如果已经是成员
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
@@ -392,7 +395,7 @@ class CoursesService
def homework_list params,current_user
course = Course.find(params[:id])
if course.is_public != 0 || current_user.member_of_course?(course)
- bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).order('created_at DESC')
+ bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC')
bids = bids.like(params[:name]) if params[:name].present?
homeworks = []
bids.each do |bid|
@@ -495,7 +498,7 @@ class CoursesService
def course_attachments params
result = []
course = Course.find(params[:course_id])
- attachments = course.attachments.where("is_publish = 1").order("created_on desc")
+ attachments = course.attachments.where("is_publish = 1").reorder("created_on desc")
if !params[:name].nil? && params[:name] != ""
attachments.each do |atta|
result << atta if atta.filename.include?(params[:name])
@@ -632,7 +635,7 @@ class CoursesService
:homework_submit_num => bid.student_works.count,
:homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid),
:student_evaluation_part => get_evaluation_part( bid ,3),
- :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?}
+ :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?,:current_user_is_teacher => is_course_teacher}
end
diff --git a/app/services/resources_service.rb b/app/services/resources_service.rb
index bc97437e4..b56da8ad3 100644
--- a/app/services/resources_service.rb
+++ b/app/services/resources_service.rb
@@ -49,6 +49,125 @@ class ResourcesService
[@ori, @flag, @save_message]
end
+ def send_homework_to_course user,params
+ homework = HomeworkCommon.find params[:send_id].to_i
+ @ori = homework
+ course_ids = params[:course_ids]
+ @flag = false
+ unless course_ids.nil?
+ course_ids.each do |course_id|
+ course = Course.find course_id.to_i
+ new_homework = HomeworkCommon.new
+ new_homework.name = homework.name
+ new_homework.user_id = user.id
+ new_homework.description = homework.description
+ new_homework.homework_type = homework.homework_type
+ new_homework.late_penalty = homework.late_penalty
+ new_homework.course_id = course.id
+ new_homework.teacher_priority = homework.teacher_priority
+ new_homework.anonymous_comment = homework.anonymous_comment
+ new_homework.quotes = 0
+ new_homework.is_open = homework.is_open
+ homework.attachments.each do |attachment|
+ att = attachment.copy
+ att.container_id = nil
+ att.container_type = nil
+ att.copy_from = attachment.id
+ att.save
+ new_homework.attachments << att
+ end
+ homework_detail_manual = homework.homework_detail_manual
+ homework_detail_programing = homework.homework_detail_programing
+ homework_detail_group = homework.homework_detail_group
+ if homework_detail_manual
+ new_homework.homework_detail_manual = HomeworkDetailManual.new
+ new_homework_detail_manual = new_homework.homework_detail_manual
+ new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
+ new_homework_detail_manual.comment_status = 0
+ new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
+ new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
+ end
+ if homework_detail_programing
+ new_homework.homework_detail_programing = HomeworkDetailPrograming.new
+ new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
+ new_homework.homework_detail_programing.language = homework_detail_programing.language
+ homework.homework_tests.each_with_index do |homework_test|
+ new_homework.homework_tests << HomeworkTest.new(
+ input: homework_test.input,
+ output: homework_test.output
+ )
+ end
+ end
+
+ if homework_detail_group
+ new_homework.homework_detail_group = HomeworkDetailGroup.new
+ new_homework.homework_detail_group.min_num = homework_detail_group.min_num
+ new_homework.homework_detail_group.max_num = homework_detail_group.max_num
+ new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
+ end
+ if new_homework.save
+ new_homework_detail_manual.save if new_homework_detail_manual
+ new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
+ new_homework.homework_detail_group.save if new_homework.homework_detail_group
+ @flag = true
+ else
+ @flag = false
+ @save_message = new_homework.errors.full_messages
+ break
+ end
+ homework.update_column(:quotes, homework.quotes+1)
+ end
+ end
+ [@ori, @flag, @save_message]
+ end
+
+ def send_exercise_to_course user,params
+ # send_id = params[:send_id]
+ # @ori = Attachment.find_by_id(send_id)
+ # course_ids = params[:course_ids]
+ # @flag = false
+ # unless course_ids.nil?
+ # course_ids.each do |id|
+ # next if @ori.blank?
+ # @exist = false
+ # Course.find(id).attachments.each do |att| #如果课程中包含该资源
+ # if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
+ # att.created_on = Time.now
+ # att.save
+ # @exist = true
+ # @flag = true
+ # break
+ # end
+ # end
+ # next if @exist
+ # attach_copied_obj = @ori.copy
+ # attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
+ # attach_copied_obj.container = Course.find(id)
+ # attach_copied_obj.created_on = Time.now
+ # attach_copied_obj.author_id = user.id
+ # attach_copied_obj.is_public = 0
+ # attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
+ # if attach_copied_obj.attachtype == nil
+ # attach_copied_obj.attachtype = 4
+ # end
+ # if attach_copied_obj.save
+ # # 更新引用次数
+ # quotes = @ori.quotes.to_i + 1
+ # @ori.update_attribute(:quotes, quotes) unless @ori.nil?
+ # @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ # @flag = true
+ # else
+ # @flag = false
+ # @save_message = attach_copied_obj.errors.full_messages
+ # break
+ # end
+ #
+ # end
+ # end
+
+ [@ori, @flag, @save_message]
+ end
+
# 我的资源-课件 已发布的
def all_course_attachments user
diff --git a/app/services/syllabuses_service.rb b/app/services/syllabuses_service.rb
index d5dec9f88..fcb70653b 100644
--- a/app/services/syllabuses_service.rb
+++ b/app/services/syllabuses_service.rb
@@ -71,8 +71,8 @@ class SyllabusesService
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count
if count == 0
ws = WechatService.new
- title = "恭喜您创建班级成功"
- ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情"
+ title = "恭喜您创建班级成功。"
+ ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情。"
end
end
diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb
index 2da942ea6..7ac4e99d3 100644
--- a/app/services/wechat_service.rb
+++ b/app/services/wechat_service.rb
@@ -229,7 +229,7 @@ class WechatService
color:"#707070"
},
remark:{
- value:"绑定成功后可使用微信查看Trustie平台最新动态",
+ value:"绑定成功后可使用微信查看Trustie平台最新动态。",
color:"#707070"
}
}
diff --git a/app/views/account/about_us.html.erb b/app/views/account/about_us.html.erb
index f990cd64c..a2b1c895b 100644
--- a/app/views/account/about_us.html.erb
+++ b/app/views/account/about_us.html.erb
@@ -1,4 +1,4 @@
-<%= stylesheet_link_tag 'new_user'%>
+<%= stylesheet_link_tag 'css/public'%>
关于我们
diff --git a/app/views/account/agreement.html.erb b/app/views/account/agreement.html.erb
index 921f66350..ac0b9906c 100644
--- a/app/views/account/agreement.html.erb
+++ b/app/views/account/agreement.html.erb
@@ -1,4 +1,4 @@
-<%= stylesheet_link_tag 'new_user'%>
+<%= stylesheet_link_tag 'css/public'%>
Trustie服务协议
@@ -28,24 +28,5 @@
-
-
+
diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb
index cfe9cd695..eae72bdb6 100644
--- a/app/views/account/login.html.erb
+++ b/app/views/account/login.html.erb
@@ -1,5 +1,5 @@
-<%= stylesheet_link_tag 'new_user'%>
-<%= stylesheet_link_tag 'leftside'%>
+<%= stylesheet_link_tag 'css/common'%>
+<%= stylesheet_link_tag 'css/public'%>
\ No newline at end of file
diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb
index e336c7d01..de7be84c1 100644
--- a/app/views/blog_comments/_new.html.erb
+++ b/app/views/blog_comments/_new.html.erb
@@ -36,6 +36,8 @@
:maxlength => 5000 }%>
+
+
-
\ No newline at end of file
+
diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb
index bde98d456..f5c7c9094 100644
--- a/app/views/blog_comments/show.html.erb
+++ b/app/views/blog_comments/show.html.erb
@@ -135,13 +135,8 @@
<%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
-
- <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %>
- <%= time_from_now(comment.created_on) %>
-
- <% if !comment.parent.nil? && !comment.parent.parent.nil? %>
- <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
- <% end %>
+ <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
+
<% if !comment.content_detail.blank? %>