diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 086ecfb7f..a44b58789 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -337,6 +337,19 @@ class AdminController < ApplicationController
format.html
end
end
+
+ #学校列表
+ def schools
+ @school_name = params[:school_name]
+ if @school_name
+ @schools = School.where("name like '%#{@school_name}%'")
+ else
+ @schools = School.all
+ end
+ respond_to do |format|
+ format.html
+ end
+ end
#移动端版本管理
def mobile_version
@versions = PhoneAppVersion.reorder('created_at desc')
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index a1c7ae875..71715035e 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -39,9 +39,14 @@ class CoursesController < ApplicationController
else
@state = 5 #未登录
end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
- end
+ # if @state == 1 || @state == 3
+ # respond_to course_path(course.id)
+ # else
+ respond_to do |format|
+ format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
+ end
+ #end
+
rescue Exception => e
@state = 4 #已经加入了课程
respond_to do |format|
@@ -119,47 +124,47 @@ class CoursesController < ApplicationController
@course_pages = Paginator.new @course_count, per_page_option, params['page']
# 课程的动态数
- @course_activity_count=Hash.new
- @courses_all.each do |course|
- @course_activity_count[course.id]=0
- end
-
- case params[:course_sort_type]
- when '0'
- @courses = @courses_all.order("created_at desc")
- @s_type = 0
- @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
-
- @course_activity_count=get_course_activity @courses,@course_activity_count
-
- when '1'
- @courses = @courses_all.order("course_ac_para desc")
- @s_type = 1
- @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
-
- @course_activity_count=get_course_activity @courses,@course_activity_count
-
- when '2'
- @courses = @courses_all.order("watchers_count desc")
- @s_type = 2
- @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
-
- @course_activity_count=get_course_activity @courses,@course_activity_count
-
- when '3'
- @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
- @courses=handle_course @courses_all,@course_activity_count
- @s_type = 3
- @courses = @courses[@course_pages.offset, @course_pages.per_page]
-
- else
- @s_type = 0
- @courses = @courses_all.order("created_at desc")
- @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
-
- @course_activity_count=get_course_activity @courses,@course_activity_count
-
- end
+ # @course_activity_count=Hash.new
+ # @courses_all.each do |course|
+ # @course_activity_count[course.id]=0
+ # end
+ #
+ # case params[:course_sort_type]
+ # when '0'
+ # @courses = @courses_all.order("created_at desc")
+ # @s_type = 0
+ # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
+ #
+ # @course_activity_count=get_course_activity @courses,@course_activity_count
+ #
+ # when '1'
+ # @courses = @courses_all.order("course_ac_para desc")
+ # @s_type = 1
+ # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
+ #
+ # @course_activity_count=get_course_activity @courses,@course_activity_count
+ #
+ # when '2'
+ # @courses = @courses_all.order("watchers_count desc")
+ # @s_type = 2
+ # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
+ #
+ # @course_activity_count=get_course_activity @courses,@course_activity_count
+ #
+ # when '3'
+ # @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
+ # @courses=handle_course @courses_all,@course_activity_count
+ # @s_type = 3
+ # @courses = @courses[@course_pages.offset, @course_pages.per_page]
+ #
+ # else
+ # @s_type = 0
+ # @courses = @courses_all.order("created_at desc")
+ # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
+ #
+ # @course_activity_count=get_course_activity @courses,@course_activity_count
+ #
+ # end
end
respond_to do |format|
@@ -604,7 +609,7 @@ class CoursesController < ApplicationController
def toggleCourse
@course_prefs = Course.find_by_extra(@course.extra)
- unless (@course_prefs.student != User.current || User.current.admin?)
+ unless (User.current.allowed_to?(:as_teacher,@course_prefs) || User.current.admin?)
render_403
end
end
@@ -658,92 +663,9 @@ class CoursesController < ApplicationController
end
def show
- if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
- return
- end
- @users_by_role = @course.users_by_role
- if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
- @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
- end
- @key = User.current.rss_key
- #新增内容
- @days = Setting.activity_days_default.to_i
- if params[:from]
- begin; @date_to = params[:from].to_date + 1; rescue; end
- end
- has = {
- "show_course_files" => true,
- "show_course_news" => true,
- "show_course_messages" => true,
- #"show_course_journals_for_messages" => true,
- # "show_bids" => true,
- # "show_homeworks" => true,
- "show_polls" => true
- }
- @date_to ||= Date.today + 1
- @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
- @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
- if @author.nil?
- # 显示老师和助教的活动
- # @authors = searchTeacherAndAssistant(@course)
- @authors = course_all_member(@course)
- events = []
- key = "course_events_#{@course.id}".to_sym
- if Rails.env.production? && Setting.course_cahce_enabled?
- events = Rails.cache.read(key) || []
- end
- if events.empty?
- @authors.each do |author|
- @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
- :with_subprojects => false,
- :author => author.user)
-
- @activity.scope_select {|t| has["show_#{t}"]}
- # modify by nwb
- # 添加私密性判断
- if User.current.member_of_course?(@course)|| User.current.admin?
- events += @activity.events(@days, @course.created_at)
- else
- events += @activity.events(@days, @course.created_at, :is_public => 1)
- end
- end
- Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
- end
- else
- # @author = @course.teacher
- @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
- :with_subprojects => false,
- :author => @author)
-
- @activity.scope_select {|t| has["show_#{t}"]}
- # modify by nwb
- # 添加私密性判断
- if User.current.member_of_course?(@course)|| User.current.admin?
- events = @activity.events(@days, @course.created_at)
- else
- events = @activity.events(@days, @course.created_at, :is_public => 1)
- end
- end
-
- # 无新动态时,显示老动态
- if events.count == 0
- if User.current.member_of_course?(@course)|| User.current.admin?
- events = @activity.events
- else
- events = @activity.events(:is_public => 1)
- end
- end
- @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
- if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
- @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
- end
-
- sorted_events = sort_activity_events_course(events)
- events = paginateHelper sorted_events,10
- @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
- # documents
-
-
+ course_activities = @course.course_activities.order("created_at desc")
+ @canShowRealName = User.current.member_of_course? @course
+ @course_activities = paginateHelper course_activities,10
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 19c1214e2..7b81d12db 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -177,11 +177,11 @@ class FilesController < ApplicationController
def index
@flag = params[:flag] || false
#sort_init 'filename', 'asc'
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
+ # sort_init 'created_on', 'desc'
+ # sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ # 'filename' => "#{Attachment.table_name}.filename",
+ # 'size' => "#{Attachment.table_name}.filesize",
+ # 'downloads' => "#{Attachment.table_name}.downloads"
sort = ""
@sort = ""
@order = ""
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 0a33ef87a..21f781a1a 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -1,6 +1,7 @@
class HomeworkCommonController < ApplicationController
require 'net/http'
require 'json'
+ require "base64"
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
@@ -22,7 +23,7 @@ class HomeworkCommonController < ApplicationController
#
# @homework = HomeworkCommon.new
# @homework.safe_attributes = params[:homework_common]
- # @homework.late_penalty = 0
+ # @homework.late_penalty = 2
# @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
# @homework.publish_time = Time.now.strftime('%Y-%m-%d')
#
@@ -30,7 +31,7 @@ class HomeworkCommonController < ApplicationController
# #匿评作业相关属性
# @homework_detail_manual = HomeworkDetailManual.new
# @homework_detail_manual.ta_proportion = 0.6
- # @homework_detail_manual.absence_penalty = 0
+ # @homework_detail_manual.absence_penalty = 2
# @homework_detail_manual.evaluation_num = 3
# @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
# @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@@ -40,9 +41,9 @@ class HomeworkCommonController < ApplicationController
# @homework_detail_programing = HomeworkDetailPrograming.new
# @homework.homework_detail_programing = @homework_detail_programing
# end
- # respond_to do |format|
- # format.html
- # end
+ respond_to do |format|
+ format.html
+ end
end
#新建作业下一步
@@ -51,7 +52,7 @@ class HomeworkCommonController < ApplicationController
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
- @homework.late_penalty = 0
+ @homework.late_penalty = 2
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
@@ -59,7 +60,7 @@ class HomeworkCommonController < ApplicationController
#匿评作业相关属性
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
- @homework_detail_manual.absence_penalty = 0
+ @homework_detail_manual.absence_penalty = 2
@homework_detail_manual.evaluation_num = 3
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@@ -99,12 +100,14 @@ class HomeworkCommonController < ApplicationController
question = {title:homework.name,content:homework.description}
question[:input] = []
question[:output] = []
- if params[:input] && params[:output]
+ if params[:input] && params[:output] && params[:result]
params[:input].each do |k,v|
if params[:output].include? k
homework_test = HomeworkTest.new
homework_test.input = v
homework_test.output = params[:output][k]
+ homework_test.result = params[:result][k]
+ homework_test.error_msg = params[:error_msg]
homework.homework_tests << homework_test
question[:input] << homework_test.input
question[:output] << homework_test.output
@@ -221,17 +224,21 @@ class HomeworkCommonController < ApplicationController
homework_test = HomeworkTest.find id
homework_test.destroy if homework_test
end
- if params[:input] && params[:output]
+ if params[:input] && params[:output] && params[:result]
params[:input].each do |k,v|
if params[:output].include? k
homework_test = HomeworkTest.find_by_id k
if homework_test #已存在的测试,修改
homework_test.input = v
homework_test.output = params[:output][k]
+ homework_test.result = params[:result][k]
+ homework_test.error_msg = params[:error_msg]
else #不存在的测试,增加
homework_test = HomeworkTest.new
homework_test.input = v
homework_test.output = params[:output][k]
+ homework_test.result = params[:result][k]
+ homework_test.error_msg = params[:error_msg]
homework_test.homework_common = @homework
end
homework_test.save
@@ -351,6 +358,24 @@ class HomeworkCommonController < ApplicationController
end
end
+ def programing_test
+ test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
+ @index = params[:index]
+ uri = URI('http://192.168.80.21:8080/api/realtime.json')
+ body = test.to_json
+ res = Net::HTTP.new(uri.host, uri.port).start do |client|
+ request = Net::HTTP::Post.new(uri.path)
+ request.body = body
+ request["Content-Type"] = "application/json"
+ client.request(request)
+ end
+ result = JSON.parse(res.body)
+ @err_msg = result["compile_error_msg"]
+ result["results"].each do |re|
+ @result = re["status"]
+ end
+ end
+
private
#获取课程
def find_course
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 185e7128e..1a8e75b54 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -72,7 +72,7 @@ class NewsController < ApplicationController
@news_count = scope.count
@q = params[:subject]
- if params[:subject].nil?
+ if params[:subject].nil? || params[:subject].blank?
scope_order = scope.all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC")
else
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index 758747e02..edf8c2259 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -1,3 +1,4 @@
+#encoding utf-8
class PollController < ApplicationController
before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll]
before_filter :find_container, :only => [:new,:create, :index]
@@ -137,11 +138,19 @@ class PollController < ApplicationController
@poll_questions.poll_answers.new question_option
end
end
- if @poll_questions.save
- respond_to do |format|
- format.js
- end
+ # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1
+ if params[:quest_id]
+ @is_insert = true
+ @poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1")
+ @poll_question_num = params[:quest_num].to_i
+ @poll_questions.question_number = params[:quest_num].to_i + 1
end
+ if @poll_questions.save
+ respond_to do |format|
+ format.js
+ end
+ end
+
end
#修改题目
@@ -328,6 +337,37 @@ class PollController < ApplicationController
end
end
+
+ def import_poll
+ @poll = Poll.find(params[:to_id])
+ question_num = @poll.poll_questions.select("max(question_number) question_number").first.question_number
+ import_poll = Poll.find(params[:import_id])
+ import_poll.poll_questions.each_with_index do |question,index|
+ option = {
+ :is_necessary => question.is_necessary,
+ :question_title => question.question_title,
+ :question_type => question.question_type,
+ :question_number => question_num + index+1
+ }
+ poll_questions = @poll.poll_questions.new option
+ for i in 1..question.poll_answers.count
+ answer = question.poll_answers[i-1][:answer_text]
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ poll_questions.poll_answers.new question_option
+ end
+ @poll.poll_questions << poll_questions
+ end
+ if @poll.save
+ @poll = Poll.find(params[:to_id])
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
#重新发布问卷
def republish_poll
@poll.poll_questions.each do |poll_question|
@@ -371,6 +411,70 @@ class PollController < ApplicationController
end
end
+ # 将其他地方的问卷导出来
+ 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]}")
+ @polls_group_id = params[:polls_group_id]
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ # 将问卷导入本课程
+ def import_other_poll
+ course_id = params[:course_id]
+ @course = Course.find(course_id)
+ params[:polls].each_with_index do |p,i|
+ poll = Poll.find(p)
+ option = {
+ :polls_name => poll.polls_name || l(:label_poll_new),
+ :polls_type => 'Course',
+ :polls_group_id => course_id,
+ :polls_status => 1,
+ :user_id => User.current.id,
+ :published_at => Time.now,
+ :closed_at => Time.now,
+ :show_result => 1,
+ :polls_description => poll.polls_description
+ }
+ @poll = Poll.create option
+
+ poll.poll_questions.each do | q|
+ #question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
+ option = {
+ :is_necessary => q[:is_necessary],
+ :question_title => q[:question_title],
+ :question_type => q[:question_type] || 1,
+ :question_number => q[:question_number]
+ }
+ @poll_questions = @poll.poll_questions.new option
+
+ for i in 1..q.poll_answers.count
+ answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text]
+ question_option = {
+ :answer_position => i,
+ :answer_text => answer
+ }
+ @poll_questions.poll_answers.new question_option
+ end
+ end
+ @poll.save
+ end
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course)
+ if @is_teacher
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}")
+ else
+ polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2")
+ end
+ @polls = paginateHelper polls,20 #分页
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_poll_and_course
@poll = Poll.find params[:id]
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2efaf591a..f042bba50 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -86,8 +86,14 @@ class ProjectsController < ApplicationController
@project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10)
else
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
+ @project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
end
@projects = @project_pages.order("created_on desc")
+ @limit = 10#per_page_option
+
+ @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
+ @project_pages = Paginator.new @project_count, @limit, params['page']
+
respond_to do |format|
format.html {
render :layout => 'base'
@@ -150,11 +156,15 @@ class ProjectsController < ApplicationController
end
def new
- @issue_custom_fields = IssueCustomField.sorted.all
- @trackers = Tracker.sorted.all
- @project = Project.new
- @project.safe_attributes = params[:project]
- render :layout => 'base'
+ if User.current.login?
+ @issue_custom_fields = IssueCustomField.sorted.all
+ @trackers = Tracker.sorted.all
+ @project = Project.new
+ @project.safe_attributes = params[:project]
+ render :layout => 'base'
+ else
+ redirect_to signin_url
+ end
end
def share
@@ -167,6 +177,10 @@ class ProjectsController < ApplicationController
end
def create
+ unless User.current.login?
+ redirect_to signin_url
+ return
+ end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@@ -280,11 +294,11 @@ class ProjectsController < ApplicationController
# 根据私密性,取出符合条件的所有数据
if User.current.member_of?(@project) || User.current.admin?
- @events_pages = ForgeActivity.where("project_id = ?",@project).order("created_at desc").page(params['page'|| 1]).per(20);
+ @events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20);
#events = @activity.events(@date_from, @date_to)
else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
- = ?",@project,1).order("created_at desc")
+ = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
.page(params['page'|| 1]).per(10);
# @events = @activity.events(@date_from, @date_to, :is_public => 1)
end
@@ -361,37 +375,6 @@ class ProjectsController < ApplicationController
end
end
- # dts测试工具
- def dts_dep
- render_403 unless User.current.admin?
- @dts = Dts.all
- end
-
- # dts云部署
- def yun_dep
- render_403 unless User.current.admin?
- end
-
- # 软件知识库
- def soft_knowledge
- render_403 unless User.current.admin?
- end
-
- # 在线开发平台
- def online_dev
- render_403 unless User.current.admin?
- end
-
- # 软件资源库
- def soft_file
- render_403 unless User.current.admin?
- end
-
- # 软件服务
- def soft_service
- render_403 unless User.current.admin?
- end
-
#发送邮件邀请新用户
def invite_members_by_mail
if User.current.member_of?(@project) || User.current.admin?
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 303e4a213..e0aea0c2e 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -449,6 +449,8 @@ update
def stats
@project_id = params[:id]
@repository_id = @repository.identifier
+ # 提交次数统计
+ @status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
render :layout => 'base_projects'
end
@@ -463,8 +465,6 @@ update
data = graph_author_commits_per_month(@repository)
when "author_commits_six_month"
data = author_commits_six_month(@repository)
- when "author_qoc_per_author"
- data = graph_author_qoc_per_author(@repository)
when "author_code_six_months"
data = author_code_six_month(@repository)
end
@@ -658,7 +658,7 @@ update
)
graph.add_data(
:data => commits_data,
- :title => l(:label_revision_plural)
+ :title => l(:label_revision_commit_count)
)
graph.burn
end
@@ -694,7 +694,7 @@ update
)
graph.add_data(
:data => commits_data,
- :title => l(:label_revision_plural)
+ :title => l(:label_revision_commit_count)
)
graph.burn
end
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 008fe00fc..3e0c280ac 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -4,28 +4,21 @@ class SchoolController < ApplicationController
def upload
uploaded_io = params[:logo]
- school_id = 0
- schools = School.where("name = ?", params[:school])
-
- schools.each do |s|
- school_id = s.id
- end
-
+ school_id ||= params[:id]
unless uploaded_io.nil?
File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file|
file.write(uploaded_io.read)
end
-
s1 = School.find(school_id)
s1.logo_link = '/images/school/'+school_id.to_s+'.png'
s1.save
-
-
- end
+ end
+ redirect_to admin_schools_url(:school_name => params[:school_name])
end
def upload_logo
-
+ @school = School.find params[:id]
+ @school_name = params[:school_name]
end
#获取制定学校开设的课程数
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 3e1e0ba29..01f858442 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -387,8 +387,8 @@ class StudentWorkController < ApplicationController
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common
params[:results].each do |result|
- homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first
- if homework_test
+ homework_tests = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'")
+ homework_tests.each do |homework_test|
student_work_test = StudentWorkTest.new
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index fa5ce8405..410bd44e1 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -112,39 +112,20 @@ class UsersController < ApplicationController
#added by young
def user_projects
-
- #add by huang
unless User.current.admin?
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
render_404
return
end
end
- #end
- # if User.current.admin?
- # @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
- # else
- # cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
- # @memberships = @user.memberships.all(:conditions => cond)
- # end
- #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
- #@events_by_day = events.group_by(&:event_date)
- # @state = 0
-
- limit = 10;
- query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
- query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project)
+ projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc")
if(params[:status] == '1')
- query = query.where("#{Project.table_name}.user_id = ?",@user.id);
+ projects = projects.where("projects.user_id = ?",@user.id)
elsif(params[:status] == '2')
- query = query.where("#{Project.table_name}.user_id <> ?",@user.id);
+ projects = projects.where("projects.user_id <> ?",@user.id)
end
- @obj_count = query.count();
-
- @obj_pages = Paginator.new @obj_count,limit,params['page']
- @list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
- @params = params
-
+ @list = paginateHelper projects,10
+ @params = params[:status]
respond_to do |format|
format.html{render :layout=>'base_users_new'}
format.api
@@ -262,75 +243,35 @@ class UsersController < ApplicationController
def user_courses
unless User.current.admin?
- if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
+ if !@user.active?
render_404
return
end
end
-
- #@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
-
- limit = 10;
- query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
- query = query.where("m.user_id = ?",@user.id)
+ courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
if(params[:status] == '1')
- query = query.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now);
+ courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
elsif(params[:status] == '2')
- query = query.where("endup_time < ?",Time.now);
+ courses = courses.where("endup_time < ?",Time.now)
end
- @obj_count = query.count();
-
- @obj_pages = Paginator.new @obj_count,limit,params['page']
- @list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
- @params = params
+ @list = paginateHelper courses,10
+ @params = params[:status]
render :layout=>'base_users_new'
-
- # if User.current == @user || User.current.admin?
- # membership = @user.coursememberships.all
- # else
- # membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
- # end
- #
- # membership.sort! {|older, newer| newer.created_on <=> older.created_on }
- # @memberships = []
- # membership.collect { |e|
- # @memberships.push(e)
- # }
- # ## 判断课程是否过期 [需封装]
- # @memberships_doing = []
- # @memberships_done = []
- # #now_time = Time.now.year
- # @memberships.map { |e|
- # #end_time = e.course.get_time.year
- # isDone = course_endTime_timeout?(e.course)
- # if isDone
- # @memberships_done.push e
- # else
- # @memberships_doing.push e
- # end
- # }
- # respond_to do |format|
- # format.html
- # format.api
- # end
end
# modified by fq
def user_newfeedback
- @jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @jours.update_all(:is_readed => true, :status => false)
- @jours.each do |journal|
- fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
+ jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ if User.current == @user
+ jours.update_all(:is_readed => true, :status => false)
+ jours.each do |journal|
+ fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false)
+ end
end
-
- #@limit = 10
- #@feedback_count = @jours.count
- #@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
- #@offset ||= @feedback_pages.offset
- @jour = paginateHelper @jours,10
+ @jour = paginateHelper jours,10
@state = false
+ render :layout=>'base_users_new'
end
- # end
def user_comments
@@ -482,95 +423,6 @@ class UsersController < ApplicationController
render :layout=>nil
end
- # def user_course_activities
- # @list = []
- # lastid = nil
- # if params[:lastid]!=nil && !params[:lastid].empty?
- # lastid = params[:lastid];
- # end
- #
- # user_ids = []
- # if @user == User.current
- # watcher = User.watched_by(@user)
- # watcher.push(User.current)
- # user_ids = watcher.map{|x| x.id}
- # else
- # user_ids << @user.id
- # end
- #
- # query_rec_count = 8
- # query_times = 10 #query_times次没查到query_rec_count条记录就不查了
- # query_i = 0;
- # while( true )
- # query_i = query_i+1
- # if(query_i>query_times)
- # break
- # end
- # query = Activity.where(user_id: user_ids)
- # if(lastid != nil)
- # query = query.where("id < ?",lastid)
- # end
- # lastid,item_list = query_activities(query,'course');
- # for item in item_list
- # @list << item
- # if @list.count() >= query_rec_count
- # break
- # end
- # end
- # if @list.count() >= query_rec_count
- # break
- # end
- # if lastid == nil
- # break
- # end
- # end
- # render :layout=>nil
- # end
- #
- # def user_project_activities
- # @list = []
- # lastid = nil
- # if params[:lastid]!=nil && !params[:lastid].empty?
- # lastid = params[:lastid];
- # end
- #
- # user_ids = []
- # if @user == User.current
- # watcher = User.watched_by(@user)
- # watcher.push(User.current)
- # user_ids = watcher.map{|x| x.id}
- # else
- # user_ids << @user.id
- # end
- #
- # query_rec_count = 8
- # query_times = 10 #query_times次没查到query_rec_count条记录就不查了
- # query_i = 0;
- # while( true )
- # query_i = query_i+1
- # if(query_i>query_times)
- # break
- # end
- # query = Activity.where(user_id: user_ids)
- # if(lastid != nil)
- # query = query.where("id < ?",lastid)
- # end
- # lastid,item_list = query_activities(query,'project');
- # for item in item_list
- # @list << item
- # if @list.count() >= query_rec_count
- # break
- # end
- # end
- # if @list.count() >= query_rec_count
- # break
- # end
- # if lastid == nil
- # break
- # end
- # end
- # render :action=>'user_course_activities',:layout=>nil
- # end
def user_course_activities
lastid = nil
if params[:lastid]!=nil && !params[:lastid].empty?
@@ -629,7 +481,7 @@ class UsersController < ApplicationController
query = query.where("#{Activity.table_name}.id < ?",lastid)
end
query = query.order("#{Activity.table_name}.id desc")
- @list = query_activities(query);
+ @list = query_activities(query)
render :action=>'user_course_activities',:layout=>nil
end
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 9ce107f8b..6b14db9bb 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -100,44 +100,6 @@ class WelcomeController < ApplicationController
@course_page = FirstPage.find_by_page_type('course')
@school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
@logoLink ||= logolink()
-
- ##3-8月份为查找春季课程,9-2月份为查找秋季课程
- #month_now = Time.now.strftime("%m").to_i
- #year_now = Time.new.strftime("%Y").to_i
- #(month_now >= 3 && month_now < 9) ? course_term = l(:label_spring) : course_term = l(:label_autumn)
- ##year_now -= 1 if year_now < 3
- #@school_id.nil? ? @cur_school_course = [] : @cur_school_course = find_miracle_course(10,7,@school_id, year_now, course_term)
- ##未登录或者当前学校未开设课程
- #if @cur_school_course.empty?
- # @has_course = false
- # User.current.logged? ? course_count = 9 : course_count = 10
- # @cur_school_course += find_all_new_hot_course(course_count, @school_id, year_now, course_term)
- # while @cur_school_course.count < 9 do
- # if course_term == l(:label_spring)
- # course_term = l(:label_autumn)
- # year_now -= 1
- # else
- # course_term = l(:label_spring)
- # end
- # @cur_school_course += find_all_new_hot_course((10-@cur_school_course.count), nil, year_now, course_term)
- # end
- #else
- # if @cur_school_course.count < 9
- # @has_course = false
- # @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, @school_id, year_now, course_term)
- # if @cur_school_course.count < 9
- # if course_term == l(:label_spring)
- # course_term = l(:label_autumn)
- # year_now -= 1
- # else
- # course_term = l(:label_spring)
- # end
- # @cur_school_course += find_all_new_hot_course(9-@cur_school_course.count, nil, year_now, course_term)
- # end
- # else
- # @has_course = true
- # end
- #end
end
def logolink()
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 161791954..fc723d5d5 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -4,7 +4,7 @@ class WordsController < ApplicationController
include ApplicationHelper
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
def create
- if params[:new_form][:user_message].size>0
+ if params[:new_form][:user_message].size>0 && User.current.logged?
unless params[:user_id].nil?
if params[:reference_content]
message = params[:new_form][:user_message] + "\n" + params[:reference_content]
@@ -18,22 +18,13 @@ class WordsController < ApplicationController
list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
end
@jour = list.last
- # @user.count_new_jour
- # if a_message.size > 5
- # @message = a_message[-5, 5]
- # else
- # @message = a_message
- # end
- # @message_count = a_message.count
end
end
- # @jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse
- # @jour = paginateHelper @jours,10
+ jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ @jour = paginateHelper jours,10
respond_to do |format|
- # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
format.js
- #format.api { render_api_ok }
end
end
@@ -93,7 +84,6 @@ class WordsController < ApplicationController
end
respond_to do |format|
format.js
- #format.api { render_api_ok }
end
end
@@ -206,7 +196,15 @@ class WordsController < ApplicationController
flash[:error] = feedback.errors.full_messages[0]
redirect_to project_feedback_url(params[:id])
end
+ end
+ #给用户留言
+ def leave_user_message
+ @user = User.find(params[:id])
+ if params[:new_form][:user_message].size>0 && User.current.logged? && @user
+ @user.add_jour(User.current, params[:new_form][:user_message])
+ end
+ redirect_to feedback_path(@user)
end
# add by nwb
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 165e22071..9b9bf5f76 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1812,7 +1812,7 @@ module ApplicationHelper
#获取用户未过期的课程
def get_user_course user
courses_doing = []
- user.courses.each do |course|
+ user.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course|
if !course_endTime_timeout?(course)
courses_doing.push course
end
@@ -2378,4 +2378,98 @@ module ApplicationHelper
end
notice.html_safe
end
+
+ #老师C语言的标准代码
+ def c_stantard_code_teacher
+ "// 老师您好!这是一个C语言的样例程序
+// 程序功能:输入两个整数,输出两者之和
+// 测试集合:老师可以给出多组测试集,例如:
+// 输入1和2,输出3
+// 输入3和4,输出7
+// ... ...
+// 系统将根据您给出的测试集对学生代码进行自动评分
+
+// 特别提醒:程序采用命令行传参方式,输入通过argv传入
+// 否则您的作业标准代码将不能通过测试
+
+#include
"
+ end
+ s.html_safe
+ end
+
end
\ No newline at end of file
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 0b2d74ee8..49865d335 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -321,6 +321,7 @@ module UsersHelper
list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
return [count,list];
end
+
def get_visitor_users(obj)
query = Visitor.where("master_id=?",obj.id)
count = query.count
@@ -332,46 +333,59 @@ module UsersHelper
end
def get_create_course_count(user)
- if user == User.current
- user.courses.count
- else
- user.courses.where("is_public = 1").count
- end
+ user.courses.visible.where("tea_id = ?",user.id).count
end
+
+ #获取加入课程数
def get_join_course_count(user)
- user.coursememberships.count - get_create_course_count(user)
+ user.courses.visible.count - get_create_course_count(user)
end
+
+ #发布作业数
def get_homework_commons_count(user)
HomeworkCommon.where("user_id = ?",user.id).count
end
+
+ #资源数
def get_projectandcourse_attachment_count(user)
Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
end
+
+ #创建项目数
def get_create_project_count(user)
- Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count
+ user.projects.visible.where("projects.user_id=#{user.id}").count
end
+
+ #加入项目数
def get_join_project_count(user)
- user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user)
+ user.projects.visible.count - get_create_project_count(user)
end
+
+ #创建缺陷数
def get_create_issue_count(user)
Issue.where("author_id = ?",user.id).count
end
+
+ #解决缺陷数
def get_resolve_issue_count(user)
Issue.where("assigned_to_id = ? and status_id=3",user.id).count
end
+
+ #参与匿评数
def get_anonymous_evaluation_count(user)
StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
end
def query_activities(query)
- list = query.limit(8).all
- result = [];
+ list = query.limit(13).all
+ result = []
for item in list
container = get_activity_container(item)
result << { :item=>item,:e=>container }
end
- return result
+ result
end
+
def get_activity_container activity
return activity.activity_container
end
@@ -387,6 +401,7 @@ module UsersHelper
end
return str.html_safe
end
+
def get_activity_act_showname(activity)
case activity.act_type
when "HomeworkCommon"
@@ -417,6 +432,7 @@ module UsersHelper
return activity.act_type
end
end
+
def get_activity_act_createtime(activity)
case activity.act_type
when "HomeworkCommon"
@@ -427,6 +443,7 @@ module UsersHelper
return activity.act.created_on
end
end
+
def get_activity_container_url e
if !e.visible?
return "javascript:;"
@@ -437,6 +454,7 @@ module UsersHelper
end
return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
end
+
def get_activity_url(activity,e)
if !e.visible?
return "javascript:;"
@@ -465,6 +483,7 @@ module UsersHelper
return 'javascript:;'
end
end
+
def get_activity_opt(activity,e)
case activity.act_type
when "HomeworkCommon"
@@ -474,14 +493,14 @@ module UsersHelper
when "Issue"
return '发表了问题'
when "Journal"
- return '回复了问题'
+ return '更新了问题'
when "JournalsForMessage"
return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
#return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
when "Message"
return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
when "Poll"
- return '发布了问卷'
+ return '创建了问卷'
else
return '有了新动态'
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index f999e27d6..f7fb9b1aa 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
include UserScoreHelper
@@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base
cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
- before_save :files_to_final_location
- after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
+ before_save :files_to_final_location,:act_as_course_activity
+ after_create :office_conver, :be_user_score,:act_as_forge_activity
after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score
@@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.container_type == "Course" && self.course_acts.empty?
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
+ end
+ end
end
diff --git a/app/models/course.rb b/app/models/course.rb
index 6d71ad967..89990dd48 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -33,6 +33,10 @@ class Course < ActiveRecord::Base
has_many :student_works, :through => :homework_commons, :dependent => :destroy
has_many :course_groups, :dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
+
+ has_many :course_activities
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy
@@ -44,7 +48,7 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
- after_create :create_board_sync
+ after_create :create_board_sync, :act_as_course_activity
before_destroy :delete_all_members
safe_attributes 'extra',
@@ -310,6 +314,11 @@ class Course < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
+ end
+
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
#def name
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
new file mode 100644
index 000000000..02b6dacf1
--- /dev/null
+++ b/app/models/course_activity.rb
@@ -0,0 +1,7 @@
+class CourseActivity < ActiveRecord::Base
+ attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
+ # 虚拟关联
+ belongs_to :course_act ,:polymorphic => true
+ belongs_to :course
+ belongs_to :user
+end
diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb
index 291c14563..5fe01db96 100644
--- a/app/models/homework_common.rb
+++ b/app/models/homework_common.rb
@@ -13,17 +13,27 @@ class HomeworkCommon < ActiveRecord::Base
has_many :student_works, :dependent => :destroy
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
acts_as_attachable
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
- after_create :act_as_activity, :send_mail
+ after_create :act_as_activity, :send_mail, :act_as_course_activity
after_destroy :delete_kindeditor_assets
def act_as_activity
self.acts << Activity.new(:user_id => self.user_id)
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
+ end
+ end
+
#删除对应的图片
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON
diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb
index 4ed290ecd..df2848194 100644
--- a/app/models/homework_test.rb
+++ b/app/models/homework_test.rb
@@ -1,5 +1,5 @@
class HomeworkTest < ActiveRecord::Base
- attr_accessible :input, :output, :homework_common_id
+ attr_accessible :input, :output, :homework_common_id,:result,:error_msg
belongs_to :homework_common
has_many :student_work_test
diff --git a/app/models/issue.rb b/app/models/issue.rb
index c2670a0cc..147e26cef 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -235,9 +235,10 @@ class Issue < ActiveRecord::Base
base_reload(*args)
end
- def to_param
- @to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
- end
+ # 之所以注释是以为最终以id形式显示,另外如果项目名称带点号或者纯数字会出现问题
+ # def to_param
+ # @to_param ||= "#{id}_#{self.project.name}(#{self.project.issues.index(self).to_i+1}-#{self.project.issues.count})"#.parameterize
+ # end
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
def available_custom_fields
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index b15c9b2d1..bcae58174 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base
acts_as_attachable
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour?
- after_create :act_as_activity #huang
+ after_create :act_as_activity, :act_as_course_activity
after_create :reset_counters!
after_destroy :reset_counters!
after_save :be_user_score
@@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,7
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.jour_type == 'Course'
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
+ end
+ end
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 5ae9df001..a25aff6bb 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -388,7 +388,8 @@ class Mailer < ActionMailer::Base
@user = applied.user
recipients = @project.manager_recipients
s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name)
- @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members')
+ @token = Token.get_token_from_user(@user, 'autologin')
+ @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members', :token => @token.value)
mail :to => recipients,
:subject => s
end
diff --git a/app/models/message.rb b/app/models/message.rb
index 15d358789..de5cc3f9b 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -32,6 +32,8 @@ class Message < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@@ -68,7 +70,7 @@ class Message < ActiveRecord::Base
after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
- after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail
+ after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail
#before_save :be_user_score
scope :visible, lambda {|*args|
@@ -185,6 +187,13 @@ class Message < ActiveRecord::Base
:project_id => self.board.project.id)
end
end
+
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
+ end
+ end
#更新用户分数 -by zjc
def be_user_score
diff --git a/app/models/news.rb b/app/models/news.rb
index 7d33d760e..e5c1d192a 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -28,6 +28,8 @@ class News < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@@ -49,7 +51,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
- after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail
+ after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail
after_destroy :delete_kindeditor_assets
@@ -121,6 +123,13 @@ class News < ActiveRecord::Base
end
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.course
+ self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
+ end
+ end
+
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 64e9df79a..34a381246 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -8,7 +8,9 @@ class Poll < ActiveRecord::Base
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
# 添加课程的poll动态
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
- after_create :act_as_activity
+ # 课程动态
+ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
+ after_create :act_as_activity, :act_as_course_activity
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
@@ -27,4 +29,10 @@ class Poll < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.user_id)
end
+ #课程动态公共表记录
+ def act_as_course_activity
+ if self.polls_type == "Course"
+ self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
+ end
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 005c394a8..1cd0675c8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -291,9 +291,10 @@ class User < Principal
name
end
## end
-
+
+ # 查询用户未读过的记录
def count_new_jour
- count = self.new_jours.count
+ count = self.journals_for_messages.where("status=?", 1).count
end
#added by nie
@@ -418,7 +419,7 @@ class User < Principal
end
def nickname(formatter = nil)
- login
+ login.nil? || (login && login.empty?) ? "AnonymousUser" : login
end
def name(formatter = nil)
diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb
new file mode 100644
index 000000000..0956981e8
--- /dev/null
+++ b/app/views/admin/schools.html.erb
@@ -0,0 +1,50 @@
+
+ <%=l(:label_school_plural)%>
+
+<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
+ <%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
+
+<% end %>
+
+
+
+
+
+
+
+
+
+ <% @schools.each do |school|%>
+
+ 序号
+
+
+ LOGO
+
+
+ 学校名称
+
+
+ ">
+
+ <% end%>
+
+
+ <%= school.id %>
+
+
+ <%= image_tag(school.logo_link,width:40,height:40) %>
+
+
+
+ <%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
+ <%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
+
+
- <%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %> - <%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %> + <%= content_tag('span', link_to("#{@course.course_activities.count}", course_path(@course)), :class => "info") %> + <%= content_tag('span', l(:label_x_activity, :count => @course.course_activities.count)) %>
diff --git a/app/views/courses/_new_groups_name.html.erb b/app/views/courses/_new_groups_name.html.erb index 39fa33677..6ffbb6dd2 100644 --- a/app/views/courses/_new_groups_name.html.erb +++ b/app/views/courses/_new_groups_name.html.erb @@ -21,7 +21,7 @@ <% end%> - + <% end %> @@ -31,7 +31,7 @@ <% if @canShowCode%> <%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, :id => 'update_group_'+group.id.to_s) do %> <% end %> @@ -47,7 +47,7 @@<%= e.event_description.html_safe %>
-
-
<%= l(:label_no_data) %>
-<% end%> -<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %> -
-
- <%= l :label_create_time %> : <%= format_time(@course.created_at) %>
-
+ <%= course_activity_desc activity%>
+
+
+ 错误信息: + | ++ <% if homework.homework_tests.first && homework.homework_tests.first && homework.homework_tests.first.error_msg %> + <%= homework.homework_tests.first.error_msg%> + <% end%> + | +
- 输入 - | -- 输出 - | -
- <%=test.input%> + 输入 | - <%= test.output%> + 输出 |