Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
This commit is contained in:
commit
1c95e76209
|
@ -30,3 +30,4 @@ vendor/cache
|
|||
/public/files
|
||||
/tags
|
||||
/config/initializers/gitlab_config.rb
|
||||
1234567
|
||||
|
|
1
1234567
1
1234567
|
@ -1 +0,0 @@
|
|||
{"access_token":"q51KZUeA6_-CCCH-Buy1m4pR7G9hh-9GT_Vn-h9oFq8qfF9SVVeagJZ7Jeuvv3k12UEXk7IxtAuXkrBlufaanGd81bNEEkXkPyhPveTHenmjj5fQa3GQmxCM9kUPhZjyXMPjCIAKZC","expires_in":7200,"got_token_at":1464146250}
|
25
Client.html
25
Client.html
|
@ -1,25 +0,0 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>
|
||||
Client
|
||||
</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<hr />
|
||||
<h2>这是一张图片</h2>
|
||||
<p>photo<a href="http://10.0.47.15:3000/shares/new?access_token='2d3dda45dsd'&comment='verygood'&title=davide&share_type=1&url=http://www.baidu.com"> Share A </a></p>
|
||||
<hr />
|
||||
|
||||
<h2>这是一段视频</h2>
|
||||
<p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=kaka&share_type=2&url=http://www.sina.com"> Share B </a></p>
|
||||
<hr />
|
||||
|
||||
<h2>这是一篇文章</h2>
|
||||
<p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=pepe&share_type=3&url=http://www.sina.com"> Share C </a></p>
|
||||
<hr />
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
13
Gemfile
13
Gemfile
|
@ -1,12 +1,14 @@
|
|||
source 'https://ruby.taobao.org'
|
||||
#source 'http://ruby.sdutlinux.org/'
|
||||
source 'https://rubygems.org/'
|
||||
### <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>bundle config mirror.https://rubygems.org https://gems.ruby-china.org <20>л<EFBFBD><D0BB><EFBFBD>ruby-chinaԴ
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
gem 'iconv'
|
||||
end
|
||||
|
||||
gem 'wechat',git: 'https://github.com/guange2015/wechat.git'
|
||||
gem 'certified'
|
||||
|
||||
gem 'wechat',path: 'lib/wechat'
|
||||
gem 'grack', path:'lib/grack'
|
||||
gem 'gitlab', path: 'lib/gitlab-cli'
|
||||
gem 'rest-client'
|
||||
|
@ -42,9 +44,14 @@ gem 'kaminari'
|
|||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
|
||||
|
||||
### profile
|
||||
#gem 'oneapm_rpm'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
# gem "query_reviewer"
|
||||
# gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
if RUBY_PLATFORM =~ /w32/
|
||||
gem 'win32console'
|
||||
|
|
|
@ -33,10 +33,10 @@ module Mobile
|
|||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
page = params[:page] ? params[:page] : 0
|
||||
user_project_ids = (user.projects.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
principal_types = "JournalsForMessage"
|
||||
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 + ")"
|
||||
|
|
|
@ -14,7 +14,7 @@ module Mobile
|
|||
else
|
||||
case f
|
||||
when :user_act
|
||||
if ac.act_type == "ProjectCreateInfo"
|
||||
if ac.act_type == "Project"
|
||||
ac unless ac.nil?
|
||||
else
|
||||
ac.act unless ac.nil? || ac.act.nil?
|
||||
|
@ -87,7 +87,7 @@ module Mobile
|
|||
"项目问题"
|
||||
when "Message"
|
||||
"项目讨论区"
|
||||
when "ProjectCreateInfo"
|
||||
when "Project"
|
||||
"项目"
|
||||
end
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ module Mobile
|
|||
expose :container_type #课程/项目/博客/个人
|
||||
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
|
||||
if a.is_a? ::UserActivity
|
||||
if a.act_type == "ProjectCreateInfo"
|
||||
if a.act_type == "Project"
|
||||
get_user(get_project(a.act_id).user_id)
|
||||
elsif !a.act.nil?
|
||||
if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
|
||||
|
|
|
@ -47,6 +47,7 @@ module Mobile
|
|||
blog_comment_expose :created_at
|
||||
blog_comment_expose :lasted_comment
|
||||
blog_comment_expose :id
|
||||
blog_comment_expose :locked
|
||||
blog_comment_expose :praise_count
|
||||
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
|
|
|
@ -51,6 +51,7 @@ module Mobile
|
|||
message_expose :replies_count
|
||||
message_expose :praise_count
|
||||
message_expose :created_on
|
||||
message_expose :locked
|
||||
message_expose :id
|
||||
message_expose :lasted_comment
|
||||
expose :message_children,using:Mobile::Entities::Message do |c,opt|
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the sub_document_comments controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the sub_domains controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -593,7 +593,7 @@ class AdminController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#代码测试列表
|
||||
#代码测试列表
|
||||
def code_work_tests
|
||||
#求出所有条数
|
||||
tCount = CodeTests.count()
|
||||
|
@ -610,15 +610,33 @@ class AdminController < ApplicationController
|
|||
tStart = @page*30
|
||||
@code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ")
|
||||
|
||||
#取出各个作业是否是模拟答题的
|
||||
#取出各个作品是否是模拟答题的
|
||||
is_test = {}
|
||||
#作品是否存在
|
||||
link_swork = {}
|
||||
#作业是否存在
|
||||
link_hwork = {}
|
||||
@code_work_tests.each do |test|
|
||||
#作品是否存在
|
||||
if is_test[test['student_work_id']] != nil
|
||||
test['link_swork'] = link_swork[test['student_work_id']]
|
||||
test['is_test'] = is_test[test['student_work_id']]
|
||||
else
|
||||
test['is_test'] = StudentWork.find(test['student_work_id']).is_test
|
||||
work = StudentWork.where("id=?",test['student_work_id']).first
|
||||
test['link_swork'] = !work.nil?
|
||||
test['is_test'] = work.nil? ? false : work.is_test
|
||||
#test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test']
|
||||
is_test[test['student_work_id']] = test['is_test']
|
||||
link_swork[test['student_work_id']] = test['link_swork']
|
||||
end
|
||||
|
||||
#作业是否存在
|
||||
if link_hwork[test['homework_id']] != nil
|
||||
test['link_hwork'] = link_hwork[test['homework_id']]
|
||||
else
|
||||
hwork = HomeworkCommon.where("id=?",test['homework_id']).first
|
||||
test['link_hwork'] = !hwork.nil?
|
||||
link_hwork[test['homework_id']] = test['link_hwork']
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -626,4 +644,13 @@ class AdminController < ApplicationController
|
|||
format.html
|
||||
end
|
||||
end
|
||||
#分享作业申请
|
||||
def apply_for_homework
|
||||
homeworks = ApplyHomework.where("user_id != 0")
|
||||
@homework = paginateHelper homeworks,30
|
||||
@page = (params['page'] || 1).to_i - 1
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -363,7 +363,11 @@ class ApplicationController < ActionController::Base
|
|||
when "contest"
|
||||
return true
|
||||
when "Course"
|
||||
allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false)
|
||||
if @attachment.get_status_by_attach(User.current.id) == 2
|
||||
return true
|
||||
else
|
||||
allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false)
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ class AtController < ApplicationController
|
|||
end
|
||||
|
||||
def find_project(id)
|
||||
return [] if id<0
|
||||
return [] if id.to_i<0
|
||||
at_persons = Project.find(id).users
|
||||
at_persons.delete_if { |u| u.id == User.current.id }
|
||||
end
|
||||
|
|
|
@ -1,9 +1,55 @@
|
|||
class BlogsController < ApplicationController
|
||||
before_filter :find_blog,:except => [:index,:create,:new,:set_homepage, :cancel_homepage]
|
||||
before_filter :find_user
|
||||
include PraiseTreadHelper
|
||||
|
||||
def index
|
||||
@article = BlogComment.new
|
||||
|
||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type 1升序 2 降序
|
||||
if @order.to_i == @type.to_i
|
||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||
else
|
||||
@b_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_at"
|
||||
|
||||
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||
|
||||
@topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{sort_type}")
|
||||
|
||||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
|
||||
@topics.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
|
||||
if topic[:infocount] < 0
|
||||
topic[:infocount] = 0
|
||||
end
|
||||
end
|
||||
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
|
||||
@topics = sort_by_sticky @topics
|
||||
@topics = sortby_time_countcommon_hassticky @topics,sort_name
|
||||
else
|
||||
@type = 1
|
||||
end
|
||||
|
||||
#分页
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@atta_count = @topics.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@topics = paginateHelper @topics,@limit
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout=>'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ class BoardsController < ApplicationController
|
|||
helper :watchers
|
||||
helper :project_score
|
||||
helper :attachments
|
||||
include PraiseTreadHelper
|
||||
def index
|
||||
#modify by nwb
|
||||
@flag = params[:flag] || false
|
||||
|
@ -62,13 +63,24 @@ class BoardsController < ApplicationController
|
|||
else
|
||||
render_403
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
# 讨论区消息状态更新(已读和未读)
|
||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type 1升序 2 降序
|
||||
if @order.to_i == @type.to_i
|
||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||
else
|
||||
@b_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_on"
|
||||
|
||||
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||
|
||||
if @project
|
||||
ForgeMessage.where("user_id =? and project_id =? and viewed =?", User.current.id, @project.id, 0).update_all(:viewed => true)
|
||||
# 更新@消息为已读
|
||||
|
@ -82,63 +94,88 @@ class BoardsController < ApplicationController
|
|||
CourseMessage.where("user_id =? and course_id =? and viewed =?", User.current.id, @course.id, 0).update_all(:viewed => true)
|
||||
end
|
||||
|
||||
sort_init 'updated_on', 'desc'
|
||||
sort_update 'created_on' => "#{Message.table_name}.created_on",
|
||||
'replies' => "#{Message.table_name}.replies_count",
|
||||
'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
|
||||
# sort_init 'updated_on', 'desc'
|
||||
# sort_update 'created_on' => "#{Message.table_name}.created_on",
|
||||
# 'replies' => "#{Message.table_name}.replies_count",
|
||||
# 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
|
||||
|
||||
@is_new = params[:is_new]
|
||||
@topic_count = @board ? @board.topics.count : 0
|
||||
if @project
|
||||
if @board
|
||||
limit = 10;
|
||||
@topic_count = @board.topics.count();
|
||||
@topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10
|
||||
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) desc").
|
||||
limit(limit).offset(@topic_pages).includes(:last_reply).
|
||||
@topic_pages = 0#(params[:page] ? params[:page].to_i + 1 : 0) *10
|
||||
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").
|
||||
offset(@topic_pages).includes(:last_reply).
|
||||
preload(:author, {:last_reply => :author}).all();
|
||||
else
|
||||
@topics = [];
|
||||
end
|
||||
elsif @course
|
||||
if (@board)
|
||||
limit = 10;
|
||||
@topic_count = @board.topics.count();
|
||||
@topic_pages = (params[:page] ? params[:page].to_i + 1 : 0) *10
|
||||
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) desc").
|
||||
limit(limit).offset(@topic_pages).includes(:last_reply).
|
||||
preload(:author, {:last_reply => :author}).all();
|
||||
@topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10
|
||||
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
|
||||
else
|
||||
@topics = [];
|
||||
end
|
||||
end
|
||||
|
||||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@topics.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
|
||||
if topic[:infocount] < 0
|
||||
topic[:infocount] = 0
|
||||
end
|
||||
end
|
||||
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
@topics = sort_by_sticky @topics
|
||||
@topics = sortby_time_countcommon_hassticky @topics,sort_name
|
||||
else
|
||||
@type = 1
|
||||
end
|
||||
|
||||
#分页
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
@atta_count = @topics.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@topics = paginateHelper @topics,@limit
|
||||
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@message = Message.new(:board => @board)
|
||||
#modify by nwb
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {
|
||||
if @project
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
elsif @course
|
||||
@params=params
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
end
|
||||
}
|
||||
format.atom {
|
||||
@messages = @board.messages.
|
||||
reorder('created_on DESC').
|
||||
includes(:author, :board).
|
||||
limit(Setting.feeds_limit.to_i).
|
||||
all
|
||||
if @project
|
||||
render_feed(@messages, :title => "#{@project}: #{@board}")
|
||||
elsif @course
|
||||
render_feed(@messages, :title => "#{@course}: #{@board}")
|
||||
end
|
||||
|
||||
}
|
||||
if (params[:page] || params[:order])
|
||||
respond_to do |format|
|
||||
format.js{render "show.js.erb"}
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {
|
||||
if @project
|
||||
render :action => 'show', :layout => 'base_projects'
|
||||
elsif @course
|
||||
@params=params
|
||||
render :action => 'show', :layout => 'base_courses'
|
||||
end
|
||||
}
|
||||
format.atom {
|
||||
@messages = @board.messages.
|
||||
reorder('created_on DESC').
|
||||
includes(:author, :board).
|
||||
limit(Setting.feeds_limit.to_i).
|
||||
all
|
||||
if @project
|
||||
render_feed(@messages, :title => "#{@project}: #{@board}")
|
||||
elsif @course
|
||||
render_feed(@messages, :title => "#{@course}: #{@board}")
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ class CoursesController < ApplicationController
|
|||
@subPage_title = l :label_student_list
|
||||
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
||||
# @is_remote = true
|
||||
@sort_type = 'score'
|
||||
@score_sort_by = "desc"
|
||||
q = "#{params[:name].strip}"
|
||||
if params[:incourse]
|
||||
|
@ -185,9 +186,11 @@ class CoursesController < ApplicationController
|
|||
group.course_id = @course.id
|
||||
group.save
|
||||
end
|
||||
@sort_type = 'score'
|
||||
@score_sort_by = "desc"
|
||||
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
||||
@is_remote = true
|
||||
@members = student_homework_score(0,0, 10,"desc")
|
||||
@members = student_homework_score(0,0, 10,@score_sort_by)
|
||||
@course_groups = @course.course_groups
|
||||
end
|
||||
|
||||
|
@ -196,7 +199,9 @@ class CoursesController < ApplicationController
|
|||
@subPage_title = l :label_student_list
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||
@is_remote = true
|
||||
|
||||
@sort_type = 'score'
|
||||
@score_sort_by = "desc"
|
||||
@members = student_homework_score(0,0, 10,@score_sort_by)
|
||||
@course_groups = @course.course_groups
|
||||
end
|
||||
|
||||
|
@ -281,6 +286,7 @@ class CoursesController < ApplicationController
|
|||
@render_file = 'new_member_list'
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||
@is_remote = true
|
||||
@sort_type = 'score'
|
||||
@score_sort_by = "desc"
|
||||
if params[:group_id] && params[:group_id] != "0"
|
||||
@group = CourseGroup.find(params[:group_id])
|
||||
|
@ -298,6 +304,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
@render_file = 'new_member_list'
|
||||
@score_sort_by = "desc"
|
||||
@sort_type = "score"
|
||||
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
||||
@role = params[:role].nil? ? '2':params[:role]
|
||||
@is_remote = true
|
||||
|
@ -312,7 +319,7 @@ class CoursesController < ApplicationController
|
|||
if @course.open_student == 1 || User.current.member_of_course?(@course)
|
||||
@subPage_title = l :label_student_list
|
||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||
@all_members = student_homework_score(0,page, 10,"desc")
|
||||
@all_members = student_homework_score(0,page, 10,@score_sort_by)
|
||||
@members = @all_members
|
||||
else
|
||||
render_403
|
||||
|
@ -334,7 +341,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
def export_course_member_excel
|
||||
@all_members = student_homework_score(0,0,0,"desc")
|
||||
@homeworks = @course.homework_commons.order("created_at asc")
|
||||
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||
filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}";
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -350,28 +357,29 @@ class CoursesController < ApplicationController
|
|||
@subPage_title = l :label_student_list
|
||||
@render_file = 'new_member_list'
|
||||
@is_remote = true
|
||||
@sort_type = params[:sort_type] if params[:sort_type]
|
||||
@score_sort_by = params[:sort_by] if params[:sort_by]
|
||||
@search_name = params[:search_name] if params[:search_name]
|
||||
group_id = params[:group_id]
|
||||
if !@search_name.nil?
|
||||
if group_id == '0'
|
||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
|
||||
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by,@sort_type), @search_name)
|
||||
@result_count = @results.count
|
||||
# @results = paginateHelper @results, 10
|
||||
else
|
||||
@group = CourseGroup.find(group_id)
|
||||
@results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by),@search_name)
|
||||
@results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type),@search_name)
|
||||
@result_count = @results.count
|
||||
# @results = paginateHelper @results, 10
|
||||
end
|
||||
else
|
||||
if group_id == '0'
|
||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||
@results = student_homework_score(0,page, 10,@score_sort_by)
|
||||
@results = student_homework_score(0,page, 10,@score_sort_by,@sort_type)
|
||||
else
|
||||
@group = CourseGroup.find(group_id)
|
||||
@results = student_homework_score(group_id, 0, 0,@score_sort_by)
|
||||
@results = student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -384,6 +392,15 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 显示每个学生的作业评分详情
|
||||
def show_member_act_score
|
||||
@member = Member.find(params[:member_id]) if params[:member_id]
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'course_base'}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def handle_course courses, activities
|
||||
course_activity_count_array=activities.values()
|
||||
course_array=[]
|
||||
|
@ -1149,33 +1166,37 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def student_homework_score(groupid,start_from, nums, score_sort_by)
|
||||
def student_homework_score(groupid,start_from, nums, score_sort_by, sort_type = 'score')
|
||||
start_from = start_from * nums
|
||||
sql_select = ""
|
||||
if groupid == 0
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
|
||||
SELECT SUM(student_works.work_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{@course.id}
|
||||
AND student_works.user_id = members.user_id
|
||||
) AS score
|
||||
) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 +
|
||||
resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id
|
||||
) AS act_score
|
||||
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}"
|
||||
WHERE members.course_id = #{@course.id} ORDER BY #{sort_type} #{score_sort_by}"
|
||||
else
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
|
||||
SELECT SUM(student_works.work_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{@course.id}
|
||||
AND student_works.user_id = members.user_id
|
||||
) AS score
|
||||
) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 +
|
||||
resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id
|
||||
) AS act_score
|
||||
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} AND members.course_group_id = #{groupid} ORDER BY score #{score_sort_by}"
|
||||
WHERE members.course_id = #{@course.id} AND members.course_group_id = #{groupid} ORDER BY #{sort_type} #{score_sort_by}"
|
||||
end
|
||||
sql = ActiveRecord::Base.connection()
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
|
@ -1225,8 +1246,7 @@ class CoursesController < ApplicationController
|
|||
sheet1[5,i+4] = "第"+(i+1).to_s+"次"
|
||||
end
|
||||
sheet1[5,homeworks.count+4] = "总成绩"
|
||||
sheet1[5,0] = "排名"
|
||||
sheet1[5,0] = "排名"
|
||||
sheet1[5,homeworks.count+5] = "活跃度"
|
||||
count_row = 6
|
||||
members.each_with_index do |member, i|
|
||||
sheet1[count_row,0]= i+1
|
||||
|
@ -1236,14 +1256,15 @@ class CoursesController < ApplicationController
|
|||
homeworks.each_with_index do |homework, j|
|
||||
student_works = homework.student_works.where("user_id = #{member.user.id}")
|
||||
if student_works.empty?
|
||||
sheet1[count_row,j+4] = format("%0.2f",0)
|
||||
sheet1[count_row,j+4] = 0
|
||||
else
|
||||
final_score = student_works.first.final_score.nil? ? 0 : student_works.first.final_score
|
||||
score = final_score - student_works.first.absence_penalty - student_works.first.late_penalty
|
||||
sheet1[count_row,j+4] = format("%0.2f",score <0 ? 0:score)
|
||||
sheet1[count_row,j+4] = score <0 ? 0:score.round(2)
|
||||
end
|
||||
end
|
||||
sheet1[count_row,homeworks.count+4] = format("%0.2f",member.score.nil? ? 0:member.score.to_s)
|
||||
sheet1[count_row,homeworks.count+4] = member.score.nil? ? 0:member.score.round(2)
|
||||
sheet1[count_row,homeworks.count+5] = member.act_score.nil? ? 0:member.act_score
|
||||
count_row += 1
|
||||
end
|
||||
|
||||
|
|
|
@ -256,6 +256,13 @@ class FilesController < ApplicationController
|
|||
@order = ""
|
||||
@is_remote = false
|
||||
if params[:project_id]
|
||||
# 更新资源申请消息为已读
|
||||
# ar_ids = ApplyResource.where("user_id =? and container_id =? and container_type =?", User.current.id, params[:project_id].to_i, "Project").map{|ar| ar.id}
|
||||
# cms = CourseMessage.where("course_message_type =? and user_id =? and course_message_id in (#{ar_ids.empty? ? '0': ar_ids.join(',')})", "ApplyResource", User.current.id)
|
||||
# cms.each do |cm|
|
||||
# cm.update_column(:viewed, true)
|
||||
# end
|
||||
# over
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 2
|
||||
@container_type = 0
|
||||
if params[:sort]
|
||||
|
|
|
@ -11,21 +11,25 @@ class HomeworkCommonController < ApplicationController
|
|||
before_filter :member_of_course, :only => [:index]
|
||||
|
||||
def index
|
||||
#unless params[:page]
|
||||
# update_homework_time(@course.homework_commons)
|
||||
#end
|
||||
@new_homework = HomeworkCommon.new
|
||||
@new_homework.homework_detail_manual = HomeworkDetailManual.new
|
||||
@new_homework.course = @course
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
||||
if @is_teacher
|
||||
@homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10)
|
||||
#@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
|
||||
@homework_commons = @course.homework_commons.order("created_at desc")
|
||||
else
|
||||
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10)
|
||||
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@homework_commons = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc")
|
||||
end
|
||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||
@is_new = params[:is_new]
|
||||
|
||||
@homeworks = paginateHelper @homework_commons,10
|
||||
#设置at已读
|
||||
@homeworks.each do |homework|
|
||||
homework.journals_for_messages.each do |j|
|
||||
|
@ -73,16 +77,23 @@ class HomeworkCommonController < ApplicationController
|
|||
else
|
||||
@homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
|
||||
@homework.end_time = params[:homework_common][:end_time] || Time.now
|
||||
@homework.course_id = params[:course_id]
|
||||
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
|
||||
anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0
|
||||
if anonymous != @homework.anonymous_comment
|
||||
if anonymous == 1
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4
|
||||
else
|
||||
homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 0.6 : 0.3
|
||||
end
|
||||
end
|
||||
|
||||
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
|
||||
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
|
||||
homework_detail_manual.comment_status = 1
|
||||
end
|
||||
eval_start = homework_detail_manual.evaluation_start
|
||||
if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1
|
||||
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
||||
homework_detail_manual.evaluation_start = @homework.end_time + 7
|
||||
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
|
||||
end
|
||||
|
@ -94,6 +105,13 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework.homework_detail_programing ||= HomeworkDetailPrograming.new
|
||||
@homework_detail_programing = @homework.homework_detail_programing
|
||||
@homework_detail_programing.language = params[:language_type].to_i
|
||||
if anonymous != @homework.anonymous_comment
|
||||
if anonymous == 1
|
||||
@homework_detail_programing.ta_proportion = 0.6
|
||||
else
|
||||
@homework_detail_programing.ta_proportion = 0.5
|
||||
end
|
||||
end
|
||||
|
||||
@homework.homework_tests.delete_all
|
||||
inputs = params[:program][:input]
|
||||
|
@ -116,8 +134,9 @@ class HomeworkCommonController < ApplicationController
|
|||
@homework_detail_group.base_on_project = params[:base_on_project].to_i
|
||||
end
|
||||
|
||||
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0
|
||||
if @homework.save
|
||||
@homework_detail_manual.save if @homework_detail_manual
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
@homework_detail_programing.save if @homework_detail_programing
|
||||
@homework_detail_group.save if @homework_detail_group
|
||||
|
||||
|
@ -273,9 +292,9 @@ class HomeworkCommonController < ApplicationController
|
|||
|
||||
def open_student_works
|
||||
if @homework.is_open == 0
|
||||
@homework.update_attribute(:is_open, 1)
|
||||
@homework.update_column('is_open', 1)
|
||||
else
|
||||
@homework.update_attribute(:is_open, 0)
|
||||
@homework.update_column('is_open', 0)
|
||||
end
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
@is_in_course = params[:is_in_course] if params[:is_in_course]
|
||||
|
@ -385,4 +404,47 @@ class HomeworkCommonController < ApplicationController
|
|||
student_works += student_works
|
||||
student_works[index + 1 .. index + n]
|
||||
end
|
||||
|
||||
def update_homework_time homeworks
|
||||
unless homeworks.nil?
|
||||
homeworks.each do |h|
|
||||
if h.homework_type == 3
|
||||
student_works = h.student_work_projects.where("is_leader = 1")
|
||||
time = h.updated_at
|
||||
unless student_works.nil?
|
||||
student_works.each do |s|
|
||||
project = Project.find s.project_id
|
||||
unless project.nil? && project.gpid.nil?
|
||||
project_time=project.updated_on
|
||||
project_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last
|
||||
if format_time(time) < format_time(project_time)
|
||||
time = project_time
|
||||
end
|
||||
begin
|
||||
# gitlab端获取默认分支
|
||||
g = Gitlab.client
|
||||
default_branch = g.project(project.gpid).default_branch
|
||||
changesets = g.commits(project.gpid, :ref_name => default_branch)
|
||||
changesets_latest_coimmit = changesets[0]
|
||||
unless changesets[0].blank?
|
||||
if format_time(time) < format_time(changesets_latest_coimmit.created_at)
|
||||
time = changesets_latest_coimmit.created_at
|
||||
end
|
||||
end
|
||||
rescue
|
||||
logger.error("############## ==> update homework project time")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
puts h.updated_at
|
||||
puts time
|
||||
s_time = time
|
||||
if format_time(time) > format_time(h.updated_at)
|
||||
h.update_column('updated_at', s_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,25 +70,71 @@ class NewsController < ApplicationController
|
|||
end
|
||||
elsif @course
|
||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type 1升序 2 降序
|
||||
if @order.to_i == @type.to_i
|
||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||
else
|
||||
@b_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_at"
|
||||
|
||||
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||
|
||||
#scope = News.find_by_sql("select a.*,b.updated_at from news a, course_activities b where a.course_id = 532 and a.course_id = b.course_id and b.course_act_id = a.id ) ")
|
||||
|
||||
scope = @course ? @course.news.course_visible : News.course_visible
|
||||
news_arr = scope.map{|news| news.id}
|
||||
|
||||
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
news_page = @page *10
|
||||
news_page = 0 #@page *10
|
||||
@news_count = scope.count
|
||||
@is_new = params[:is_new]
|
||||
@q = params[:subject]
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all()
|
||||
scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on #{sort_type}").offset(news_page).includes(:author,:course).all()
|
||||
#all(:include => [:author, :course],
|
||||
#:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page)
|
||||
else
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all()
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:course).all()
|
||||
#.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
|
||||
end
|
||||
|
||||
scope_order.each do |topic|
|
||||
topic[:updated_at] = topic.course_acts.first.updated_at
|
||||
#topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at
|
||||
end
|
||||
|
||||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
scope_order.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + topic.comments.count
|
||||
if topic[:infocount] < 0
|
||||
topic[:infocount] = 0
|
||||
end
|
||||
end
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
scope_order = sort_by_sticky scope_order
|
||||
scope_order = sortby_time_countcommon_hassticky scope_order,sort_name
|
||||
else
|
||||
@type = 1
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:updated_at] <=> y[:updated_at] } : scope_order = scope_order.sort{|x,y| y[:updated_at] <=> x[:updated_at] }
|
||||
scope_order = sort_by_sticky scope_order
|
||||
end
|
||||
|
||||
@newss = scope_order
|
||||
|
||||
#分页
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
@atta_count = @newss.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@newss = paginateHelper @newss,@limit
|
||||
|
||||
#@newss = paginateHelper scope_order,10
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
|
@ -79,7 +79,7 @@ class OrgDocumentCommentsController < ApplicationController
|
|||
|
||||
def add_reply
|
||||
@document = OrgDocumentComment.find(params[:id]).root
|
||||
@act = OrgActivity.find(params[:id])
|
||||
@act = OrgActivity.find(params[:act_id])
|
||||
@comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
|
||||
@comment.content = params[:org_content]
|
||||
@document.children << @comment
|
||||
|
@ -103,6 +103,7 @@ class OrgDocumentCommentsController < ApplicationController
|
|||
|
||||
def destroy
|
||||
@org_document_comment = OrgDocumentComment.find(params[:id])
|
||||
@org_sub_id = @org_document_comment.org_subfield_id
|
||||
org = @org_document_comment.organization
|
||||
if @org_document_comment.id == org.home_id
|
||||
org.update_attributes(:home_id => nil)
|
||||
|
|
|
@ -15,6 +15,12 @@ class OrgSubfieldsController < ApplicationController
|
|||
end
|
||||
end
|
||||
@subfield.update_attributes(:field_type => params[:field_type])
|
||||
# 如果栏目是教师,不参入类型的配置,定义为右三模式
|
||||
# 新增模块命名规则,左边1开头,右边2开头,以前的不变
|
||||
# eg:23 右三
|
||||
if params[:field_type] == "Comptec"
|
||||
@subfield.update_attributes(:status => 23)
|
||||
end
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController
|
|||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout]
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers]
|
||||
layout 'base_org'
|
||||
def index
|
||||
|
||||
|
@ -76,7 +76,7 @@ class OrganizationsController < ApplicationController
|
|||
|
||||
def show
|
||||
# 组织新类型 show_mode:判断标准 1为新类型,0为旧
|
||||
if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:list] .nil?
|
||||
if @organization.show_mode.to_i == 1 && params[:org_subfield_id].nil? && params[:list] .nil?
|
||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||
# REDO:时间紧,暂时先这样
|
||||
@org_logo_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 0 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first
|
||||
|
@ -84,13 +84,6 @@ class OrganizationsController < ApplicationController
|
|||
|
||||
@subfield_content = @organization.org_subfields.order("priority")
|
||||
@organization = Organization.find(params[:id])
|
||||
# 统计访问量
|
||||
@organization.update_column(:visits, @organization.visits.to_i + 1)
|
||||
|
||||
# @org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
# @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
# @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
|
||||
shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
|
||||
project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0
|
||||
|
@ -98,37 +91,33 @@ class OrganizationsController < ApplicationController
|
|||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
@project_acts = get_project_activities_org @organization, project_ids
|
||||
@course_acts = get_course_activities_org @organization, course_ids
|
||||
#@org_acts = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc')
|
||||
#@project_acts = OrgActivity.where("(container_id =? and container_type =?) " +
|
||||
# "or (container_type ='Project' and org_act_type in ('Issue','Message') and container_id in (#{project_ids.join(',')})) ",
|
||||
# @organization.id, 'Organization').order('updated_at desc').limit(8)
|
||||
|
||||
#@course_acts = OrgActivity.where("(container_id =? and container_type =?) " +
|
||||
# "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
|
||||
# @organization.id, 'Organization').order('updated_at desc').limit(8)
|
||||
|
||||
|
||||
|
||||
# 项目两种动态
|
||||
#@project_acts = get_project_activities_org @organization
|
||||
|
||||
# 课程动态
|
||||
#@project_acts_issues = get_project_activities_org @organization
|
||||
#@course_acts = get_course_activities_org @organization
|
||||
|
||||
render :layout => 'base_org_newstyle'
|
||||
render :layout => 'base_org2'
|
||||
else
|
||||
render_403
|
||||
end
|
||||
else
|
||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||
@organization = Organization.find(params[:id])
|
||||
# 统计访问量
|
||||
@organization.update_column(:visits, @organization.visits.to_i + 1)
|
||||
# params[:org_subfield_id] 存在即对应的栏目,否则进入组织动态
|
||||
if params[:org_subfield_id]
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu"
|
||||
|
||||
# @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count
|
||||
# from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc")
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc")
|
||||
# @org_count = @org_teachers.count
|
||||
# @limit = 25
|
||||
# @is_remote = true
|
||||
# @atta_count = @attachments.count
|
||||
# @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
# @offset ||= @atta_pages.offset
|
||||
# #@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
# @attachments = paginateHelper @attachments,25
|
||||
else
|
||||
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
|
||||
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
end
|
||||
else
|
||||
shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
|
||||
|
@ -138,7 +127,7 @@ class OrganizationsController < ApplicationController
|
|||
case params[:type]
|
||||
when nil
|
||||
@org_activities = OrgActivity.where("(container_id =? and container_type =?) " +
|
||||
"or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+
|
||||
"or (container_type ='Project' and org_act_type in ('Issue','Message','Project') and container_id in (#{project_ids.join(',')})) "+
|
||||
"or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))",
|
||||
@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10)
|
||||
when 'project_issue'
|
||||
|
@ -169,6 +158,57 @@ class OrganizationsController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def teachers
|
||||
unless @organization.allow_set_teachers
|
||||
render_403
|
||||
return
|
||||
end
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Comptec").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
if @type == "courses" || @type.nil?
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "students"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "resources"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "famous"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
end
|
||||
limit = 10
|
||||
# @is_remote = true
|
||||
@teachers_count = @org_teachers.count
|
||||
@atta_pages = Paginator.new @teachers_count, limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
@org_teachers = paginateHelper @org_teachers, limit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def searchmember_by_name members, name
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
mems = []
|
||||
if name != ""
|
||||
name = name.to_s.downcase
|
||||
members.each do |m|
|
||||
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
||||
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
||||
mems << m
|
||||
end
|
||||
end
|
||||
else
|
||||
mems = members
|
||||
end
|
||||
mems
|
||||
end
|
||||
|
||||
def get_project_message_activities_org org
|
||||
project_ids = org.projects.map{|project| project.id}.join(",")
|
||||
unless project_ids.blank?
|
||||
|
@ -192,7 +232,7 @@ class OrganizationsController < ApplicationController
|
|||
def get_project_activities_org org, project_ids
|
||||
unless project_ids.blank?
|
||||
project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids.join(',')}) and container_type = 'project'
|
||||
and org_act_type in ('Message', 'Issue') order by updated_at desc limit 8;")
|
||||
and org_act_type in ('Message', 'Issue') order by updated_at desc limit 5;")
|
||||
else
|
||||
project_acts = nil
|
||||
end
|
||||
|
@ -203,7 +243,7 @@ class OrganizationsController < ApplicationController
|
|||
def get_course_activities_org org, course_ids
|
||||
unless course_ids.blank?
|
||||
project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids.join(',')}) and container_type = 'course'
|
||||
and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 8;")
|
||||
and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 5;")
|
||||
else
|
||||
project_acts = nil
|
||||
end
|
||||
|
@ -248,6 +288,7 @@ class OrganizationsController < ApplicationController
|
|||
# @organization.domain = params[:organization][:domain]
|
||||
@organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0
|
||||
@organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0
|
||||
@organization.allow_teacher = params[:organization][:allow_teacher] == 'on' ? 1 : 0
|
||||
@organization.show_mode = params[:show_mode]
|
||||
#@organization.name = params[:organization][:name]
|
||||
@organization.save
|
||||
|
@ -430,6 +471,18 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 设置为名师
|
||||
def set_excellent_teacher
|
||||
@ex_teacher = User.find(params[:user])
|
||||
@ex_teacher.update_column(:excellent_teacher, 1)
|
||||
end
|
||||
|
||||
# 取消名师
|
||||
def reset_excellent_teacher
|
||||
@ex_teacher = User.find(params[:user])
|
||||
@ex_teacher.update_column(:excellent_teacher, 0)
|
||||
end
|
||||
|
||||
def hide_org_subfield
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@org_subfield.update_attribute(:hide, 1)
|
||||
|
|
|
@ -423,9 +423,13 @@ class PollController < ApplicationController
|
|||
# 将其他地方的问卷导出来
|
||||
def other_poll
|
||||
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入
|
||||
tea_ids = '('
|
||||
tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
|
||||
@polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
|
||||
courses = User.current.courses.select { |course| User.current.allowed_to?(:as_teacher,course)}
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map { |course| course.id}.join(',') + ")"
|
||||
none_courses = User.current.courses.where("is_delete = 1 or #{Course.table_name}.id = #{params[:polls_group_id].to_i}")
|
||||
none_course_ids = none_courses.empty? ? "(-1)" : "(" + none_courses.map { |course| course.id}.join(',') + ")"
|
||||
#tea_ids = '('
|
||||
#tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
|
||||
@polls = Poll.where("(user_id = #{User.current.id} or polls_group_id in #{course_ids}) and polls_type = 'course' and polls_group_id not in #{none_course_ids}")
|
||||
@polls_group_id = params[:polls_group_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -32,9 +32,9 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats]
|
||||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive]
|
||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff]
|
||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive]
|
||||
accept_rss_auth :revisions
|
||||
# hidden repositories filter // 隐藏代码过滤器
|
||||
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ]
|
||||
|
@ -95,6 +95,13 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
# 一键ZIP下载
|
||||
def project_archive
|
||||
g = Gitlab.client
|
||||
g.get()
|
||||
# g.project_archive(params[:gpid].to_i, params[:rev])
|
||||
end
|
||||
|
||||
# 判断用户是否已经fork过该项目
|
||||
def has_forked?(project, user)
|
||||
projects = Project.where("user_id =?", user)
|
||||
|
@ -325,27 +332,11 @@ update
|
|||
end
|
||||
end
|
||||
|
||||
# unless @repository.gitlab?
|
||||
# # redirect_to to_gitlab_project_repository_path(@project, @repository)
|
||||
# render :to_gitlab
|
||||
# return
|
||||
# end
|
||||
|
||||
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
||||
# @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||
|
||||
# :name, :path, :kind, :size, :lastrev, :changeset
|
||||
@entries = @repository.entries(@path, @rev)
|
||||
# @trees = g.trees(project, @path)
|
||||
@changeset = @repository.find_changeset_by_name(@rev)
|
||||
#@project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
#@ip = RepositoriesHelper::REPO_IP_ADDRESS
|
||||
|
||||
if request.xhr?
|
||||
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||||
else
|
||||
#Modified by young
|
||||
# (show_error_not_found; return) unless @entries
|
||||
g = Gitlab.client
|
||||
@changesets = g.commits(@project.gpid, :ref_name => @rev)
|
||||
g_project = g.project(@project.gpid)
|
||||
|
@ -360,18 +351,19 @@ update
|
|||
if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0
|
||||
update_commits_count(@project, @changesets_all_count)
|
||||
end
|
||||
# end
|
||||
# 最近一次提交
|
||||
@changesets_latest_coimmit = @changesets[0]
|
||||
unless @changesets[0].blank?
|
||||
update_commits_date(@project, @changesets_latest_coimmit)
|
||||
end
|
||||
@creator = User.where("id =?", @project.user_id).first.try(:login)
|
||||
@properties = @repository.properties(@path, @rev)
|
||||
@repositories = @project.repositories
|
||||
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
ip = RepositoriesHelper::REPO_IP_ADDRESS
|
||||
# @properties = @repository.properties(@path, @rev)
|
||||
# @repositories = @project.repositories
|
||||
# project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
|
||||
# ip = RepositoriesHelper::REPO_IP_ADDRESS
|
||||
gitlab_address = Redmine::Configuration['gitlab_address']
|
||||
# REDO:需优化,仅测试用
|
||||
@zip_path = gitlab_address.to_s + "/api/v3/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=YTyCv4978MXmdL2B9C62"
|
||||
if @repository.type.to_s == "Repository::Gitlab"
|
||||
@repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
|
||||
else
|
||||
|
@ -586,8 +578,6 @@ update
|
|||
end
|
||||
end
|
||||
end
|
||||
# @static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2)
|
||||
# @static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3)
|
||||
rescue
|
||||
render_404
|
||||
return
|
||||
|
|
|
@ -32,6 +32,10 @@ class SettingsController < ApplicationController
|
|||
hidden_non_project = Setting.find_by_name("hidden_non_project")
|
||||
@text = (hidden_non_project && hidden_non_project.value == "0") ? l(:label_show_non_project) : l(:label_hidden_non_project)
|
||||
|
||||
#1隐藏了课程信息 0显示了课程信息
|
||||
hidden_courses = Setting.find_by_name("hidden_courses")
|
||||
@text_1 = (hidden_courses && hidden_courses.value == "1") ? l(:label_show_courses) : l(:label_hidden_courses)
|
||||
|
||||
@notifiables = Redmine::Notifiable.all
|
||||
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
||||
settings = (params[:settings] || {}).dup.symbolize_keys
|
||||
|
@ -89,4 +93,22 @@ class SettingsController < ApplicationController
|
|||
|
||||
redirect_to settings_url
|
||||
end
|
||||
|
||||
#隐藏/显示课程信息
|
||||
def hidden_courses
|
||||
@notifiable = Setting.find_by_name("hidden_courses")
|
||||
if @notifiable
|
||||
@notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1
|
||||
@notifiable.save
|
||||
else
|
||||
@notifiable = Setting.new()
|
||||
@notifiable.name = "hidden_courses"
|
||||
@notifiable.value = 1
|
||||
@notifiable.save
|
||||
end
|
||||
|
||||
redirect_to settings_url
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
#coding=utf-8
|
||||
|
||||
require 'base64'
|
||||
require 'json'
|
||||
require 'openssl'
|
||||
|
||||
## 单点登录 <=> 北斗
|
||||
class SsosController < ApplicationController
|
||||
|
||||
skip_before_filter :check_if_login_required
|
||||
layout false
|
||||
|
||||
def show
|
||||
begin
|
||||
# suRh2nFEJd0Ai_TFbqZ-1yQXnGfIB-YD_f4KTA3O4dQGSBMiXfOMt-0mzizgXekWTjHKfn62nJ60iHM3_eY_KS0Qn8SF8vANfa46GhzZRt4T0iC5ZOSs4cWeK43OU0RoekQLZZAo5OyOVibxabmiPGzEFCnVVtdmRk9d7X_B0Is=
|
||||
@auth = params[:auth]
|
||||
@options = parse(params[:auth])
|
||||
|
||||
if params[:login].present?
|
||||
@options["name"] = params[:login]
|
||||
end
|
||||
|
||||
logger.debug @options
|
||||
## 认证
|
||||
sso = login(@options)
|
||||
|
||||
## 加入组织
|
||||
@organization = Organization.find(82)
|
||||
unless @organization.org_members.exists?(user_id: sso.user_id)
|
||||
member = OrgMember.create(:user_id => sso.user_id, :created_at => Time.now)
|
||||
# member = OrgMember.new(:user_id => sso.user_id)
|
||||
@organization.org_members << member
|
||||
OrgMemberRole.create(:org_member_id => member.id, :role_id => 12)
|
||||
end
|
||||
|
||||
## 选择性跳转
|
||||
redirect_to @organization
|
||||
rescue => e
|
||||
logger.error e
|
||||
if e.message == "exist user"
|
||||
render 'ssos/show', :layout => false
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
## 改用户名
|
||||
def create
|
||||
show and return
|
||||
end
|
||||
|
||||
private
|
||||
def base64_safe(content)
|
||||
content = content.gsub('-', '+')
|
||||
content.gsub('_', '/')
|
||||
end
|
||||
|
||||
def parse(auth)
|
||||
content = decrypt(auth)
|
||||
ActiveSupport::JSON.decode(content)
|
||||
end
|
||||
|
||||
def login(opt)
|
||||
sso = Sso.sync_user(opt)
|
||||
start_user_session(sso.user)
|
||||
sso
|
||||
end
|
||||
|
||||
def decrypt(auth)
|
||||
crypted_str = Base64.decode64(base64_safe(auth))
|
||||
pkey = OpenSSL::PKey::RSA.new(File.new(File.join(Rails.root,"config/private.key")))
|
||||
|
||||
#to large
|
||||
max_dec_len = 1024/8
|
||||
size = (crypted_str.size + max_dec_len-1) / max_dec_len
|
||||
|
||||
content = ''
|
||||
size.times do |time|
|
||||
tmps = crypted_str[time*max_dec_len, max_dec_len]
|
||||
content += pkey.private_decrypt(tmps,OpenSSL::PKey::RSA::PKCS1_PADDING)
|
||||
end
|
||||
content
|
||||
end
|
||||
|
||||
end
|
|
@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController
|
|||
include ApplicationHelper
|
||||
require 'bigdecimal'
|
||||
require "base64"
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:code_repeattest,:work_canrepeat,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
|
||||
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students,:work_canrepeat]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
|
||||
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
|
||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||
|
@ -17,41 +17,41 @@ class StudentWorkController < ApplicationController
|
|||
is_test = params[:is_test] == 'true'
|
||||
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
|
||||
|
||||
student_work = find_or_save_student_work(is_test)
|
||||
student_work = find_or_save_student_work(is_test)
|
||||
|
||||
unless student_work
|
||||
resultObj[:status] = 100
|
||||
else
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
result = test_realtime(student_work, params[:src])
|
||||
logger.debug result
|
||||
resultObj[:status] = result["status"]
|
||||
resultObj[:results] = result["results"]
|
||||
resultObj[:error_msg] = result["error_msg"]
|
||||
results = result["results"]
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
results = [result["error_msg"]]
|
||||
end
|
||||
student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
|
||||
src: params[:src])
|
||||
unless student_work.save
|
||||
resultObj[:status] = 200
|
||||
unless student_work
|
||||
resultObj[:status] = 100
|
||||
else
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
result = test_realtime(student_work, params[:src])
|
||||
logger.debug result
|
||||
resultObj[:status] = result["status"]
|
||||
resultObj[:results] = result["results"]
|
||||
resultObj[:error_msg] = result["error_msg"]
|
||||
results = result["results"]
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
results = [result["error_msg"]]
|
||||
end
|
||||
student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
|
||||
src: params[:src])
|
||||
unless student_work.save
|
||||
resultObj[:status] = 200
|
||||
else
|
||||
student_work.name = params[:title]
|
||||
student_work.description = params[:src]
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.name = params[:title]
|
||||
student_work.description = params[:src]
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.late_penalty = 0
|
||||
end
|
||||
student_work.save
|
||||
resultObj[:status] = result["status"].to_i
|
||||
resultObj[:time] = student_work_test.created_at.to_s(:db)
|
||||
resultObj[:index] = student_work.student_work_tests.count
|
||||
student_work.late_penalty = 0
|
||||
end
|
||||
student_work.save
|
||||
resultObj[:status] = result["status"].to_i
|
||||
resultObj[:time] = student_work_test.created_at.to_s(:db)
|
||||
resultObj[:index] = student_work.student_work_tests.count
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => resultObj
|
||||
end
|
||||
|
||||
|
@ -81,6 +81,7 @@ class StudentWorkController < ApplicationController
|
|||
#根据传入的tIndex确定是第几次测试
|
||||
#之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来
|
||||
def program_test_ex
|
||||
|
||||
tStarttime = Time.now
|
||||
|
||||
is_test = params[:is_test] == 'true'
|
||||
|
@ -94,62 +95,73 @@ class StudentWorkController < ApplicationController
|
|||
resultObj[:status] = 100
|
||||
else
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
||||
#找到第index个测试的输入输出
|
||||
index = params[:tIndex].to_i
|
||||
resultObj[:tseq] = index
|
||||
test = @homework.homework_tests[index - 1]
|
||||
#找到第index个测试的输入输出
|
||||
index = params[:tIndex].to_i
|
||||
resultObj[:tseq] = index
|
||||
test = @homework.homework_tests[index - 1]
|
||||
|
||||
#请求测试
|
||||
begin
|
||||
result = test_realtime_ex(test, params[:src])
|
||||
rescue Timeout::Error
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒"
|
||||
#请求测试
|
||||
begin
|
||||
result = test_realtime_ex(test, params[:src])
|
||||
rescue Timeout::Error
|
||||
tEndtime = Time.now
|
||||
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
|
||||
logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒"
|
||||
#status 0:答案正确 -5program_test_ex 函数出错 -4judge代码出错 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
|
||||
resultObj[:status] = -3
|
||||
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
|
||||
rescue
|
||||
#-4 judge代码 出错
|
||||
logger.debug "program_test_error 1"
|
||||
resultObj[:status] = -4
|
||||
tmpstatus = -4
|
||||
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>0,:wait_time=>0,:student_work_id=>student_work.id)
|
||||
end
|
||||
|
||||
#status 0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
|
||||
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
|
||||
begin
|
||||
if resultObj[:status] != -3 && resultObj[:status] != -4
|
||||
if result["status"].to_i != -2
|
||||
#result["results"].first['output'] = result["results"].first['output'].gsub(" ","□")
|
||||
#result["results"].first['result'] = result["results"].first['result'].gsub(" ","□")
|
||||
space_replace_1(result["results"].first['output'])
|
||||
space_replace_1(result["results"].first['result'])
|
||||
end
|
||||
|
||||
end
|
||||
if result["status"].to_i != -2
|
||||
#result["results"].first['output'] = result["results"].first['output'].gsub(" ","□")
|
||||
#result["results"].first['result'] = result["results"].first['result'].gsub(" ","□")
|
||||
space_replace_1(result["results"].first['output'])
|
||||
space_replace_1(result["results"].first['result'])
|
||||
end
|
||||
logger.debug result
|
||||
|
||||
logger.debug result
|
||||
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
|
||||
resultObj[:status] = -1
|
||||
resultObj[:results] = result["results"].first #本次测试结果
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
result["error_msg"] = result["error_msg"][0..2047]
|
||||
end
|
||||
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
|
||||
|
||||
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
|
||||
resultObj[:status] = -1
|
||||
resultObj[:results] = result["results"].first #本次测试结果
|
||||
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
|
||||
|
||||
#该状态用于存入CodeTests
|
||||
tmpstatus = -1
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
#该状态用于存入CodeTests
|
||||
tmpstatus = -1
|
||||
if result["status"].to_i == -2 #编译错误
|
||||
resultObj[:results] = result["error_msg"]
|
||||
resultObj[:status] = -2
|
||||
tmpstatus = -2
|
||||
elsif result["results"][0]["status"].to_i == 2
|
||||
elsif result["results"][0]["status"].to_i == 2
|
||||
resultObj[:status] = 2
|
||||
tmpstatus = 2
|
||||
end
|
||||
end
|
||||
|
||||
if result["status"] == 0
|
||||
tmpstatus = 0
|
||||
end
|
||||
if result["status"] == 0
|
||||
tmpstatus = 0
|
||||
end
|
||||
|
||||
unless student_work.save
|
||||
unless student_work.save
|
||||
resultObj[:status] = 200
|
||||
else
|
||||
else
|
||||
student_work.name = params[:title]
|
||||
student_work.description = params[:src]
|
||||
|
||||
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
student_work.late_penalty = @homework.late_penalty
|
||||
else
|
||||
student_work.late_penalty = 0
|
||||
student_work.late_penalty = 0
|
||||
end
|
||||
|
||||
#每次从数据库取出上次的结果加上本次的结果再存入数据库
|
||||
|
@ -181,12 +193,12 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#超时或编译错误则直接返回了并存入数据库
|
||||
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
|
||||
if status == 0
|
||||
resultObj[:status] = 0
|
||||
end
|
||||
student_work.save!
|
||||
resultObj[:time] = student_work_test.created_at.to_s(:db)
|
||||
resultObj[:index] = student_work.student_work_tests.count
|
||||
if status == 0
|
||||
resultObj[:status] = 0
|
||||
end
|
||||
student_work.save!
|
||||
resultObj[:time] = student_work_test.created_at.to_s(:db)
|
||||
resultObj[:index] = student_work.student_work_tests.count
|
||||
end
|
||||
|
||||
#将每次用户等待时间都存起来以便管理界面显示用
|
||||
|
@ -201,17 +213,24 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
#0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
|
||||
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>time_used,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
|
||||
|
||||
#渲染返回结果
|
||||
render :json => resultObj
|
||||
end
|
||||
end
|
||||
rescue
|
||||
#-5 program_test_ex 函数出错
|
||||
logger.debug "program_test_error 2"
|
||||
resultObj[:status] = -5
|
||||
tmpstatus = -5
|
||||
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>0,:wait_time=>0,:student_work_id=>student_work.id)
|
||||
end
|
||||
#渲染返回结果
|
||||
render :json => resultObj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#找出该作业的所有提交作业
|
||||
def find_all_student_work_by_homeid()
|
||||
all_studentwork = StudentWork.where("homework_common_id =#{@homework.id} and is_test = 0 ")
|
||||
all_studentwork = StudentWork.where("homework_common_id = #{@homework.id} and is_test = 0 ")
|
||||
|
||||
all_studentwork
|
||||
end
|
||||
|
@ -287,9 +306,9 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
logger.debug "time3 is #{Time.now.usec} "
|
||||
result['results'].each do |key,value|
|
||||
@student_work = StudentWork.where("id =?", key.to_i).first
|
||||
@student_work.update_column('simi_id', value['simiworkid'].to_i)
|
||||
@student_work.update_column('simi_value', value['simivalue'].to_i)
|
||||
@student_work = StudentWork.where("id =?", key.to_i).first
|
||||
@student_work.update_column('simi_id', value['simiworkid'].to_i)
|
||||
@student_work.update_column('simi_value', value['simivalue'].to_i)
|
||||
# sqlstr = "update student_works set simi_id=#{value['simiworkid']},simi_value=#{value['simivalue']} where id=#{key.to_i} "
|
||||
# dbh.execute(sqlstr)
|
||||
end
|
||||
|
@ -310,7 +329,7 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#转换一下
|
||||
if @homework.simi_time != nil
|
||||
resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S")
|
||||
resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S")
|
||||
else
|
||||
resultObj[:comparetime] = 0
|
||||
end
|
||||
|
@ -357,6 +376,7 @@ class StudentWorkController < ApplicationController
|
|||
##################################################################################################################
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
|
||||
@homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
@all_homework_commons = @course.homework_commons.order("created_at desc")
|
||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
|
||||
@is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
|
||||
@show_all = false
|
||||
|
@ -372,11 +392,11 @@ class StudentWorkController < ApplicationController
|
|||
#开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
|
||||
if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
@show_all = true
|
||||
elsif User.current.member_of_course?(@course)
|
||||
|
@ -386,10 +406,10 @@ class StudentWorkController < ApplicationController
|
|||
if pro.nil?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
|
||||
@stundet_works = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
|
||||
@stundet_works = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:user_id => User.current.id)
|
||||
end
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
if @homework.homework_type == 3
|
||||
|
@ -409,20 +429,20 @@ class StudentWorkController < ApplicationController
|
|||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
|
||||
my_work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
|
||||
my_work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:user_id => User.current.id)
|
||||
end
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
@show_all = true
|
||||
end
|
||||
|
@ -434,15 +454,15 @@ class StudentWorkController < ApplicationController
|
|||
return
|
||||
end
|
||||
|
||||
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
|
||||
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
|
||||
else
|
||||
if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
@show_all = true
|
||||
elsif User.current.member_of_course?(@course)
|
||||
|
@ -452,10 +472,10 @@ class StudentWorkController < ApplicationController
|
|||
if pro.nil?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
|
||||
@stundet_works = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
|
||||
@stundet_works = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:user_id => User.current.id)
|
||||
end
|
||||
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
|
||||
if @homework.homework_type == 3
|
||||
|
@ -475,20 +495,20 @@ class StudentWorkController < ApplicationController
|
|||
if pro.nil?
|
||||
my_work = []
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
|
||||
my_work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => pro.student_work_id)
|
||||
end
|
||||
else
|
||||
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
|
||||
my_work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:user_id => User.current.id)
|
||||
end
|
||||
if my_work.empty?
|
||||
@stundet_works = []
|
||||
else
|
||||
if @order == 'lastname'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
elsif @order == 'student_id'
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
else
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
|
||||
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name
|
||||
end
|
||||
@show_all = true
|
||||
end
|
||||
|
@ -499,11 +519,11 @@ class StudentWorkController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name).count
|
||||
|
||||
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count
|
||||
end
|
||||
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
|
||||
# 消息传过来的ID
|
||||
@message_student_work_id = params[:student_work_id]
|
||||
respond_to do |format|
|
||||
|
@ -653,7 +673,7 @@ class StudentWorkController < ApplicationController
|
|||
if @homework.homework_detail_group.base_on_project == 1
|
||||
stu_project.project_id = @student_work_project.project_id
|
||||
else @homework.homework_detail_group.base_on_project == 0
|
||||
stu_project.project_id = -1
|
||||
stu_project.project_id = -1
|
||||
end
|
||||
stu_project.user_id = members[i].to_i
|
||||
stu_project.is_leader = 0
|
||||
|
@ -761,49 +781,64 @@ class StudentWorkController < ApplicationController
|
|||
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
|
||||
render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
|
||||
@score = student_work_score @work,User.current
|
||||
if @score
|
||||
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@score.score = params[:score] if params[:score]
|
||||
if User.current.admin?
|
||||
@score.reviewer_role = 1
|
||||
else
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
@score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
@is_new = false
|
||||
#@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
#@score.score = params[:score] if params[:score]
|
||||
#if User.current.admin?
|
||||
# @score.reviewer_role = 1
|
||||
#else
|
||||
# role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
# @score.reviewer_role = get_role_by_name(role)
|
||||
#end
|
||||
#@is_new = false
|
||||
@is_last_a = @work.student_works_scores.empty?
|
||||
@new_score = StudentWorksScore.new
|
||||
if @score && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? @score.score : params[:score]
|
||||
elsif @score.nil? && params[:score]
|
||||
@new_score.score = params[:score].to_i == -1 ? nil : params[:score]
|
||||
end
|
||||
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@new_score.user_id = User.current.id
|
||||
@new_score.student_work_id = @work.id
|
||||
if User.current.admin?
|
||||
@new_score.reviewer_role = 1
|
||||
else
|
||||
@is_last_a = @work.student_works_scores.empty?
|
||||
@score = StudentWorksScore.new
|
||||
@score.score = params[:score] if params[:score]
|
||||
@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
|
||||
@score.user_id = User.current.id
|
||||
@score.student_work_id = @work.id
|
||||
if User.current.admin?
|
||||
@score.reviewer_role = 1
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
@new_score.reviewer_role = get_role_by_name(role)
|
||||
end
|
||||
if @score
|
||||
if @is_teacher
|
||||
@is_new = true
|
||||
@is_last_a = false
|
||||
else
|
||||
role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
|
||||
@score.reviewer_role = get_role_by_name(role)
|
||||
@is_new = false
|
||||
end
|
||||
else
|
||||
@is_new = true
|
||||
end
|
||||
|
||||
@score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@score)
|
||||
@new_score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@new_score)
|
||||
|
||||
if @score.save
|
||||
case @score.reviewer_role
|
||||
if @new_score.save
|
||||
case @new_score.reviewer_role
|
||||
when 1 #教师评分:最后一个教师评分为最终评分
|
||||
@work.teacher_score = @score.score
|
||||
@work.teacher_score = @new_score.score
|
||||
when 2 #教辅评分 教辅评分显示平均分
|
||||
@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
|
||||
#@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
|
||||
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
|
||||
@work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
|
||||
when 3 #学生评分 学生评分显示平均分
|
||||
@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
|
||||
#@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
|
||||
stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
|
||||
@work.student_score = stu_score.first.score.try(:round, 2).to_f
|
||||
end
|
||||
@homework.update_attributes(:updated_at => Time.now)
|
||||
@homework.update_column('updated_at', Time.now)
|
||||
update_course_activity(@homework.class,@homework.id)
|
||||
update_user_activity(@homework.class,@homework.id)
|
||||
update_org_activity(@homework.class,@homework.id)
|
||||
if @work.save
|
||||
@work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -836,6 +871,14 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#提交未评分的评语
|
||||
def add_comments_to_work
|
||||
@work = StudentWork.find params[:id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#为作品点赞
|
||||
def praise_student_work
|
||||
pt = PraiseTread.new
|
||||
|
@ -920,8 +963,6 @@ class StudentWorkController < ApplicationController
|
|||
student_work.late_penalty = @homework.late_penalty
|
||||
student_work.save
|
||||
end
|
||||
|
||||
@homework.save
|
||||
end
|
||||
|
||||
if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s
|
||||
|
@ -942,9 +983,8 @@ class StudentWorkController < ApplicationController
|
|||
if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion]
|
||||
homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing
|
||||
@homework.teacher_priority = teacher_priority
|
||||
@homework.update_column('teacher_priority', teacher_priority)
|
||||
|
||||
@homework.save
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
homework_detail_programing.save if homework_detail_programing
|
||||
|
||||
|
@ -953,6 +993,8 @@ class StudentWorkController < ApplicationController
|
|||
student_work.save
|
||||
end
|
||||
end
|
||||
|
||||
@homework.save
|
||||
if params[:student_path]
|
||||
redirect_to student_work_index_url(:homework => @homework.id)
|
||||
else
|
||||
|
@ -992,6 +1034,10 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
attachment = @work.attachments.where("attachtype = 7").first
|
||||
attachment.update_attributes(:description => params[:description])
|
||||
if attachment.attachtype == 7
|
||||
student_work = StudentWork.find attachment.container_id
|
||||
CourseMessage.create(:user_id => student_work.homework_common.user_id, :course_id => student_work.homework_common.course_id, :viewed => false,:course_message_id=>attachment.container_id,:course_message_type=>'StudentWork',:status=>2)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -1149,7 +1195,7 @@ class StudentWorkController < ApplicationController
|
|||
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
|
||||
sheet1.row(0).default_format = blue
|
||||
if @homework.homework_type == 1 #匿评作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
|
@ -1159,15 +1205,16 @@ class StudentWorkController < ApplicationController
|
|||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,10] = format_time(homework.created_at)
|
||||
sheet1[count_row,6] = strip_html homework.description
|
||||
sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2)
|
||||
sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2)
|
||||
sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2)
|
||||
sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score)
|
||||
sheet1[count_row,11] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
elsif @homework.homework_type == 2 #编程作业
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
|
||||
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des),
|
||||
l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
|
||||
count_row = 1
|
||||
items.each do |homework|
|
||||
|
@ -1177,12 +1224,13 @@ class StudentWorkController < ApplicationController
|
|||
sheet1[count_row,3] = homework.user.user_extensions.student_id
|
||||
sheet1[count_row,4] = homework.user.mail
|
||||
sheet1[count_row,5] = homework.name
|
||||
sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
|
||||
sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
|
||||
sheet1[count_row,8] = homework.system_score.nil? ? l(:label_without_score) : format("%.2f",homework.system_score)
|
||||
sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
|
||||
sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
|
||||
sheet1[count_row,11] = format_time(homework.created_at)
|
||||
sheet1[count_row,6] = homework.description
|
||||
sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2)
|
||||
sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2)
|
||||
sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2)
|
||||
sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2)
|
||||
sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score)
|
||||
sheet1[count_row,12] = format_time(homework.created_at)
|
||||
count_row += 1
|
||||
end
|
||||
end
|
||||
|
@ -1245,11 +1293,11 @@ class StudentWorkController < ApplicationController
|
|||
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
|
||||
if student_work.nil?
|
||||
@homework.student_works.build(
|
||||
name: params[:title],
|
||||
description: params[:src],
|
||||
user_id: User.current.id,
|
||||
is_test: is_test
|
||||
)
|
||||
name: params[:title],
|
||||
description: params[:src],
|
||||
user_id: User.current.id,
|
||||
is_test: is_test
|
||||
)
|
||||
unless @homework.save
|
||||
logger.debug @homework.errors.full_messages
|
||||
else
|
||||
|
@ -1270,7 +1318,7 @@ class StudentWorkController < ApplicationController
|
|||
src:src,
|
||||
language:@homework.homework_detail_programing.language,
|
||||
factor: factor
|
||||
}
|
||||
}
|
||||
uri = URI(url)
|
||||
body = solutions.to_json
|
||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||
|
@ -1311,6 +1359,7 @@ class StudentWorkController < ApplicationController
|
|||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
student_work.work_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
|
@ -1323,6 +1372,12 @@ class StudentWorkController < ApplicationController
|
|||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
|
@ -1336,11 +1391,18 @@ class StudentWorkController < ApplicationController
|
|||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
student_work.work_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
|
@ -1369,6 +1431,12 @@ class StudentWorkController < ApplicationController
|
|||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
|
@ -1398,6 +1466,12 @@ class StudentWorkController < ApplicationController
|
|||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,210 @@
|
|||
class SubDocumentCommentsController < ApplicationController
|
||||
before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index, :destroy, :edit]
|
||||
before_filter :find_subfield_content, :only => [:show, :index]
|
||||
helper :attachments,:organizations
|
||||
layout 'base_sub_domain'
|
||||
|
||||
def new
|
||||
@sub_document_comment = SubDocumentComment.new
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@sub_document_comment = SubDocumentComment.new(:sub_domain_id => params[:sub_domain_id], :creator_id => User.current.id, :org_subfield_id => params[:org_subfield_id])
|
||||
@sub_document_comment.title = params[:sub_document_comment][:title]
|
||||
@sub_document_comment.content = params[:sub_document_comment][:content]
|
||||
# @sub_document_comment.save_attachments(params[:attachments])
|
||||
if params[:field_id]
|
||||
@sub_document_comment.org_subfield_id = params[:field_id].to_i
|
||||
end
|
||||
if @sub_document_comment.save
|
||||
flash.keep[:notice] = l(:notice_successful_create)
|
||||
redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id)
|
||||
# EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @sub_document_comment.id, :created_at => @sub_document_comment.updated_at)
|
||||
# if params[:field_id]
|
||||
# @org_subfield = OrgSubfield.find(params[:field_id])
|
||||
# if @org_subfield.subfield_subdomain_dir.nil?
|
||||
# redirect_to organization_path(@organization, :org_subfield_id => params[:field_id])
|
||||
# else
|
||||
# redirect_to show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => @org_subfield.subfield_subdomain_dir.name)
|
||||
# end
|
||||
# else
|
||||
# redirect_to organization_org_document_comments_path(@organization)
|
||||
# end
|
||||
else
|
||||
redirect_to new_org_document_comment_path(:organization_id => @organization.id)
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||
@document = SubDocumentComment.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'}
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
|
||||
@documents = @subdomain.sub_document_comments.where("parent_id is null").order("created_at desc")
|
||||
@is_remote = true
|
||||
@limit = 20
|
||||
@atta_count = @documents.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@documents = paginateHelper @documents,20
|
||||
respond_to do |format|
|
||||
format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'}
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@sub_document = SubDocumentComment.find(params[:id])
|
||||
@sub_document.update_attributes(:title => params[:sub_document_comment][:title], :content => params[:sub_document_comment][:content])
|
||||
@organization = OrgSubfield.find(params[:org_subfield_id]).organization
|
||||
# Attachment.attach_files(@org_document, params[:attachments])
|
||||
# @org_document.save_attachments(params[:attachments])
|
||||
if @sub_document.parent.nil?
|
||||
act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", @sub_document.id).first
|
||||
act.update_attributes(:updated_at => @sub_document.updated_at)
|
||||
# EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if params[:flag].to_i == 0
|
||||
|
||||
# render :action => 'index', :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'
|
||||
redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id])
|
||||
# render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'
|
||||
# redirect_to organization_path(@organization)
|
||||
else
|
||||
redirect_to org_subfield_sub_domain_sub_document_comment_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id])
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@sub_document = SubDocumentComment.find(params[:id])
|
||||
@flag = params[:flag]
|
||||
render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'
|
||||
end
|
||||
|
||||
def add_reply
|
||||
@document = SubDocumentComment.find(params[:id]).root
|
||||
@subdomain = @document.sub_domain
|
||||
@org_subfield = @subdomain.org_subfield
|
||||
@organization = @org_subfield.organization
|
||||
@act = OrgActivity.find(params[:id])
|
||||
@comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain, :creator_id => User.current.id, :reply_id => params[:id])
|
||||
@comment.content = params[:sub_content]
|
||||
@document.children << @comment
|
||||
@document.save
|
||||
end
|
||||
|
||||
def add_reply_in_doc
|
||||
@document = SubDocumentComment.find(params[:id]).root
|
||||
@subdomain = @document.sub_domain
|
||||
@org_subfield = @subdomain.org_subfield
|
||||
@organization = @org_subfield.organization
|
||||
@comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain_id, :creator_id => User.current.id, :reply_id => params[:id])
|
||||
@comment.content = params[:flag] ? params[:sub_content] : params[:org_comment][:sub_content]
|
||||
@document.children << @comment
|
||||
@document.save
|
||||
respond_to do |format|
|
||||
format.html {redirect_to org_subfield_sub_domain_sub_document_comment_path(:id => @document.id, :org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id)}
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@sub_document_comment = SubDocumentComment.find(params[:id])
|
||||
@sub_document_comment.destroy
|
||||
@sub_domain = @sub_document_comment.sub_domain
|
||||
@org_subfield = @sub_domain.org_subfield
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
respond_to do |format|
|
||||
# format.html{
|
||||
# redirect_to org_subfield_sub_domain_sub_document_comments_path(:id => params[:sub_domain_id], :org_subfield_id => params[:org_subfield_id])
|
||||
# }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def delete_reply
|
||||
@sub_document_comment = OrgDocumentComment.find(params[:id])
|
||||
@document = @sub_document_comment.root
|
||||
org = @sub_document_comment.organization
|
||||
@sub_document_comment.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)}
|
||||
end
|
||||
end
|
||||
def quote
|
||||
@org_comment = OrgDocumentComment.find(params[:id])
|
||||
@subject = @org_comment.content
|
||||
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
|
||||
|
||||
@content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> "
|
||||
@temp = OrgDocumentComment.new
|
||||
#@course_id = params[:course_id]
|
||||
@temp.content = "<blockquote>#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)} <br/>#{@org_comment.content.html_safe}</blockquote>".html_safe
|
||||
respond_to do | format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def reply
|
||||
@document = OrgDocumentComment.find(params[:id]).root
|
||||
@quote = params[:quote][:quote]
|
||||
@org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id])
|
||||
|
||||
# params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0
|
||||
# params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0
|
||||
@org_document.title = params[:org_document_comment][:title]
|
||||
@org_document.content = params[:org_document_comment][:content]
|
||||
@org_document.content = @quote + @org_document.content
|
||||
#@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title]
|
||||
@document.children << @org_document
|
||||
# @user_activity_id = params[:user_activity_id]
|
||||
# user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first
|
||||
# if user_activity
|
||||
# user_activity.updated_at = Time.now
|
||||
# user_activity.save
|
||||
# end
|
||||
# attachments = Attachment.attach_files(@org_document, params[:attachments])
|
||||
# render_attachment_warning_if_needed(@org_document)
|
||||
#@article.save
|
||||
# redirect_to user_blogs_path(:user_id=>params[:user_id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
# if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的
|
||||
# redirect_to syllabus_course_path(:id=>params[:course_id])
|
||||
# else
|
||||
redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)
|
||||
# end
|
||||
|
||||
}
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_subdomain_and_subfield
|
||||
@subdomain = SubDomain.find(params[:sub_domain_id])
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@organization = @org_subfield.organization
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# source_subdomain_subfield not found
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_subfield_content
|
||||
@subfield_content = @organization.org_subfields.order("priority")
|
||||
end
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
class SubDomainsController < ApplicationController
|
||||
layout 'base_org'
|
||||
before_filter :find_org_subfield_and_subdomain, :only => [:show, :index, :domain_update_priority, :destroy, :update, :hide_sub_domain, :show_sub_domain]
|
||||
|
||||
def new
|
||||
@subdomain = SubDomain.new
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@organization = @org_subfield.organization
|
||||
end
|
||||
|
||||
def create
|
||||
if SubDomain.where("org_subfield_id=#{params[:org_subfield_id]} and name=?",params[:name]).count == 0
|
||||
@res = true
|
||||
@subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@organization = @subfield.organization
|
||||
@subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id], :priority => @subfield.sub_domains.blank? ? 1 : @subfield.sub_domains.order("priority").last.priority + 1)
|
||||
@subdomain.update_column(:field_type, params[:field_type])
|
||||
else
|
||||
@res = false
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@subdomain.update_column(:name, params[:name])
|
||||
end
|
||||
|
||||
def domain_update_priority
|
||||
@subdomain.update_attribute(:priority, params[:priority].to_i)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@subdomain.destroy
|
||||
end
|
||||
|
||||
def show
|
||||
render_404
|
||||
# @subfield_content = @organization.org_subfields.order("priority")
|
||||
# render layout: @organization.switch_type ? 'base_sub_domain' : 'base_org'
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
def hide_sub_domain
|
||||
@subdomain.update_attribute(:hide, 1)
|
||||
end
|
||||
|
||||
def show_sub_domain
|
||||
@subdomain.update_attribute(:hide, 0)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def find_org_subfield_and_subdomain
|
||||
@subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
@subdomain = SubDomain.find(params[:id])
|
||||
@organization = @subfield.organization
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# source_subdomain not found
|
||||
render_404
|
||||
end
|
||||
end
|
|
@ -41,7 +41,7 @@ class UsersController < ApplicationController
|
|||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
||||
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course]
|
||||
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
|
@ -85,6 +85,29 @@ class UsersController < ApplicationController
|
|||
helper :issues
|
||||
include UsersHelper
|
||||
|
||||
#展开所有回复
|
||||
def show_all_replies
|
||||
@comment = JournalsForMessage.find params[:comment].to_i
|
||||
end
|
||||
|
||||
#二级回复
|
||||
def reply_to
|
||||
case params[:type]
|
||||
when 'HomeworkCommon'
|
||||
@reply = JournalsForMessage.find params[:reply_id]
|
||||
if params[:user_activity_id]
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
else
|
||||
@user_activity_id = -1
|
||||
end
|
||||
@is_in_course = params[:is_in_course]
|
||||
@course_activity = params[:course_activity].to_i
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def refresh_changests
|
||||
if !(@user.nil?) && !(@user.memberships.nil?)
|
||||
@user.memberships.each do |member|
|
||||
|
@ -288,6 +311,52 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 处理资源引用请求
|
||||
# status
|
||||
def deal_with_apply_resource
|
||||
@msg = CourseMessage.find(params[:msg_id])
|
||||
ar = ApplyResource.where("id = ?", @msg.course_message_id).first
|
||||
unless ar.nil?
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
ar.update_column('status', 2)
|
||||
@msg.update_attributes(:apply_result => 1, :viewed => 1)
|
||||
ar.course_messages << CourseMessage.new(:user_id => ar.user_id, :course_id => -1, :viewed => false, :apply_result => 2, :status => 1)
|
||||
when 'N'
|
||||
ar.update_column('status', 3)
|
||||
@msg.update_attributes(:apply_result => 2, :viewed => 1)
|
||||
ar.course_messages << CourseMessage.new(:user_id => ar.user_id, :course_id => -1, :viewed => false, :apply_result => 3, :status => 1)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#处理引用作业的请求
|
||||
#status 1 同意 2 拒绝
|
||||
def dealwith_apply_homework
|
||||
@msg = CourseMessage.find(params[:msg_id])
|
||||
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id)
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
unless ah.empty?
|
||||
ah.first.update_column('status', 2)
|
||||
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>1)
|
||||
@msg.update_attributes(:apply_result=>1,:viewed=>1)
|
||||
end
|
||||
when 'N'
|
||||
unless ah.empty?
|
||||
ah.first.update_column('status', 3)
|
||||
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>2)
|
||||
@msg.update_attributes(:apply_result=>2,:viewed=>1)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# added by bai
|
||||
def show_score
|
||||
|
||||
|
@ -372,13 +441,85 @@ class UsersController < ApplicationController
|
|||
end
|
||||
# end
|
||||
|
||||
# 资源分享请求弹框
|
||||
def apply_resource
|
||||
if User.current.logged?
|
||||
@attachment = Attachment.find params[:attachment_id]
|
||||
@state = 2
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#引用作业请求弹框
|
||||
def apply_homework
|
||||
if User.current.logged?
|
||||
@homework = HomeworkCommon.find params[:homework_id]
|
||||
@state = 2
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 申请引用资源
|
||||
def apply_for_resource
|
||||
if User.current.logged?
|
||||
@attachment = Attachment.where("id =?", params[:attachment_id].to_i).first
|
||||
unless @attachment.nil?
|
||||
ar = ApplyResource.where("user_id = ? and attachment_id = ?", User.current.id, params[:attacment_id].to_i)
|
||||
if ar.empty?
|
||||
ApplyResource.create(:user_id => params[:id].to_i, :attachment_id => params[:attachment_id].to_i, :status => true, :container_id => @attachment.container_id, :container_type => @attachment.container_type, :content => params[:content], :apply_user_id => @attachment.author_id)
|
||||
@state = 2
|
||||
else
|
||||
@state = 3
|
||||
end
|
||||
end
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#申请引用非公开作业
|
||||
def apply_for_homework
|
||||
if User.current.logged?
|
||||
homework = HomeworkCommon.find params[:homework_id]
|
||||
unless homework.nil?
|
||||
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework_id].to_i)
|
||||
if ah.empty?
|
||||
ApplyHomework.create(:user_id => params[:id].to_i, :homework_common_id => params[:homework_id].to_i, :status => 1)
|
||||
Mailer.run.apply_for_homework_request(homework, User.current)
|
||||
CourseMessage.create(:user_id => homework.user_id, :course_id => homework.course.id, :viewed => false,:course_message_id=>params[:homework_id].to_i,:course_message_type=>'HomeworkCommon',:status=>5,:apply_user_id=>params[:id].to_i,:content=>params[:content])
|
||||
@state = 2
|
||||
@ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", params[:id].to_i, params[:homework_id].to_i).first
|
||||
@homework = homework
|
||||
else
|
||||
@state = 3
|
||||
end
|
||||
end
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#用户作业列表
|
||||
def user_homeworks
|
||||
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||
@user = User.current
|
||||
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||
if(params[:type].blank? || params[:type] == "1") #公共题库
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
if(params[:type].blank? || params[:type] == "1") #题库
|
||||
visible_course = Course.where("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("#{@order} #{@b_sort}")
|
||||
elsif params[:type] == "2" #我的题库
|
||||
|
@ -398,32 +539,40 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def student_homeworks
|
||||
if User.current == @user
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
if User.current == @user
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
|
||||
#判断当前用户在当前课程的身份
|
||||
visibleCourse = @user.courses.empty? ? [] : @user.courses.visible
|
||||
homework_ids = []
|
||||
visibleCourse.each do |course|
|
||||
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
|
||||
homework_ids << homeworks.pluck(:id) unless homeworks.empty?
|
||||
end
|
||||
visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
|
||||
@homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
|
||||
@is_in_course = params[:is_in_course].to_i || 0
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
else
|
||||
render_403
|
||||
#判断当前用户在当前课程的身份
|
||||
visibleCourse = @user.courses.empty? ? [] : @user.courses.where("is_delete = 0").visible
|
||||
homework_ids = []
|
||||
visibleCourse.each do |course|
|
||||
homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
|
||||
homework_ids << homeworks.pluck(:id) unless homeworks.empty?
|
||||
end
|
||||
visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
|
||||
@homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10)
|
||||
@is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
|
||||
@is_in_course = params[:is_in_course].to_i || 0
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def choose_user_course
|
||||
homework = HomeworkCommon.find params[:send_id].to_i
|
||||
if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)
|
||||
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
|
||||
if ah.empty?
|
||||
@status = 2
|
||||
elsif ah.first.status != 2
|
||||
@status = ah.first.status
|
||||
end
|
||||
end
|
||||
if !params[:search].nil?
|
||||
search = "%#{params[:search].to_s.strip.downcase}%"
|
||||
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||
|
@ -496,7 +645,7 @@ class UsersController < ApplicationController
|
|||
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
|
||||
new_homework.homework_detail_group.save if new_homework.homework_detail_group
|
||||
end
|
||||
homework.update_attribute(:quotes, homework.quotes+1)
|
||||
homework.update_column(:quotes, homework.quotes+1)
|
||||
end
|
||||
@homework = homework
|
||||
respond_to do |format|
|
||||
|
@ -528,19 +677,40 @@ class UsersController < ApplicationController
|
|||
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||
@user = User.current
|
||||
if(params[:type].blank? || params[:type] == "1") #公共题库
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
if(params[:type].blank? || params[:type] == "1") #题库
|
||||
if params[:is_import].to_i == 1
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
elsif params[:is_import].to_i == 0
|
||||
visible_course = Course.where("is_delete = 0")
|
||||
end
|
||||
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("#{@order} #{@b_sort}")
|
||||
elsif params[:type] == "2" #我的题库
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||
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}")
|
||||
elsif params[:type] == "3" #申请题库
|
||||
none_visible_course = Course.where("is_delete = 1")
|
||||
none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
|
||||
#apply_homeworks = ApplyHomework.where("user_id = ?",@user.id).order('created_at desc')
|
||||
#homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
|
||||
#@homeworks = HomeworkCommon.where("id in #{homework_ids} and course_id not in #{none_visible_course_ids}")
|
||||
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN apply_homeworks as ah ON homework_commons.id = ah.homework_common_id where ah.user_id = #{@user.id} and homework_commons.course_id not in #{none_visible_course_ids} order by ah.created_at desc"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
end
|
||||
if params[:property] && params[:property] == "1"
|
||||
@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] && params[:property] == "2"
|
||||
@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] && params[:property] == "3"
|
||||
@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||
if params[:property]
|
||||
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
|
||||
if params[:property] == "1"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
|
||||
#@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] == "2"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
|
||||
#@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||
elsif params[:property] == "3"
|
||||
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
|
||||
#@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||
end
|
||||
end
|
||||
@type = params[:type]
|
||||
@property = params[:property]
|
||||
|
@ -557,7 +727,21 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def show_homework_detail
|
||||
@homework = HomeworkCommon.find params[:homework].to_i
|
||||
homework = HomeworkCommon.find params[:homework].to_i
|
||||
if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) && User.current != homework.user
|
||||
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework].to_i)
|
||||
if ah.empty?
|
||||
@status = 2
|
||||
@homework = nil
|
||||
elsif ah.first.status != 2
|
||||
@status = ah.first.status
|
||||
@homework = nil
|
||||
elsif ah.first.status == 2
|
||||
@homework = homework
|
||||
end
|
||||
else
|
||||
@homework = homework
|
||||
end
|
||||
@is_import = params[:is_import]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -571,8 +755,12 @@ class UsersController < ApplicationController
|
|||
@user = User.current
|
||||
search = params[:name].to_s.strip.downcase
|
||||
type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")"
|
||||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
if params[:is_import].to_i == 1
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
elsif params[:is_import].to_i == 0
|
||||
visible_course = Course.where("is_delete = 0")
|
||||
end
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
|
||||
all_user_ids = all_homeworks.map{|hw| hw.user_id}
|
||||
|
@ -586,14 +774,29 @@ class UsersController < ApplicationController
|
|||
else
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
elsif params[:type] == "2" #课程资源
|
||||
elsif params[:type] == "2" #我的题库
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
if @order == "course_name"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
elsif @order == "user_name"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
else
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
elsif params[:type] == "3" #申请题库
|
||||
apply_homeworks = ApplyHomework.where("user_id = ?",@user.id)
|
||||
homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")"
|
||||
none_visible_course = Course.where("is_delete = 1")
|
||||
none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")"
|
||||
if @order == "course_name"
|
||||
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
|
||||
@homeworks = HomeworkCommon.find_by_sql(sql)
|
||||
elsif @order == "user_name"
|
||||
@homeworks = HomeworkCommon.where("homework_commons.id in #{homework_ids} and course_id not in #{none_visible_course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
|
||||
else
|
||||
@homeworks = HomeworkCommon.where("id in #{homework_ids} and (name like '%#{search}%') and course_id not in #{none_visible_course_ids} and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
|
||||
end
|
||||
end
|
||||
=begin
|
||||
|
@ -715,7 +918,7 @@ class UsersController < ApplicationController
|
|||
|
||||
student_work.save
|
||||
send_message_to_teacher(student_work)
|
||||
homework.update_attributes(:updated_at => Time.now)
|
||||
homework.update_column(:updated_at, Time.now)
|
||||
update_course_activity(homework.class,homework.id)
|
||||
update_user_activity(homework.class,homework.id)
|
||||
update_org_activity(homework.class,homework.id)
|
||||
|
@ -750,7 +953,11 @@ class UsersController < ApplicationController
|
|||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
|
||||
if homework.anonymous_comment == 1
|
||||
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4
|
||||
else
|
||||
homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3
|
||||
end
|
||||
if homework.publish_time > Date.today
|
||||
homework_detail_manual.comment_status = 0
|
||||
else
|
||||
|
@ -766,7 +973,11 @@ class UsersController < ApplicationController
|
|||
if homework.homework_type == 2
|
||||
homework_detail_programing = HomeworkDetailPrograming.new
|
||||
homework.homework_detail_programing = homework_detail_programing
|
||||
homework_detail_programing.ta_proportion = 0.5
|
||||
if homework.anonymous_comment == 1
|
||||
homework_detail_programing.ta_proportion = 0.6
|
||||
else
|
||||
homework_detail_programing.ta_proportion = 0.5
|
||||
end
|
||||
homework_detail_programing.language = params[:language_type].to_i
|
||||
|
||||
inputs = params[:program][:input]
|
||||
|
@ -795,7 +1006,7 @@ class UsersController < ApplicationController
|
|||
homework_detail_group.save if homework_detail_group
|
||||
if params[:quotes] && !params[:quotes].blank?
|
||||
quotes_homework = HomeworkCommon.find params[:quotes].to_i
|
||||
quotes_homework.update_attribute(:quotes, quotes_homework.quotes+1)
|
||||
quotes_homework.update_column(:quotes, quotes_homework.quotes+1)
|
||||
end
|
||||
if params[:is_in_course] == "1"
|
||||
redirect_to homework_common_index_path(:course => homework.course_id)
|
||||
|
@ -884,22 +1095,27 @@ class UsersController < ApplicationController
|
|||
|
||||
#引入资源列表根据关键词过滤
|
||||
def user_ref_resource_search
|
||||
search = params[:search].to_s.strip.downcase
|
||||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
|
||||
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
||||
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
|
||||
elsif params[:type] == "2" #课程资源
|
||||
if User.current.id.to_i != params[:id].to_i
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@resource_id = params[:mul_id]
|
||||
@resource_type = params[:mul_type]
|
||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
@user = User.current
|
||||
@switch_search = params[:search].nil? ? " " : params[:search]
|
||||
search = "%#{@switch_search.strip.downcase}%"
|
||||
# 别人的资源库是没有权限去看的
|
||||
if(params[:type] == "1") # 我的资源
|
||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
|
||||
elsif params[:type] == "3" #项目资源
|
||||
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
|
||||
elsif params[:type] == "4" #附件
|
||||
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
|
||||
elsif params[:type] == "5" #用户资源
|
||||
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
|
||||
elsif params[:type] == "6" #公共资源
|
||||
@attachments = Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)" + "or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc")
|
||||
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
|
||||
elsif (params[:type].blank? || params[:type] == "6") # 公共资源
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 7
|
||||
|
@ -1216,9 +1432,9 @@ class UsersController < ApplicationController
|
|||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id)
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
user_course_ids = (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
principal_types = "JournalsForMessage"
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
|
@ -1731,7 +1947,7 @@ class UsersController < ApplicationController
|
|||
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
||||
def add_exist_file_to_course
|
||||
@flag = true
|
||||
if params[:send_id].present?
|
||||
if params[:send_id].present?
|
||||
send_id = params[:send_id]
|
||||
@ori = Attachment.find_by_id(send_id)
|
||||
course_ids = params[:course_ids]
|
||||
|
@ -1778,14 +1994,14 @@ class UsersController < ApplicationController
|
|||
end
|
||||
send_ids.each do |send_id|
|
||||
quotes = 0
|
||||
ori = Attachment.find_by_id(send_id)
|
||||
@ori = Attachment.find_by_id(send_id)
|
||||
unless course_ids.nil?
|
||||
course_ids.each do |id|
|
||||
quotes = 0
|
||||
next if ori.blank?
|
||||
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
|
||||
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
|
||||
|
@ -1793,21 +2009,21 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
next if @exist
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
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.current.id
|
||||
attach_copied_obj.is_public = 0
|
||||
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
|
||||
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)
|
||||
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)
|
||||
end
|
||||
@save_message = attach_copied_obj.errors.full_messages
|
||||
end
|
||||
|
@ -1847,6 +2063,18 @@ class UsersController < ApplicationController
|
|||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
# elsif params[:type] == "2"
|
||||
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||
# if params[:status] == "2"
|
||||
# resource_type = "'Course'"
|
||||
# elsif params[:status] == "3"
|
||||
# resource_type = "'Project'"
|
||||
# elsif params[:status] == "5"
|
||||
# resource_type = "'Principal'"
|
||||
# else
|
||||
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||
# end
|
||||
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 25
|
||||
|
@ -1988,6 +2216,18 @@ class UsersController < ApplicationController
|
|||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
# elsif params[:type] == "2"
|
||||
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||
# if params[:status] == "2"
|
||||
# resource_type = "'Course'"
|
||||
# elsif params[:status] == "3"
|
||||
# resource_type = "'Project'"
|
||||
# elsif params[:status] == "5"
|
||||
# resource_type = "'Principal'"
|
||||
# else
|
||||
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||
# end
|
||||
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||
end
|
||||
@status = params[:status]
|
||||
@type = params[:type]
|
||||
|
@ -2117,6 +2357,18 @@ class UsersController < ApplicationController
|
|||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
# elsif params[:type] == "2"
|
||||
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||
# if params[:status] == "2"
|
||||
# resource_type = "'Course'"
|
||||
# elsif params[:status] == "3"
|
||||
# resource_type = "'Project'"
|
||||
# elsif params[:status] == "5"
|
||||
# resource_type = "'Principal'"
|
||||
# else
|
||||
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||
# end
|
||||
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 25
|
||||
|
@ -2453,12 +2705,12 @@ class UsersController < ApplicationController
|
|||
|
||||
# 获取公共资源
|
||||
def get_public_resources user_course_ids, user_project_ids, order, score
|
||||
attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
attachments = Attachment.where("(is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
end
|
||||
|
||||
# 获取公共资源搜索
|
||||
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
|
||||
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
end
|
||||
|
||||
# 获取我的资源
|
||||
|
@ -2478,10 +2730,20 @@ class UsersController < ApplicationController
|
|||
# 获取我的课程资源
|
||||
def get_course_resources author_id, user_course_ids, order, score
|
||||
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
|
||||
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
||||
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
|
||||
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
end
|
||||
|
||||
# # 获取我的私有资源分享结果
|
||||
# def get_my_private_resources apply_ids, resource_type, order, score
|
||||
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
# end
|
||||
#
|
||||
# # 获取我的私有资源分享搜索结果
|
||||
# def get_my_private_resources_search apply_ids, resource_type, order, score, search
|
||||
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
# end
|
||||
|
||||
# 获取我的课程资源中搜索结果
|
||||
def get_course_resources_search author_id, user_course_ids, order, score, search
|
||||
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
|
||||
|
@ -2502,7 +2764,7 @@ class UsersController < ApplicationController
|
|||
# 获取我的项目资源
|
||||
def get_project_resources author_id, user_project_ids, order, score
|
||||
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
|
||||
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
||||
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
|
||||
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
end
|
||||
|
||||
|
@ -2559,7 +2821,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# 获取我的用户类型资源
|
||||
def get_principal_resources_public order, score
|
||||
attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
attchments = Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||
end
|
||||
|
||||
# 获取我的用户类型资源
|
||||
|
@ -2570,7 +2832,7 @@ class UsersController < ApplicationController
|
|||
# 资源库 分为全部 课程资源 项目资源 附件
|
||||
def user_resource
|
||||
# 别人的资源库是没有权限去看的
|
||||
if User.current.id.to_i != params[:id].to_i
|
||||
if User.current.id.to_i != @user.id.to_i
|
||||
render_403
|
||||
return
|
||||
end
|
||||
|
@ -2579,7 +2841,7 @@ class UsersController < ApplicationController
|
|||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||
if( params[:type] == "1") # 我的资源
|
||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||
if params[:status] == "2"
|
||||
@attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
|
||||
|
@ -2593,7 +2855,7 @@ class UsersController < ApplicationController
|
|||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
||||
end
|
||||
elsif params[:type] == "6" # 公共资源
|
||||
elsif (params[:type].blank? || params[:type] == "6") # 公共资源
|
||||
if params[:status] == "2"
|
||||
@attachments = get_course_resources_public( user_course_ids, @order, @score)
|
||||
elsif params[:status] == "3"
|
||||
|
@ -2606,6 +2868,18 @@ class UsersController < ApplicationController
|
|||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
# elsif params[:type] == "2" # 私有资源
|
||||
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||
# if params[:status] == "2"
|
||||
# resource_type = "'Course'"
|
||||
# elsif params[:status] == "3"
|
||||
# resource_type = "'Project'"
|
||||
# elsif params[:status] == "5"
|
||||
# resource_type = "'Principal'"
|
||||
# else
|
||||
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||
# end
|
||||
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||
end
|
||||
@status = params[:status]
|
||||
@type = params[:type]
|
||||
|
@ -2625,13 +2899,12 @@ class UsersController < ApplicationController
|
|||
# 导入资源
|
||||
def import_resources
|
||||
# 别人的资源库是没有权限去看的
|
||||
if User.current.id.to_i != params[:id].to_i
|
||||
if User.current.id != params[:id].to_i
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
|
||||
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
|
||||
@user = User.find(params[:id])
|
||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||
|
@ -2784,8 +3057,21 @@ class UsersController < ApplicationController
|
|||
@attachments = get_principal_resources_public_search(@order, @score, search)
|
||||
else
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
||||
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
||||
end
|
||||
# elsif params[:type] == "2" # 私有资源
|
||||
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||
# if params[:status] == "2"
|
||||
# resource_type = "'Course'"
|
||||
# elsif params[:status] == "3"
|
||||
# resource_type = "'Project'"
|
||||
# elsif params[:status] == "5"
|
||||
# resource_type = "'Principal'"
|
||||
# else
|
||||
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||
# end
|
||||
# @attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search)
|
||||
# @attachments
|
||||
end
|
||||
@status = params[:status]
|
||||
@type = params[:type]
|
||||
|
@ -2849,6 +3135,96 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def user_courselist
|
||||
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type
|
||||
if @order.to_i == @type.to_i
|
||||
@c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序
|
||||
else
|
||||
@c_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_on"
|
||||
sort_type = @c_sort == 1 ? "asc" : "desc"
|
||||
|
||||
# @courses = @user.courses.visible.where("is_delete =?", 0).order("#{sort_name} #{sort_type}")
|
||||
@courses = @user.courses.visible.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
|
||||
@type = 2
|
||||
@courses.each do |course|
|
||||
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
|
||||
if course[:infocount] < 0
|
||||
course[:infocount] = 0
|
||||
end
|
||||
end
|
||||
@c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]})
|
||||
@courses = sortby_time_countcommon_nosticky @courses,sort_name
|
||||
else
|
||||
@type = 1
|
||||
end
|
||||
|
||||
#分页
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@atta_count = @courses.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@courses = paginateHelper @courses,@limit
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
||||
def user_projectlist
|
||||
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type
|
||||
if @order.to_i == @type.to_i
|
||||
@c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序
|
||||
else
|
||||
@c_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_at"
|
||||
sort_type = @c_sort == 1 ? "asc" : "desc"
|
||||
|
||||
#@projects = @user.projects.visible.order("#{sort_name} #{sort_type}")
|
||||
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS #{sort_name} ").order("#{sort_name} #{sort_type}")
|
||||
|
||||
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
@projects.each do |project|
|
||||
project[:infocount] = project.project_score.issue_num+project.project_score.attach_num
|
||||
if project[:infocount] < 0
|
||||
project[:infocount] = 0
|
||||
end
|
||||
end
|
||||
@c_sort == 1 ? (@projects = @projects.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@projects = @projects.sort{|x,y| y[:infocount] <=> x[:infocount] })
|
||||
@projects = sortby_time_countcommon_nosticky @projects,sort_name
|
||||
else
|
||||
@type = 1
|
||||
end
|
||||
|
||||
#分页
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@atta_count = @projects.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@projects = paginateHelper @projects,@limit
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_user
|
||||
|
|
|
@ -166,7 +166,7 @@ class WechatsController < ActionController::Base
|
|||
raise "非法操作, code不存在" unless params[:code]
|
||||
openid = get_openid_from_code(params[:code])
|
||||
raise "无法获取到openid" unless openid
|
||||
raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid)
|
||||
raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid)
|
||||
|
||||
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||
raise "用户名或密码错误,请重新登录" unless user
|
||||
|
@ -178,7 +178,6 @@ class WechatsController < ActionController::Base
|
|||
openid: openid,
|
||||
user: user
|
||||
)
|
||||
request.reply.text "欢迎加入Trustie创新实践社区"
|
||||
render :json => {status:0, msg: "绑定成功"}
|
||||
rescue Exception=>e
|
||||
render :json => {status: -1, msg: e.message}
|
||||
|
@ -211,7 +210,7 @@ class WechatsController < ActionController::Base
|
|||
user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
principal_types = "JournalsForMessage"
|
||||
|
||||
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(','))+")"
|
||||
|
|
|
@ -276,7 +276,7 @@ class WordsController < ApplicationController
|
|||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
||||
end
|
||||
@homework_common.update_column(:updated_at, Time.now)
|
||||
@homework_common.update_column('updated_at', Time.now)
|
||||
update_course_activity(@homework_common.class,@homework_common.id)
|
||||
update_user_activity(@homework_common.class,@homework_common.id)
|
||||
update_org_activity(@homework_common.class,@homework_common.id)
|
||||
|
@ -296,6 +296,40 @@ class WordsController < ApplicationController
|
|||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
#作业的二级回复
|
||||
def reply_to_homework
|
||||
if User.current.logged?
|
||||
@user = User.current
|
||||
reply = JournalsForMessage.find params[:id].to_i
|
||||
@homework_common = HomeworkCommon.find reply.jour_id
|
||||
if params[:reply_message].size>0 && User.current.logged? && @user
|
||||
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
|
||||
feedback = HomeworkCommon.add_homework_jour(@user, params[:reply_message], reply.jour_id, options)
|
||||
if (feedback.errors.empty?)
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
||||
end
|
||||
@homework_common.update_column('updated_at', Time.now)
|
||||
update_course_activity(@homework_common.class,@homework_common.id)
|
||||
update_user_activity(@homework_common.class,@homework_common.id)
|
||||
update_org_activity(@homework_common.class,@homework_common.id)
|
||||
respond_to do |format|
|
||||
format.js{
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@is_in_course = params[:is_in_course].to_i
|
||||
@course_activity = params[:course_activity].to_i
|
||||
}
|
||||
end
|
||||
else
|
||||
flash[:error] = feedback.errors.full_messages[0]
|
||||
end
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def add_brief_introdution
|
||||
user = User.current
|
||||
|
|
|
@ -33,10 +33,46 @@ module ApplicationHelper
|
|||
extend Forwardable
|
||||
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
|
||||
|
||||
|
||||
# def user_blogs_path(resource,parameters={})
|
||||
# super
|
||||
# end
|
||||
|
||||
|
||||
def update_visiti_count container
|
||||
container.update_column(:visits, container.visits + 1)
|
||||
end
|
||||
|
||||
def if_hidden_subdomain field
|
||||
domains = field.sub_domains.select{|domain| domain.hide.to_i == 0}
|
||||
result = domains.length > 0 ? true : false
|
||||
return result
|
||||
end
|
||||
|
||||
# 判断某个资源是否可以申请
|
||||
def attach_show_allow attach_id
|
||||
attachment = Attachment.find(attach_id)
|
||||
case attachment.container_type
|
||||
when "Project"
|
||||
User.current.member_of?(attachment.container) ? true : false
|
||||
when "Course"
|
||||
User.current.member_of_course?(attachment.container) ? true : false
|
||||
when "OrgSubfield"
|
||||
User.current.member_of_org?(attachment.container.organization) ? true : false
|
||||
when "Principal"
|
||||
User.current.id == attachment.author_id ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
# 判断某个私有资源是否可以发送下载权限
|
||||
# 结果为true不能下载,false可以下载
|
||||
def private_attachment_allow attachment_id
|
||||
attach = Attachment.find(attachment_id)
|
||||
# 条件取否,result结果为true则不能下载
|
||||
result = attach.is_public == 0 && attach.author != User.current && !attach.get_apply_resource_status(attach.id, User.current.id) && !attach_show_allow(attach)
|
||||
return result
|
||||
end
|
||||
|
||||
# Time 2015-03-24 15:27:29
|
||||
# Author lizanle
|
||||
# Description 从硬盘上删除对应的资源文件
|
||||
|
@ -76,11 +112,13 @@ module ApplicationHelper
|
|||
|
||||
# 获取组织成员中文名字
|
||||
def get_org_member_role_name member
|
||||
case member.roles[0].name
|
||||
when 'orgManager'
|
||||
'管理人员'
|
||||
when 'orgMember'
|
||||
'组织成员'
|
||||
unless member.roles[0].nil?
|
||||
case member.roles[0].name
|
||||
when 'orgManager'
|
||||
'管理人员'
|
||||
when 'orgMember'
|
||||
'组织成员'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -123,7 +161,7 @@ module ApplicationHelper
|
|||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1)
|
||||
else
|
||||
score = course_contributor_score.homework_journal_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:homework_journal_num => score)
|
||||
course_contributor_score.update_column(:homework_journal_num, score)
|
||||
end
|
||||
# 课程留言
|
||||
when "Course"
|
||||
|
@ -131,42 +169,42 @@ module ApplicationHelper
|
|||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1)
|
||||
else
|
||||
score = course_contributor_score.journal_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:journal_num => score)
|
||||
course_contributor_score.update_column(:journal_num, score)
|
||||
end
|
||||
when "Message"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1)
|
||||
else
|
||||
score = course_contributor_score.message_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:message_num => score)
|
||||
course_contributor_score.update_column(:message_num, score)
|
||||
end
|
||||
when "MessageReply"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1)
|
||||
else
|
||||
score = course_contributor_score.message_reply_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:message_reply_num => score)
|
||||
course_contributor_score.update_column(:message_reply_num, score)
|
||||
end
|
||||
when "NewReply"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1)
|
||||
else
|
||||
score = course_contributor_score.news_reply_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:news_reply_num => score)
|
||||
course_contributor_score.update_column(:news_reply_num, score)
|
||||
end
|
||||
when "News"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1)
|
||||
else
|
||||
score = course_contributor_score.news_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:news_num => score)
|
||||
course_contributor_score.update_column(:news_num, score)
|
||||
end
|
||||
when "Attachment"
|
||||
if course_contributor_score.nil?
|
||||
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1)
|
||||
else
|
||||
score = course_contributor_score.resource_num.to_i + 1
|
||||
course_contributor_score.update_attributes(:resource_num => score)
|
||||
course_contributor_score.update_column(:resource_num, score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -178,38 +216,38 @@ module ApplicationHelper
|
|||
when "HomeworkCommon"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.homework_journal_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:homework_journal_num, score < 0 ? 0 : score)
|
||||
end
|
||||
# 课程留言
|
||||
when "Course"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.journal_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:journal_num, score < 0 ? 0 : score)
|
||||
end
|
||||
when "Message"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.message_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:message_num, score < 0 ? 0 : score)
|
||||
end
|
||||
when "MessageReply"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.message_reply_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:message_reply_num, score < 0 ? 0 : score)
|
||||
end
|
||||
when "NewReply"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.news_reply_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:news_reply_num, score < 0 ? 0 : score)
|
||||
end
|
||||
when "News"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.news_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:news_num, score < 0 ? 0 : score)
|
||||
end
|
||||
when "Attachment"
|
||||
unless course_contributor_score.nil?
|
||||
score = course_contributor_score.resource_num.to_i - 1
|
||||
course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score)
|
||||
course_contributor_score.update_column(:resource_num, score < 0 ? 0 : score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2080,20 +2118,20 @@ module ApplicationHelper
|
|||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif attachment.container.is_a?(Project)
|
||||
project = attachment.container
|
||||
candown= User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
candown = User.current.member_of?(project) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
|
||||
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
|
||||
attachment.container.board.project
|
||||
project = attachment.container.board.project
|
||||
candown = User.current.member_of?(project) || (project.is_public && attachment.is_public == 1)
|
||||
elsif (attachment.container.has_attribute?(:course) ||attachment.container.has_attribute?(:course_id) ) && attachment.container.course
|
||||
course = attachment.container.course
|
||||
candown = User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
|
||||
candown = User.current.member_of_course?(course) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
|
||||
elsif attachment.container.is_a?(Course)
|
||||
course = attachment.container
|
||||
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
|
||||
candown= User.current.member_of_course?(course) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
|
||||
elsif attachment.container.is_a?(OrgSubfield)
|
||||
org = attachment.container.organization
|
||||
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
|
||||
candown = User.current.member_of_org?(org) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2
|
||||
elsif attachment.container.is_a?(OrgDocumentComment)
|
||||
org = attachment.container.organization
|
||||
candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
|
||||
|
@ -2953,6 +2991,14 @@ int main(int argc, char** argv){
|
|||
return sort_projects
|
||||
end
|
||||
end
|
||||
|
||||
def project_sort_first projects
|
||||
unless projects.empty?
|
||||
project_ids = '('+projects.map{|pro|pro.project_id}.join(',')+')'
|
||||
sort_projects = ForgeActivity.find_by_sql("SELECT updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} ORDER BY updated_at DESC limit 1")
|
||||
return sort_projects
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def user_url_in_org(user_id)
|
||||
|
@ -2983,8 +3029,14 @@ def homework_common_index_url_in_org(course_id)
|
|||
Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s
|
||||
end
|
||||
|
||||
def student_work_index_url_in_org(homework_id)
|
||||
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
|
||||
def student_work_index_url_in_org(homework_id, is_focus = '', show_work_id = '')
|
||||
if is_focus != ''
|
||||
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&is_focus=" + is_focus.to_s
|
||||
elsif show_work_id != ''
|
||||
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&show_work_id=" + show_work_id.to_s
|
||||
else
|
||||
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def course_url_in_org(course_id)
|
||||
|
@ -3061,10 +3113,155 @@ def host_with_protocol
|
|||
return Setting.protocol + "://" + Setting.host_name
|
||||
end
|
||||
|
||||
def secdomain_with_protocol secdomain
|
||||
return Setting.protocol + "://" + secdomain + ".trustie.net"
|
||||
end
|
||||
|
||||
|
||||
#获取回复的所有父节点
|
||||
def get_reply_parents parents_rely, comment
|
||||
unless comment.parent.nil?
|
||||
parents_rely << comment.parent
|
||||
get_reply_parents parents_rely, comment.parent
|
||||
end
|
||||
parents_rely
|
||||
end
|
||||
|
||||
#将有置顶属性的提到数组前面
|
||||
def sort_by_sticky topics
|
||||
tmpTopics = []
|
||||
tmpIndex = 0
|
||||
topics.each do |topic|
|
||||
if topic.sticky == 1
|
||||
tmpTopics[tmpIndex] = topic
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
end
|
||||
|
||||
topics.each do |topic|
|
||||
if topic.sticky == 0
|
||||
tmpTopics[tmpIndex] = topic
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
end
|
||||
return tmpTopics
|
||||
end
|
||||
|
||||
#按人气排序的时候 相同的人气必须按某种时间顺序排序 有置顶属性
|
||||
def sortby_time_countcommon_hassticky topics,sortstr
|
||||
tmpTopics = []
|
||||
tmpTopics = topics
|
||||
tStart = -1
|
||||
tEnd = -1
|
||||
|
||||
tmpTopics_1 = []
|
||||
tmpIndex = 0
|
||||
|
||||
tmpTopics.each_with_index do |topic,index|
|
||||
if topic.sticky == 0
|
||||
if tStart == -1
|
||||
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
|
||||
tStart = index
|
||||
end
|
||||
else
|
||||
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
|
||||
tEnd = index
|
||||
else
|
||||
if (topic[:infocount] == tmpTopics[index-1][:infocount])
|
||||
tEnd = index
|
||||
end
|
||||
if tEnd > tStart
|
||||
for i in tStart..tEnd
|
||||
tmpTopics_1[tmpIndex] = tmpTopics[i]
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
|
||||
if sortstr == "created_at"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
|
||||
elsif sortstr == "created_on"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
|
||||
elsif sortstr == "updated_at"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
|
||||
elsif sortstr == "updated_on"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
|
||||
end
|
||||
|
||||
tmpIndex = 0
|
||||
for i in tStart..tEnd
|
||||
tmpTopics[i] = tmpTopics_1[tmpIndex]
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
end
|
||||
tStart = -1
|
||||
tEnd = -1
|
||||
tmpTopics_1 = []
|
||||
tmpIndex = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return tmpTopics
|
||||
end
|
||||
|
||||
#按人气排序的时候 相同的人气必须按某种时间顺序排序 无置顶属性
|
||||
def sortby_time_countcommon_nosticky topics,sortstr
|
||||
tmpTopics = []
|
||||
tmpTopics = topics
|
||||
tStart = -1
|
||||
tEnd = -1
|
||||
|
||||
tmpTopics_1 = []
|
||||
tmpIndex = 0
|
||||
|
||||
tmpTopics.each_with_index do |topic,index|
|
||||
if tStart == -1
|
||||
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
|
||||
tStart = index
|
||||
end
|
||||
else
|
||||
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
|
||||
tEnd = index
|
||||
else
|
||||
if (topic[:infocount] == tmpTopics[index-1][:infocount])
|
||||
tEnd = index
|
||||
end
|
||||
if tEnd > tStart
|
||||
for i in tStart..tEnd
|
||||
tmpTopics_1[tmpIndex] = tmpTopics[i]
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
|
||||
if sortstr == "created_at"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
|
||||
elsif sortstr == "created_on"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
|
||||
elsif sortstr == "updated_at"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
|
||||
elsif sortstr == "updated_on"
|
||||
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
|
||||
end
|
||||
|
||||
tmpIndex = 0
|
||||
for i in tStart..tEnd
|
||||
tmpTopics[i] = tmpTopics_1[tmpIndex]
|
||||
tmpIndex = tmpIndex + 1
|
||||
end
|
||||
end
|
||||
tStart = -1
|
||||
tEnd = -1
|
||||
tmpTopics_1 = []
|
||||
tmpIndex = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
return tmpTopics
|
||||
end
|
||||
|
||||
def strip_html(text,len=0,endss="...")
|
||||
ss = ""
|
||||
if text.length>0
|
||||
ss=text.gsub(/<\/?.*?>/, '').strip
|
||||
ss = ss.gsub(/ /, ' ')
|
||||
|
||||
if len > 0 && ss.length > len
|
||||
ss = ss[0, len] + endss
|
||||
|
@ -3076,3 +3273,13 @@ def strip_html(text,len=0,endss="...")
|
|||
return ss
|
||||
end
|
||||
|
||||
def get_hw_index(hw,is_teacher)
|
||||
if is_teacher
|
||||
homeworks = hw.course.homework_commons.order("created_at asc")
|
||||
else
|
||||
homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||
end
|
||||
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty?
|
||||
index = hw_ids.index(hw.id)
|
||||
return index
|
||||
end
|
||||
|
|
|
@ -850,7 +850,7 @@ module CoursesHelper
|
|||
# 学生按作业总分排序,取前8个
|
||||
def hero_homework_score(course, score_sort_by)
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))
|
||||
SELECT SUM(work_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{course.id}
|
||||
|
|
|
@ -63,14 +63,128 @@ module OrganizationsHelper
|
|||
def subfield_status_option
|
||||
type = []
|
||||
option1 = []
|
||||
option1 << "列表"
|
||||
option1 << "左一"
|
||||
option1 << "1"
|
||||
type << option1
|
||||
option2 = []
|
||||
option2 << "图片"
|
||||
option2 << "0"
|
||||
type << option2
|
||||
# option2 = []
|
||||
# option2 << "中一"
|
||||
# option2 << "2"
|
||||
# type << option2
|
||||
option3 = []
|
||||
option3 << "左二"
|
||||
option3 << "3"
|
||||
type << option3
|
||||
option4 = []
|
||||
option4 << "左三"
|
||||
option4 << "4"
|
||||
type << option4
|
||||
option5 = []
|
||||
option5 << "左四"
|
||||
option5 << "5"
|
||||
type << option5
|
||||
option6 = []
|
||||
option6 << "右一"
|
||||
option6 << "6"
|
||||
type << option6
|
||||
option7 = []
|
||||
option7 << "右二"
|
||||
option7 << "7"
|
||||
type << option7
|
||||
option8 = []
|
||||
option8 << "右三"
|
||||
option8 << "8"
|
||||
type << option8
|
||||
type
|
||||
end
|
||||
|
||||
# 课程和项目不参与某些模块的排列
|
||||
def subfield_status_option_default
|
||||
type = []
|
||||
option1 = []
|
||||
option1 << "左一"
|
||||
option1 << "1"
|
||||
type << option1
|
||||
option3 = []
|
||||
option3 << "左二"
|
||||
option3 << "3"
|
||||
type << option3
|
||||
option4 = []
|
||||
option4 << "左三"
|
||||
option4 << "4"
|
||||
type << option4
|
||||
option6 = []
|
||||
option6 << "右一"
|
||||
option6 << "6"
|
||||
type << option6
|
||||
type
|
||||
end
|
||||
|
||||
def subfield_list_type subfield
|
||||
case subfield.to_i
|
||||
when 1
|
||||
resulet = "左一"
|
||||
when 2
|
||||
resulet = "左二"
|
||||
when 3
|
||||
resulet = "左二"
|
||||
when 4
|
||||
resulet = "左三"
|
||||
when 5
|
||||
resulet = "左四"
|
||||
when 6
|
||||
resulet = "右一"
|
||||
when 7
|
||||
resulet = "右二"
|
||||
when 8
|
||||
resulet = "右三"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_subfield_acts field
|
||||
org_subfield = OrgSubfield.find(field.id)
|
||||
org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0
|
||||
org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc')
|
||||
org_acts
|
||||
end
|
||||
|
||||
def org_subfield_had_created?(org, type)
|
||||
sub_field = org.org_subfields.select{|subfield| subfield.field_type == type}
|
||||
result = sub_field.length > 0 ? true : false
|
||||
result
|
||||
end
|
||||
|
||||
def org_subfield_type(field)
|
||||
case field.field_type
|
||||
when "Post"
|
||||
result = "帖子"
|
||||
when "Resource"
|
||||
result = "资源"
|
||||
when "Compstu"
|
||||
result = "学生"
|
||||
when "Comptec"
|
||||
result = "教师"
|
||||
when "Complex"
|
||||
result = "综合"
|
||||
end
|
||||
end
|
||||
|
||||
def org_teacher_resource_count user
|
||||
results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count
|
||||
end
|
||||
|
||||
def org_teacher_course_count user
|
||||
results = Course.find_by_sql("select * from courses where courses.tea_id = #{user.id}").count
|
||||
end
|
||||
|
||||
def org_student_course_count user
|
||||
course_ids = user.courses.map { |c| c.is_delete == 0 && c.id}
|
||||
results = Member.find_by_sql("select id from courses where courses.tea_id = #{user.id}").count
|
||||
end
|
||||
|
||||
def excellent_teachers
|
||||
User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 order by course_count desc").first(5)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -41,6 +41,23 @@ module RepositoriesHelper
|
|||
identifiers.include?(iden) ? false :true
|
||||
end
|
||||
|
||||
# 获取文件目录的最新动态
|
||||
def get_trees_last_changes(project_id, rev, ent_name)
|
||||
g = Gitlab.client
|
||||
begin
|
||||
tree_changes = g.rep_last_changes(project_id, :rev => rev, :path => ent_name)
|
||||
tree_changes
|
||||
rescue
|
||||
logger.error("faile to get tress activities!")
|
||||
end
|
||||
end
|
||||
|
||||
def translate_time time
|
||||
case time
|
||||
when time.include("")
|
||||
end
|
||||
end
|
||||
|
||||
# 获取diff内容行号
|
||||
def diff_line_num content
|
||||
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
|
||||
|
|
|
@ -23,7 +23,7 @@ module StudentWorkHelper
|
|||
|
||||
#获取指定用户对某一作业的评分结果
|
||||
def student_work_score work,user
|
||||
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first
|
||||
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).last
|
||||
end
|
||||
|
||||
#获取指定评分的角色
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module SubDocumentCommentsHelper
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
module SubDomainsHelper
|
||||
include OrganizationsHelper
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class ApplyHomework < ActiveRecord::Base
|
||||
#status:1. 等待回复 2.审核通过 3.已拒绝
|
||||
belongs_to :user
|
||||
belongs_to :homework_common
|
||||
attr_accessible :status, :user_id, :homework_common_id
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
class ApplyResource < ActiveRecord::Base
|
||||
# status:1. 等待回复 2.审核通过 3.已拒绝
|
||||
attr_accessible :attachment_id, :status, :user_id, :container_type, :container_id, :apply_user_id, :content
|
||||
belongs_to :user
|
||||
belongs_to :attachment
|
||||
has_many :course_messages, :class_name => 'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
after_create :act_as_apply_resource_message
|
||||
|
||||
def act_as_apply_resource_message
|
||||
self.course_messages << CourseMessage.new(:user_id => self.apply_user_id, :course_id => -1, :viewed => false, :status => 0, )
|
||||
# REDO:发送邮件
|
||||
# Mailer.run.apply_for_resource_request(self.container_id, User.current)
|
||||
end
|
||||
|
||||
def find_attachment attachment_id
|
||||
Attachment.find(attachment_id)
|
||||
end
|
||||
|
||||
end
|
|
@ -35,6 +35,7 @@ class Attachment < ActiveRecord::Base
|
|||
# end
|
||||
include UserScoreHelper
|
||||
has_many :attachment_histories
|
||||
has_many :apply_resources, :dependent => :destroy
|
||||
|
||||
validates :filename, presence: true, length: {maximum: 254}
|
||||
validates :author, presence: true
|
||||
|
@ -139,6 +140,12 @@ class Attachment < ActiveRecord::Base
|
|||
}
|
||||
)
|
||||
end
|
||||
|
||||
def get_apply_resource_status attachment_id, author_id
|
||||
status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status)
|
||||
status == 2 ? true :false
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
# 公开的项目id列表
|
||||
def self.public_project_id
|
||||
|
@ -301,7 +308,7 @@ class Attachment < ActiveRecord::Base
|
|||
nil
|
||||
end
|
||||
|
||||
def filename=(arg)
|
||||
def filename=(arg)
|
||||
write_attribute :filename, sanitize_filename(arg.to_s)
|
||||
filename
|
||||
end
|
||||
|
@ -536,6 +543,11 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 获取资源申请状态
|
||||
def get_status_by_attach user_id
|
||||
ApplyResource.where("user_id =? and attachment_id =?", user_id, self.id).first.try(:status)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Physically deletes the file from the file system
|
||||
|
|
|
@ -45,7 +45,8 @@ class Comment < ActiveRecord::Base
|
|||
if self.commented.course
|
||||
if self.author_id != self.commented.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count == 0
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
|
||||
if count == 0
|
||||
content = strip_html self.comments.html_safe, 200
|
||||
ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
|
|
|
@ -5,8 +5,7 @@ class CourseActivity < ActiveRecord::Base
|
|||
belongs_to :course
|
||||
belongs_to :user
|
||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||
after_save :add_user_activity, :add_org_activity
|
||||
after_create :add_course_lead
|
||||
after_create :add_course_lead,:add_user_activity, :add_org_activity
|
||||
before_destroy :destroy_user_activity, :destroy_org_activity
|
||||
|
||||
#在个人动态里面增加当前动态
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
# status说明: status在课程不同的类型,区分不同的功能 status = 9 作品的提交记录
|
||||
# ApplyResource status:
|
||||
# 0: 发送申请 1:回复允许申请 2:拒绝申请消息
|
||||
# HomeworkCommon:status:
|
||||
# nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status
|
||||
# nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败; 5:申请引用作业, 6:申请结果
|
||||
# apply_user_id: 申请者的用户id
|
||||
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status, :apply_user_id, :apply_result
|
||||
|
||||
# 多态 虚拟关联
|
||||
belongs_to :course_message ,:polymorphic => true
|
||||
|
@ -14,7 +17,7 @@ class CourseMessage < ActiveRecord::Base
|
|||
validates :course_id,presence: true
|
||||
validates :course_message_id,presence: true
|
||||
validates :course_message_type, presence: true
|
||||
validates_length_of :content, :maximum => 100
|
||||
#validates_length_of :content, :maximum => 100
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
|
|
|
@ -20,7 +20,7 @@ class ForgeActivity < ActiveRecord::Base
|
|||
validates :forge_act_id,presence: true
|
||||
validates :forge_act_type, presence: true
|
||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||
after_save :add_user_activity, :add_org_activity
|
||||
after_create :add_user_activity, :add_org_activity
|
||||
before_destroy :destroy_user_activity, :destroy_org_activity
|
||||
|
||||
#在个人动态里面增加当前动态
|
||||
|
|
|
@ -18,6 +18,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
has_many :student_works, :dependent => :destroy, :conditions => "is_test=0"
|
||||
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :apply_homeworks, :dependent => :destroy
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
@ -28,7 +29,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
:description => :description,
|
||||
:author => :author,
|
||||
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
|
||||
after_create :act_as_activity, :send_mail, :act_as_course_message
|
||||
after_create :act_as_activity, :send_mail,:act_as_course_message
|
||||
after_update :update_activity, :wechat_message
|
||||
after_save :act_as_course_activity
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
@ -58,8 +59,9 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
else
|
||||
self.course.members.each do |m|
|
||||
# if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0
|
||||
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
end
|
||||
|
@ -108,7 +110,8 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
#修改作业后发送微信模板消息
|
||||
def wechat_message
|
||||
self.course.members.each do |member|
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
end
|
||||
|
|
|
@ -162,9 +162,22 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
self.project.members.each do |m|
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
|
||||
if m.user_id != self.author_id && count != 0
|
||||
if m.user_id != self.author_id && count == 0
|
||||
ws = WechatService.new
|
||||
content = strip_html self.project.name + " 有新缺陷了:" + self.subject.html_safe, 200
|
||||
str = " 有新缺陷了: "
|
||||
case self.tracker_id
|
||||
when 1
|
||||
str = " 有新缺陷了: "
|
||||
when 2
|
||||
str = " 有新功能了: "
|
||||
when 3
|
||||
str = " 有新支持了: "
|
||||
when 4
|
||||
str = " 有新任务了: "
|
||||
when 5
|
||||
str = " 有新周报了: "
|
||||
end
|
||||
content = strip_html self.project.name + str + self.subject.html_safe, 200
|
||||
ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
|
@ -262,7 +275,7 @@ class Issue < ActiveRecord::Base
|
|||
# set default values for new records only
|
||||
self.status ||= IssueStatus.default
|
||||
self.priority ||= IssuePriority.default
|
||||
self.watcher_user_ids = []
|
||||
# self.watcher_user_ids = []
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -239,8 +239,10 @@ class Journal < ActiveRecord::Base
|
|||
|
||||
#缺陷回复微信模板消息
|
||||
def issue_wechat_message
|
||||
ws = WechatService.new
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
if !self.notes.nil? && self.notes.gsub(' ','') != ''
|
||||
ws = WechatService.new
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -255,11 +255,30 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
if self.jour_type == 'HomeworkCommon' && ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count == 0
|
||||
ws = WechatService.new
|
||||
#content = truncate(strip_tags(self.notes.to_s), length: 200)
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
if self.jour_type == 'HomeworkCommon'
|
||||
if self.m_parent_id.nil?
|
||||
if self.user_id != self.jour.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
#content = truncate(strip_tags(self.notes.to_s), length: 200)
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
else
|
||||
if self.user_id != self.parent.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.parent.user_id,:course_id => self.jour.course.id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.parent.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
#content = truncate(strip_tags(self.notes.to_s), length: 200)
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.parent.user_id, "homework", self.jour_id, "#{l(:label_new_second_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1041,7 +1041,13 @@ class Mailer < ActionMailer::Base
|
|||
:subject => @subject
|
||||
end
|
||||
|
||||
|
||||
def apply_for_homework_request(homework, user)
|
||||
@receive = User.find(homework.user_id)
|
||||
@user = user
|
||||
@subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} "
|
||||
mail :to => @receive.mail,
|
||||
:subject => @subject
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class Member < ActiveRecord::Base
|
|||
|
||||
#当前学生在指定作业内的得分
|
||||
def homework_common_score homework_common
|
||||
StudentWork.select("IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
|
||||
StudentWork.select("work_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
|
||||
end
|
||||
|
||||
def student_work_score_avg
|
||||
|
@ -158,7 +158,7 @@ class Member < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def student_work_score_sum
|
||||
sql_select = "SELECT (SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,IF((student_works.final_score - student_works.absence_penalty - student_works.late_penalty) < 0 , 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty))))) AS score
|
||||
sql_select = "SELECT (SUM(student_works.work_score)) AS score
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{self.course_id}
|
||||
|
|
|
@ -83,7 +83,7 @@ class Message < ActiveRecord::Base
|
|||
# after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
|
||||
after_update :update_messages_board, :update_activity
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
|
||||
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count
|
||||
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message
|
||||
#before_save :be_user_score
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -261,10 +261,11 @@ class Message < ActiveRecord::Base
|
|||
ws = WechatService.new
|
||||
if self.course
|
||||
if self.parent_id.nil? # 主贴
|
||||
self.course.members.each do |m|
|
||||
self.course.members.includes(:user).each do |m|
|
||||
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count == 0
|
||||
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
|
||||
if count == 0
|
||||
content = strip_html self.subject, 200
|
||||
ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
end
|
||||
|
@ -274,7 +275,8 @@ class Message < ActiveRecord::Base
|
|||
parent_author_id = Message.find(self.parent_id).author_id
|
||||
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count == 0
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
|
||||
if count == 0
|
||||
content = strip_html self.content.html_safe, 200
|
||||
ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
|
@ -282,10 +284,11 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
elsif self.project # 项目相关
|
||||
if self.parent_id.nil? # 主贴
|
||||
self.project.members.each do |m|
|
||||
self.project.members.includes(:user).each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count == 0
|
||||
#self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count
|
||||
if count == 0
|
||||
content = strip_html self.subject, 200
|
||||
ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
end
|
||||
|
@ -295,7 +298,8 @@ class Message < ActiveRecord::Base
|
|||
parent_author_id = Message.find(self.parent_id).author_id
|
||||
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count == 0
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
|
||||
if count == 0
|
||||
content = strip_html self.content.html_safe, 200
|
||||
ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ class News < ActiveRecord::Base
|
|||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score
|
||||
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score, :act_as_system_message
|
||||
after_update :update_activity
|
||||
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
|
||||
|
||||
|
@ -163,17 +163,18 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
#课程/项目通知 消息发送
|
||||
#消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
# 课程/项目通知 消息发送
|
||||
# 消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
def act_as_system_message
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0
|
||||
# self.delay.send_message(m.user_id, self.course_id)
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
|
||||
if count == 0
|
||||
ws = WechatService.new
|
||||
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
|
||||
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on)
|
||||
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -188,6 +189,10 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# def send_message user_id, course_id
|
||||
# self.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course_id, :viewed => false)
|
||||
# end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
|
|
|
@ -7,6 +7,7 @@ class OrgSubfield < ActiveRecord::Base
|
|||
has_many :messages, :through => :org_subfield_messages
|
||||
has_many :boards, :dependent => :destroy
|
||||
has_many :news, :dependent => :destroy
|
||||
has_many :sub_domains, :dependent => :destroy
|
||||
acts_as_attachable
|
||||
after_create :create_board_sync
|
||||
after_destroy :update_priority
|
||||
|
|
|
@ -22,4 +22,16 @@ class Organization < ActiveRecord::Base
|
|||
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2)
|
||||
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3)
|
||||
end
|
||||
|
||||
def switch_type
|
||||
self.show_mode.to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
def allow_set_teachers
|
||||
self.allow_teacher.to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
def secdomain_name
|
||||
Secdomain.where("sub_type=2 and pid=?", self.id).first.try(:subname)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,4 +88,11 @@ class PraiseTread < ActiveRecord::Base
|
|||
UserLevels.update_user_level(target_user)
|
||||
end
|
||||
end
|
||||
|
||||
def self.praised(activity)
|
||||
self.where(praise_tread_object_id: activity.id,
|
||||
praise_tread_object_type: activity.class.to_s,
|
||||
user_id: User.current.id).empty?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class Repository < ActiveRecord::Base
|
|||
# validates_uniqueness_of :identifier, :allow_blank => true
|
||||
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
|
||||
# donwcase letters, digits, dashes, underscores but not digits only
|
||||
validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true
|
||||
validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]*[a-zA-Z_\-]+[a-zA-Z0-9_\-]*$/, :allow_blank => true
|
||||
# Checks if the SCM is enabled when creating a repository
|
||||
validate :repo_create_validation, :on => :create
|
||||
|
||||
|
|
|
@ -5,4 +5,5 @@ class School < ActiveRecord::Base
|
|||
def to_s
|
||||
self.name.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#coding=utf-8
|
||||
|
||||
require 'base64'
|
||||
|
||||
class Sso < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :email, :name, :openid, :password, :school, :sex, :user, :user_id
|
||||
|
||||
validates :user_id, :user, :email, :openid, :presence => true
|
||||
|
||||
def self.sync_user(opt)
|
||||
sso = Sso.where(openid: opt["openid"]).first
|
||||
return sso if sso
|
||||
|
||||
sso = Sso.new
|
||||
sso.name = opt["name"]
|
||||
sso.openid = opt["openid"]
|
||||
sso.email = opt["email"]
|
||||
sso.password = opt["password"]
|
||||
sso.school = opt["school"]
|
||||
sso.sex = opt["sex"]
|
||||
|
||||
|
||||
# 查邮箱
|
||||
user = User.where(mail: opt["email"]).first
|
||||
|
||||
unless user
|
||||
# 查用户名
|
||||
|
||||
user = User.where(login: opt["name"]).first
|
||||
if user
|
||||
# 跳到修改用户名
|
||||
raise "exist user"
|
||||
end
|
||||
|
||||
password = opt["password"]
|
||||
if password.size < 8
|
||||
password = random_pwd
|
||||
end
|
||||
us = UsersService.new
|
||||
user = us.register(login: opt["name"], mail: opt["email"],
|
||||
password: password,
|
||||
:should_confirmation_password => false)
|
||||
if user.new_record?
|
||||
raise user.errors.full_messages.first
|
||||
end
|
||||
end
|
||||
|
||||
sso.user = user
|
||||
sso.save!
|
||||
return sso
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def self.random_pwd
|
||||
('a'..'z').to_a.shuffle[0..7].join
|
||||
end
|
||||
|
||||
end
|
|
@ -50,6 +50,7 @@ class StudentWork < ActiveRecord::Base
|
|||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
student_work.work_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
|
@ -62,9 +63,17 @@ class StudentWork < ActiveRecord::Base
|
|||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil?
|
||||
if student_work.student_score.nil? && student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.teacher_score
|
||||
elsif student_work.teaching_asistant_score.nil?
|
||||
student_work.final_score = student_work.student_score
|
||||
elsif student_work.student_score.nil?
|
||||
student_work.final_score = student_work.teaching_asistant_score
|
||||
|
@ -75,11 +84,18 @@ class StudentWork < ActiveRecord::Base
|
|||
final_score = final_ta_score + final_s_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
|
||||
if homework.teacher_priority == 1 #教师优先
|
||||
if student_work.teacher_score
|
||||
student_work.final_score = student_work.teacher_score
|
||||
student_work.work_score = student_work.teacher_score
|
||||
else
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
|
@ -108,7 +124,13 @@ class StudentWork < ActiveRecord::Base
|
|||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
else #不考虑教师评分
|
||||
if student_work.teaching_asistant_score.nil? #教辅未评分
|
||||
if student_work.student_score.nil?
|
||||
|
@ -137,6 +159,12 @@ class StudentWork < ActiveRecord::Base
|
|||
final_score = final_sy_score + final_ts_score + final_st_score
|
||||
student_work.final_score = format("%.2f",final_score.to_f)
|
||||
end
|
||||
if student_work.final_score
|
||||
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
|
||||
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
|
||||
else
|
||||
student_work.work_score = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,17 +18,29 @@ class StudentWorksScore < ActiveRecord::Base
|
|||
receiver = self.student_work.user
|
||||
# 判断是第一次评阅还是更新 status:0 新建;1 更新
|
||||
if self.created_at == self.updated_at
|
||||
if self.comment.nil?
|
||||
if self.comment.nil? && self.score
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> false)
|
||||
elsif self.score.nil? && self.comment
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "评语:#{self.comment}", :status=> false)
|
||||
elsif self.comment.nil? && self.score.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "上传了批阅附件", :status=> false)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> false)
|
||||
end
|
||||
else # 更新
|
||||
if self.comment.nil?
|
||||
if self.comment.nil? && self.score
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score}", :status=> true)
|
||||
elsif self.score.nil? && self.comment
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "评语:#{self.comment}", :status=> true)
|
||||
elsif self.comment.nil? && self.score.nil?
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "上传了批阅附件", :status=> true)
|
||||
else
|
||||
self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id,
|
||||
:viewed => false, :content => "作业评分:#{self.score} 评语:#{self.comment}", :status=> true)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
class SubDocumentComment < ActiveRecord::Base
|
||||
attr_accessible :content, :creator_id, :locked, :org_subfield_id, :parent_id, :reply_id, :sticky, :sub_domain_id, :title
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
include ApplicationHelper
|
||||
belongs_to :sub_domain
|
||||
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
|
||||
acts_as_tree :order => "#{SubDocumentComment.table_name}.sticky asc, #{SubDocumentComment.table_name}.created_at desc"
|
||||
acts_as_attachable
|
||||
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
|
||||
after_create :document_save_as_sub_activity
|
||||
after_update :update_activity
|
||||
validates_presence_of :content
|
||||
|
||||
#动态的更新
|
||||
private
|
||||
def update_activity
|
||||
org_activity = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", id).first
|
||||
if org_activity
|
||||
org_activity.updated_at = Time.now
|
||||
org_activity.save
|
||||
end
|
||||
end
|
||||
|
||||
def document_save_as_sub_activity
|
||||
if(self.parent().nil?)
|
||||
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.sub_domain.id, :container_type => 'SubDomain')
|
||||
else
|
||||
act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", self.root.id).first
|
||||
act.update_attributes(:updated_at => self.updated_at)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class SubDomain < ActiveRecord::Base
|
||||
attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status
|
||||
belongs_to :org_subfield, :foreign_key => :org_subfield_id
|
||||
has_many :sub_document_comments, :dependent => :destroy
|
||||
end
|
|
@ -108,6 +108,8 @@ class User < Principal
|
|||
has_many :student_works_evaluation_distributions, :dependent => :destroy
|
||||
has_many :student_works_scores, :dependent => :destroy
|
||||
has_many :student_work_projects, :dependent => :destroy
|
||||
has_many :apply_homeworks, :dependent => :destroy
|
||||
has_many :apply_resources, :dependent => :destroy
|
||||
#end
|
||||
|
||||
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
|
||||
|
@ -181,6 +183,8 @@ class User < Principal
|
|||
|
||||
has_one :user_wechat
|
||||
|
||||
has_one :sso
|
||||
|
||||
# add by zjc
|
||||
has_one :level, :class_name => 'UserLevels', :dependent => :destroy
|
||||
has_many :memos , :foreign_key => 'author_id'
|
||||
|
@ -306,6 +310,20 @@ class User < Principal
|
|||
end
|
||||
|
||||
# ======================================================================
|
||||
def my_workplace
|
||||
self.user_extensions.try(:occupation).to_s
|
||||
end
|
||||
|
||||
def my_blogs_count
|
||||
self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count
|
||||
end
|
||||
|
||||
def my_students
|
||||
my_students=StudentsForCourse.find_by_sql("SELECT SUM(student_count) as students_count, c.tea_id FROM courses c, (SELECT course_id , COUNT(id) AS student_count FROM students_for_courses GROUP BY course_id) AS ct
|
||||
WHERE c.id= ct.course_id and c.tea_id = #{self.id} GROUP BY c.tea_id").first
|
||||
results = my_students.blank? ? 0 : my_students.students_count
|
||||
results
|
||||
end
|
||||
|
||||
# 查询用户未读过的记录
|
||||
# 用户留言记录
|
||||
|
@ -1070,16 +1088,22 @@ class User < Principal
|
|||
anonymous_user
|
||||
end
|
||||
|
||||
def self.is_id?(id)
|
||||
Fixnum===id || id.to_i.to_s == id
|
||||
end
|
||||
|
||||
# refactor User model find function,
|
||||
# return anonymous user when can not find user id = user_id
|
||||
def self.find (*args, &block)
|
||||
begin
|
||||
return find_by_login(args.first) if args.size==1 && !is_id?(args.first)
|
||||
super
|
||||
rescue
|
||||
self.anonymous
|
||||
end
|
||||
# super
|
||||
end
|
||||
|
||||
# Salts all existing unsalted passwords
|
||||
# It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password))
|
||||
# This method is used in the SaltPasswords migration and is to be kept as is
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#encoding: utf-8
|
||||
class WechatService
|
||||
|
||||
def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="")
|
||||
data = {
|
||||
touser:openid,
|
||||
template_id:template_id,
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{Setting.protocol}://#{Setting.host_name}/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
topcolor:"#FF0000",
|
||||
data:{
|
||||
first: {
|
||||
|
@ -33,7 +33,7 @@ class WechatService
|
|||
data
|
||||
end
|
||||
|
||||
def homework_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def homework_template(user_id, type, id, first, key1, key2, key3, remark="")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", type, id, first, key1, key2, key3, remark
|
||||
|
@ -44,10 +44,9 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", type, id,first, key1, key2, key3, remark
|
||||
|
@ -59,10 +58,9 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def comment_template(user_id,type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def comment_template(user_id,type, id, first, key1, key2, key3, remark="")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",type, id,first, key1, key2, key3, remark
|
||||
|
@ -74,16 +72,15 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def message_update_template(user_id, type, id, first, key1, key2, remark="具体内容请点击详情查看网站")
|
||||
def message_update_template(user_id, type, id, first, key1, key2, remark="")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = {
|
||||
touser:uw.openid,
|
||||
template_id:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg",
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{Setting.protocol}://#{Setting.host_name}/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
topcolor:"#FF0000",
|
||||
data:{
|
||||
first: {
|
||||
|
@ -112,6 +109,5 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,89 @@
|
|||
<h3>
|
||||
<%=l(:label_apply_homework)%>
|
||||
</h3>
|
||||
|
||||
<div class="autoscroll">
|
||||
<table class="list" style="width: 100%;table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 30px;">
|
||||
序号
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
作业名称
|
||||
</th>
|
||||
<th style="width: 120px;">
|
||||
课程名称
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
作者
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
申请者
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
申请状态
|
||||
</th>
|
||||
<th style="width: 70px;">
|
||||
申请日期
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%@count=@page*30 %>
|
||||
<% for homework in @homework do %>
|
||||
<% unless homework.nil? %>
|
||||
<% @count+=1 %>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<%=@count %>
|
||||
</td>
|
||||
<% c_h = HomeworkCommon.find homework.homework_common_id %>
|
||||
<% if c_h %>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=c_h.name%>'>
|
||||
<%=link_to(c_h.try(:name), student_work_index_path(:homework => c_h.id))%>
|
||||
</td>
|
||||
<% if c_h.course %>
|
||||
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=c_h.course.name%>'>
|
||||
<%= link_to(c_h.course.name, course_path(c_h.course.id)) %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if c_h.try(:user).try(:realname) == ' '%><%= c_h.try(:user)%><% else %><%=c_h.try(:user).try(:realname) %><% end %>'>
|
||||
<% if c_h.try(:user).try(:realname) == ' '%>
|
||||
<%= link_to(c_h.try(:user), user_path(c_h.user_id)) %>
|
||||
<% else %>
|
||||
<%= link_to(c_h.try(:user).try(:realname), user_path(c_h.user_id)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if homework.try(:user).try(:realname) == ' '%><%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
|
||||
<% if homework.try(:user).try(:realname) == ' '%>
|
||||
<%= link_to(homework.try(:user), user_path(homework.user_id)) %>
|
||||
<% else %>
|
||||
<%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<% if homework.status == 1 %>
|
||||
等待回复
|
||||
<% elsif homework.status == 2 %>
|
||||
已通过
|
||||
<% else %>
|
||||
已拒绝
|
||||
<% end %>
|
||||
</td>
|
||||
<td align="center">
|
||||
<%=format_date( homework.created_at ) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||
</div>
|
||||
|
||||
<% html_title(l(:label_apply_homework)) -%>
|
|
@ -24,8 +24,8 @@
|
|||
<th style="width: 100px;">
|
||||
测试完成时间
|
||||
</th>
|
||||
<th style="width: 60px;">
|
||||
<span style="float:left; margin-left:20px;">答题状态</span>
|
||||
<th style="width: 80px;">
|
||||
<span style="float:left; margin-left:30px;">答题状态</span>
|
||||
</th>
|
||||
<th style="width: 50px;">
|
||||
<span style="float:left; margin-left:20px;">耗时</span>
|
||||
|
@ -37,13 +37,21 @@
|
|||
<% if test['homework_id'] != nil %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="text-align: center; " title='<%=test['homework_id']%>'>
|
||||
<%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%>
|
||||
<% if test['link_hwork'] %>
|
||||
<%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%>
|
||||
<% else %>
|
||||
<%= test['homework_id'] %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td style="text-align: center; " title='<%=test['student_work_id']%>'>
|
||||
<% if !test['is_test'] %>
|
||||
<%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%>
|
||||
<% if test['link_swork'] && test['link_hwork'] %>
|
||||
<% if !test['is_test'] %>
|
||||
<%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%>
|
||||
<% else %>
|
||||
<%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%>
|
||||
<%= test['student_work_id'] %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
|
@ -68,6 +76,10 @@
|
|||
<%= "代码超时" %>
|
||||
<% elsif test.status == -3 %>
|
||||
<%= "请求超时" %>
|
||||
<% elsif test.status == -4 %>
|
||||
<%= "judge代码出错!" %>
|
||||
<% elsif test.status == -5 %>
|
||||
<%= "trustie代码出错!" %>
|
||||
<% else %>
|
||||
<%= "答题错误" %>
|
||||
<% end %>
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
<script type="text/javascript">
|
||||
$(function(){
|
||||
showNormalImage('reply_message_description_<%= reply.id %>');
|
||||
autoUrl('reply_message_description_<%= reply.id %>');
|
||||
});
|
||||
</script>
|
||||
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
|
||||
|
@ -215,5 +216,6 @@
|
|||
var postContent = $("#message_description_<%= @article.id %>").html();
|
||||
postContent = postContent.replace(/ /g," ");
|
||||
$("#message_description_<%= @article.id %>").html(postContent);
|
||||
autoUrl('message_description_<%= @article.id %>');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,226 +1,82 @@
|
|||
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" >
|
||||
<div class="homepagePostBrief" onmouseover="$('#message_setting_<%=activity.id%>').show();" onmouseout="$('#message_setting_<%= activity.id%>').hide();">
|
||||
<div class="homepagePostPortrait">
|
||||
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
|
||||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<% if activity.author.id == User.current.id || User.current.admin? %>
|
||||
<div class="homepagePostSetting" id="message_setting_<%= activity.id%>" style="display: none">
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li>
|
||||
<%= link_to(
|
||||
l(:button_edit),
|
||||
{:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current.admin? || User.current.id == activity.author.id %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to(
|
||||
l(:button_delete),
|
||||
{:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
|
||||
:method => :delete,
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:class => 'postOptionLink'
|
||||
) if User.current.admin? || User.current.id == activity.author.id %>
|
||||
</li>
|
||||
<li>
|
||||
<% if activity.id == activity.blog.homepage_id %>
|
||||
<%= link_to(
|
||||
l(:button_cancel_homepage),
|
||||
{:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
|
||||
:method => :post,
|
||||
:class => 'postOptionLink'
|
||||
) if User.current && User.current.id == activity.blog.author_id %>
|
||||
<% else %>
|
||||
<%= link_to(
|
||||
l(:button_set_homepage),
|
||||
{:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
|
||||
:method => :post,
|
||||
:class => 'postOptionLink'
|
||||
) if User.current && User.current.id == activity.blog.author_id %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class = "cl"> </div>
|
||||
<div id="blog-list">
|
||||
<div class="listbox mt10" >
|
||||
<h2 class="list-h2">博客列表</h2>
|
||||
<div class="category">
|
||||
<span class="grayTxt ">排序:</span>
|
||||
<%= link_to "时间", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
|
||||
<% if @type.to_i == 1 %>
|
||||
<%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
|
||||
<% end %>
|
||||
<%= link_to "人气", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
|
||||
<% if @type.to_i == 2 %>
|
||||
<%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="bloglistbox">
|
||||
<% if topics.any? %>
|
||||
<% topics.each do |activity| %>
|
||||
<ul class="list-file">
|
||||
<li><span class="item_list fl"></span>
|
||||
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
|
||||
<%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %>
|
||||
<% else %>
|
||||
<%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%>
|
||||
<% end %>
|
||||
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
|
||||
<span class="font_normal ml10 fr">[已设为首页]</span>
|
||||
<% end %>
|
||||
<% if activity.sticky == 1 %>
|
||||
<span class="fl ml10 red-cir-btn">顶</span>
|
||||
<% end%>
|
||||
<% if activity.locked %>
|
||||
<span class="fl ml10 green-cir-btn" title="已锁定">锁</span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% count=0 %>
|
||||
<% if activity.parent %>
|
||||
<% count=activity.parent.children.count%>
|
||||
<% else %>
|
||||
<% count=activity.children.count%>
|
||||
<% end %>
|
||||
<li class="ml15">
|
||||
<span class="grayTxt">发布:<%= format_time(activity.created_on) %></span>
|
||||
<span class="grayTxt">更新:<%= format_time(activity.updated_on) %></span>
|
||||
<p class="list-info fr grayTxt">
|
||||
<span><%= count>0 ? "#{count}" :"0" %></span>
|
||||
<span>回复</span>
|
||||
<span>|</span>
|
||||
<span><%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" :"0" %></span>
|
||||
<span>赞</span>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%end%>
|
||||
<div class="homepagePostTo fl">
|
||||
<% if activity.try(:author).try(:realname) == ' ' %>
|
||||
<%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
|
||||
<% else %>
|
||||
<%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
|
||||
<% end %>
|
||||
TO
|
||||
<%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
|
||||
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
|
||||
<span class="red_homework_btn_cir ml5">已设为首页</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="homepagePostTitle hidden m_w530 fl">
|
||||
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
|
||||
<%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
|
||||
<% else %>
|
||||
<%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey"%>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if activity.sticky == 1%>
|
||||
<span class="sticky_btn_cir ml10">置顶</span>
|
||||
<% end%>
|
||||
<% if activity.locked%>
|
||||
<span class="locked_btn_cir ml10 fl" title="已锁定"> </span>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
<div class="homepagePostDate fl">
|
||||
发帖时间:<%= format_time(activity.created_on) %>
|
||||
</div>
|
||||
<div class="homepagePostDate fl ml15">
|
||||
更新时间:<%= format_time(activity.updated_on) %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% if activity.parent_id.nil? %>
|
||||
<% content= activity.content%>
|
||||
<% else %>
|
||||
<% content= activity.parent.content%>
|
||||
<% end %>
|
||||
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<!--<div class=" fl" style="width: 600px">
|
||||
<%# if activity.attachments.any?%>
|
||||
<%# options = {:author => true, :deletable => false } %>
|
||||
<%#= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %>
|
||||
<%# end %>
|
||||
</div>
|
||||
<div class="cl"></div>-->
|
||||
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
|
||||
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
|
||||
<div class="cl"></div>
|
||||
<div class="mt10" style="font-weight:normal;">
|
||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
|
||||
</div>
|
||||
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li>
|
||||
<li><a href="javascript:void(0);" class="postOptionLink">复制</a></li>
|
||||
<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% count=0 %>
|
||||
<% if activity.parent %>
|
||||
<% count=activity.parent.children.count%>
|
||||
<% else %>
|
||||
<% count=activity.children.count%>
|
||||
<% end %>
|
||||
<div class="homepagePostReply">
|
||||
<div class="homepagePostReplyBanner">
|
||||
<div class="homepagePostReplyBannerCount">回复
|
||||
<sapn class="mr15"><%= count>0 ? "(#{count})" : "" %></sapn><span style="color: #cecece;">▪</span>
|
||||
<span id="praise_count_<%=user_activity_id %>">
|
||||
<% if activity.author == User.current %>
|
||||
<span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %></span></span>
|
||||
<% else %>
|
||||
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
|
||||
<%if count > 3 %>
|
||||
<div class="homepagePostReplyBannerMore">
|
||||
<a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >
|
||||
展开更多
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% activity= activity.parent ? activity.parent : activity%>
|
||||
<% replies_all_i = 0 %>
|
||||
<% if count > 0 %>
|
||||
<div class="" id="reply_div_<%= user_activity_id %>">
|
||||
<ul>
|
||||
<% activity.children.reorder("created_on desc").each do |reply|%>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
showNormalImage('reply_content_<%= reply.id %>');
|
||||
});
|
||||
</script>
|
||||
<% replies_all_i=replies_all_i+1 %>
|
||||
<li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>3 ? 'none' : '' %>">
|
||||
<div class="homepagePostReplyPortrait">
|
||||
<%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
|
||||
</div>
|
||||
<div class="homepagePostReplyDes">
|
||||
<div class="homepagePostReplyPublisher">
|
||||
<% if reply.try(:author).try(:realname) == ' ' %>
|
||||
<%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
|
||||
<% else %>
|
||||
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
|
||||
<% end %>
|
||||
<%= format_time(reply.created_on) %>
|
||||
<span id="reply_praise_count_<%=reply.id %>">
|
||||
<% if reply.author == User.current %>
|
||||
<span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %></span></span>
|
||||
<% else %>
|
||||
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="homepagePostReplyContent break_word list_style upload_img" id="reply_content_<%= reply.id %>">
|
||||
<%= reply.content.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if !activity.locked? %>
|
||||
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
|
||||
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div>
|
||||
<div class="homepagePostReplyInputContainer mb10">
|
||||
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
|
||||
<%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
|
||||
<input type="hidden" name="quote[quote]" value="">
|
||||
<input type="hidden" name="blog_comment[sticky]" value="0">
|
||||
<input type="hidden" name="blog_comment[locked]" value="0">
|
||||
<input type="hidden" name="blog_comment[title]" value="RE:<%= activity.title%>">
|
||||
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
|
||||
<div nhname='toolbar_container_<%= user_activity_id%>'></div>
|
||||
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="blog_comment[content]"></textarea>
|
||||
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
|
||||
<div class="cl"></div>
|
||||
<p nhname='contentmsg_<%= user_activity_id%>'></p>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</ul>
|
||||
<% end %>
|
||||
<div>
|
||||
<ul class="wlist" id="pages" >
|
||||
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$("#moreProject_<%=user_activity_id %>").click(function(){
|
||||
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
|
||||
$("#relatePWrap_<%=user_activity_id %>").css("height","auto");
|
||||
$(this).hide();
|
||||
//如果右边的博客列表比左边的高度低则将右边的高度设为与左边对齐
|
||||
$(function() {
|
||||
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 10;
|
||||
var rightHeight = $(".homepageRight").height();
|
||||
if (rightHeight < leftHeight) {
|
||||
var diffHeight = leftHeight - rightHeight;
|
||||
var tmpHeight = $(".listbox").height() + diffHeight;
|
||||
$(".listbox").css("height", tmpHeight);
|
||||
}
|
||||
});
|
||||
$("#hideProject_<%=user_activity_id %>").click(function(){
|
||||
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
|
||||
$("#moreProject_<%=user_activity_id %>").show();
|
||||
});
|
||||
</script>
|
||||
</script>
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
<div class="homepageRight mt0">
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">
|
||||
<div class="f16 fl fontGrey3">
|
||||
<%= @user.name%>的博客
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,44 +51,9 @@
|
|||
<% end %>
|
||||
|
||||
<% if topics%>
|
||||
<% topics.each do |topic| %>
|
||||
<script>
|
||||
function expand_reply(container, btnid) {
|
||||
var target = $(container);
|
||||
var btn = $(btnid);
|
||||
if (btn.data('init') == '0') {
|
||||
btn.data('init', 1);
|
||||
btn.html('收起回复');
|
||||
target.show();
|
||||
} else {
|
||||
btn.data('init', 0);
|
||||
btn.html('展开更多');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
target.eq(2).show();
|
||||
}
|
||||
}
|
||||
|
||||
function expand_reply_input(id) {
|
||||
$(id).toggle();
|
||||
}
|
||||
|
||||
$(function () {
|
||||
sd_create_editor_from_data(<%= topic.id%>, null, "100%", "<%=topic.class.to_s%>");
|
||||
});
|
||||
</script>
|
||||
<% if topic %>
|
||||
<%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# if topics.count == 10 %>
|
||||
<!--<div id="show_more_course_topic" class="loadMore mt10 f_grey">展开更多<%#= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %></div>-->
|
||||
<%# end %>
|
||||
<%= render :partial => 'blogs/article', :locals => {:topics => topics} %>
|
||||
<% end%>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#show_more_course_topic").mouseover(function () {
|
||||
$("#more_topic_link").click();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<%= import_ke(enable_at: false, prettify: false) %>
|
||||
|
||||
|
||||
<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.updated_on desc"), :page => 0, :user => @user} %>
|
||||
<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @topics, :page => 0, :user => @user} %>
|
||||
|
||||
|
||||
<script type="text/javascript">//侧导航
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#blog-list").replaceWith('<%= escape_javascript( render :partial => 'blogs/article', :locals => {:topics => @topics} ) %>');
|
|
@ -2,6 +2,7 @@
|
|||
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
var first_click = true;
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(!regexTopicSubject()) {
|
||||
|
@ -49,10 +50,12 @@
|
|||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
if(is_checked){
|
||||
if(first_click && is_checked){
|
||||
if(flag){
|
||||
first_click = false;
|
||||
return true;
|
||||
}else{
|
||||
first_click = false;
|
||||
$(this)[0].submit();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,41 +2,7 @@
|
|||
<%= import_ke(enable_at: false, prettify: false) %>
|
||||
<%= javascript_include_tag "create_kindeditor" %>
|
||||
<% end %>
|
||||
<% if topics %>
|
||||
<% topics.each do |topic| %>
|
||||
<script>
|
||||
function expand_reply(container, btnid) {
|
||||
var target = $(container);
|
||||
var btn = $(btnid);
|
||||
if (btn.data('init') == '0') {
|
||||
btn.data('init', 1);
|
||||
btn.html('收起回复');
|
||||
target.show();
|
||||
} else {
|
||||
btn.data('init', 0);
|
||||
btn.html('展开更多');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
target.eq(2).show();
|
||||
}
|
||||
}
|
||||
|
||||
function expand_reply_input(id) {
|
||||
$(id).toggle();
|
||||
}
|
||||
|
||||
$(function () {
|
||||
sd_create_editor_from_data(<%= topic.id%>, null, "100%", "<%=topic.class.to_s%>");
|
||||
});
|
||||
</script>
|
||||
<% if topic %>
|
||||
<%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id, :is_course => 1, :is_board=>1} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if topics.count == 10 %>
|
||||
<%= link_to "点击展开更多",boards_topic_path(@board, :course_id => @board.course.id ,:page => page),:id => "show_more_course_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<% end %>
|
||||
<% end%>
|
||||
|
||||
<% if @topics || topics %>
|
||||
<%= render :partial => 'users/course_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
|
||||
<% end %>
|
|
@ -2,60 +2,7 @@
|
|||
<%= import_ke(enable_at: false, prettify: false) %>
|
||||
<%= javascript_include_tag "create_kindeditor" %>
|
||||
<% end %>
|
||||
<style type="text/css">
|
||||
/*回复框*/
|
||||
/*.homepagePostReplyInputContainer .ke-toolbar {display: none; width: 400px; border: none; background: none; padding: 0px 0px;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-toolbar-icon {line-height: 26px; font-size: 14px; padding-left: 26px;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-toolbar-icon-url {background-image: url(/images/public_icon.png)}*/
|
||||
/*.homepagePostReplyInputContainer .ke-outline {padding: 0px 0px; line-height: 26px; font-size: 14px;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-icon-emoticons {background-position: 0px -671px; width: 50px; height: 26px;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-icon-emoticons:hover {background-position: -79px -671px; width: 50px; height: 26px;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-outline {border: none;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-inline-block {display: none;}*/
|
||||
/*.homepagePostReplyInputContainer .ke-container {float: left;}*/
|
||||
</style>
|
||||
<% if topics%>
|
||||
<% topics.each do |topic| %>
|
||||
<script>
|
||||
function expand_reply(container, btnid) {
|
||||
var target = $(container);
|
||||
var btn = $(btnid);
|
||||
if (btn.data('init') == '0') {
|
||||
btn.data('init', 1);
|
||||
btn.html('收起回复');
|
||||
target.show();
|
||||
} else {
|
||||
btn.data('init', 0);
|
||||
btn.html('展开更多');
|
||||
target.hide();
|
||||
target.eq(0).show();
|
||||
target.eq(1).show();
|
||||
target.eq(2).show();
|
||||
}
|
||||
}
|
||||
|
||||
function expand_reply_input(id) {
|
||||
$(id).toggle();
|
||||
}
|
||||
|
||||
$(function () {
|
||||
sd_create_editor_from_data(<%= topic.id%>, null, "100%");
|
||||
});
|
||||
</script>
|
||||
<% if topic %>
|
||||
<%= render :partial => 'users/project_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if topics.count == 10 %>
|
||||
<!--<div id="show_more_course_topic" class="loadMore mt10 f_grey">展开更多<%#= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %></div>-->
|
||||
<%= link_to "点击展开更多", boards_topic_path(@board, :project_id => @board.project.id ,:page => page), :id => "show_more_project_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<% end %>
|
||||
<% end%>
|
||||
|
||||
<!--
|
||||
<script type="text/javascript">
|
||||
$("#show_more_course_topic").mouseover(function () {
|
||||
$("#more_topic_link").click();
|
||||
});
|
||||
</script>-->
|
||||
<%if @topics || topics %>
|
||||
<%= render :partial => 'users/project_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
|
||||
<% end %>
|
|
@ -1,5 +1,5 @@
|
|||
<% if @course %>
|
||||
$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
|
||||
$("#course-boardlist").replaceWith('<%= escape_javascript( render :partial => 'users/course_boardlist', :locals => {:topics => @topics, :is_course => 1, :is_board=>1}) %>');
|
||||
<% else %>
|
||||
$("#show_more_project_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/project_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
|
||||
$("#project-boardlist").replaceWith('<%= escape_javascript( render :partial => 'users/project_boardlist', :locals => {:topics => @topics, :is_course => 1, :is_board=>1}) %>');
|
||||
<% end %>
|
|
@ -1,17 +1,17 @@
|
|||
<script type="text/javascript">
|
||||
function submit_copy_course() {
|
||||
if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password())
|
||||
if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')&®ex_course_password('new'))
|
||||
{
|
||||
$("#new_course").submit();
|
||||
document.getElementById("submit_copy_course").onclick = "";
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
$("#time").change(function(){
|
||||
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
|
||||
$("#new_time").change(function(){
|
||||
document.getElementById("new_end_time").options[document.getElementById("new_time").selectedIndex].selected = true;
|
||||
});
|
||||
$("#term").change(function(){
|
||||
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
|
||||
$("#new_term").change(function(){
|
||||
document.getElementById("new_end_term").options[document.getElementById("new_term").selectedIndex].selected = true;
|
||||
});
|
||||
|
||||
var popupHeight = $(".referenceResourcesPopup").outerHeight(true);
|
||||
|
@ -56,35 +56,35 @@
|
|||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
<input type="text" name="course[name]" id="course_name" class="courses_input grey_border" maxlength="100" onkeyup="regex_course_name();" value="<%=@course.name %>">
|
||||
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
<input type="text" name="course[name]" id="new_course_name" class="courses_input grey_border" maxlength="100" onkeyup="regex_course_name('new');" value="<%=@course.name %>">
|
||||
<span class="c_red" id="new_course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:label_class_period)%> :</label>
|
||||
<input type="text" name="class_period" id="class_period" class="hwork_input02 grey_border" onkeyup="regex_course_class_period();" maxlength="6" value="<%=@course.class_period %>">
|
||||
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
|
||||
<input type="text" name="class_period" id="new_class_period" class="hwork_input02 grey_border" onkeyup="regex_course_class_period('new');" maxlength="6" value="<%=@course.class_period %>">
|
||||
<span class="c_red" id="new_course_class_period_notice" style="display: none;"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_course_term)%> :</label>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@new_course.time),@new_course.time), {} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@new_course.term || cur_course_term),{} %>
|
||||
<span class="c_red" id="course_time_term_notice"></span>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@new_course.time),@new_course.time), {:id=>"new_time"} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@new_course.term || cur_course_term),{:id=>"new_term"} %>
|
||||
<span class="c_red" id="new_course_time_term_notice"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> 结束学期 :</label>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@new_course.end_time),@new_course.end_time), {} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@new_course.end_term || cur_course_term),{} %>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@new_course.end_time),@new_course.end_time), {:id=>"new_end_time"} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@new_course.end_term || cur_course_term),{:id=>"new_end_term"} %>
|
||||
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="text" style="display: none;">
|
||||
<input type="text" name="course[password]" id="course_course_password" class="hwork_input02 grey_border" onkeyup="regex_course_password();" value="<%=@course.password %>">
|
||||
<input type="text" name="course[password]" id="new_course_course_password" class="hwork_input02 grey_border" onkeyup="regex_course_password('new');" value="<%=@course.password %>">
|
||||
<!--<a id="psw_btn" href="javascript:void(0)">显示明码</a>-->
|
||||
<span class="c_red" id="course_course_password_notice"></span>
|
||||
<span class="c_red" id="new_course_course_password_notice"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="ml95 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<li class="fl">
|
||||
<input name="outline_id" type="radio" value="<%= article.id%>" class="courseSendCheckbox"/>
|
||||
</li>
|
||||
<li class="blogTitle fl"><%= article.title%></li>
|
||||
<li class="blogTitle fl mw220"><%= article.title%></li>
|
||||
</ul>
|
||||
<div class="homeworkPublishTime">发布时间:<%= format_date(article.created_at)%></div>
|
||||
<% end %>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea>
|
||||
<p nhname='contentmsg_'></p>
|
||||
<a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10">取消</a>
|
||||
<a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="submit_feedback_course" >留言</a>
|
||||
<a href="javascript:void(0);" class="blue_btn fr ml10 mt10" id="new_message_submit_btn_" >留言</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -55,9 +55,6 @@
|
|||
<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
$("#submit_feedback_course").one('click',function() {
|
||||
$("#course_feedback_new").submit();
|
||||
});
|
||||
KindEditor.ready(function(K){
|
||||
$("a[nhname='reply_btn']").live('click',function(){
|
||||
var params = {};
|
||||
|
@ -68,15 +65,18 @@
|
|||
params.textarea = $("textarea[name='user_notes']",params.div_form);
|
||||
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
|
||||
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
|
||||
params.submit_btn = $("input[nhname='submit_btn']",params.div_form);
|
||||
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
|
||||
params.height = 55;
|
||||
if(params.textarea.data('init') == undefined){
|
||||
params.editor = init_editor(params);
|
||||
init_form(params);
|
||||
params.cancel_btn.click(function(){
|
||||
nh_reset_form(params);
|
||||
});
|
||||
}
|
||||
params.editor = init_editor(params);
|
||||
init_form(params);
|
||||
params.cancel_btn.click(function(){
|
||||
nh_reset_form(params);
|
||||
});
|
||||
params.submit_btn.one('click', function () {
|
||||
params.form.submit();
|
||||
});
|
||||
params.textarea.data('init',1);
|
||||
params.cancel_btn.click();
|
||||
toggleAndSettingWordsVal(params.div_form, params.textarea);
|
||||
setTimeout(function(){
|
||||
|
@ -86,7 +86,6 @@
|
|||
params.textarea.hide();
|
||||
}
|
||||
},300);
|
||||
params.textarea.data('init',1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,16 +24,24 @@
|
|||
<ul class="st_box_top">
|
||||
<li class="ml50" style="padding-right: 5px;"><a href="">姓名</a></li>
|
||||
<li class="ml10" style="padding-right: 15px;"><a href="">学号</a></li>
|
||||
<li style="padding-right: 55px; margin-left: 260px;"><a href="">分班</a></li>
|
||||
<li style="margin-left: 25px;">
|
||||
<%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
|
||||
<% if @score_sort_by == 'desc' %>
|
||||
<li style="padding-right: 55px; margin-left: 160px;"><a href="">分班</a></li>
|
||||
<li class="st_list_score ml10">
|
||||
<%= link_to '作业积分', member_score_sort_course_path(:sort_type => 'score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true, :class => 'ml25'%>
|
||||
<% if @sort_type == "score" && @score_sort_by == 'desc' %>
|
||||
<a id="pic" href="javascript:" class= "st_down"></a>
|
||||
<% else %>
|
||||
<% elsif @sort_type == "score" && @score_sort_by == 'asc' %>
|
||||
<a id="pic" href="javascript:" class= "st_up"></a>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="ml50"><a href="javascript:void(0)" >加入时间</a></li>
|
||||
<li class="st_list_score">
|
||||
<%= link_to '活跃度', member_score_sort_course_path(:sort_type => 'act_score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true, :class => 'ml35'%>
|
||||
<% if @sort_type == "act_score" && @score_sort_by == 'desc' %>
|
||||
<a id="pic" href="javascript:" class= "st_down"></a>
|
||||
<% elsif @sort_type == "act_score" && @score_sort_by == 'asc' %>
|
||||
<a id="pic" href="javascript:" class= "st_up"></a>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="ml20"><a href="javascript:void(0)" >加入时间</a></li>
|
||||
</ul>
|
||||
<div class="cl"></div><!--st_box_top end-->
|
||||
|
||||
|
@ -61,21 +69,21 @@
|
|||
</ul>
|
||||
<% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %>
|
||||
<% if @course.course_groups.nil? || @group %>
|
||||
<div class="select-class-option fl" style="margin-left: 105px;">
|
||||
<div class="select-class-option fl" style="margin-left: 5px;">
|
||||
<span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %>
|
||||
<div class="select-class-option fl" style="margin-left: 105px;"><span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
|
||||
<div class="select-class-option fl" style="margin-left: 5px;"><span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
|
||||
<a style="display: inline-block;" href="javascript:void(0)" class="pic_edit2 ml5"></a>
|
||||
</div>
|
||||
<%= select( :name,:group_id, course_group_option(@course),
|
||||
{ :include_blank => false,:selected => member.course_group_id},
|
||||
{:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 105px;"}) %>
|
||||
{:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 5px;"}) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="select-class-option fl" style="margin-left: 105px;">
|
||||
<div class="select-class-option fl" style="margin-left: 5px;">
|
||||
<span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -83,7 +91,12 @@
|
|||
:action => 'show_member_score',
|
||||
:member_id => member.id,
|
||||
:remote => true},
|
||||
:class => 'ml25 c_red' %>
|
||||
:class => 'st_list_score c_red' %>
|
||||
<%= link_to member.act_score.nil? ? 0 : member.act_score.to_s, {
|
||||
:action => 'show_member_act_score',
|
||||
:member_id => member.id,
|
||||
:remote => true},
|
||||
:class => 'st_list_score c_red' %>
|
||||
<span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
|
||||
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<style>
|
||||
.tscore_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; text-align: center; padding-top:5px;}
|
||||
.tscore_box li{ height:25px;}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="tscore_con" id="user_score">
|
||||
<% act_score = CourseContributorScore.where("user_id = ? and course_id = ?", member.user_id, member.course_id).first %>
|
||||
<h2><%= member.user.show_name %> 活跃度计算</h2>
|
||||
<% if act_score.nil? %>
|
||||
<div style="padding-left: 40px;padding-bottom: 2px;padding-right: 2px;padding-top: 10px;">
|
||||
资源发布数 x 5 = 0 x 5 = 0</br>
|
||||
问答发布数 x 2 = 0 x 2 = 0</br>
|
||||
通知发布数 x 1 = 0 x 1 = 0</br>
|
||||
问答回帖数 x 1 = 0 x 1 = 0</br>
|
||||
作业留言数 x 1 = 0 x 1 = 0</br>
|
||||
通知留言数 x 1 = 0 x 1 = 0</br>
|
||||
课程留言数 x 1 = 0 x 1 = 0</br>
|
||||
总得分:0
|
||||
</div>
|
||||
<% else %>
|
||||
<% total_score = act_score.resource_num.to_i * 5 + act_score.message_num.to_i * 2 +
|
||||
act_score.message_reply_num.to_i * 1 + act_score.journal_num.to_i * 1 +
|
||||
+ act_score.homework_journal_num.to_i * 1 + act_score.news_reply_num.to_i * 1 +
|
||||
act_score.news_num.to_i * 1 %>
|
||||
<div style="padding-left: 40px;padding-bottom: 2px;padding-right: 2px;padding-top: 10px;">
|
||||
资源发布数 x 5 = <%= act_score.resource_num.to_i %> x 5 = <%= act_score.resource_num.to_i * 5 %></br>
|
||||
问答发布数 x 2 = <%= act_score.message_num.to_i %> x 2 = <%= act_score.message_num.to_i * 2 %></br>
|
||||
通知发布数 x 1 = <%= act_score.news_num.to_i %> x 1 = <%= act_score.news_num.to_i %></br>
|
||||
问答回帖数 x 1 = <%= act_score.message_reply_num.to_i %> x 1 = <%= act_score.message_reply_num.to_i %></br>
|
||||
作业留言数 x 1 = <%= act_score.homework_journal_num.to_i %> x 1 = <%= act_score.homework_journal_num.to_i %></br>
|
||||
通知留言数 x 1 = <%= act_score.news_reply_num.to_i %> x 1 = <%= act_score.news_reply_num.to_i %></br>
|
||||
课程留言数 x 1 = <%= act_score.journal_num.to_i %> x 1 = <%= act_score.journal_num.to_i %></br>
|
||||
总得分:<%=total_score %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
|
@ -8,27 +8,27 @@
|
|||
|
||||
|
||||
.tscore_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; text-align: center; padding-top:5px;}
|
||||
.tscore_box{ width:350px; margin:15px auto;}
|
||||
.tscore_box{ width:370px; margin:15px auto;}
|
||||
.tscore_box li{ height:25px;}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="tscore_con" id="user_score">
|
||||
<h2><%= @member_score.user.name %> 历次作业积分</h2>
|
||||
<ul class="tscore_box">
|
||||
<ul class="tscore_box" style="max-height: 400px; overflow: auto;">
|
||||
<li ><span class="c_blue02 w280">作业名称</span><span class="c_blue02 w70">得分</span></li>
|
||||
<% @member_score.homework_common_list.each do |homework_common| %>
|
||||
<% @member_score.homework_common_list.each_with_index do |homework_common, index| %>
|
||||
<li>
|
||||
<span class="c_grey02 w280 hiddent">
|
||||
<%= homework_common.name %>
|
||||
作业<%=index + 1 %>:<%= homework_common.name %>
|
||||
</span>
|
||||
<span class="c_red w70">
|
||||
<% final_score = @member_score.homework_common_score(homework_common).first%>
|
||||
<%= final_score.nil? || final_score.final_score.nil? ? "--" : format("%0.2f", final_score.final_score < 0 ? 0 : final_score.final_score) %>
|
||||
<%= final_score.nil? || final_score.work_score.nil? ? "--" : format("%0.2f", final_score.work_score < 0 ? 0 : final_score.work_score) %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
<li><span class="c_blue03 w280">作业积分(总分)</span><span class="c_red w70"><%= format("%0.2f",(@member_score.student_work_score_sum).first.score) %></span></li>
|
||||
<li><span class="c_blue03 w280">作业积分(总分)</span><span class="c_red w70"><%= format("%0.2f",(@member_score.student_work_score_sum).first.score.nil? ? 0 : (@member_score.student_work_score_sum).first.score) %></span></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");
|
||||
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");
|
||||
$("#member_content").html("<%= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @members})%>");
|
|
@ -8,36 +8,36 @@
|
|||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();">
|
||||
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
<input type="text" name="course[name]" id="new_course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name('new');">
|
||||
<span class="c_red" id="new_course_name_notice" style="display: none;">课程名称不能为空且至少有两个字符</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:label_class_period)%> :</label>
|
||||
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6">
|
||||
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
|
||||
<input type="text" name="class_period" id="new_class_period" class="hwork_input02" onkeyup="regex_course_class_period('new');" maxlength="6">
|
||||
<span class="c_red" id="new_course_class_period_notice" style="display: none;"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_course_term)%> :</label>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %>
|
||||
<span class="c_red" id="course_time_term_notice"></span>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"new_time"} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"new_term"} %>
|
||||
<span class="c_red" id="new_course_time_term_notice"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> 结束学期 :</label>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{} %>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"new_end_time"} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"new_end_term"} %>
|
||||
<span class="mr15 c_red">仅针对跨越多个学期的班级,否则不用修改。</span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="text" style="display: none;">
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" onkeyup="regex_course_password();">
|
||||
<input type="password" name="course[password]" id="new_course_course_password" class="hwork_input02" onkeyup="regex_course_password('new');">
|
||||
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
|
||||
<span class="c_red" id="course_course_password_notice"></span>
|
||||
<span class="c_red" id="new_course_course_password_notice"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="ml80 c_red">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
|
@ -75,11 +75,11 @@
|
|||
<div class="cl"></div>
|
||||
<script>
|
||||
$(function(){
|
||||
$("#time").change(function(){
|
||||
document.getElementById("end_time").options[document.getElementById("time").selectedIndex].selected = true;
|
||||
$("#new_time").change(function(){
|
||||
document.getElementById("new_end_time").options[document.getElementById("new_time").selectedIndex].selected = true;
|
||||
});
|
||||
$("#term").change(function(){
|
||||
document.getElementById("end_term").options[document.getElementById("term").selectedIndex].selected = true;
|
||||
$("#new_term").change(function(){
|
||||
document.getElementById("new_end_term").options[document.getElementById("new_term").selectedIndex].selected = true;
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -33,35 +33,35 @@
|
|||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<label><span class="c_red">*</span> <%= l(:label_tags_course_name)%> :</label>
|
||||
<input type="text" name="course[name]" id="course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name();" value="<%= @course.name%>">
|
||||
<span class="c_red" id="course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
<input type="text" name="course[name]" id="edit_course_name" class="courses_input" maxlength="100" onkeyup="regex_course_name('edit');" value="<%= @course.name%>">
|
||||
<span class="c_red" id="edit_course_name_notice" style="display: none;">课程名称不能为空</span>
|
||||
<input type="password" style="top: -100000px;position: fixed;">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:label_class_period)%> :</label>
|
||||
<input type="text" name="class_period" id="class_period" class="hwork_input02" onkeyup="regex_course_class_period();" maxlength="6" value="<%= @course.class_period%>">
|
||||
<span class="c_red" id="course_class_period_notice" style="display: none;"></span>
|
||||
<input type="text" name="class_period" id="edit_class_period" class="hwork_input02" onkeyup="regex_course_class_period('edit');" maxlength="6" value="<%= @course.class_period%>">
|
||||
<span class="c_red" id="edit_course_class_period_notice" style="display: none;"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_course_term)%> :</label>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"time"} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term"} %>
|
||||
<%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"edit_time"} %>
|
||||
<%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"edit_term"} %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> 结束学期 :</label>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time"} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term"} %>
|
||||
<span class="c_red" id="course_time_term_notice"></span>
|
||||
<%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"edit_end_time"} %>
|
||||
<%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"edit_end_term"} %>
|
||||
<span class="c_red" id="edit_course_time_term_notice"></span>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45 mb10">
|
||||
<label><span class="c_red">*</span> <%= l(:label_new_course_password)%> :</label>
|
||||
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" value="<%= @course.password%>" onkeyup="regex_course_password();">
|
||||
<input type="password" name="course[password]" id="edit_course_course_password" class="hwork_input02" value="<%= @course.password%>" onkeyup="regex_course_password('edit');">
|
||||
<a id="psw_btn" href="javascript:void(0)">显示明码</a>
|
||||
<span class="c_red" id="course_course_password_notice"></span>
|
||||
<span class="c_red" id="edit_course_course_password_notice"></span>
|
||||
<div class="cl"></div>
|
||||
<span class=" ml80 c_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
|
||||
</li>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'courses/show_member_act_score', :locals => {:member => @member}) %>');
|
||||
showModal('ajax-modal', '300px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span>" +
|
||||
"<a href='javascript:void(0)' onclick='hidden_homework_score_form();'><img src='/images/bid/close.png' width='26px' height='26px' style='margin-left: 275px;' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","30%").css("left","40%").css("position","fixed").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("new-watcher");
|
|
@ -120,6 +120,7 @@
|
|||
<script type="text/javascript">
|
||||
$(function(){
|
||||
showNormalImage('reply_message_description_<%= reply.id %>');
|
||||
autoUrl('reply_message_description_<%= reply.id %>');
|
||||
});
|
||||
</script>
|
||||
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
|
||||
|
@ -214,5 +215,6 @@
|
|||
postContent=postContent.replace(/ /g," ");
|
||||
$(this).html(postContent);
|
||||
});
|
||||
autoUrl('message_description_<%= @article.id %>');
|
||||
});
|
||||
</script>
|
|
@ -87,10 +87,19 @@
|
|||
var standard_ans = $.trim($("#question_standard_ans").val());
|
||||
if(title.length == 0 || score.length == 0){
|
||||
alert("题目标题/分数不能为空");
|
||||
doc.one('click', function(){
|
||||
add_poll_question($(this),quest_type);
|
||||
});
|
||||
}else if(!/^[1-9][0-9]*$/.test(score)) {
|
||||
alert("分数必须是非零开头的数字");
|
||||
doc.one('click', function(){
|
||||
add_poll_question($(this),quest_type);
|
||||
});
|
||||
}else if(quest_type !=3 && standard_ans.length == 0) {
|
||||
alert("标准答案不能为空");
|
||||
doc.one('click', function(){
|
||||
add_poll_question($(this),quest_type);
|
||||
});
|
||||
}else{
|
||||
doc.parent().parent().parent().submit();}
|
||||
}
|
||||
|
|
|
@ -54,9 +54,16 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);"> 保存 </a>
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),1);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -54,9 +54,16 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);"> 保存 </a>
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),2);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -42,9 +42,16 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);"> 保存 </a>
|
||||
<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question"> 保存 </a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),3);
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -90,7 +90,7 @@
|
|||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),1);">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
|
@ -102,6 +102,9 @@
|
|||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),1);
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),2);">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
|
@ -101,6 +101,9 @@
|
|||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),2);
|
||||
});
|
||||
}
|
||||
}else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
'</ul>'+
|
||||
'</div>'+
|
||||
'<div class="ur_editor_footer">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this),3);">'+
|
||||
'<a class="btn btn_dark btn_submit c_white" data-button="ok" id="add_new_question">'+
|
||||
'保存'+
|
||||
'</a>'+
|
||||
'<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();">'+
|
||||
|
@ -77,6 +77,9 @@
|
|||
'<% end%>'
|
||||
);
|
||||
$("#poll_questions_title").focus();
|
||||
$("#add_new_question").one('click', function(){
|
||||
add_poll_question($(this),3);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$("#insert_new_poll_question_"+quest_type+"_"+quest_id).html("");
|
||||
|
|
|
@ -22,70 +22,6 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<div class="fl">
|
||||
<%= render :partial => "student_table"%>
|
||||
<%= render :partial => "student_table" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% @exercise_users_list.each do |exercise|%>
|
||||
<script type="text/javascript">
|
||||
$(".student_work_<%= exercise.id%>").mouseenter(function(){
|
||||
$("#work_click_<%= exercise.id%>").show();
|
||||
}).mouseleave(function(){
|
||||
$("#work_click_<%= exercise.id%>").hide();
|
||||
});
|
||||
$(function(){
|
||||
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").on('click',function() {
|
||||
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user_id) %>';
|
||||
});
|
||||
<% else %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
<% end %>
|
||||
});
|
||||
/*function show_result(id) {
|
||||
window.location.href = '<%#=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
|
||||
}*/
|
||||
</script>
|
||||
<ul class="hworkListRow" id="student_work_<%= exercise.id%>">
|
||||
<li class="hworkList340 width530">
|
||||
<ul>
|
||||
<li class="hworkPortrait mt15 mr10">
|
||||
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40"),user_activities_path(exercise.user)) %>
|
||||
</li>
|
||||
<div id="show_student_result_div_<%= exercise.id%>" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
|
||||
<li>
|
||||
<ul class="mt10 fl">
|
||||
<li class="hworkStName mr15 mt16" title="姓名" id="student_name_<%= exercise.id%>">
|
||||
<%=exercise.user.show_name %>
|
||||
</li>
|
||||
<li class="hworkStID mr10 mt16" title="学号" id="student_id_<%= exercise.id%>">
|
||||
<%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%>
|
||||
</li>
|
||||
<li class="hworkStID mt16" title="班级" id="student_class_<%= exercise.id%>">
|
||||
--
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="hworkList130 c_grey student_work_<%= exercise.id%>">
|
||||
<% if exercise.created_at%>
|
||||
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>
|
||||
<% if @exercise.end_time <= exercise.created_at %>
|
||||
<span class="c_red">[未答]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="hworkList50 <%= score_color exercise.score%> student_final_scor_info">
|
||||
<%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%>
|
||||
</li>
|
||||
<li class="hworkTip" style="display: none" id="work_click_<%= exercise.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></li>
|
||||
</ul>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
|
@ -0,0 +1,81 @@
|
|||
<div class="fl" style="padding-bottom:10px; width:720px;">
|
||||
<span class="c_dark f14 fb fl mr30">
|
||||
测验
|
||||
<font class="f12 c_red">
|
||||
(<%= @exercise_count%>人已交)
|
||||
</font>
|
||||
<% if !@is_teacher && @exercise_users_list.empty?%>
|
||||
<span class="f12 c_red">您尚未提交</span>
|
||||
<% elsif !@is_teacher && !@exercise_users_list.empty?%>
|
||||
<span class="f12 c_red">您已提交</span>
|
||||
<% end %>
|
||||
</span>
|
||||
<%#if @is_teacher || @exercise.exercise_status == 3%>
|
||||
<!--<div class="hworkSearchBox">
|
||||
<input type="text" id="course_student_name" value="<%#= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%#= student_work_index_path(:homework => @homework.id)%>',event);"/>
|
||||
<a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%#= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a>
|
||||
</div>-->
|
||||
<%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %>
|
||||
<%# end%>
|
||||
<span class="fr c_grey"> <a href="javascript:void(0);" class="linkGrey2" id="homework_info_show" style="display: none">[ 显示测验信息 ]</a> </span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="fl">
|
||||
<%= render :partial => "student_table"%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% @exercise_users_list.each do |exercise|%>
|
||||
<script type="text/javascript">
|
||||
$(".student_work_<%= exercise.id%>").mouseenter(function(){
|
||||
$("#work_click_<%= exercise.id%>").show();
|
||||
}).mouseleave(function(){
|
||||
$("#work_click_<%= exercise.id%>").hide();
|
||||
});
|
||||
$(function(){
|
||||
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").on('click',function() {
|
||||
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user_id) %>';
|
||||
});
|
||||
<% else %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
<% end %>
|
||||
});
|
||||
/*function show_result(id) {
|
||||
window.location.href = '<%#=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
|
||||
}*/
|
||||
</script>
|
||||
<ul class="hworkListRow" id="student_work_<%= exercise.id%>">
|
||||
<li class="ml5 mr5" style="width:28px; text-align:center;">1</li>
|
||||
<li class="hworkPortrait mt15 mr10">
|
||||
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40",:style => "display:block;"),user_activities_path(exercise.user)) %>
|
||||
</li>
|
||||
<li class="hworkStName" title="姓名" id="student_name_<%= exercise.id%>" style="cursor:pointer;">
|
||||
<%=exercise.user.show_name %>
|
||||
</li><li class="hworkStID pl15 pr10" title="学号" id="student_id_<%= exercise.id%>" style="cursor:pointer;">
|
||||
<%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%>
|
||||
</li>
|
||||
<li class="hworkStID" title="班级" id="student_class_<%= exercise.id%>" style="cursor:pointer;">
|
||||
--
|
||||
</li>
|
||||
<li class="hworkList130 ml200 c_grey student_work_<%= exercise.id%>">
|
||||
<% if exercise.created_at%>
|
||||
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>
|
||||
<% if @exercise.end_time <= exercise.created_at %>
|
||||
<span class="c_red">[未答]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li class="hworkList50 <%= score_color exercise.score%> student_final_scor_info">
|
||||
<%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%>
|
||||
</li>
|
||||
<li class="hworkTip" style="display: none" id="work_click_<%= exercise.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></li>
|
||||
</ul>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
|
@ -1,22 +1,71 @@
|
|||
<ul class="hworkUl">
|
||||
<li class="hworkList340 hworkH30 width530">
|
||||
<span class="c_dark f14 fb fl mr55"> </span>
|
||||
<span class="c_dark f14 fb fl mr60">姓名</span>
|
||||
<span class="c_dark f14 fb fl mr60">学号</span>
|
||||
<span class="c_dark f14 fb fl">班级</span>
|
||||
</li>
|
||||
<table class="hwork-table-wrap">
|
||||
<tr class="b_grey hworkH30" style="border-bottom:1px solid #eaeaea;">
|
||||
<th class="hworkList340 width530" colspan="6">
|
||||
<span class="c_dark f14 fb fl mr5">序号</span>
|
||||
<span class="c_dark f14 fb fl mr55"> </span>
|
||||
<span class="c_dark f14 fb fl mr60">姓名</span>
|
||||
<span class="c_dark f14 fb fl mr60">学号</span>
|
||||
<span class="c_dark f14 fb fl">班级</span>
|
||||
</th>
|
||||
<th class="hworkList130">
|
||||
<%= link_to "时间",'',:class => "c_dark f14 fb fl ml50" ,:remote => true%>
|
||||
</th>
|
||||
<th class="hworkList50">
|
||||
<%= link_to "成绩",'',:class => "c_dark f14 fb fl ml10",:remote => true%>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<li class="hworkList130 hworkH30">
|
||||
<%= link_to "时间",'',:class => "c_dark f14 fb fl ml50" ,:remote => true%>
|
||||
<%# if @show_all && @order == "created_at"%>
|
||||
<%#= link_to "", student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10",:remote => true%>
|
||||
<%# end%>
|
||||
</li>
|
||||
<% @exercise_users_list.each do |exercise|%>
|
||||
<script type="text/javascript">
|
||||
$(".student_work_<%= exercise.id%>").mouseenter(function(){
|
||||
$("#work_click_<%= exercise.id%>").show();
|
||||
}).mouseleave(function(){
|
||||
$("#work_click_<%= exercise.id%>").hide();
|
||||
});
|
||||
$(function(){
|
||||
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").on('click',function() {
|
||||
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user_id) %>';
|
||||
});
|
||||
<% else %>
|
||||
$("#show_student_result_div_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
|
||||
<% end %>
|
||||
});
|
||||
/*function show_result(id) {
|
||||
window.location.href = '<%#=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
|
||||
}*/
|
||||
</script>
|
||||
|
||||
<li class="hworkList50 hworkH30">
|
||||
<%= link_to "成绩",'',:class => "c_dark f14 fb fl ml10",:remote => true%>
|
||||
<%# if @show_all && @order == "score"%>
|
||||
<%#= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10",:remote => true%>
|
||||
<%# end%>
|
||||
</li>
|
||||
</ul>
|
||||
<tr class="hworkListRow" id="student_work_<%= exercise.id%>">
|
||||
<td class="pl5 pr5" style="width:28px; text-align:center;">1</td>
|
||||
<td class="hworkPortrait pr10 float-none">
|
||||
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40",:style => "display:block;", :class => "mt15"),user_activities_path(exercise.user)) %>
|
||||
</td>
|
||||
<td class="hworkStName" title="姓名" id="student_name_<%= exercise.id%>" style="cursor:pointer;">
|
||||
<%=exercise.user.show_name %>
|
||||
</td>
|
||||
<td class="hworkStID pl15 pr10 float-none" title="学号" id="student_id_<%= exercise.id%>" style="cursor:pointer;">
|
||||
<span class="hidden fl" style="width:80px;"><%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%></span>
|
||||
</td>
|
||||
<td class="hworkStID float-none" title="班级" id="student_class_<%= exercise.id%>" style="cursor:pointer;">
|
||||
--
|
||||
</td>
|
||||
<td width="200"> </td>
|
||||
<td class="hworkList130 c_grey student_work_<%= exercise.id%>">
|
||||
<% if exercise.created_at%>
|
||||
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>
|
||||
<% if @exercise.end_time <= exercise.created_at %>
|
||||
<span class="c_red">[未答]</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="hworkList50 <%= score_color exercise.score%> student_final_scor_info">
|
||||
<%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%>
|
||||
</td>
|
||||
<td><div style="position:relative;"><div class="hworkTip" style="display: none" id="work_click_<%= exercise.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></div></div></td>
|
||||
</tr>
|
||||
<% end%>
|
||||
</table>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue