@ -38,7 +38,8 @@ class ApplicationController < ActionController::Base
protect_from_forgery
defhandle_unverified_request
super
cookies.delete(autologin_cookie_name)
raise(ActionController::InvalidAuthenticityToken)
# cookies.delete(autologin_cookie_name)
end
before_filter:find_first_page
@ -381,6 +382,11 @@ class ApplicationController < ActionController::Base
ifallowed
true
else
ifparams[:action]=='show'
#更新申请结果反馈消息的状态
messages=CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?",'CourseRequestDealResult',@course.id,User.current.id,false)
create_course_messages=@course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?",User.current.id,'Course',@course.id,0)
create_course_messages.update_all(:viewed=>true)
#更新申请结果反馈消息的状态
course_request_messages=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@course.id,'CourseRequestDealResult',false)
@ -134,8 +135,12 @@ class FilesController < ApplicationController
ifsort==""
sort="created_on DESC"
end
ifkeywords!="%%"
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ",like:"%#{keywords}%").
reorder(sort)
else
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' ").reorder(sort)
end
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end
@ -176,12 +181,6 @@ class FilesController < ApplicationController
absence_penalty_count=student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count-student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
absence_penalty_count=student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count-student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
@ -322,6 +325,12 @@ class ProjectsController < ApplicationController
end
defsettings
# 修改查看消息状态
applied_messages=ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?",User.current.id,@project,"AppliedProject",0)
applied_messages.eachdo|applied_message|
applied_message.update_attributes(:viewed=>true)
end
# end
@issue_custom_fields=IssueCustomField.sorted.all
@issue_category||=IssueCategory.new
@member||=@project.members.new
@ -342,7 +351,7 @@ class ProjectsController < ApplicationController
studentworks_scores=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@homework.course,"StudentWorksScore",0)
journals_for_teacher=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?",User.current.id,@homework.course,"JournalsForMessage",0)
no_evaluation=CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =? and status =?",User.current.id,@homework.course,"StudentWork",0,0)
no_evaluation.update_all(:viewed=>true)
# 作品留言
# 消息end
#设置作业对应的forge_messages表的viewed字段
query_student_work=@homework.course_messages
query_student_work.eachdo|query|
@ -18,8 +74,13 @@ class StudentWorkController < ApplicationController
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
ifmy_work.empty?
@stundet_works=[]
else
if@order=="name"
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name).count
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
ifmy_work.empty?
@stundet_works=[]
else
if@order=="name"
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).order("users.lastname #{@b_sort}, users.firstname #{@b_sort}"),@name
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@show_all=true
end
else
@stundet_works=[]
end
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name).count
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
absence_penalty_count=student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count-student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","HomeworkCommon",@user).order("created_at desc")
@message_alls_count=@message_alls.count
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?",@user).order("created_at desc")
when'course_message'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Message",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'forge_message'
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","Message",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'course_news'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","News",@user).order("created_at desc")
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","News",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'course_news_reply'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Comment",@user).order("created_at desc")
when'forge_news_reply'
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","Comment",@user).order("created_at desc")
@message_alls_count=@message_alls.count
# 课程通知包含发布的通知和回复的通知
@message_alls=CourseMessage.where("course_message_type in (?, ? ,?)","News","Comment","Course").where("user_id =?",@user).order("created_at desc")
when'poll'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Poll",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'works_reviewers'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","StudentWorksScore",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'works_reply'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","JournalsForMessage",@user).order("created_at desc")
@message_alls_count=@message_alls.count
#项目相关消息
when'issue'
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","Issue",@user).order("created_at desc")
@message_alls_count=@message_alls.count
when'issue_update'# 缺陷状态更新、留言
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","Journal",@user).order("created_at desc")
@message_alls_count=@message_alls.count
@message_alls=ForgeMessage.where("forge_message_type =? or forge_message_type =?","Issue","Journal").where("user_id=?",@user).order("created_at desc")
when'forge_message'
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","Message",@user).order("created_at desc")
when'forge_news'
@message_alls=ForgeMessage.where("forge_message_type in (?,?) and user_id =?","News","Comment",@user).order("created_at desc")
when'apply'
@message_alls=ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?",@user).order("created_at desc")
#贴吧消息
when'forum'
@message_alls=MemoMessage.where("memo_type =? and user_id =?","Memo",@user).order("created_at desc")
@message_alls_count=@message_alls.count
#用户留言
when'user_feedback'
@message_alls=UserFeedbackMessage.where("journals_for_message_type =? and user_id =?","JournalsForMessage",@user).order("created_at desc")
@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(',')}))").order("created_on desc")
elsifparams[:type]=="2"#课程资源
user_course_ids=User.current.courses.map{|c|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(',')})) ").order("created_on desc")
elsifparams[:type]=="3"#项目资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
elsifparams[:type]=="4"#附件
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
elsifparams[:type]=="5"#用户资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
@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")
elsifparams[:type]=="2"#课程资源
user_course_ids=User.current.courses.map{|c|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")
elsifparams[:type]=="3"#项目资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
elsifparams[: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")
elsifparams[:type]=="5"#用户资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page*10)
when"course_news"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('updated_at desc').limit(10).offset(@page*10)
when"course_message"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
when"course_poll"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page*10)
when"project_issue"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page*10)
when"project_message"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
when"user_journals"
@user_activities=UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page*10)
when"current_user"
@user_activities=UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page*10)
else
@user_activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page*10)
@user_activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})"+
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) "+
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page*10)
end
else
@user_activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page*10)
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
@ -1453,15 +1890,21 @@ class UsersController < ApplicationController
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
end
elsifparams[:type]=="5"#用户资源
ifUser.current.id.to_i==params[:id].to_i
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c|user.allowed_to?(:as_teacher,c)}.eachdo|course|
has_many:articles,:class_name=>'BlogComment',:conditions=>"#{BlogComment.table_name}.parent_id IS NULL ",:order=>"#{BlogComment.table_name}.created_on DESC"
course_count=CourseMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
forge_count=ForgeMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_feedback_count=UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
user_memo_count=MemoMessage.where("user_id =? and viewed =? and created_at >?",User.current.id,0,User.current.onclick_time.onclick_time).count
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count!=0
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count!=0
Trustie是一个面向高校创新实践的在线协作社区,是在中国高校推行大规模开放在线研究(Massive Open Online Research, MOORE)的支撑平台,也简称Trustie平台。老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。
</p>
<p class="AgreementTxt">
MOORE是国防科学技术大学杨学军院士提出的一个面向高校科研教学活动的新型创新实践概念,为全面支持高校人才培养和科学研究提供了一种新思路。MOORE是对大规模在线开放课程(Massive Open Online Course, MOOC)的拓展,是课堂教学与创新实践深度结合的全新模式,可以看作MOOC2.0。