diff --git a/Gemfile b/Gemfile index 01671daf9..a690b224b 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,9 @@ group :development, :test do gem 'pry-byebug' end gem 'pry-stack_explorer' + if RUBY_PLATFORM =~ /darwin/ + gem 'puma' + end end gem 'rspec-rails', '~> 3.0' diff --git a/app/assets/javascripts/system_messages.js.coffee b/app/assets/javascripts/system_messages.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/system_messages.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/system_messages.css.scss b/app/assets/stylesheets/system_messages.css.scss new file mode 100644 index 000000000..a9947d45a --- /dev/null +++ b/app/assets/stylesheets/system_messages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the SystemMessages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 82f92c2d1..af501fdf9 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -41,6 +41,10 @@ class AccountController < ApplicationController render :layout => 'static_base' end + def about_us + render :layout => 'static_base' + end + # Log out current user and redirect to welcome page def logout if User.current.anonymous? diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1624008f2..5666934b6 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -79,6 +79,11 @@ class AdminController < ApplicationController end end + # 系统消息 + def messages + @admin_messages = SystemMessage.new + end + def plugins @plugins = Redmine::Plugin.all end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c233ed6b..a6554075f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -563,7 +563,7 @@ class ApplicationController < ActionController::Base uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) - back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) + back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(:User) redirect_to(back_url) return end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 72301754d..53fb21b8c 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -68,7 +68,7 @@ class BoardsController < ApplicationController end def show - #¶Ӧforge_messagesviewedֶ + # 讨论区消息状态更新(已读和未读) if @project query_forge_messages = @board.messages query_forge_messages.each do |query_forge_message| diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c10f8bc84..6b421bf2a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,7 +19,7 @@ class CommentsController < ApplicationController default_search_scope :news include ApplicationHelper model_object News - before_filter :find_model_object + before_filter :find_model_object before_filter :find_project_from_association before_filter :authorize @@ -34,24 +34,34 @@ class CommentsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT end - # ض̬ļ¼add start - if( @comment.id && @news.course ) - if(@news.author_id != User.current.id) - notify = ActivityNotify.new() - notify.activity_container_id = @news.course.id - notify.activity_container_type = 'Course' - notify.activity_id = @comment.id - notify.activity_type = 'Comment' - notify.notify_to = @news.author_id - notify.is_read = 0 - notify.save() - end - end - # ض̬ļ¼add end + # # ������ض�̬�ļ�¼add start + # if( @comment.id && @news.course ) + # if(@news.author_id != User.current.id) + # notify = ActivityNotify.new() + # notify.activity_container_id = @news.course.id + # notify.activity_container_type = 'Course' + # notify.activity_id = @comment.id + # notify.activity_type = 'Comment' + # notify.notify_to = @news.author_id + # notify.is_read = 0 + # notify.save() + # end + # end + # # ������ض�̬�ļ�¼add end flash[:notice] = l(:label_comment_added) + user_activity = UserActivity.where("act_type='News' and act_id =#{@news.id}").first + user_activity.updated_at = @comment.created_on + user_activity.save end - redirect_to news_url(@news) + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + else + redirect_to news_url(@news) + end end def destroy @@ -69,6 +79,6 @@ class CommentsController < ApplicationController @comment = nil @news end - - + + end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index db972941e..b30715a1f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -468,13 +468,17 @@ class CoursesController < ApplicationController end def new - @course_type = params[:course_type] ||= params[:course] - @issue_custom_fields = IssueCustomField.sorted.all - @trackers = Tracker.sorted.all - @course = Course.new - @course.safe_attributes = params[:course] - # month = Time.now.month - render :layout => 'new_base' + if User.current.login? + @course_type = params[:course_type] ||= params[:course] + @issue_custom_fields = IssueCustomField.sorted.all + @trackers = Tracker.sorted.all + @course = Course.new + @course.safe_attributes = params[:course] + # month = Time.now.month + render :layout => 'new_base' + else + redirect_to signin_url + end end def desc_sort_course_by_avtivity(activity_count, courses) @@ -627,6 +631,11 @@ class CoursesController < ApplicationController end def feedback + @course.journals_for_messages.each do |messages| + query = messages.course_messages.where("user_id = ?", User.current.id) + query.update_all(:viewed => true); + end + if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) page = params[:page] # Find the page of the requested reply diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 87c1e288b..35d6f2b85 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -3,6 +3,8 @@ class HomeworkCommonController < ApplicationController require 'json' require "base64" layout "base_courses" + + include StudentWorkHelper 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] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] @@ -18,272 +20,160 @@ class HomeworkCommonController < ApplicationController end end + #新建作业,在个人作业列表创建作业 def new - @homework_type = "1" - - @homework = HomeworkCommon.new - @homework.safe_attributes = params[:homework_common] - @homework.late_penalty = 2 - @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - @homework.publish_time = Time.now.strftime('%Y-%m-%d') - - if @homework_type == "1" - #匿评作业相关属性 - @homework_detail_manual = HomeworkDetailManual.new - @homework_detail_manual.ta_proportion = 0.6 - @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') - @homework.homework_detail_manual = @homework_detail_manual - elsif @homework_type == "2" - #编程作业相关属性 - @homework_detail_programing = HomeworkDetailPrograming.new - @homework.homework_detail_programing = @homework_detail_programing - end - respond_to do |format| - format.html - end - end - - #新建作业下一步 - def next_step - @homework_type = params[:homework_common_type] - - @homework = HomeworkCommon.new - @homework.safe_attributes = params[:homework_common] - @homework.late_penalty = 2 - @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - @homework.publish_time = Time.now.strftime('%Y-%m-%d') - - if @homework_type == "1" - #匿评作业相关属性 - @homework_detail_manual = HomeworkDetailManual.new - @homework_detail_manual.ta_proportion = 0.6 - @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') - @homework.homework_detail_manual = @homework_detail_manual - elsif @homework_type == "2" - #编程作业相关属性 - @homework_detail_programing = HomeworkDetailPrograming.new - @homework.homework_detail_programing = @homework_detail_programing - end - - - respond_to do |format| - format.html - end + render_404 + # @homework_type = "1" + # + # @homework = HomeworkCommon.new + # @homework.safe_attributes = params[:homework_common] + # @homework.late_penalty = 2 + # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + # @homework.publish_time = Time.now.strftime('%Y-%m-%d') + # + # if @homework_type == "1" + # #匿评作业相关属性 + # @homework_detail_manual = HomeworkDetailManual.new + # @homework_detail_manual.ta_proportion = 0.6 + # @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') + # @homework.homework_detail_manual = @homework_detail_manual + # elsif @homework_type == "2" + # #编程作业相关属性 + # @homework_detail_programing = HomeworkDetailPrograming.new + # @homework.homework_detail_programing = @homework_detail_programing + # end + # respond_to do |format| + # format.html + # end end + #新建作业,在个人作业列表创建作业 def create - if params[:homework_common] - homework = HomeworkCommon.new - homework.name = params[:homework_common][:name] - homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] - homework.publish_time = params[:homework_common][:publish_time] - homework.homework_type = params[:homework_common][:homework_type] - homework.late_penalty = params[:late_penalty] - homework.user_id = User.current.id - homework.course_id = @course.id - - homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(homework) - - if homework.homework_type == 2 - homework_detail_programing = HomeworkDetailPrograming.new - homework_detail_programing.language = params[:language] - homework_detail_programing.standard_code = params[:standard_code] - homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - question = {title:homework.name,content:homework.description} - question[:input] = [] - question[: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 - end - end - end - - # uri = URI('http://test.gitlab.trustie.net/api/questions.json') - # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) - # req.body = question.to_json - # res = Net::HTTP.start(uri.hostname, uri.port) do |http| - # http.request(req) - # end - - uri = URI('http://192.168.80.21:8080/api/questions.json') - body = question.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) - homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 - - homework.homework_detail_programing = homework_detail_programing - else - #匿评作业相关属性 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = params[:evaluation_start] - homework_detail_manual.evaluation_end = params[:evaluation_end] - homework_detail_manual.evaluation_num = params[:evaluation_num] - homework_detail_manual.absence_penalty = params[:absence_penalty] - homework.homework_detail_manual = homework_detail_manual - end - - if homework.save - homework_detail_programing.save if homework_detail_programing - homework_detail_manual.save if homework_detail_manual - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - redirect_to homework_common_index_path(:course => @course.id) - } - end - return - end - end - - respond_to do |format| - format.html { - flash[:notice] = l(:notice_failed_create) - redirect_to new_homework_common_path(:course => @course.id) - } - end + redirect_to user_homeworks_user_path(User.current.id) + # if params[:homework_common] + # homework = HomeworkCommon.new + # homework.name = params[:homework_common][:name] + # homework.description = params[:homework_common][:description] + # homework.end_time = params[:homework_common][:end_time] + # homework.publish_time = params[:homework_common][:publish_time] + # homework.homework_type = params[:homework_common][:homework_type] + # homework.late_penalty = params[:late_penalty] + # homework.user_id = User.current.id + # homework.course_id = @course.id + # + # homework.save_attachments(params[:attachments]) + # render_attachment_warning_if_needed(homework) + # + # if homework.homework_type == 2 + # homework_detail_programing = HomeworkDetailPrograming.new + # homework_detail_programing.language = params[:language] + # homework_detail_programing.standard_code = params[:standard_code] + # homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + # question = {title:homework.name,content:homework.description} + # question[:input] = [] + # question[: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 + # end + # end + # end + # + # # uri = URI('http://192.168.80.21:8080/api/questions.json') + # # body = question.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) + # # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + # + # homework.homework_detail_programing = homework_detail_programing + # else + # #匿评作业相关属性 + # homework_detail_manual = HomeworkDetailManual.new + # homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + # homework_detail_manual.comment_status = 1 + # homework_detail_manual.evaluation_start = params[:evaluation_start] + # homework_detail_manual.evaluation_end = params[:evaluation_end] + # homework_detail_manual.evaluation_num = params[:evaluation_num] + # homework_detail_manual.absence_penalty = params[:absence_penalty] + # homework.homework_detail_manual = homework_detail_manual + # end + # + # if homework.save + # homework_detail_programing.save if homework_detail_programing + # homework_detail_manual.save if homework_detail_manual + # respond_to do |format| + # format.html { + # flash[:notice] = l(:notice_successful_create) + # redirect_to homework_common_index_path(:course => @course.id) + # } + # end + # return + # end + # end + # + # respond_to do |format| + # format.html { + # flash[:notice] = l(:notice_failed_create) + # redirect_to new_homework_common_path(:course => @course.id) + # } + # end end def edit + @user = User.current respond_to do |format| - format.html + format.html{render :layout => 'new_base_user'} end end def update - @homework.name = params[:homework_common][:name] - @homework.description = params[:homework_common][:description] - @homework.end_time = params[:homework_common][:end_time] - @homework.publish_time = params[:homework_common][:publish_time] - @homework.homework_type = params[:homework_common][:homework_type] if params[:homework_common][:homework_type] - unless @homework.late_penalty == params[:late_penalty] - @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work| - student_work.late_penalty = params[:late_penalty] - student_work.save - end - @homework.late_penalty = params[:late_penalty] - end - # @homework.course_id = @course.id + if params[:homework_common] + @homework.name = params[:homework_common][:name] + @homework.description = params[:homework_common][:description] + @homework.end_time = params[:homework_common][:end_time] || Time.now + @homework.course_id = params[:course_id] - #匿评作业相关属性 - if @homework.homework_type == 1 && @homework_detail_manual - @homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - @homework_detail_manual.evaluation_start = params[:evaluation_start] - @homework_detail_manual.evaluation_end = params[:evaluation_end] - @homework_detail_manual.evaluation_num = params[:evaluation_num] - unless @homework_detail_manual.absence_penalty == params[:absence_penalty] - if @homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 - work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" - @homework.student_works.each do |student_work| - 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 - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 - student_work.save - end - end - @homework_detail_manual.absence_penalty = params[:absence_penalty] - end - elsif @homework.homework_type == 0 #普通作业,缺评扣分为0分,每个作品的缺评扣分改为0分,防止某些作业在结束匿评之后改为普通作业 - @homework.student_works.where("absence_penalty != 0").each do |student_work| - student_work.late_penalty = 0 - student_work.save - end - @homework_detail_manual.absence_penalty = 0 if @homework_detail_manual - end + @homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@homework) - if @homework.homework_type == 2 && @homework_detail_programing #编程作业 - @homework_detail_programing.language = params[:language] - @homework_detail_programing.standard_code = params[:standard_code] - @homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - homework_tests = @homework.homework_tests - #需要删除的测试 - ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i) - ids.each do |id| - homework_test = HomeworkTest.find id - homework_test.destroy if homework_test - end - 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 + #编程作业相关属性 + if @homework.homework_type == 2 + @homework.homework_detail_programing ||= HomeworkDetailPrograming.new + @homework_detail_programing = @homework.homework_detail_programing + @homework_detail_programing.language = params[:language_type].to_i + + @homework.homework_tests.delete_all + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + @homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) end - homework_test.save end - end end - #发送修改作业的请求 - question = {title:@homework.name,content:@homework.description} - question[:input] = [] - question[:output] = [] - @homework.homework_tests.each do |test| - question[:input] << test.input - question[:output] << test.output - end - uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json") - body = question.to_json - res = Net::HTTP.new(uri.host, uri.port).start do |client| - request = Net::HTTP::Put.new(uri.path) - request.body = body - request["Content-Type"] = "application/json" - client.request(request) - end - result = JSON.parse(res.body) - end - - @homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(@homework) - - if @homework.save - @homework_detail_manual.save if @homework_detail_manual - @homework_detail_programing.save if @homework_detail_programing - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_edit) - redirect_to homework_common_index_path(:course => @course.id) - } - end - return - else - respond_to do |format| - format.html { - flash[:notice] = l(:notice_failed_edit) - redirect_to edit_homework_common_path(@homework) - } + if @homework.save + @homework_detail_manual.save if @homework_detail_manual + @homework_detail_programing.save if @homework_detail_programing + redirect_to user_homeworks_user_path(User.current.id) end end end @@ -291,7 +181,7 @@ class HomeworkCommonController < ApplicationController def destroy if @homework.destroy respond_to do |format| - format.html {redirect_to homework_common_index_path(:course => @course.id)} + format.html {redirect_to user_homeworks_user_path(User.current.id)} end end end @@ -299,11 +189,11 @@ class HomeworkCommonController < ApplicationController #开启匿评 #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限 def start_anonymous_comment - @statue =4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) + @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course) @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") if @homework_detail_manual.comment_status == 1 student_works = @homework.student_works - if student_works && student_works.size >=2 + if student_works && student_works.size >= 2 student_works.each_with_index do |work, index| user = work.user n = @homework_detail_manual.evaluation_num @@ -316,6 +206,7 @@ class HomeworkCommonController < ApplicationController end @homework_detail_manual.update_column('comment_status', 2) @statue = 1 + # send_message_homework(@homework) else @statue = 2 end @@ -327,19 +218,28 @@ class HomeworkCommonController < ApplicationController #关闭匿评 def stop_anonymous_comment @homework_detail_manual.update_column('comment_status', 3) - + #计算缺评扣分 work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" @homework.student_works.each do |student_work| 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 student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0 student_work.save end - + # send_message_homework(@homework) respond_to do |format| format.js end end + # 开启/关闭匿评消息通知 + # def send_message_homework(homework) + # # status 标记匿评状态 1为关闭 0为开启 + # course = @homework.course + # course.student.each do |st| + # @homework.course_messages << CourseMessage.new(:user_id => st.user_id, :course_id => course.id, :viewed => false, :status => false) + # end + # end + #提示 def alert_anonymous_comment @cur_size = 0 @@ -406,4 +306,4 @@ class HomeworkCommonController < ApplicationController student_works += student_works student_works[index + 1 .. index + n] end -end \ No newline at end of file +end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 0995d1304..bf854abe8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index] + before_filter :authorize, :except => [:index,:add_journal] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -66,14 +66,14 @@ class IssuesController < ApplicationController if @query.valid? case params[:format] - when 'csv', 'pdf' - @limit = 10#Setting.issues_export_limit.to_i - when 'atom' - @limit = 10#Setting.feeds_limit.to_i - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 10}) - else - @limit = 10#per_page_option + when 'csv', 'pdf' + @limit = 10#Setting.issues_export_limit.to_i + when 'atom' + @limit = 10#Setting.feeds_limit.to_i + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 10}) + else + @limit = 10#per_page_option end @assign_to_id = params[:assigned_to_id] @author_id = params[:author_id] @@ -84,9 +84,9 @@ class IssuesController < ApplicationController @issue_pages = Paginator.new @issue_count, @limit, params['page'] @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], - :order => sort_clause, - :offset => @offset, - :limit => @limit) + :order => sort_clause, + :offset => @offset, + :limit => @limit) @issue_count_by_group = @query.issue_count_by_group respond_to do |format| format.js @@ -114,17 +114,21 @@ class IssuesController < ApplicationController def show # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = @issue.forge_messages - if User.current.id == @issue.assigned_to_id - query.update_all(:viewed => true) + query.each do |m| + if m.user_id == User.current.id + m.update_attribute(:viewed, true) + end end # 缺陷状态更新 query_journals = @issue.journals - if User.current.id == @issue.author_id query_journals.each do |query_journal| - query_journal.forge_messages.update_all(:viewed => true) + query_journal.forge_messages.each do |f| + if User.current.id == f.user_id + f.update_attributes(:viewed => true) + end + end end - end - # + # end @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) @@ -143,16 +147,16 @@ class IssuesController < ApplicationController @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq respond_to do |format|`` - format.html { - retrieve_previous_and_next_issue_ids - render :template => 'issues/show', :layout => @project_base_tag#by young - } - format.api - format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } - format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") - } + format.html { + retrieve_previous_and_next_issue_ids + render :template => 'issues/show', :layout => @project_base_tag#by young + } + format.api + format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } + format.pdf { + pdf = issue_to_pdf(@issue, :journals => @journals) + send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + } end end @@ -322,8 +326,8 @@ class IssuesController < ApplicationController issue.reload if @copy issue = issue.copy({}, - :attachments => params[:copy_attachments].present?, - :subtasks => params[:copy_subtasks].present? + :attachments => params[:copy_attachments].present?, + :subtasks => params[:copy_subtasks].present? ) end journal = issue.init_journal(User.current, params[:notes]) @@ -353,21 +357,21 @@ class IssuesController < ApplicationController @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] - when 'destroy' - # nothing to do - when 'nullify' - TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) - when 'reassign' - reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) - if reassign_to.nil? - flash.now[:error] = l(:error_issue_not_found_in_project) - return + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end else - TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) - end - else - # display the destroy form if it's a user request - return unless api_request? + # display the destroy form if it's a user request + return unless api_request? end end @issues.each do |issue| @@ -383,6 +387,23 @@ class IssuesController < ApplicationController end end + def add_journal + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first + user_activity.updated_at = jour.created_on + user_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + private def find_project @@ -423,14 +444,14 @@ class IssuesController < ApplicationController issue_attributes = params[:issue] if issue_attributes && params[:conflict_resolution] case params[:conflict_resolution] - when 'overwrite' - issue_attributes = issue_attributes.dup - issue_attributes.delete(:lock_version) - when 'add_notes' - issue_attributes = issue_attributes.slice(:notes) - when 'cancel' - redirect_to issue_url(@issue) - return false + when 'overwrite' + issue_attributes = issue_attributes.dup + issue_attributes.delete(:lock_version) + when 'add_notes' + issue_attributes = issue_attributes.slice(:notes) + when 'cancel' + redirect_to issue_url(@issue) + return false end end @issue.safe_attributes = issue_attributes diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 11d1d6e18..27e0d472f 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -115,10 +115,24 @@ class MemosController < ApplicationController REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE) def show - #更新贴吧帖子留言对应的memo_messages的viewed字段 + # 更新贴吧帖子留言对应的memo_messages的viewed字段 + unless @memo.children.blank? + @memo.children.each do |child| + child.memo_messages.each do |memo_message| + if User.current.id == memo_message.user_id + memo_message.update_attributes(:viewed => true) + end + end + end + end query_memo_messages = @memo.memo_messages - pre_count = REPLIES_PER_PAGE + query_memo_messages.each do |query_memo_message| + if User.current.id == query_memo_message.user_id + query_memo_message.update_attributes(:viewed => true) + end + end + pre_count = REPLIES_PER_PAGE @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index a242587fb..aae33e52a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -89,72 +89,54 @@ class MessagesController < ApplicationController # Create a new topic def new - @message = Message.new - @message.author = User.current - @message.board = @board - @message.safe_attributes = params[:message] - if request.post? - @message.save_attachments(params[:attachments]) - if @message.save - # 更新kindeditor上传的图片资源所有者 - if params[:asset_id] - ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE - end - # 与我相关动态的记录add start - if(@board && @board.course) #项目的先不管 - teachers = searchTeacherAndAssistant(@board.course) - for teacher in teachers - if(teacher.user_id != User.current.id) - notify = ActivityNotify.new() - if(@board.course) - notify.activity_container_id = @board.course_id - notify.activity_container_type = 'Course' - else - notify.activity_container_id = @board.project_id - notify.activity_container_type = 'Project' - end - notify.activity_id = @message.id - notify.activity_type = 'Message' - notify.notify_to = teacher.user_id - notify.is_read = 0 - notify.save() - end + if User.current.logged? + @message = Message.new + @message.author = User.current + @message.board = @board + @message.safe_attributes = params[:message] + if request.post? + @message.save_attachments(params[:attachments]) + if @message.save + # 更新kindeditor上传的图片资源所有者 + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE end - end - # 与我相关动态的记录add end - call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) - render_attachment_warning_if_needed(@message) - if params[:is_board] - if @project - redirect_to project_boards_path(@project) - elsif @course - redirect_to course_boards_path(@course) + call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) + render_attachment_warning_if_needed(@message) + if params[:is_board] + if @project + redirect_to project_boards_path(@project) + elsif @course + redirect_to course_boards_path(@course) + end + else + redirect_to board_message_url(@board, @message) end else - redirect_to board_message_url(@board, @message) + if params[:is_board] + if @project + redirect_to project_boards_path(@project, :flag => true) + elsif @course + redirect_to course_boards_path(@course, :flag => true) + end + else + layout_file = @project ? 'base_projects' : 'base_courses' + render :action => 'new', :layout => layout_file + end + end else - if params[:is_board] - if @project - redirect_to project_boards_path(@project, :flag => true) - elsif @course - redirect_to course_boards_path(@course, :flag => true) - end - else - layout_file = @project ? 'base_projects' : 'base_courses' - render :action => 'new', :layout => layout_file + respond_to do |format| + format.html { + layout_file = @project ? 'base_projects' : 'base_courses' + render :layout => layout_file + } end - end else - respond_to do |format| - format.html { - layout_file = @project ? 'base_projects' : 'base_courses' - render :layout => layout_file - } - end + redirect_to signin_path end end @@ -177,7 +159,11 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content + @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] @topic.children << @reply + user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first + user_activity.updated_at = @reply.created_on + user_activity.save #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] @@ -185,41 +171,18 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE end - # 与我相关动态的记录add start - if(@board && @board.course) #项目的先不管 - notifyto_arr = {} - notifyto_arr[@topic.author_id] = @topic.author_id - if( params[:parent_topic] != nil && params[:parent_topic] != '') - parent_topic = Message.find(params[:parent_topic]) - notifyto_arr[parent_topic.author_id] = parent_topic.author_id - end - notifyto_arr.each do |k,user_id| - if(user_id != User.current.id) - notify = ActivityNotify.new() - if(@board.course) - notify.activity_container_id = @board.course_id - notify.activity_container_type = 'Course' - else - notify.activity_container_id = @board.project_id - notify.activity_container_type = 'Project' - end - notify.activity_id = @reply.id - notify.activity_type = 'Message' - notify.notify_to = user_id - notify.is_read = 0 - notify.save() - end - end - end - # 与我相关动态的记录add end - call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) else #render file: 'messages#show', layout: 'base_courses' end - if params[:is_board] + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + elsif params[:is_board] if @project redirect_to project_boards_path(@project) elsif @course diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index d445fc77c..d5c248f77 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -99,30 +99,32 @@ class NewsController < ApplicationController end def show - #更新news对应的forge_messages的viewed字段 - query_forge_news = @news.forge_messages - query_forge_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end + # 更新news对应的forge_messages的消息viewed字段 + if @project + query_message_news = @news.forge_messages + else + query_message_news = @news.course_messages end - #更新news对应的course_messages的viewed字段 - query_course_news = @news.course_messages - query_course_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end + query_message_news.each do |query| + if User.current.id == query.user_id + query.update_attributes(:viewed => true) + end + end + # 更新项目新闻的评阅的消息viewed字段 + current_message_comments = @news.comments + current_message_comments.each do |current_message_comment| + if @project + query_message_comment = current_message_comment.forge_messages + else + query_message_comment = current_message_comment.course_messages end - #更新项目新闻的评阅的viewed字段 - current_forge_comments = @news.comments - current_forge_comments.each do |current_forge_comment| - query_forge_comment = current_forge_comment.forge_messages - query_forge_comment.each do |query| + query_message_comment.each do |query| if User.current.id == query.user_id query.update_attributes(:viewed => true) end end end + # end cs = CoursesService.new result = cs.show_course_news params,User.current diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 1bbcf9bb4..a8f2a11f1 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -28,6 +28,7 @@ class PollController < ApplicationController render_403 return end + # 问卷消息状态更新 query_course_poll = @poll.course_messages query_course_poll.each do |query| if User.current.id == query.user_id diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 77933666f..6da45c10b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -33,7 +33,7 @@ class ProjectsController < ApplicationController before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] before_filter :file, :statistics #:watcherlist # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 - before_filter :memberAccess, only: :member + # before_filter :memberAccess, only: :member # accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy @@ -216,6 +216,7 @@ class ProjectsController < ApplicationController end } format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } + format.js end else respond_to do |format| @@ -322,6 +323,12 @@ class ProjectsController < ApplicationController end def settings + # 修改查看消息状态 + applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0) + applied_messages.each do |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 +349,7 @@ class ProjectsController < ApplicationController if params[:repository] == "pswd_is_null" html << l(:label_password_not_null) end - flash[:error] = html if !html.to_s.blank? + flash.now[:error] = html if !html.to_s.blank? end scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) @@ -351,24 +358,57 @@ class ProjectsController < ApplicationController end + # 项目邀请用户加入实现过程 # 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定) def send_mail_to_member + # 该邮箱未注册过 if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? - email = params[:mail] - Mailer.run.send_invite_in_project(email, @project, User.current) - @is_zhuce = false - flash[:notice] = l(:notice_email_sent, :value => email) + if !User.where("login =?", params[:mail]).first.nil? + # 用户名唯一,用户修改邮箱,未修改用户名,用户名等同邮箱的情况,默认改用户已经注册 + user = User.find_by_login(params[:mail].to_s) + if !user.member_of?(@project) + # 如果已经邀请过该用户,则不重复发送 + if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil? + email = params[:mail] + Mailer.request_member_to_project(email, @project, User.current).deliver + flash[:notice] = l(:notice_email_sent, :value => email) + else + flash[:error] = l(:notice_email_invited) + end + else + flash[:error] = l(:label_member_of_project, :value => email) + end + else + email = params[:mail] + Mailer.send_invite_in_project(email, @project, User.current).deliver + @is_zhuce = false + flash[:notice] = l(:notice_email_sent, :value => email) + end + + # 邮箱地址已被注册 elsif !User.find_by_mail(params[:mail].to_s).nil? user = User.find_by_mail(params[:mail].to_s) if !user.member_of?(@project) - email = params[:mail] - Mailer.run.request_member_to_project(email, @project, User.current) - flash[:notice] = l(:notice_email_sent, :value => email) + # 如果已经邀请过该用户,则不重复发送 + invite_list = InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first + if invite_list.nil? + email = params[:mail] + Mailer.request_member_to_project(email, @project, User.current).deliver + flash[:notice] = l(:notice_email_sent, :value => email) + else + # 已经发送过了,则隔3小时才能再次发送 + if Time.now - invite_list.created_at > 10800 + email = params[:mail] + Mailer.request_member_to_project(email, @project, User.current).deliver + flash[:notice] = l(:notice_email_sent, :value => email) + else + flash[:error] = l(:notice_email_invited) + end + end else flash[:error] = l(:label_member_of_project, :value => email) end else - flash[:error] = l(:notice_registed_error, :value => email) @is_zhuce = true end respond_to do |format| @@ -376,25 +416,26 @@ class ProjectsController < ApplicationController end end - #发送邮件邀请新用户 + # 发送邮件邀请新用户页面对应方法 def invite_members_by_mail if User.current.member_of?(@project) || User.current.admin? - @inviter_lists = InviteList.where(project_id:@project.id).all - @inviters = [] - @waiters = [] - unless @inviter_lists.blank? - @inviter_lists.each do|inviter_list| - unless inviter_list.user.nil? - if inviter_list.user.member_of?(@project) - @inviters << inviter_list.user - @inviters_count = @inviters.size - else - @waiters << inviter_list.user - @waiters_count = @waiters.size - end - end - end - end + @inviter_lists = InviteList.where(project_id:@project.id).order("created_at desc") + + # @inviters = [] + # @waiters = [] + # unless @inviter_lists.blank? + # @inviter_lists.each do|inviter_list| + # unless inviter_list.user.nil? + # if inviter_list.user.member_of?(@project) + # @inviters << inviter_list.user + # @inviters_count = @inviters.size + # else + # @waiters << inviter_list.user + # @waiters_count = @waiters.size + # end + # end + # end + # end @is_zhuce = false respond_to do |format| format.html @@ -406,16 +447,16 @@ class ProjectsController < ApplicationController end # 邀请Trustie注册用户 - def invite_members - if User.current.member_of?(@project) || User.current.admin? - @member ||= @project.members.new - respond_to do |format| - format.html - end - else - render_403 - end - end + # def invite_members + # if User.current.member_of?(@project) || User.current.admin? + # @member ||= @project.members.new + # respond_to do |format| + # format.html + # end + # else + # render_403 + # end + # end def edit end @@ -444,6 +485,10 @@ class ProjectsController < ApplicationController flash[:notice] = l(:label_mail_invite_success) end end + # 私有项目非项目成员无法访问成员列表 + unless @project.is_public? + return render_403 unless User.current.member_of?(@project) + end ## 有角色参数的才是课程,没有的就是项目 @render_file = 'project_member_list' # 判断是否课程 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1af832b79..251fd80c4 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,14 +3,67 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] - before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] - protect_from_forgery :except => :set_program_score + before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule] + + ### + def program_test + 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) + + 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 + 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 def index + # 作业消息状态更新 + @homework.course_messages.each do |homework_message| + if User.current.id == homework_message.user_id && homework_message.viewed == 0 + homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 + end + end + # 作品打分消息状态更新 + studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) + studentworks_scores.each do |studentworks_score| + studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0 + end + # 作品评论消息状态更新 + journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0) + journals_for_teacher.each do |journal_for_teacher| + journal_for_teacher.update_attributes(:viewed => true) + end + # 作品留言 + # 消息end #设置作业对应的forge_messages表的viewed字段 query_student_work = @homework.course_messages query_student_work.each do |query| @@ -18,80 +71,33 @@ class StudentWorkController < ApplicationController query.update_attributes(:viewed => true) end end + ################################################################################################################## @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] - @is_teacher = User.current.allowed_to?(:as_teacher,@course) - course_group = CourseGroup.find_by_id(@group) if @group - if course_group - group_students = course_group.users - if group_students.empty? - student_in_group = '(0)' + @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.comment_status == 2 && !@is_teacher #是不是匿评 + @show_all = false + if @is_teacher #老师 || 超级管理员 显示所有列表 + @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 + elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 + @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) + elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 + my_work = @homework.student_works.where(:user_id => User.current.id) + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 + 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) + if my_work.empty? + @stundet_works = [] else - student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' - end - #老师 || 非匿评作业 || 匿评结束 显示所有的作品 - @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? - if @show_all - if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 - 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 - end - else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 - 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) - if my_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 - end - end - end - else #学生 - if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 - @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) - elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 - @is_evaluation = true - my_work = @homework.student_works.where(:user_id => User.current.id) - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} - end + @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 - #老师 || 非匿评作业 || 匿评结束 显示所有的作品 - @show_all = @is_teacher || @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3 || User.current.admin? - if @show_all - if @homework.homework_type == 1 || @is_teacher || User.current.admin? #超级管理员 || 老师 || 匿评结束 显示所有的作品 - 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 - end - else #剩余情况: 学生 && 非匿评作业 如果未提交作品,只能看到自己的,提交了作品,能看到所有作品 - 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) - if my_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 - end - end - end - else #学生 - if @homework.homework_detail_manual.comment_status == 1 #未开启匿评,只显示我的作品 - @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) - elsif @homework.homework_detail_manual.comment_status == 2 #匿评列表,显示匿评作品和我的作品 - @is_evaluation = true - my_work = @homework.student_works.where(:user_id => User.current.id) - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} - end - end + @stundet_works = [] end - @homework_commons = @course.homework_commons.order("created_at desc") @score = @b_sort == "desc" ? "asc" : "desc" + respond_to do |format| format.html format.xls { @@ -102,50 +108,39 @@ class StudentWorkController < ApplicationController end def new - student_work = @homework.student_works.where("user_id = ?",User.current.id).first - if student_work.nil? - @stundet_work = StudentWork.new - respond_to do |format| - format.html - end - else - render_403 + if @homework.homework_type==2 + redirect_to new_user_commit_homework_users_path(homework_id: @homework.id) + return + end + @user = User.current + @student_work = @homework.student_works.where("user_id = ?",User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new + end + respond_to do |format| + format.html{ render :layout => "new_base_user"} end end def create if params[:student_work] - stundet_work = StudentWork.new - stundet_work.name = params[:student_work][:name] - stundet_work.description = params[:student_work][:description] - stundet_work.project_id = params[:student_work][:project_id] - stundet_work.homework_common_id = @homework.id - stundet_work.user_id = User.current.id - stundet_work.save_attachments(params[:attachments]) + student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] + student_work ||= StudentWork.new + student_work.name = params[:student_work][:name] + student_work.description = params[:student_work][:description] + student_work.project_id = params[:student_work][:project_id] + student_work.homework_common_id = @homework.id + student_work.user_id = User.current.id + student_work.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(student_work) + #提交作品时,计算是否迟交 if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") - stundet_work.late_penalty = @homework.late_penalty - else - stundet_work.late_penalty = 0 + student_work.late_penalty = @homework.late_penalty + else + student_work.late_penalty = 0 end - render_attachment_warning_if_needed(stundet_work) - - if stundet_work.save - if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分 - url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" - solutions = { - student_work_id:stundet_work.id, - src:Base64.encode64(stundet_work.description), - language:@homework.homework_detail_programing.language - } - uri = URI(url) - body = solutions.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 - end + + if student_work.save respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) @@ -164,11 +159,12 @@ class StudentWorkController < ApplicationController end def edit + @user = User.current if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业 render_403 else respond_to do |format| - format.html + format.html{ render :layout => "new_base_user"} end end end @@ -197,16 +193,15 @@ class StudentWorkController < ApplicationController def show @score = student_work_score @work,User.current - @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? + @student_work_scores = @work.student_works_scores.order("updated_at desc") respond_to do |format| format.js end end def destroy - if @homework.homework_type == 2 #编程作业,作品提交后不可以删除 - render_403 - elsif @work.destroy + if @work.destroy respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -217,10 +212,11 @@ class StudentWorkController < ApplicationController #添加评分,已评分则为修改评分 def add_score + @is_last = params[:is_last] == "true" render_403 and return if User.current == @work.user #不可以匿评自己的作品 - @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 - render_403 and return unless @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2) + 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] != "" @@ -254,35 +250,11 @@ class StudentWorkController < ApplicationController case @score.reviewer_role when 1 #教师评分:最后一个教师评分为最终评分 @work.teacher_score = @score.score - @work.final_score = @score.score when 2 #教辅评分 教辅评分显示平均分 @work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f - if @work.teacher_score.nil? - if @work.student_score.nil? - @work.final_score = @work.teaching_asistant_score - else - ta_proportion = @homework.homework_detail_manual.ta_proportion if @homework.homework_detail_manual - ta_proportion = @homework.homework_detail_programing.ta_proportion if @homework.homework_detail_programing - final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") - final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) - final_score = final_ta_score + final_s_score - @work.final_score = format("%.2f",final_score.to_f) - end - end when 3 #学生评分 学生评分显示平均分 @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f - if @work.teacher_score.nil? - if @work.teaching_asistant_score.nil? - @work.final_score = @work.student_score - else - final_ta_score = BigDecimal.new("#{@work.teaching_asistant_score}") * BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}") - final_s_score = BigDecimal.new("#{@work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{@homework.homework_detail_manual.ta_proportion}")) - final_score = final_ta_score + final_s_score - @work.final_score = format("%.2f",final_score.to_f) - end - end end - if @work.save respond_to do |format| format.js @@ -294,6 +266,7 @@ class StudentWorkController < ApplicationController #添加评分的回复 def add_score_reply @score = StudentWorksScore.find params[:score_id] + @is_last = params[:is_last] == "true" @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0) if @jour.save @status = 1 @@ -386,44 +359,53 @@ class StudentWorkController < ApplicationController end end - #设置编程作业得分 - def set_program_score - stundet_work = StudentWork.find_by_id params[:student_work_id] - @course = stundet_work.homework_common.course - student_score_count = 0 - if stundet_work && params[:results] && params[:results].class.to_s == "Array" - homework_common = stundet_work.homework_common - params[:results].each do |result| - 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 - student_work_test.result = result[:status] - if student_work_test.result == 0 - student_score_count += 1 - end - student_work_test.error_msg = params[:compile_error_msg] - student_work_test.save! - end + #设置评分规则 + def set_score_rule + homework_detail_manual = @homework.homework_detail_manual + homework_detail_programing = @homework.homework_detail_programing + + unless @homework.late_penalty.to_s == params[:late_penalty].to_s + @homework.late_penalty = params[:late_penalty] + @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work| + student_work.late_penalty = @homework.late_penalty + student_work.save end - unless homework_common.homework_tests.empty? - stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count - if stundet_work.teacher_score.nil? - if stundet_work.teaching_asistant_score.nil? - stundet_work.final_score = stundet_work.student_score - else - final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}") - final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")) - final_score = final_ta_score + final_s_score - stundet_work.final_score = format("%.1f",final_score.to_f) - end + @homework.save + end + + unless homework_detail_manual.absence_penalty.to_s == params[:absence_penalty].to_s + homework_detail_manual.absence_penalty = params[:absence_penalty] + if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 + work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" + @homework.student_works.each do |student_work| + 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 + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 + student_work.save end + end + + homework_detail_manual.save if homework_detail_manual + end + + teacher_priority = params[:teacher_priority] ? 1 : 0 + 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 - stundet_work.save! + @homework.save + homework_detail_manual.save if homework_detail_manual + homework_detail_programing.save if homework_detail_programing + + @homework.student_works.each do |student_work| + set_final_score @homework,student_work + student_work.save end end + respond_to do |format| + format.html{redirect_to student_work_index_url(:homework => @homework.id)} + end end private @@ -456,15 +438,19 @@ class StudentWorkController < ApplicationController end def teacher_of_course - render_403 unless User.current.allowed_to?(:as_teacher,@course) + render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? end #根据条件过滤作业结果 def search_homework_member homeworks,name - name = name.downcase - select_homework = homeworks.select{ |homework| - homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name) - } + if name == "" + select_homework = homeworks + else + name = name.downcase + select_homework = homeworks.select{ |homework| + homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name) + } + end select_homework end @@ -475,25 +461,7 @@ class StudentWorkController < ApplicationController sheet1 = book.create_worksheet :name => "homework" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - if @homework.homework_type == 0 #普通作业 - 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_t_score),l(:excel_ta_score),l(:excel_f_score),l(:excel_commit_time)]) - count_row = 1 - items.each do |homework| - sheet1[count_row,0]=homework.user.id - sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s - sheet1[count_row,2] = homework.user.login - 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,8] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score) - sheet1[count_row,9] = format_time(homework.created_at) - count_row += 1 - end - elsif @homework.homework_type == 1 #匿评作业 + 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), l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) count_row = 1 @@ -513,7 +481,7 @@ class StudentWorkController < ApplicationController 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), - l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_f_score),l(:excel_commit_time)]) + 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| sheet1[count_row,0]=homework.user.id @@ -524,9 +492,10 @@ class StudentWorkController < ApplicationController 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,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) count_row += 1 end end @@ -584,4 +553,145 @@ class StudentWorkController < ApplicationController book.write xls_report xls_report.string end + + def find_or_save_student_work(is_test) + 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 + ) + unless @homework.save + logger.debug @homework.errors.full_messages + else + student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first + end + end + student_work + end + + + def test_realtime(student_work, src) + url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json" + + factor = [] + @homework.homework_tests.each do |test| + factor << {input: test.input, output: test.output} + end + solutions = { + 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| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + JSON.parse(res.body) + end + + #成绩计算 + def set_final_score homework,student_work + if homework && homework.homework_detail_manual + if homework.homework_type == 1 #匿评作业 + if homework.teacher_priority == 1 #教师优先 + if student_work.teacher_score + student_work.final_score = student_work.teacher_score + else + if 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 + else + ta_proportion = homework.homework_detail_manual.ta_proportion + final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_ta_score + final_s_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + else #不考虑教师评分 + if 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 + else + ta_proportion = homework.homework_detail_manual.ta_proportion + final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_ta_score + final_s_score + student_work.final_score = format("%.2f",final_score.to_f) + 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 + else + if student_work.teaching_asistant_score.nil? #教辅未评分 + if student_work.student_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + elsif student_work.student_score.nil? #学生未评分 + if student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_ts_score + student_work.final_score = format("%.2f",final_score.to_f) + end + else + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) + final_score = final_sy_score + final_ts_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + else #不考虑教师评分 + if student_work.teaching_asistant_score.nil? #教辅未评分 + if student_work.student_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + elsif student_work.student_score.nil? #学生未评分 + if student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_ts_score + student_work.final_score = format("%.2f",final_score.to_f) + end + else + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) + final_score = final_sy_score + final_ts_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + end + end + end end \ No newline at end of file diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb new file mode 100644 index 000000000..684378e8a --- /dev/null +++ b/app/controllers/system_messages_controller.rb @@ -0,0 +1,95 @@ +class SystemMessagesController < ApplicationController + # before_filter :message_author, :only => [:show] + # + # def message_author + # if(!User.current.logged? && !token.nil?) + # + # User.current =try_to_autologin1 + # end + # if @system_messages + # render_403 :message => :notice_not_authorized_message + # else + # deny_access + # end + # end + + def index + @system_messages = SystemMessage.all + end + + # def show + # @system_messages = SystemMessage.find(params[:id]) + # end + + # GET /products/new + # def new + # @product = Product.new + # end + + # GET /products/1/edit + # def edit + # end + + # POST /products + # POST /products.json + def create + unless User.current.admin? + render_403 + return + end + @system_messages = SystemMessage.new + @system_messages.description = params[:system_message][:description] + @system_messages.subject = params[:system_message][:subject] + @system_messages.user_id = User.current.id + respond_to do |format| + if @system_messages.save + format.html {redirect_to user_system_messages_path(User.current)} + flash[:notice] = l(:notice_successful_message) + else + if params[:system_messages][:description].empty? + flash[:error] = l(:label_content_blank_fail) + else + flash[:error] = l(:label_admin_message_fail) + end + format.html {redirect_to admin_messages_path} + end + end + end + + # PATCH/PUT /products/1 + # PATCH/PUT /products/1.json + # def update + # respond_to do |format| + # if @product.update(product_params) + # format.html { redirect_to @product, notice: 'Product was successfully updated.' } + # format.json { render :show, status: :ok, location: @product } + # else + # format.html { render :edit } + # format.json { render json: @product.errors, status: :unprocessable_entity } + # end + # end + # end + + # DELETE /products/1 + # DELETE /products/1.json + # def destroy + # @system_messages.destroy + # respond_to do |format| + # format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' } + # format.json { head :no_content } + # end + # end + + # private + # # Use callbacks to share common setup or constraints between actions. + # def set_product + # @product = Product.find(params[:id]) + # end + # + # # Never trust parameters from the scary internet, only allow the white list through. + # def message_params + # params.require(:admin_system_messages).permit(:content) + # end + + +end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 253faa2b1..e0cb8af8e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -230,6 +230,53 @@ class TagsController < ApplicationController end end + #更新某个tag名称 + def update_tag_name + @tag_name = params[:tagName] + @rename_tag_name = params[:renameName] + @taggable_id = params[:taggableId] + @taggable_type = numbers_to_object_type(params[:taggableType]) + + + @rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag + @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id + @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) + @obj = get_object(@taggable_id,params[:taggableType]) + if(@rename_tag.nil?) #这次命名的是新的tag + + # 是否还有其他记录 引用了 tag_id + @tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}") + # 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字 + if @tagging.count == 1 + @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) + @tag.update_attributes({:name=>@rename_tag_name}) + else #如果tagging表中的记录大于1,那么就要新增tag记录 + + unless @obj.nil? + @obj.tag_list.add(@rename_tag_name.split(",")) + @obj.save + end + #删除原来的对应的taggings的记录 + unless @taggings.nil? + @taggings.delete + end + end + else #这是已有的tag + # 更改taggings记录里的tag_id + unless @taggings.nil? + @taggings.update_attributes({:tag_id=>@rename_tag.id}) + end + end + @obj_flag = params[:taggableType] + if @obj && @obj_flag == '6' && @obj.container.kind_of?(Course) + @course = @obj.container + @tag_list = @tag_list = get_course_tag_list @course + end + respond_to do |format| + format.js + end + end + def tag_save @select_tag_name = params[:tag_for_save][:tag_name] @tags = params[:tag_for_save][:name] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0058e6e4c..b6ac28258 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -27,26 +27,20 @@ class UsersController < ApplicationController menu_item :user_course, :only => :user_courses menu_item :user_homework, :only => :user_homeworks menu_item :user_project, :only => [:user_projects, :watch_projects] - # menu_item :requirement_focus, :only => :watch_bids menu_item :requirement_focus, :only => :watch_contests menu_item :user_newfeedback, :only => :user_newfeedback menu_item :user_messages, :only => :user_messages - #Ended by young - - # edit - # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] - #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, - :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, - :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_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, + :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :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] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -102,70 +96,95 @@ class UsersController < ApplicationController # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) def user_messages unless User.current.logged? - render_403 + redirect_to signin_url return end + # 记录当前点击按钮的时间 + # 考虑到用户未退出刷新消息页面 + message_time = OnclickTime.where("user_id =?", User.current).first + if message_time.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = Time.now + message_new_time.save + else + # 24小时内显示 + contrast_time = Time.now - 86400 + message_time.update_attributes(:onclick_time => Time.now) + end + @user_system_messages = SystemMessage.where("created_at >?", contrast_time).order("created_at desc") # 当前用户查看消息,则设置消息为已读 - course_querys = @user.course_messages - forge_querys = @user.forge_messages - user_querys = @user.user_feedback_messages - forum_querys = @user.memo_messages - if User.current.id == @user.id - course_querys.update_all(:viewed => true) - forge_querys.update_all(:viewed => true) - user_querys.update_all(:viewed => true) - forum_querys.update_all(:viewed => true) + # DO 待优化,只需查出符合条件的再更新 + if params[:viewed] == "all" + course_querys = @user.course_messages + forge_querys = @user.forge_messages + user_querys = @user.user_feedback_messages + forum_querys = @user.memo_messages + if User.current.id == @user.id + course_querys.update_all(:viewed => true) + forge_querys.update_all(:viewed => true) + user_querys.update_all(:viewed => true) + forum_querys.update_all(:viewed => true) + end end # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count case params[:type] when nil @message_alls = [] - messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages = MessageAll.where("user_id =?" ,@user).order("created_at desc") messages.each do |message_all| @message_alls << message_all.message end + when 'unviewed' + @message_alls = [] + messages = MessageAll.where("user_id =?", @user).order("created_at desc") + messages.each do |message_all| + # 在点击或者刷新消息列表后未读的消息存放在数组 + if message_all.message.viewed == 0 + @message_alls << message_all.message + end + end + # when 'system_messages' + # @message_alls = SystemMessage.order("created_at desc").all + when 'apply' + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc") when 'homework' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") - @message_alls_count = @message_alls.count 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 '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_count = @message_alls.count + # 课程通知包含发布的通知和回复的通知 + @message_alls = CourseMessage.where("course_message_type =? or course_message_type =?", "News", "Comment").where("user_id =?", @user).order("created_at desc") #@user_course_messages_count = @user_course_messages.count - when 'forge_news' - @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 - 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 'forge_news' + # @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 + # 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 'issue_update' # 缺陷状态更新、留言 + # @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + # @message_alls_count = @message_alls.count 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") - @message_alls_count = @message_alls.count else render_404 return @@ -176,6 +195,15 @@ class UsersController < ApplicationController end end + # 系统消息 + def user_system_messages + @sytem_messages = SystemMessage.order("created_at desc").all + @sytem_messages = paginateHelper @sytem_messages,25 + respond_to do |format| + format.html{render :layout=>'new_base_user'} + end + end + def user_projects_index if User.current.admin? memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first @@ -223,7 +251,7 @@ class UsersController < ApplicationController end # end - ##added by fq +##added by fq def watch_bids # cond = 'bids.reward_type <> 1' # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang @@ -286,7 +314,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?) render_404 - return + return end end @@ -299,12 +327,17 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + 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(",") + ")" + @homework_commons = HomeworkCommon.where("course_id in #{user_course_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) + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 end end @@ -327,11 +360,13 @@ class UsersController < ApplicationController #导入作业,确定按钮 def user_select_homework homework = HomeworkCommon.find_by_id params[:checkMenu] + homework_detail_programing = homework.homework_detail_programing @homework = HomeworkCommon.new if homework @homework.name = homework.name @homework.description = homework.description @homework.end_time = homework.end_time + @homework.homework_type = homework.homework_type @homework.course_id = homework.course_id homework.attachments.each do |attachment| att = attachment.copy @@ -341,49 +376,231 @@ class UsersController < ApplicationController att.save @homework.attachments << att end + + if homework_detail_programing + @homework.homework_detail_programing = HomeworkDetailPrograming.new + @homework_detail_programing = @homework.homework_detail_programing + @homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion + @homework_detail_programing.language = homework_detail_programing.language + homework.homework_tests.each_with_index do |homework_test| + @homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) + end + end end respond_to do |format| format.js end end + def new_user_commit_homework + if User.current.logged? + @user = User.current + @homework = HomeworkCommon.find(params[:homework_id]) + @is_test = params[:is_test] == 'true' + @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new + end + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 + end + end + + #修改编程作业 + def edit_user_commit_homework + if User.current.logged? + + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 + end + end + + def user_commit_homework + homework = HomeworkCommon.find(params[:homework]) + student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first + if student_work + + #提交作品时,计算是否迟交 + 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 = 1 + else + student_work.late_penalty = 0 + end + + student_work.save + flash[:notice] = l(:notice_successful_create) + redirect_to student_work_index_url(:homework => params[:homework]) + else + render_403 + end + end + def user_new_homework - if params[:homework_common] - homework = HomeworkCommon.new - homework.name = params[:homework_common][:name] - homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] || Time.now - homework.publish_time = Time.now - homework.homework_type = 1 - homework.late_penalty = 2 - homework.user_id = User.current.id - homework.course_id = params[:course_id] - - homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(homework) - - #匿评作业相关属性 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now - homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 - homework_detail_manual.absence_penalty = 2 - homework.homework_detail_manual = homework_detail_manual - - if homework.save - homework_detail_manual.save if homework_detail_manual - redirect_to user_homeworks_user_path(User.current.id) + if User.current.logged? + if params[:homework_common] + homework = HomeworkCommon.new + homework.name = params[:homework_common][:name] + homework.description = params[:homework_common][:description] + homework.end_time = params[:homework_common][:end_time] || Time.now + homework.publish_time = Time.now + homework.homework_type = params[:homework_type].to_i || 1 + homework.late_penalty = 10 + homework.teacher_priority = 1 + homework.user_id = User.current.id + homework.course_id = params[:course_id] + + homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(homework) + + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = Time.now + homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 + homework_detail_manual.absence_penalty = 5 + homework.homework_detail_manual = homework_detail_manual + + #编程作业相关属性 + if homework.homework_type == 2 + homework_detail_programing = HomeworkDetailPrograming.new + homework.homework_detail_programing = homework_detail_programing + homework_detail_programing.ta_proportion = 0.5 + homework_detail_programing.language = params[:language_type].to_i + + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) + end + end + + end + + if homework.save + homework_detail_manual.save if homework_detail_manual + homework_detail_programing.save if homework_detail_programing + redirect_to user_homeworks_user_path(User.current.id) + end end + else + render_403 end end #用户从资源库导入资源到作业 def user_import_resource - user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 + @user = User.current + user_course_ids = @user.courses.map { |c| 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(',')}))").order("created_on desc") + @type = params[:type] + @homework_id = params[:homework_id] + @limit = 7 + @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,7 + respond_to do |format| + format.js + end + end + + #引入资源列表根据类型过滤 + def user_resource_type + if User.current.id.to_i != params[:id].to_i + render_403 + return + end + if(params[:type].blank? || params[:type] == "1") #全部 + user_course_ids = User.current.courses.map { |c| 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(',')}))").order("created_on desc") + elsif params[: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") + elsif params[:type] == "3" #项目资源 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + elsif params[:type] == "4" #附件 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + elsif params[:type] == "5" #用户资源 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + end + @type = params[:type] + @limit = 7 + @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,7 + respond_to do |format| + format.js + end + end + + + #引入资源列表根据关键词过滤 + 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.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" #课程资源 + 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") + 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") + end + @type = params[:type] + @limit = 7 + @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,7 + respond_to do |format| + format.js + end + end + + #将资源批量引入 + def import_resources_to_homework + @attachments = [] + unless params[:checkbox1].nil? || params[:checkbox1].blank? + params[:checkbox1].each do |id| + atta = Attachment.find(id) + att_copy = atta.copy + att_copy.container_id = nil + att_copy.container_type = nil + att_copy.author_id = User.current.id + att_copy.copy_from = atta.id + att_copy.save + @attachments << att_copy + end + end respond_to do |format| format.js end @@ -412,6 +629,18 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback + unless User.current.logged? + redirect_to signin_url + return + end + # 自己访问自己的页面才更新消息状态 + if User.current == @user + journals_messages = UserFeedbackMessage.where("user_id =? and journals_for_message_type =? and viewed =?", User.current.id, "JournalsForMessage", 0) + journals_messages.each do |journals_message| + journals_message.update_attributes(:viewed => true) + end + end + # end 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) @@ -436,16 +665,16 @@ class UsersController < ApplicationController sort_update %w(login firstname lastname mail admin created_on last_login_on) case params[:format] - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 15}) - else - @limit = 15 + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15 end # retrieve all users # 先内连一下statuses 保证排序之后数量一致 scope = User.visible. - joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") + joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") # unknow scope = scope.in_group(params[:group_id]) if params[:group_id].present? @@ -456,29 +685,29 @@ class UsersController < ApplicationController # users classify case params[:user_sort_type] - when '0' - # 创建时间排序 - @s_type = 0 - @users = scope.reorder('users.created_on DESC') - when '1' - # 活跃度排序, 就是所谓的得分情况 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') - when '2' - # 粉丝数排序 - @s_type = 2 - @users = scope. - #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). - reorder('user_statuses.watchers_count DESC') + when '0' + # 创建时间排序 + @s_type = 0 + @users = scope.reorder('users.created_on DESC') + when '1' + # 活跃度排序, 就是所谓的得分情况 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') + when '2' + # 粉丝数排序 + @s_type = 2 + @users = scope. + #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). + reorder('user_statuses.watchers_count DESC') - else - # 默认活跃度排序 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') + else + # 默认活跃度排序 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset @@ -498,20 +727,20 @@ class UsersController < ApplicationController sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) (redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? - case params[:format] + case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) else @limit = 15#per_page_option - end - # - #@status = params[:status] || 1 - #has = { - # "show_changesets" => true - #} - # scope = User.logged.status(@status) - # @search_by = params[:search_by] ? params[:search_by][:id] : 0 - # scope = scope.like(params[:name],@search_by) if params[:name].present? + end + # + #@status = params[:status] || 1 + #has = { + # "show_changesets" => true + #} + # scope = User.logged.status(@status) + # @search_by = params[:search_by] ? params[:search_by][:id] : 0 + # scope = scope.like(params[:name],@search_by) if params[:name].present? @search_by = params[:search_by] ? params[:search_by] : 0 us = UsersService.new @@ -544,13 +773,13 @@ class UsersController < ApplicationController def user_courses4show @page = params[:page].to_i + 1 @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").limit(5).offset(@page * 5) - end + end #显示更多用户项目 def user_projects4show @page = params[:page].to_i + 1 @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").limit(5).offset(@page * 5) - end + end def user_course_activities lastid = nil @@ -627,32 +856,32 @@ class UsersController < ApplicationController end def show - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - course_types = "('Message','News','HomeworkCommon','poll')" + course_types = "('Message','News','HomeworkCommon','Poll')" project_types = "('Message','Issue')" if params[:type].present? case params[:type] when "course_homework" - @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 "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) - end + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").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})").order('updated_at desc').limit(10).offset(@page * 10) end # @user_activities = paginateHelper @user_activities,500 @type = params[:type] @@ -668,124 +897,124 @@ class UsersController < ApplicationController # Author lizanle # Description type 1 :所有动态包括我关注的人 type 2:我的动态 type 3:关于我的回复 case params[:type] - when "1" - if @user == User.current - activity = Activity.where('user_id = ?', User.current.id).order('id desc') - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all - @state = 1 - end - when "2" - message = [] - if @user == User.current - message = JournalsForMessage.reference_message(@user.id) - message += Journal.reference_message(@user.id) - end - @activity_count = message.size - @info_pages = Paginator.new @activity_count, pre_count, params['page'] - messages = message.sort {|x,y| y.created_on <=> x.created_on } - @message = messages[@info_pages.offset, @info_pages.per_page] - @state = 2 - else - # Time 2015-02-04 10:50:49 - # Author lizanle - # Description 所有动态 - where_condition = nil; - # where_condition = "act_type <> 'JournalsForMessage'" - 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 - activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') - - permission = !User.current.admin? - if permission - #Issue - act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} - project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids = [] - ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} - - #HomeworkCommon - act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} - course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: course_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + when "1" + if @user == User.current + activity = Activity.where('user_id = ?', User.current.id).order('id desc') + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all + @state = 1 end - ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} - - #Journal - act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} - project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) + when "2" + message = [] + if @user == User.current + message = JournalsForMessage.reference_message(@user.id) + message += Journal.reference_message(@user.id) end - ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} - - #News - act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} - project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) + @activity_count = message.size + @info_pages = Paginator.new @activity_count, pre_count, params['page'] + messages = message.sort {|x,y| y.created_on <=> x.created_on } + @message = messages[@info_pages.offset, @info_pages.per_page] + @state = 2 + else + # Time 2015-02-04 10:50:49 + # Author lizanle + # Description 所有动态 + where_condition = nil; + # where_condition = "act_type <> 'JournalsForMessage'" + 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 - ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} + activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') + + permission = !User.current.admin? + if permission + #Issue + act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} + project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids = [] + ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + #HomeworkCommon + act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} + course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: course_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} + + #Journal + act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} + project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} + + #News + act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} + project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} - project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} - - #Message - act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} - board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} - project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} + project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} + + #Message + act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} + board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} + project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} - project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} + project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} - logger.debug "filter ids #{ids}" + logger.debug "filter ids #{ids}" - activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? - end + activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? + end - # activity = activity.reject { |e| - # e.act.nil? || - # (!User.current.admin? && !e.act.nil? - # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || - # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || - # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || - # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || - # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) - # } - # + # activity = activity.reject { |e| + # e.act.nil? || + # (!User.current.admin? && !e.act.nil? + # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || + # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || + # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || + # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || + # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) + # } + # - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) - @state = 0 + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) + @state = 0 end if params[:user].present? @@ -813,7 +1042,7 @@ class UsersController < ApplicationController if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) # redirect_to home_path render_404 - return + return end end @@ -845,7 +1074,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? render_404 - return + return end end @@ -903,7 +1132,7 @@ class UsersController < ApplicationController unless @user.id.nil? #后台注册的用户默认权限为男性开发员 ue = UserExtensions.create(:identity => 3, - :gender => 0, + :gender => 0, :user_id => @user.id) ue.save end @@ -973,8 +1202,8 @@ class UsersController < ApplicationController @user = User.find(params[:id]) #@user.save_attachments(params[:attachments],User.current) # Container_type为Principal - Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) - if(params[:type].nil? || params[:type] == "1") #全部 + Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) + if(params[:type].blank?|| params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1029,14 +1258,14 @@ class UsersController < ApplicationController # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 def user_resource_delete if params[:resource_id].present? - Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) + Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) elsif params[:checkbox1].present? - params[:checkbox1].each do |id| - Attachment.where("author_id = #{User.current.id}").delete(id) + params[:checkbox1].each do |id| + Attachment.where("author_id = #{User.current.id}").delete(id) end end - if(params[:type].nil? || params[:type] == "1") #全部 + if(params[:type].blank? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1083,17 +1312,17 @@ class UsersController < ApplicationController @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,25 - respond_to do |format| - format.js - end + respond_to do |format| + format.js + end end #根据id或者名称搜索教师或者助教为当前用户的课程 def search_user_course @user = User.current if !params[:search].nil? - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") - .select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") + .select { |course| @user.allowed_to?(:as_teacher,course)} else @course = @user.courses .select { |course| @user.allowed_to?(:as_teacher,course)} @@ -1125,28 +1354,28 @@ 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] if course_ids.nil? @flag = false end - unless course_ids.nil? - course_ids.each do |id| - next if ori.blank? - 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 - if attach_copied_obj.attachtype == nil - attach_copied_obj.attachtype = 4 - end - attach_copied_obj.save - @save_message = attach_copied_obj.errors.full_messages - end + unless course_ids.nil? + course_ids.each do |id| + next if ori.blank? + 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 + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages end + end elsif params[:send_ids].present? send_ids = params[:send_ids].split(" ") course_ids = params[:course_ids] @@ -1173,8 +1402,20 @@ class UsersController < ApplicationController end end else - @flag = false + @flag = false end + user_course_ids = User.current.courses.map { |c| 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(',')}))").order("created_on desc") + @type = params[:type] + @limit = 25 + @user = User.current + @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 respond_to do |format| format.js end @@ -1231,7 +1472,18 @@ class UsersController < ApplicationController else @flag=true end - + user_course_ids = User.current.courses.map { |c| 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(',')}))").order("created_on desc") + @type = params[:type] + @limit = 25 + @user = User.current + @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 respond_to do |format| format.js end @@ -1239,15 +1491,15 @@ class UsersController < ApplicationController # 资源预览 def resource_preview - preview_id = params[:resource_id] - @file = Attachment.find(preview_id) - @preview_able = false; - if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} - @preview_able = true; - end - respond_to do |format| - format.js - end + preview_id = params[:resource_id] + @file = Attachment.find(preview_id) + @preview_able = false; + if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} + @preview_able = true; + end + respond_to do |format| + format.js + end end # 重命名资源 @@ -1287,7 +1539,7 @@ class UsersController < ApplicationController def destroy_membership @membership = Member.find(params[:membership_id]) if @membership.deletable? - @membership.destroy + @membership.destroy end respond_to do |format| format.html { redirect_to edit_user_url(@user, :tab => 'memberships') } @@ -1302,31 +1554,31 @@ class UsersController < ApplicationController @obj_flag = params[:tag_for_save][:object_flag] case @obj_flag - when '1' then - @obj = User.find_by_id(@obj_id) - when '2' then - @obj = Project.find_by_id(@obj_id) - when '3' then - @obj = Issue.find_by_id(@obj_id) - when '4' then - # @obj = Bid.find_by_id(@obj_id) - when '5' then - @obj = Forum.find_by_id(@obj_id) - when '6' - @obj = Attachment.find_by_id(@obj_id) - when '7' then - @obj = Contest.find_by_id(@obj_id) - when '8' - @obj = OpenSourceProject.find_by_id(@obj_id) - when '9' - @obj = Course.find_by_id(@obj_id) - else - @obj = nil + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + # @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil end unless @obj.nil? @obj.tag_list.add(@tags.split(",")) else - return + return end if @obj.save logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" @@ -1417,9 +1669,9 @@ class UsersController < ApplicationController def update_extensions(user_extensions) user_extensions = params[:user_extensions] unless user_extensions.nil? - user_extensions = UserExtensions.find_by_id(user_extensions.user_id) + user_extensions = UserExtensions.find_by_id(user_extensions.user_id) - # user_extensions. + # user_extensions. end end @@ -1446,7 +1698,7 @@ class UsersController < ApplicationController render_403 return end - if(params[:type].nil? || params[:type] == "1") #全部 + if(params[:type].blank? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1510,9 +1762,9 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + - " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like '%#{search}%') ").order("created_on desc") + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i @@ -1521,7 +1773,7 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源 diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 809f78ddc..784066378 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -96,11 +96,14 @@ class WelcomeController < ApplicationController @projects = Project.all_public.active render :layout => false, :content_type => 'text/plain' end - + def course - @course_page = FirstPage.find_by_page_type('course') - @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117 - @logoLink ||= logolink() + redirect_to signin_path + return + # + # @course_page = FirstPage.find_by_page_type('course') + # @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117 + # @logoLink ||= logolink() end def logolink() @@ -140,8 +143,11 @@ class WelcomeController < ApplicationController def contest - @contest_page = FirstPage.find_by_page_type('contest') - @contest_notifications = Contestnotification.order("created_at desc").limit(5) + redirect_to signin_path + return + + # @contest_page = FirstPage.find_by_page_type('contest') + # @contest_notifications = Contestnotification.order("created_at desc").limit(5) end def search @@ -181,28 +187,28 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - url = request.original_url.gsub('/','') - if url.include?(Setting.url_course.gsub('/','')) - if @first_page.show_course == 1 - course - render :course - else - render_404 - end - - return 0 - elsif url.include?(Setting.url_contest.gsub('/','')) - if @first_page.show_contest == 1 - contest - render :contest - else - render_404 - end - - return 0 - elsif url.include?(Setting.url_user.gsub('/','')) - #redirect_to(:controller => "users", :action => "index") - end + # url = request.original_url.gsub('/','') + # if url.include?(Setting.url_course.gsub('/','')) + # if @first_page.show_course == 1 + # course + # render :course + # else + # render_404 + # end + # + # return 0 + # elsif url.include?(Setting.url_contest.gsub('/','')) + # if @first_page.show_contest == 1 + # contest + # render :contest + # else + # render_404 + # end + # + # return 0 + # elsif url.include?(Setting.url_user.gsub('/','')) + # #redirect_to(:controller => "users", :action => "index") + # end end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index f74fbb04d..da6d48b8d 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -264,7 +264,7 @@ class WikiController < ApplicationController end @page.destroy respond_to do |format| - format.html { redirect_to project_wiki_index_url(@project) } + format.html {redirect_to edit_project_wiki_page_url @project, @page.title} format.api { render_api_ok } end end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 5158a99c4..77304c1b1 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -202,11 +202,15 @@ class WordsController < ApplicationController #给用户留言 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]) + if User.current.logged? + @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) + else + render_403 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 7f93345b4..1982542a9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -760,7 +760,8 @@ module ApplicationHelper options = args.extract_options! text = distance_of_time_in_words(Time.now, time) if @project - link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)},options.reverse_merge(:title => format_time(time))) + content_tag('acronym', text, options.reverse_merge(:title => format_time(time))) + # link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => User.current.time_to_date(time)},options.reverse_merge(:title => format_time(time))) else content_tag('acronym', text, options.reverse_merge(:title => format_time(time))) end @@ -2254,6 +2255,21 @@ module ApplicationHelper technical_title end + def get_user_roll user + technical_title = "" + case user.user_extensions.identity.to_s + when "0" + technical_title = get_technical_title user + when "1" + technical_title = l(:label_account_identity_student) + when "2" + technical_title = l(:label_account_identity_enterprise) + when "3" + technical_title = l(:label_account_identity_developer) + end + technical_title + end + def ie8? request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/ @@ -2281,25 +2297,19 @@ module ApplicationHelper #获取匿评相关连接代码 def homework_anonymous_comment homework - if homework.homework_type == 1 && homework.homework_detail_manual #匿评作业 - if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") - link = "启动匿评".html_safe - elsif homework.student_works.count >= 2 #作业份数大于2 - case homework.homework_detail_manual.comment_status - when 1 - link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' - when 2 - link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' - when 3 - link = "匿评结束".html_safe - end - else - link = "启动匿评".html_safe + if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" + elsif homework.student_works.count >= 2 #作业份数大于2 + case homework.homework_detail_manual.comment_status + when 1 + link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' + when 2 + link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' + when 3 + link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end - elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业作业 - link = "编程作业".html_safe else - link = "启动匿评".html_safe + link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于2时才可以启动匿评" end link end @@ -2307,31 +2317,49 @@ module ApplicationHelper def student_new_homework homework work = cur_user_works_for_homework homework if work.nil? - link_to l(:label_commit_homework), new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit' + link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit' else if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 - "#{l(:label_edit_homework)}".html_safe - elsif homework.homework_type == 2 #编程作业不能修改作品 - "作品已交".html_safe + link_to "作品已交", "javascript:void(0);", :class => 'fr mr10 pr_join_span c_white', :title => "开启匿评后不可修改作品" + elsif homework.homework_type == 2 #编程作业修改作品 + if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 + link_to "作品已交", "javascript:void(0);", :class => 'fr mr10 pr_join_span c_white', :title => "开启匿评后不可修改作品" + else + link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'fr mr10 work_edit' + end else - link_to l(:label_edit_homework), edit_student_work_path(work.id),:class => 'fr mr10 work_edit c_blue' + link_to "修改作品", edit_student_work_path(work.id),:class => 'fr mr10 work_edit' end end end + #动态列表中,确定学生是该提交还是进列表 + def student_work_activity_submit_status(opt={}) + default_opt = {class: 'c_blue'}.merge(opt) + + is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true) + + homework = default_opt[:homework] + work = cur_user_works_for_homework homework + if work.nil? && !is_teacher + link_to "提交("+homework.student_works.count.to_s+")", new_student_work_path(:homework => homework.id,:host=> Setting.host_course), :class=> default_opt[:class] + else + link_to "提交("+homework.student_works.count.to_s+")", student_work_index_path(:homework => homework.id,:host=> Setting.host_course), :class=> default_opt[:class] + end + end #根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量 def user_for_homework_common homework,is_teacher if is_teacher #老师显示作品数量 - link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "提交(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework if work.nil? link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' else if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 - link_to "修改作品", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" + link_to "作品已交", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" elsif homework.homework_type == 2 #编程作业不能修改作品 - link_to "作品已交", "",:class => 'c_blue',:title => "编程作业不可修改作品" + link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' else link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' end diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index 43f815250..a03c4ccd7 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +include UsersHelper module HomeworkCommonHelper #迟交扣分下拉框 def late_penalty_option diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 0eee08b6b..1a0b9ca0d 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -116,7 +116,7 @@ module JournalsHelper end end #content << content_tag('div', links.join(' ').html_safe, :class => 'contextual', :style => 'margin-top:-25px;') unless links.empty? - content << textilizable(journal, :notes) + content << textAreailizable(journal, :notes) css_classes = "wiki" css_classes << " editable" if editable content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:510px") diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 12925b0b1..7b4b9d2e4 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. include AvatarHelper +include StudentWorkHelper module ProjectsHelper def link_to_version(version, options = {}) return '' unless version && version.is_a?(Version) @@ -75,6 +76,17 @@ module ProjectsHelper return result end +# 被邀请成员的状态 + def status_for_ivitied(ivite_list, project) + if ivite_list.user.member_of?(project) + value = "已经加入了项目!" + elsif ivite_list.user.active? + value = "邀请已发送,等待用户加入!" + else + value = "账号尚未激活,等待用户应答!" + end + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index f24d5078f..e1cf3464e 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -1,16 +1,17 @@ # encoding: utf-8 +include UserScoreHelper + module StudentWorkHelper + #获取当前用户的项目列表 def user_projects_option - cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" - memberships = User.current.memberships.all(:conditions => cond) - projects = memberships.map(&:project) + projects = User.current.projects.visible not_have_project = [] - not_have_project << Setting.please_chose + not_have_project << "请选择关联项目" not_have_project << 0 type = [] type << not_have_project projects.each do |project| - if project != nil + if project option = [] option << project.name option << project.id @@ -98,4 +99,31 @@ module StudentWorkHelper end result end + + #教辅评分比例下拉框 + def ta_proportion_option + type = [] + i = 0 + while i <= 100 + option = [] + option << i.to_s + "%" + option << i.to_f / 100 + type << option + i += 10 + end + type + end + + def ta_proportion_option_to num + type = [] + i = 0 + while i <= num + option = [] + option << i.to_s + "%" + option << i.to_f / 100 + type << option + i += 10 + end + type + end end \ No newline at end of file diff --git a/app/helpers/system_messages_helper.rb b/app/helpers/system_messages_helper.rb new file mode 100644 index 000000000..fef238676 --- /dev/null +++ b/app/helpers/system_messages_helper.rb @@ -0,0 +1,2 @@ +module SystemMessagesHelper +end diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 41f76a792..c82255d00 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -27,7 +27,7 @@ module UserScoreHelper issue_c = issue_c + Journal.where("user_id = ?", user.id).count ############################ memos = Memo.where('author_id = ? AND parent_id IS NOT NULL', user.id) - + memos.each do |m| if Memo.find(m.parent_id).author.id != user.id issue_c = issue_c + 1 @@ -35,18 +35,18 @@ module UserScoreHelper issue_c = issue_c - 1 end end - - + + pmemos = Memo.where('author_id = ? AND parent_id IS NULL', user.id) pmemos.each do |pm| issue_c = issue_c + pm.replies_count end ############################ - + issue_c = issue_c + JournalsForMessage.where('user_id = ? AND reply_id IS NOT NULL AND reply_id <> ?', user.id, user.id).count + JournalsForMessage.where('reply_id = ? AND user_id <> ?', user.id, user.id).count - - - + + + return issue_c end @@ -58,14 +58,14 @@ module UserScoreHelper def calculate_skill_count(user) - + praise_count_l0 = 0 praise_count_l1 = 0 praise_count_l2 = 0 tread_count_l0 = 0 tread_count_l1 = 0 tread_count_l2 = 0 - issues = Issue.where('author_id = ?', user.id) + issues = Issue.where('author_id = ?', user.id) issues.each do |i| pts = PraiseTread.where('praise_tread_object_id = ?', i.id) pts.each do |p| @@ -75,7 +75,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -97,7 +97,7 @@ module UserScoreHelper - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id) @@ -108,7 +108,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -127,7 +127,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id) @@ -138,7 +138,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -154,12 +154,12 @@ module UserScoreHelper else tread_count_l2 + tread_count_l2 + 1 end - end - end + end + end end - - - + + + # case level # when 0 skill_score = praise_count - 0.5 * tread_count # when 1 skill_score = 2 * praise_count - 1.5 * tread_count @@ -170,9 +170,9 @@ module UserScoreHelper skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f - + tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count - + skill_score = skill_score.to_f - tread_user_count.to_f @@ -182,17 +182,17 @@ module UserScoreHelper return skill_score - - - + + + end - + def calculate_level(user) commit_count = user.changesets.count max_praise_num = 0 - - - issues = Issue.where('author_id = ?', user.id) + + + issues = Issue.where('author_id = ?', user.id) issues.each do |i| ptcs = PraiseTreadCache.where('object_id = ?', i.id) ptcs.each do |p| @@ -201,7 +201,7 @@ module UserScoreHelper end end end - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTreadCache.where('object_id = ?', b.id) @@ -211,7 +211,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTreadCache.where('object_id = ?', c.id) @@ -219,12 +219,12 @@ module UserScoreHelper if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end - end + end end - - + + best_answer_num = 0 - + isManager = 0 members = Member.where('user_id = ?', user.id) members.each do |m| @@ -238,21 +238,21 @@ module UserScoreHelper end - + level = 0 - + if max_praise_num > 4 level = 1 end if commit_count > 0 and commit_count < 101 level = 1 - end + end if commit_count > 100 or isManager == 1 level = 2 end - + return level - + end def calculate_activity_count(user) @@ -282,23 +282,23 @@ module UserScoreHelper def calculate_issue(user) commit_count = user.changesets.count - + issue_details_count = 0 issues = Issue.where('assigned_to_id = ?', user.id) - + change_count = 0 issues.each do |issue| js = issue.journals js.each do |j| change_count = change_count + j.details.where("prop_key = ?", "done_ratio").count end - - + + issue_details_count = change_count + issue_details_count end - + return (commit_count + issue_details_count) - + end @@ -306,9 +306,9 @@ module UserScoreHelper attachments = Attachment.where("container_type IS NOT NULL AND container_type <> 'Issue' AND author_id = ?", user.id).count return attachments - + end - + def calculate_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -322,7 +322,7 @@ module UserScoreHelper UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, :activity => activity, :file => file, :issue => issue, :level => level) end - + def update_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -331,7 +331,7 @@ module UserScoreHelper issue = calculate_issue(user) ##activity = calculate_activity_count(user) - + level = calculate_level(user) user.user_score.update_attributes(:collaboration => collaboration, :influence => influence, :skill => skill, :activity => activity, :file => file, :issue => issue, :level => level) @@ -423,7 +423,7 @@ module UserScoreHelper #更新分数 def update_score(option_number) - option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number) + option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + project_active(option_number) if option_number.total_score < 0 option_number.total_score = 0 end @@ -433,7 +433,7 @@ module UserScoreHelper #协同得分 def collaboration(option_number) - option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo + option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo end #影响力得分 def influence(option_number) @@ -444,8 +444,8 @@ module UserScoreHelper option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 end #项目贡献得分 - def active(option_number) - option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2 + def project_active(option_number) + option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 end #更新发帖数 diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index e7ab001da..15eebc15e 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -52,6 +52,40 @@ module UsersHelper end end + def title_for_message type + case type + when nil + '消息' + when 'unviewed' + '未读消息' + when 'apply' + '用户申请' + when 'system_messages' + '系统消息' + when 'homework' + '作业消息' + when 'course_message' + '课程讨论' + when 'course_news' + '课程通知' + when 'issue' + '项目任务' + when 'forum' + '贴吧帖子' + when 'user_feedback' + '用户留言' + end + end + + # 统计未读消息数 + def unviewed_message(user) + course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count + forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count + user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + end + def user_mail_notification_options(user) user.valid_notification_options.collect {|o| [l(o.last), o.first]} end @@ -71,7 +105,7 @@ module UsersHelper def user_settings_tabs tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} - ] + ] if Group.all.any? tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} end @@ -83,7 +117,7 @@ module UsersHelper def get_users_by_tag(tag_name) User.tagged_with(tag_name).order('updated_on desc') end - + # added by fq # - + # TODO: 待删 # def show_activity(state) # content = ''.html_safe @@ -114,19 +148,19 @@ module UsersHelper # end # content_tag('div', content, :class => "pagination") # end - + #TODO: 待删 def watch_projects(state) content = ''.html_safe case state - when 0 - s = content_tag('span', l(:label_project_take), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) - when 1 - s = content_tag('span', l(:label_has_watched_project), :class => "current-page") - content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) - content << content_tag('li', s, :class => "current-page") + when 0 + s = content_tag('span', l(:label_project_take), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) + when 1 + s = content_tag('span', l(:label_has_watched_project), :class => "current-page") + content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) + content << content_tag('li', s, :class => "current-page") end content_tag('div', content, :class => "pagination") end @@ -134,59 +168,59 @@ module UsersHelper def user_course(state) content = ''.html_safe if @user != User.current - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', '他执教的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他发布的作业', :class => "current-page") - content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '他执教的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他发布的作业', :class => "current-page") + content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', '他的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他的作业', :class => "current-page") - content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '他的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他的作业', :class => "current-page") + content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end else - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', l(:label_teaching_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', l(:label_release_homework), :class => "current-page") - content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_teaching_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', l(:label_release_homework), :class => "current-page") + content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', l(:label_my_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '我的作业', :class => "current-page") - content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_my_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '我的作业', :class => "current-page") + content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end end @@ -196,42 +230,42 @@ module UsersHelper def sort_user(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs") - end - + end + def sort_user_enterprise(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs_enterprise") - end + end def gender_avatar_uri user img_uri = '/images/sidebar/female.png' @@ -256,7 +290,7 @@ module UsersHelper # people_ids += (members_to_user_ids(tmp)) unless tmp.nil? # end # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? - + false end @@ -290,7 +324,7 @@ module UsersHelper membership.collect { |e| memberships.push(e) } - ## 判断课程是否过期 [需封装] + ## 判断课程是否过期 [需封装] memberships_doing = [] memberships_done = [] memberships.map { |e| @@ -544,9 +578,13 @@ module UsersHelper #获取指定用户作为老师的课程 def get_as_teacher_courses user type = [] + option = [] + option << "请选择发布作业的课程" + option << -1 + type << option user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| option = [] - option << course.name + option << course.name+"("+course.time.to_s+course.term+")" option << course.id type << option end diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb index accbc90e2..fb8bf90af 100644 --- a/app/models/applied_project.rb +++ b/app/models/applied_project.rb @@ -1,8 +1,21 @@ class AppliedProject < ActiveRecord::Base attr_accessible :project_id, :user_id - belongs_to :user - belongs_to :project + belongs_to :user + belongs_to :project + has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + + after_create :send_appliled_message + + def send_appliled_message + # if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.project.members.each do |m| + if m.roles.first.to_s.include?("Manager") + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + # end + end #删除用户申请 def self.deleteappiled(userid, projectid) @@ -11,5 +24,4 @@ class AppliedProject < ActiveRecord::Base applied.destroy end end - end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f7fb9b1aa..47ab30cb1 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -73,7 +73,7 @@ class Attachment < ActiveRecord::Base cattr_accessor :thumbnails_storage_path @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") - before_save :files_to_final_location,:act_as_course_activity + before_save :files_to_final_location,:act_as_course_activity,:act_as_forge_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 diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 284687870..4e74142ad 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -14,12 +14,19 @@ class CourseActivity < ActiveRecord::Base if user_activity user_activity.save else - user_activity = UserActivity.new - user_activity.act_id = self.course_act_id - user_activity.act_type = self.course_act_type - user_activity.container_type = "Course" - user_activity.container_id = self.course_id - user_activity.save + if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? + user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.course_act.parent.id}").first + user_activity.created_at = self.created_at + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.course_act_id + user_activity.act_type = self.course_act_type + user_activity.container_type = "Course" + user_activity.container_id = self.course_id + user_activity.user_id = self.user_id + user_activity.save + end end end diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 4f62d24c2..eae880380 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -15,6 +15,8 @@ class CourseMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 9bc10bebf..c4f13c6d0 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -29,12 +29,19 @@ class ForgeActivity < ActiveRecord::Base if user_activity user_activity.save else - user_activity = UserActivity.new - user_activity.act_id = self.forge_act_id - user_activity.act_type = self.forge_act_type - user_activity.container_type = "Project" - user_activity.container_id = self.project_id - user_activity.save + if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? + user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.forge_act.parent.id}").first + user_activity.created_at = self.created_at + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.forge_act_id + user_activity.act_type = self.forge_act_type + user_activity.container_type = "Project" + user_activity.container_id = self.project_id + user_activity.user_id = self.user_id + user_activity.save + end end end diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index 2d05972ab..0c8b3384f 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -22,6 +22,8 @@ class ForgeMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 217c7d770..c1e5666ac 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -10,7 +10,7 @@ class HomeworkCommon < ActiveRecord::Base has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy has_many :homework_tests, :dependent => :destroy - has_many :student_works, :dependent => :destroy + has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 @@ -56,4 +56,10 @@ class HomeworkCommon < ActiveRecord::Base Mailer.run.homework_added(self) end + def is_program_homework? + self.homework_type == 2 && self.homework_detail_programing + end + + delegate :language_name, :language, :to => :homework_detail_programing + end diff --git a/app/models/homework_detail_programing.rb b/app/models/homework_detail_programing.rb index 4c7134806..f6286a45e 100644 --- a/app/models/homework_detail_programing.rb +++ b/app/models/homework_detail_programing.rb @@ -2,4 +2,8 @@ class HomeworkDetailPrograming < ActiveRecord::Base attr_accessible :language, :standard_code, :homework_common_id belongs_to :homework_common + + def language_name + %W(C C++).at(self.language.to_i - 1) + end end diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index df2848194..b4d8a4262 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -2,5 +2,4 @@ class HomeworkTest < ActiveRecord::Base attr_accessible :input, :output, :homework_common_id,:result,:error_msg belongs_to :homework_common - has_many :student_work_test end diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb index 4868fc3d7..66efc8609 100644 --- a/app/models/invite_list.rb +++ b/app/models/invite_list.rb @@ -1,5 +1,5 @@ class InviteList < ActiveRecord::Base - attr_accessible :project_id, :user_id + attr_accessible :project_id, :user_id, :mail belongs_to :user belongs_to :project diff --git a/app/models/issue.rb b/app/models/issue.rb index fa8cee988..2a6da44c5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -147,6 +147,13 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end + if self.tracker_id == 5 + self.project.members.each do |m| + if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + end end # 更新缺陷 @@ -1009,7 +1016,7 @@ class Issue < ActiveRecord::Base if leaf.start_date # Only move subtask if it starts at the same date as the parent # or if it starts before the given date - if start_date == leaf.start_date || date > leaf.start_date + if start_date == leaf.start_date || date > leaf.start_date leaf.reschedule_on!(date) end else @@ -1392,6 +1399,7 @@ class Issue < ActiveRecord::Base def attachment_added(obj) if @current_journal && @current_journal.user_id == obj.author_id && JournalDetail.find_all_by_value(obj.filename).count == 0 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) + end end @@ -1400,6 +1408,9 @@ class Issue < ActiveRecord::Base if @current_journal && !obj.new_record? @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :old_value => obj.filename) @current_journal.save + user_activity = UserActivity.where("act_type='Issue' and act_id =#{@current_journal.journalized_id}").first + user_activity.updated_at = Time.now + user_activity.save end end @@ -1506,6 +1517,9 @@ class Issue < ActiveRecord::Base } end @current_journal.save + user_activity = UserActivity.where("act_type='Issue' and act_id =#{@current_journal.journalized_id}").first + user_activity.updated_at = Time.now + user_activity.save # reset current journal init_journal @current_journal.user, @current_journal.notes end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 6f775e7a2..81ada2f80 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -190,36 +190,68 @@ class JournalsForMessage < ActiveRecord::Base end end - # 课程作品留言消息通知 + # 课程/作品回复 留言消息通知 def act_as_course_message if self.jour_type == 'StudentWorksScore' if self.user_id != self.jour.user_id self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id, :viewed => false) end end + # 课程留言 + if self.jour_type == 'Course' + receivers = [] + teachers = [] + # 获取课程的老师 + self.jour.members.each do |m| + if m.user.allowed_to?(:as_teacher, self.jour) + teachers << m + end + end + if self.reply_id == 0 # 主留言,即不是回复某条留言 + teachers.each do |teacher| + if teacher.user_id != self.user_id + receivers << teacher.user_id + end + end + else # 留言回复 + reply_to = User.find(self.reply_id) + if self.user_id != self.reply_id # 添加我回复的那个人 + receivers << reply_to.id + end + # 给老师发送。 过滤条件:老师自己给自己发;回复对象为老师则排除改老师 + teachers.each do |teacher| + if teacher.user_id != self.user_id && self.reply_id != teacher.user_id + receivers << teacher.user_id + end + end + end + receivers.each do |r| + self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false) + end + end end # 用户留言消息通知 def act_as_user_feedback_message # 主留言 - receivers = [] - if self.reply_id == 0 - if self.user_id != self.jour_id # 过滤自己给自己的留言消息 - receivers << self.jour - end - else # 留言回复 - reply_to = User.find(self.reply_id) - if self.user_id != self.reply_id # 添加我回复的那个人 - receivers << reply_to - end - if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 - receivers << self.parent.jour - end - end if self.jour_type == 'Principal' - receivers.each do |r| - self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + receivers = [] + if self.reply_id == 0 + if self.user_id != self.jour_id # 过滤自己给自己的留言消息 + receivers << self.jour end + else # 留言回复 + reply_to = User.find(self.reply_id) + if self.user_id != self.reply_id # 添加我回复的那个人 + receivers << reply_to + end + if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 + receivers << self.parent.jour + end + end + receivers.each do |r| + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + end end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a25aff6bb..c9ab6e58e 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -34,8 +34,10 @@ class Mailer < ActionMailer::Base end def method_missing(name, *args, &block) if Setting.delayjob_enabled? && Object.const_defined?('Delayed') + # with delayed_job @target.delay.send(name, *args, &block) else + # without delayed_job @target.send(name, *args, &block).deliver end end @@ -46,9 +48,9 @@ class Mailer < ActionMailer::Base end # author: alan - # 发送邀请未注册用户加入项目邮件 + # 邀请未注册用户加入项目 # 功能: 在加入项目的同时自动注册用户 - def send_invite_in_project(email, project, invitor) + def send_invite_in_project(email, project, invitor) @email = email @subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} " @password = newpass(6) @@ -57,8 +59,8 @@ class Mailer < ActionMailer::Base login = login.sub(/%40/,'@') us = UsersService.new # 自动激活用户 - user = us.register_auto(login, @email, @password) - InviteList.create(:user_id => user.id, :project_id => project.id) + user = us.register_auto(login, email, @password) + InviteList.create(:user_id => user.id, :project_id => project.id, :mail =>email) User.current = user unless User.current.nil? @user = user @token = Token.get_token_from_user(user, 'autologin') @@ -74,15 +76,22 @@ class Mailer < ActionMailer::Base @project_name = "#{project.name}" @user = user @project = project - inviter_lists = InviteList.where(project_id:@project.id, user_id:@user.id).all - if inviter_lists.blank? - InviteList.create(:user_id => user.id, :project_id => project.id) + if InviteList.where("project_id= ? and user_id =? and mail =?", project.id, @user.id, email).first.nil? + InviteList.create(:user_id => user.id, :project_id => project.id, :mail => email) end @token = Token.get_token_from_user(user, 'autologin') @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) + # 发送消息邀请 + send_message(user,project) + # end mail :to => email, :subject => @subject end + # 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况) + def send_message(user, project) + ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "Project_Invite",:forge_message_id => User.current.id, :viewed => false) + end + # author: alan # 根据用户选择发送个人日报或周报 # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言 @@ -206,6 +215,20 @@ class Mailer < ActionMailer::Base mail :to => user.mail,:subject => subject if has_content end + # 作业截止时间邮件提醒 + def homework_endtime__added(homework_common, user_id) + user = User.find(user_id) + @subject = "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} " + @token = Token.get_token_from_user(user, 'autologin') + @homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + @homework_endtime_name = homework_common.name + @author = homework_common.user + #收件人邮箱 + recipient = user.mail + mail :to => recipient, + :subject => "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} " + end + # 公共讨论区发帖、回帖添加邮件发送信息 def forum_message_added(memo) @memo = memo diff --git a/app/models/member.rb b/app/models/member.rb index 292dd2034..655c79895 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -30,6 +30,9 @@ class Member < ActiveRecord::Base validate :validate_role before_destroy :set_issue_category_nil + # 删除项目成员一并删除该成员的邀请记录 + after_destroy :delete_ivite_list + def role end @@ -97,6 +100,16 @@ class Member < ActiveRecord::Base end end + # 删除成员一并删除该成员的邀请信息 + def delete_ivite_list + member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id) + unless member_invite_lists.nil? + member_invite_lists.each do |member_invite_list| + member_invite_list.destroy + end + end + end + # Find or initilize a Member with an id, attributes, and for a Principal def self.edit_membership(id, new_attributes, principal=nil) @membership = id.present? ? Member.find(id) : Member.new(:principal => principal) diff --git a/app/models/memo_message.rb b/app/models/memo_message.rb index 9be00ce14..ce3896389 100644 --- a/app/models/memo_message.rb +++ b/app/models/memo_message.rb @@ -12,6 +12,8 @@ class MemoMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/news.rb b/app/models/news.rb index 6e2725d1c..a9e9d1d18 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -121,7 +121,7 @@ class News < ActiveRecord::Base # Description 公用表中也要记录 def act_as_forge_activity # 如果是project为空,那么是课程相关的,不需要保存 - if !self.project.nil? + if self.project self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.project.id) end diff --git a/app/models/onclick_time.rb b/app/models/onclick_time.rb new file mode 100644 index 000000000..c62a9274c --- /dev/null +++ b/app/models/onclick_time.rb @@ -0,0 +1,5 @@ +class OnclickTime < ActiveRecord::Base + attr_accessible :onclick_time, :user_id + + belongs_to :user +end diff --git a/app/models/project.rb b/app/models/project.rb index 0618dd145..0cd6af35b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -66,8 +66,8 @@ class Project < ActiveRecord::Base # has_many :students_for_courses, :dependent => :destroy has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy - has_many :applied_projects - has_many :invite_lists + has_many :applied_projects, :dependent => :destroy + has_many :invite_lists, :dependent => :destroy has_one :dts # end diff --git a/app/models/query.rb b/app/models/query.rb index 19bd1bed5..65c78e71f 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -492,26 +492,29 @@ class Query < ActiveRecord::Base def project_statement project_clauses = [] - if project && !project.descendants.active.empty? - ids = [project.id] - if has_filter?("subproject_id") - case operator_for("subproject_id") - when '=' - # include the selected subprojects - ids += values_for("subproject_id").each(&:to_i) - when '!*' - # main project only - else - # all subprojects - ids += project.descendants.collect(&:id) - end - elsif Setting.display_subprojects_issues? - ids += project.descendants.collect(&:id) - end - project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') - elsif project - project_clauses << "#{Project.table_name}.id = %d" % project.id + # unless project.descendants.blank? + # if project && project.descendants && project.descendants.active && !project.descendants.active.empty? + # ids = [project.id] + # if has_filter?("subproject_id") + # case operator_for("subproject_id") + # when '=' + # # include the selected subprojects + # ids += values_for("subproject_id").each(&:to_i) + # when '!*' + # # main project only + # else + # # all subprojects + # ids += project.descendants.collect(&:id) + # end + # elsif Setting.display_subprojects_issues? + # ids += project.descendants.collect(&:id) + # end + # project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') + # elsif project + if project + project_clauses << "#{Project.table_name}.id = %d" % project.id end + # end project_clauses.any? ? project_clauses.join(' AND ') : nil end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index b95c11c11..cd4d81a32 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -1,19 +1,139 @@ #学生提交作品表 class StudentWork < ActiveRecord::Base - attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test belongs_to :homework_common belongs_to :user has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project - has_many :student_work_test + has_many :student_work_tests, order: 'id desc' before_destroy :delete_praise + before_save :set_program_score, :set_src acts_as_attachable def delete_praise PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all end + + def last_test + student_work_tests.order('id desc').first + end + + private + def set_program_score + if homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 + #根据最后一次测试计算得分 + unless last_test + self.system_score = 0 + else + self.system_score = last_test.test_score + end + end + set_final_score self.homework_common,self + end + def set_src + self.description = last_test.src if last_test + end + + #成绩计算 + def set_final_score homework,student_work + if homework && homework.homework_detail_manual + if homework.homework_type == 1 #匿评作业 + if homework.teacher_priority == 1 #教师优先 + if student_work.teacher_score + student_work.final_score = student_work.teacher_score + else + if 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 + else + ta_proportion = homework.homework_detail_manual.ta_proportion + final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_ta_score + final_s_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + else #不考虑教师评分 + if 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 + else + ta_proportion = homework.homework_detail_manual.ta_proportion + final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}") + final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_ta_score + final_s_score + student_work.final_score = format("%.2f",final_score.to_f) + 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 + else + if student_work.teaching_asistant_score.nil? #教辅未评分 + if student_work.student_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + elsif student_work.student_score.nil? #学生未评分 + if student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_ts_score + student_work.final_score = format("%.2f",final_score.to_f) + end + else + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) + final_score = final_sy_score + final_ts_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + else #不考虑教师评分 + if student_work.teaching_asistant_score.nil? #教辅未评分 + if student_work.student_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + elsif student_work.student_score.nil? #学生未评分 + if student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.system_score + else + ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2 + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}")) + final_score = final_sy_score + final_ts_score + student_work.final_score = format("%.2f",final_score.to_f) + end + else + final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") + final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}") + final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")) + final_score = final_sy_score + final_ts_score + final_st_score + student_work.final_score = format("%.2f",final_score.to_f) + end + end + end + end + end end diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 413528b82..1cfb7f8b2 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -1,12 +1,12 @@ # encoding: utf-8 class StudentWorkTest < ActiveRecord::Base - attr_accessible :student_work_id, :homework_test_id, :result, :error_msg - - belongs_to :homework_test + attr_accessible :student_work_id, :results, :status, :src belongs_to :student_work + serialize :results, Array + def status_to_s - case self.result.to_i + case self.status.to_i when -1 '编译出错' when -2 @@ -33,10 +33,20 @@ class StudentWorkTest < ActiveRecord::Base end def test_score - if self.result.to_i == 0 - format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count) - else + if self.status.to_i == 0 + 100 + elsif self.results.empty? 0 + else + get_success_count * 100 / self.results.count end end + + private + def get_success_count + self.results.inject(0) do |sum, result| + sum += (result["status"].to_i == 0 ? 1 : 0) + end || 0 + end + end diff --git a/app/models/system_message.rb b/app/models/system_message.rb new file mode 100644 index 000000000..2a810e8b8 --- /dev/null +++ b/app/models/system_message.rb @@ -0,0 +1,8 @@ +class SystemMessage < ActiveRecord::Base + attr_accessible :content, :id, :user_id, :description, :subject + belongs_to :user + + validates :subject, presence: true + # validates :description, presence: true + validates_length_of :description, maximum: 10000 +end diff --git a/app/models/user.rb b/app/models/user.rb index b08b29981..48b269e6e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,13 +132,15 @@ class User < Principal has_many :course_messages has_many :memo_messages has_many :user_feedback_messages + has_one :onclick_time + has_many :system_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"' has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"' # 邮件邀请状态 - # has_many :invite_lists + has_many :invite_lists, :dependent => :destroy # end ######added by nie @@ -209,8 +211,10 @@ class User < Principal before_save :update_hashed_password before_destroy :remove_references_before_destroy # added by fq - after_create :act_as_activity + after_create :act_as_activity, :add_onclick_time # end + # 更新邮箱用户或用户名的同事,同步更新邀请信息 + after_update :update_invite_list scope :in_group, lambda {|group| group_id = group.is_a?(Group) ? group.id : group.to_i @@ -257,11 +261,18 @@ class User < Principal # 新消息统计 def count_new_message - course_count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count - forge_count = ForgeMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_memo_count = MemoMessage.where("user_id =? and viewed =?", User.current.id, 0).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + if OnclickTime.where("user_id =?", User.current).first.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on + message_new_time.save + end + 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 + system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count end # 查询指派给我的缺陷记录 @@ -994,6 +1005,23 @@ class User < Principal self.acts << Activity.new(:user_id => self.id) end + # 注册用户的时候消息默认点击时间为用户创建时间 + def add_onclick_time + if OnclickTime.where("user_id =?" , self.id).first.nil? + OnclickTime.create(:user_id => self.id, :onclick_time => self.created_on) + end + end + + # 更新邮箱的同事,更新invite_lists表中的邮箱信息 + def update_invite_list + invite_lists = InviteList.where("user_id =?",self.id).all + unless invite_lists.blank? + invite_lists.each do |invite_list| + invite_list.update_attribute(:mail, self.mail) + end + end + end + # Removes references that are not handled by associations # Things that are not deleted are reassociated with the anonymous user def remove_references_before_destroy diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb index 1dda157d6..db7d3a384 100644 --- a/app/models/user_feedback_message.rb +++ b/app/models/user_feedback_message.rb @@ -8,9 +8,11 @@ class UserFeedbackMessage < ActiveRecord::Base validates :user_id,presence: true validates :journals_for_message_id,presence: true validates :journals_for_message_type, presence: true - after_create :add_user_message + after_save :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/views/account/about_us.html.erb b/app/views/account/about_us.html.erb new file mode 100644 index 000000000..f990cd64c --- /dev/null +++ b/app/views/account/about_us.html.erb @@ -0,0 +1,50 @@ +<%= stylesheet_link_tag 'new_user'%> +
+

关于我们

+
+

+ Trustie是一个面向高校创新实践的在线协作社区,是在中国高校推行大规模开放在线研究(Massive Open Online Research, MOORE)的支撑平台,也简称Trustie平台。老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。 +

+

+ MOORE是国防科学技术大学杨学军院士提出的一个面向高校科研教学活动的新型创新实践概念,为全面支持高校人才培养和科学研究提供了一种新思路。MOORE是对大规模在线开放课程(Massive Open Online Course, MOOC)的拓展,是课堂教学与创新实践深度结合的全新模式,可以看作MOOC2.0。 +

+

+ 2005年开始,Trustie研制团队围绕网络时代的软件开发效率和质量这一核心问题展开研究,经过十年的磨砺与攻关,逐步揭示出以大众化协同开发、开放式资源共享、持续性可信评估为核心的互联网大规模协同机理,提出了全新的软件开发群体化方法。2008年起,研制团队开始探索如何将这种协同机理引入软件人才培养。MOORE概念的提出为研制团队的人才培养实践提供了新的发展方向和应用模式,使Trustie技术和工具能够更直接、更有效地与高校人才培养对接,形成了今天已被大量师生接受的在线人才培养平台。 +

+

+ 研制团队认为MOORE的创新人才培养模式(如图1左图)是将互联网大规模协同机理与高校创新实践活动相结合的全新人才培养方法和模式,研制团队并基于本平台的架构形成了对MOORE核心机理的三方面认识(如图1右图)。 +

+
+ +

图1 基于MOORE的创新人才培养模式与核心机理

+
+

+ 目前,Trustie平台已经初步展现出大规模开放在线研究的生态系统蓝图,其核心是在线教学实践平台和在线协同研究平台,如图2。Trustie在线教学实践平台是支持教师和学生围绕课堂学习开展实践的平台(如图2),Trustie在线协同研究平台是支持开发小组围绕实践任务或研究工作开展分布式协作的平台(如图2)。两个核心平台为一名"新手"大学生成长为具有一定创新能力的"创客"提供了从学习到研究的一个渐进式成长环境(如图2)。 +

+

+ 特别是,根据师生的实际需要,Trustie平台提供了私有模式和公开模式,支持针对未公开成果实施有效知识产权保护为前提的交流分享(如图2)。随着越来越多的高校、课程和研究小组的加入,MOORE创新实践模式的生态效益将不断显现出来。 +

+
+ +

图2 基于MOORE的支撑平台和生态系统

+
+

+ 研制团队特别感谢高校老师和学生的积极反馈、无私创意。平台的很多实用便捷的功能都是老师们积极参与和设计的结果,汇聚了大量师生的宝贵贡献,是研制团队和用户群体共同成长的结果。 +

+

+ Trustie平台的基本思路是将开源模式与中国高校人才培养活动相结合,但其本质上是一种O2O(Online To Offline)的创新人才培养模式,只有在以下两个方面同步推进,才能在持续解决实际需求的过程中快速发展:
+     (1)构建实践平台,激活创新能力:成为支持不同规模的团队进行协同研究和协同开发的实践平台,支持各类可公开的课程实验任务、教研室科研任务的在线协同,能够有效提升和评估学生的创新能力、协作能力和实践能力。
+     (2)引入开源理念,形成创客文化:将互联网开源软件运动中的自由、对等、共享、创新的理念引入高校,使"自主创意并亲自动手实现创意"的创客精神深入人才培养活动,在学生群体中形成大胆创意、大胆实践的创新文化。 +

+

+ 研制团队认为,Trustie平台是一种"互联网+"思维在高校教育领域的大型探索性实践。作为一种互联网应用,Trustie平台自身的开发也采取了互联网模式:Trustie研制团队采用了"网构化软件开发模式",坚持"每周一更"的快速上线、快速体验模式,以最大程度上贴近用户实际需求提升。欢迎高校师生一同投身创新实践,共同见证MOORE创新生态的早日形成。 +

+
+ + + +
+ + + + diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 56f2c5454..ed43f455a 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -1,286 +1,286 @@ -<%= stylesheet_link_tag 'new_user'%> -<%= stylesheet_link_tag 'leftside'%> - - -
-
-
- -
欢迎加入Trustie高校创新实践社区!老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。Trustie是在中国推行大规模开放在线研究模式(MOORE)的支撑平台。
-
-
-
-
-
-
    -
  • 登录
  • -
  • -
-
-
<%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %>
-
-
- - <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> - <%= back_url_hidden_field_tag %> -
- <%= text_field_tag 'username', params[:username], :tabindex => '1' , - :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> - -
- <% if Setting.openid? %> -
- <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> -
- <% end %> -
- - <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> -
-
- <% if Setting.autologin? %> -
- <%= check_box_tag 'autologin', 1, true, :tabindex => 4 %> -
- <%= l(:label_stay_logged_in) %> - <% end %> - - <% if Setting.lost_password? %> - 忘记密码? - <% end %> -
- <% end %> -
- 登录 -
- -
- -
-
-
-
    -
  • 注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %> -
  • -
-
-
- <%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %> - <%= error_messages_for 'user' %> -
- - <%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%> - -
-
- - <%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %> - -
-
- - <%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %> - -
-
- - <%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%> - -
-
-
- -
- 我已阅读并接受Trustie服务协议条款
-
- 注册 - -
- <% end %> -
-
-
-
-
-
+<%= stylesheet_link_tag 'new_user'%> +<%= stylesheet_link_tag 'leftside'%> + + +
+
+
+ +
  欢迎加入Trustie高校创新实践社区!老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。

  Trustie是在中国推行大规模开放在线研究模式(MOORE)的支撑平台。
+
+
+
+
+
+
    +
  • 登录
  • +
  • +
+
+
<%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %>
+
+
+ + <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> + <%= back_url_hidden_field_tag %> +
+ <%= text_field_tag 'username', params[:username], :tabindex => '1' , + :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> + +
+ <% if Setting.openid? %> +
+ <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> +
+ <% end %> +
+ + <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> +
+
+ <% if Setting.autologin? %> +
+ <%= check_box_tag 'autologin', 1, true, :tabindex => 4 %> +
+ <%= l(:label_stay_logged_in) %> + <% end %> + + <% if Setting.lost_password? %> + 忘记密码? + <% end %> +
+ <% end %> +
+ 登录 +
+ +
+ +
+
+
+
    +
  • 注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %> +
  • +
+
+
+ <%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %> + <%= error_messages_for 'user' %> +
+ + <%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%> + +
+
+ + <%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %> + +
+
+ + <%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %> + +
+
+ + <%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%> + +
+
+
+ +
+ 我已阅读并接受Trustie服务协议条款
+
+ 注册 + +
+ <% end %> +
+
+
+
+
+
diff --git a/app/views/account/lost_password.html.erb b/app/views/account/lost_password.html.erb index 0e4ddd1ff..5bf93fd14 100644 --- a/app/views/account/lost_password.html.erb +++ b/app/views/account/lost_password.html.erb @@ -1,6 +1,6 @@ <%= stylesheet_link_tag 'new_user'%> -
+

忘记密码

@@ -9,7 +9,7 @@ <%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱',:class=>'NomalInput mb20'%> <% if flash[:error] %> -

<%= flash[:error]%>

+

<%= flash[:error]%>

<% elsif flash[:notice] %>

<%= flash[:notice]%>

diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb index 89514726a..28ef8091e 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -54,7 +54,7 @@ <%=@count %> - <%=format_date(user.last_login_on) %> + <%=format_time(user.last_login_on) %> <%=user.id %> @@ -70,18 +70,20 @@ <%=link_to(user.login, user_path(user)) %> - <% case user.user_extensions.identity %> - <% when 0 %> - <%='老师' %> - <% when 1 %> - <%='学生' %> - <% when 2 %> - <%='企业' %> - <% when 3 %> - <%='开发者' %> - <% else %> - <%='未知身份' %> - <% end %> + <%if user.user_extensions%> + <% case user.user_extensions.identity %> + <% when 0 %> + <%='老师' %> + <% when 1 %> + <%='学生' %> + <% when 2 %> + <%='企业' %> + <% when 3 %> + <%='开发者' %> + <% else %> + <%='未知身份' %> + <% end %> + <% end%> <% end %> diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb new file mode 100644 index 000000000..f87741dd9 --- /dev/null +++ b/app/views/admin/messages.html.erb @@ -0,0 +1,64 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +

+ <%=l(:label_system_message)%> +


+
+ <%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %> +
  • + + +

    +
  • +
  • + + <%= f.kindeditor :description,:width=>'87.5%',:editor_id=>'system_message_editor' %> +

    +
  • +
    +

    +
    +
    + <%= link_to l(:label_submit), "javascript:void(0)", :class => "btn_message_free", :onclick => "system_message_editor.sync();submit_message();" %> +
    + <% end %> +
    + + diff --git a/app/views/attachments/_new_form.html.erb b/app/views/attachments/_new_form.html.erb index 38b471897..47f6fd202 100644 --- a/app/views/attachments/_new_form.html.erb +++ b/app/views/attachments/_new_form.html.erb @@ -23,6 +23,7 @@ <% end %> <% end %> +
    <% project = project %> <%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %> diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index da3d19267..554702d97 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -1,4 +1,5 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'prettify','/assets/kindeditor/pasteimg' %> +<%= stylesheet_link_tag 'prettify'%> <%= labelled_form_for @bid,:html => { :multipart => true } do |f| %> <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %> <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index b8bbf3d63..f117acd7f 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -37,7 +37,7 @@ <% @topics.each do |topic| %>
    <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> -
    +
    <% author = topic.author.to_s %>
    <%= link_to User.current.member_of_course?(@board.course) ? "#{topic.author.show_name}(#{topic.author.login})" : "#{topic.author}" , user_path(topic.author), @@ -48,7 +48,7 @@

      <%= h(topic.subject) %>

    <% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> <% end %> @@ -120,7 +120,7 @@ <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %>
    - <%= l(:button_reply) %> + <%= l(:button_reply) %>
    @@ -171,7 +171,7 @@

    - <%= format_time(message.created_on) %> + <%= format_time(message.created_on) %> <%= link_to( l(:button_delete), @@ -179,13 +179,13 @@ :method => :post, :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete), - :class => ' c_dblue fr f14' + :class => ' linkBlue fr f12' ) if message.course_destroyable_by?(User.current) %> <%= link_to( l(:button_reply), 'javascript:;', :nhname =>'showbtn_child_reply', - :class => ' c_dblue fr f14', + :class => ' linkBlue fr f12', :style => 'margin-right: 10px;', 'data-topic-id' =>message.id, :title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %> diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 609294161..a9c0e9101 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -82,13 +82,19 @@ function nh_init_board(params){ var editor = params.kindutil.create(params.textarea, { // allowPreviewEmoticons : false, // allowImageUpload : false, + autoHeightMode : true, resizeType : 1,minWidth:"1px",width:"560px",height:"150px", allowFileManager:true,uploadJson:"/kindeditor/upload", fileManagerJson:"/kindeditor/filemanager", afterChange:function(){//按键事件 nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); +// var edit = this.edit; +// var body = edit.doc.body; +// edit.iframe.height(minHeight); +// this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 30, minHeight)); }, afterCreate:function(){ + this.loadPlugin("autoheight"); var userAgent = navigator.userAgent.toLowerCase(); if(/trident/.test(userAgent)){ $("div.talk_new .ke-container").css({'margin-left':'0px'}); diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 000000000..51cb4458e --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); + +init_activity_KindEditor_data('<%= @user_activity_id%>',"","85%"); diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index cedc05f4b..12dd67c91 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -10,10 +10,13 @@ div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} div.recall_con{width:570px;} div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} + /*.ke-container{height: 80px !important;}*/ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> -
    - <%# reply_allow = JournalsForMessage.create_by_user? User.current %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> + +

    <%= l(:label_leave_message) %>

    <% if !User.current.logged?%> @@ -23,21 +26,15 @@
    <% else %> - <%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%#= f.kindeditor 'course_message',:height => '140px;',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", - :placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%> - -

    - <% end %> -
    -
    -
    - 取  消 - - <%= l(:button_leave_meassge)%> - +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_course_message'},:method => "post") do |f|%> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + +

    +
    + 取消 + 留言 + <% end%>
    <% end %>
    @@ -54,106 +51,6 @@ diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index 70e943e99..864509546 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -5,7 +5,7 @@
    <%= link_to image_tag(url_to_avatar(journal.user),:width => '46',:height => '46'), user_path(journal.user) %>
    -
    +
    diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 934a4eb33..4cc8b9fbf 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -57,6 +57,8 @@ :id => 'new-watcher-form') do %>
    • + + 课 程 ID: diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 8c7a41ddc..d2c17917e 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -5,6 +5,8 @@
        <%= labelled_form_for @course do |f| %>
      • + + diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb index c19f9821a..e7f344df2 100644 --- a/app/views/courses/search.html.erb +++ b/app/views/courses/search.html.erb @@ -20,12 +20,12 @@ <% end %> <% end %> - + diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 4ca8d3d43..a462db79d 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -20,6 +20,8 @@
      • + + diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index aefa1a5a9..fa15c1fc7 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -223,6 +223,54 @@ }); } + var tagNameHtml; //当前双击的链接的父节点的html + var tagName; //标签的值 + var parentCssBorder; //当前双击的链接的父节点 + var ele; //当前双击的链接 + var tagId; //标签的id + var taggableType; //被标签的类型 + function rename_tag(domEle,name,id,type){ + if(domEle.children().get(0) != undefined ){ //已经是编辑框的情况下不要动 + return; + } + tagNameHtml = domEle.parent().html() + tagName = name; + parentCssBorder = domEle.parent().css("border"); + ele = domEle; + tagId = id; + taggableType = type; + domEle.html(''); + domEle.parent().css("border","1px solid #ffffff"); + $("#renameTagName").focus(); + } + //监听所有的单击事件 + $(document.body).click(function(e){ + node = document.elementFromPoint(e.clientX, e.clientY); + if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了 + return; + } + if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态 + if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态 + ele.parent().css("border",""); + ele.parent().html(tagNameHtml); + + }else{ //否则就要更新tag名称了 + if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ + $.post( + '<%= update_tag_name_path %>', + {"taggableId":tagId,"taggableType":taggableType,"tagName":tagName,"renameName":$("#renameTagName").val().trim()} +// function(data){ +// ele.parent().css("border",""); +// ele.parent().html(tagNameHtml); +// } + ) + }else{ + ele.parent().css("border",""); + ele.parent().html(tagNameHtml); + } + } + } + }); diff --git a/app/views/homework_common/_new_homework_detail_manual_form.html.erb b/app/views/homework_common/_new_homework_detail_manual_form.html.erb new file mode 100644 index 000000000..af5a8bf50 --- /dev/null +++ b/app/views/homework_common/_new_homework_detail_manual_form.html.erb @@ -0,0 +1,74 @@ +
        +
        +
        +
        发布作业
        +
        +
        +
        + +
        +
        + 导入作业 + +
        + +
        +
        +
        +
        + <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor' %> + <% end %> +
        +
        + +
        + + +
        + 高级功能 +
        +
        +
        + +
        + 发布 + <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'fr mr10 mt3'%> +
        +
        +
        +
        + +
        + + + diff --git a/app/views/homework_common/alert_anonymous_comment.js.erb b/app/views/homework_common/alert_anonymous_comment.js.erb index 2b3248dc2..1c354aa45 100644 --- a/app/views/homework_common/alert_anonymous_comment.js.erb +++ b/app/views/homework_common/alert_anonymous_comment.js.erb @@ -3,5 +3,4 @@ showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); -$('#ajax-modal').parent().css("top","").css("left",""); -$('#ajax-modal').parent().addClass("anonymos"); \ No newline at end of file +$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed"); \ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 5b65b5982..d6815a00a 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -1,24 +1,23 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> -<%= error_messages_for 'homework_common' %> - -
        -

        - <%= l(:label_course_homework_edit)%> -

        + +
        +
        编辑作业
        -
        - <%if @homework.homework_type == 2%> - <%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_detail_programing_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> - <% else %> - <%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> - 提交 - <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> - <% end%> - <% end%> -
        + + +
        + <%= form_for @homework do |f| %> +
        + <%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> +
        + <% end%> +
        diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 4a804ae60..d7723452b 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -9,7 +9,7 @@ <%= @obj_count%> <%= l(:label_homework_count)%>

        - <%= link_to( l(:label_course_homework_new), new_homework_common_path(:course => @course.id), :class => 'problem_new_btn fl c_dorange') if @is_teacher %> + <%#= link_to( l(:label_course_homework_new), new_homework_common_path(:course => @course.id), :class => 'problem_new_btn fl c_dorange') if @is_teacher %>
        <% @homeworks.each do |homework|%> @@ -98,17 +98,17 @@
        <% end%> -
        + <%= l(:label_end_time)%>:<%= homework.end_time%> <% if betweentime(homework.end_time) < 0 %> diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb index e84d0f87a..7ed852fea 100644 --- a/app/views/homework_common/next_step.html.erb +++ b/app/views/homework_common/next_step.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= error_messages_for 'homework_common' %>

        diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb index 5f27a5b82..b0424bf7a 100644 --- a/app/views/homework_common/start_anonymous_comment.js.erb +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -1,6 +1,6 @@ <% if @statue == 1%> alert('启动成功'); -$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>'); +$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>'); <% elsif @statue == 2 %> alert('启动失败\n作业总数大于等于2份时才能启动匿评'); <% elsif @statue == 3%> diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb index 9a6131c64..3cbac1bf6 100644 --- a/app/views/homework_common/stop_anonymous_comment.js.erb +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -1,2 +1,2 @@ -$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith('匿评结束'); +$("#<%= @homework.id %>_stop_anonymous_comment").replaceWith('匿评结束'); alert('关闭成功'); \ No newline at end of file diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb new file mode 100644 index 000000000..edc722dbc --- /dev/null +++ b/app/views/issues/add_journal.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); + +init_activity_KindEditor_data(<%= @user_activity_id%>,"","85%"); \ No newline at end of file diff --git a/app/views/journals/diff.html.erb b/app/views/journals/diff.html.erb index 190459b71..b842d87d0 100644 --- a/app/views/journals/diff.html.erb +++ b/app/views/journals/diff.html.erb @@ -1,8 +1,8 @@

        <%=h @issue.tracker %> #<%= @issue.id %>

        由<%= @journal.user %> 更新于 <%= format_time @journal.created_on %>

        -
        - <%= simple_format_without_paragraph @diff.to_html %> +
        + <%= @diff.to_html.gsub("<","<").gsub(">",">").gsub(""","\"").gsub("&gt;", ">").gsub("&lt;", "<").gsub("&quot;", "\"").html_safe %>

        <%= link_to l(:button_back), issue_path(@issue), :onclick => 'history.back(); return false;' %>

        diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 720ff3e8f..812873045 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -1,11 +1,11 @@ -
      • <%= l(:mail_issue_content)%> -

        <%= @invitor_name %> 邀请您加入项目:<%= @project_name %>

        +

        <%= @invitor_name %> 邀请您加入项目:<%=link_to @project_name, project_url(@project) %>

        -

        点击“同意加入”按钮,即可快速加入项目!


        +

        点击“同意加入”按钮,即可快速加入项目,查看项目相关信息!


        diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb index ec559732f..54435e9ef 100644 --- a/app/views/mailer/send_invite_in_project.html.erb +++ b/app/views/mailer/send_invite_in_project.html.erb @@ -1,7 +1,5 @@ -
          -
        • <%= l(:mail_issue_content)%>

          <%= @subject %>

          @@ -9,13 +7,9 @@

          <%= link_to @project_url, @project_url%>

          您的账号为:<%= @email %>

          密码为: <%= @password %>

          - +

          为了您的账号安全,请勿将邮件信息告知他人!

        • -
        -
        -
        - - +
    \ No newline at end of file diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb new file mode 100644 index 000000000..3d4878cf7 --- /dev/null +++ b/app/views/messages/reply.js.erb @@ -0,0 +1,6 @@ +<%if @project%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +<%elsif @course%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +<%end%> +init_activity_KindEditor_data(<%= @user_activity_id%>,"","85%"); \ No newline at end of file diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 688d7e2ac..0e36d5fd9 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -213,6 +213,7 @@ <% occupation1 = User.current.user_extensions.occupation %> <% occupation = User.current.user_extensions.occupation %> <% title = User.current.user_extensions.technical_title %> + <% gender = User.current.user_extensions.gender %> <% language = User.current.language %> <% else %> <% province = "湖南省" %> @@ -510,6 +511,13 @@ } } } + function init_gender(pField, gender) { + for (var i=0; i" init_identity_and_title(document.getElementById('userIdentity'), identity, document.getElementById('userTechnical_title'), title, language); + //sex + var gender = "<%= "#{gender}" %>" + init_gender(document.getElementById('gender'), gender); + $("#userIdentity").change(); <% if( !@act.nil? && @act == 'password') %> $("#users_tb_2").click(); diff --git a/app/views/my/save_user_avatar.js.erb b/app/views/my/save_user_avatar.js.erb index 03608a768..1e24a4a7c 100644 --- a/app/views/my/save_user_avatar.js.erb +++ b/app/views/my/save_user_avatar.js.erb @@ -1,3 +1,3 @@ -$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:90px;height:90px;overflow:hidden",:alt=>"头像") %>'); +$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:78px;height:78px;overflow:hidden",:alt=>"头像") %>'); $("#nh_user_logo").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_logo',:width =>"40",:height => "40",:alt=>"头像") %>'); hideModal(); \ No newline at end of file diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 6d4e915ea..0a5488714 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -27,7 +27,7 @@ <%= render :partial => 'attachments/new_form', :locals => {:container => @news} %>
    -
  • +
  • <% if is_new %> <%= link_to l(:button_create), "javascript:void(0)", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %> <%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %> diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index f39eb8266..9ae951779 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -32,7 +32,8 @@ <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> <%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>
  • -

    +

    +

    <%= l(:label_cancel_with_space) %> @@ -48,7 +49,7 @@ <% comments.each do |comment| %> <% next if comment.new_record? %>

    -
    <%= link_to image_tag(url_to_avatar(comment.author),:width => 42,:height => 42), user_path(comment.author)%>
    +
    <%= link_to image_tag(url_to_avatar(comment.author),:width => 42,:height => 42), user_path(comment.author), :class => "problem_pic fl"%>
    <%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %> @@ -76,4 +77,4 @@ <% end %> -<% html_title @news.title -%> +<% html_title @news.title -%> \ No newline at end of file diff --git a/app/views/news/_project_form.html.erb b/app/views/news/_project_form.html.erb index dfe1fb937..269420bfe 100644 --- a/app/views/news/_project_form.html.erb +++ b/app/views/news/_project_form.html.erb @@ -1,7 +1,7 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
  • - +

  • diff --git a/app/views/news/_project_news.html.erb b/app/views/news/_project_news.html.erb index 04fdb6dac..0cd26382b 100644 --- a/app/views/news/_project_news.html.erb +++ b/app/views/news/_project_news.html.erb @@ -1,3 +1,9 @@ + <% btn_tips = l(:label_news_new) label_tips = l(:label_news) diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 1d5752a28..1828ede6d 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -2,7 +2,7 @@ <% poll_name = poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%> <% if @is_teacher%>
  • -
    +
    <% if has_commit %> <%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> <% else %> diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 1e3f4b620..4df254fd0 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -12,14 +12,6 @@

    <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:0px;" %>

    -

    - <%#= f.text_field :enterprise_name, :size => 60, :style => "width:490px;" %> - - <%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %> -

    <%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH, value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %> diff --git a/app/views/projects/create.js.erb b/app/views/projects/create.js.erb new file mode 100644 index 000000000..9bb447789 --- /dev/null +++ b/app/views/projects/create.js.erb @@ -0,0 +1,3 @@ +$("#project_id").replaceWith("<%= escape_javascript(select_tag :project_id, options_for_select(user_projects_option), {:class => "InputBox W680 fl"})%>"); +hideModal("#popbox02"); +alert("创建成功"); \ No newline at end of file diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index 4c6ee47d8..44c571422 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -24,16 +24,24 @@ if(email == "") { $("#valid_email").text("<%= l(:label_input_email_blank)%>"); + return false; } - else if (filter.test(email)) { - $("#valid_email").html(""); - return true; + else if(!filter.test(email)) + { + $("#valid_email").text("<%= l(:label_email_format_error)%>"); + return false; + } + else if(email.length > 25) + { + $("#valid_email").text("邮箱名过长,最长为25个字符"); + return false; } else { - $("#valid_email").text("<%= l(:label_email_format_error)%>"); + $("#valid_email").text(""); + return true; } - return false; + } function senderEmail(obj) @@ -77,7 +85,39 @@ <%= l(:label_send_email)%> <% end %> + <%# 邀请用户的状态 %> + <% unless @inviter_lists.blank? %> +

    +
    +
    项目成员邀请状态列表
    +
    +
    + <% @inviter_lists.each do |inviter_list| %> + + + <% if inviter_list.user != nil %> + + + + + + + <% end %> + +
    + <% if inviter_list.user.active? %> + <%=link_to inviter_list.user.name, user_path(inviter_list.user), :class => "c_eblue" %> + <% else %> + <%= inviter_list.user.name %> + <% end %> + <%= status_for_ivitied(inviter_list, @project) %>
    + <% end %> +
    +
    + <% end %> + + <% unless @inviter_lists.blank? %>
    <% unless @inviters_count.nil? %> diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index c5edc4667..fbb046171 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -17,13 +17,13 @@ <% end %> <% end %> - + <%= link_to request.host() + "/projects", :controller => 'projects', :action => 'course', :project_type => 1 %> @@ -44,14 +44,14 @@ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> <% end %> - + - + <%#= text_field_tag 'name', params[:name], :size => 30, :onkeyup => "regexName();" %> + <%#= hidden_field_tag 'project_type', params[:project_type] %> + <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %> <!–修改项目搜索按钮的样式 –> + <!– + <%#= l(:label_search)%> + –>
    - + --> diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index e70e20cef..3fc9a89d6 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -2,13 +2,15 @@ $(function(){ <%if @select_tab%> <%if @select_tab == "modules"%> - project_setting(2); + project_setting(2); + <% elsif @select_tab == "members"%> + project_setting(3); <% elsif @select_tab == "versions"%> - project_setting(4); - $("#pro_st_edit_ban").toggle(); + project_setting(4); + $("#pro_st_edit_ban").toggle(); <% elsif @select_tab == "repositories" %> - project_setting(6); - $("#pro_st_edit_ku").toggle(); + project_setting(6); + $("#pro_st_edit_ku").toggle(); <%else%> <% end%> <% end%> diff --git a/app/views/projects/settings/_new_edit.html.erb b/app/views/projects/settings/_new_edit.html.erb index a8998ece5..8de9b8229 100644 --- a/app/views/projects/settings/_new_edit.html.erb +++ b/app/views/projects/settings/_new_edit.html.erb @@ -19,11 +19,6 @@
  • -
  • - - <%= select_tag :organization_id,options_for_select(project_organizations_id_option,@project.organization_id),{} %> -
  • -
  • > diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index be793a409..410bd8c32 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -59,7 +59,7 @@
    -<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %> +<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
    • @@ -79,6 +79,8 @@
    • <% end %>
    • + + <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %> <% unless @repository.identifier_frozen? %> @@ -87,7 +89,7 @@
    • - <%= f.password_field :upassword, :label=> "", :no_label => true %> + <%= f.password_field :upassword, :label=> "", :no_label => true%> <%= l(:label_upassword_info)%>
    • diff --git a/app/views/student_work/_add_score_reply.html.erb b/app/views/student_work/_add_score_reply.html.erb index 2866b2da6..417d3d2c1 100644 --- a/app/views/student_work/_add_score_reply.html.erb +++ b/app/views/student_work/_add_score_reply.html.erb @@ -1,4 +1,5 @@ <%= form_for('', :remote => true, :method => :post,:url => add_score_reply_student_work_index_path(:score_id => score.id)) do |f|%> <%= f.text_area 'message', :class => 'ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %> + 回复 <% end%> \ No newline at end of file diff --git a/app/views/student_work/_evaluation_student_work_title.html.erb b/app/views/student_work/_evaluation_student_work_title.html.erb deleted file mode 100644 index f19438f78..000000000 --- a/app/views/student_work/_evaluation_student_work_title.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -
    • - 学号 -
    • -
    • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "name"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - <% end%> -
    • -
    • - 作品名称 -
    • -
    • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% 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'%> - <% end%> -
    • -
    • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - <% end%> -
    • -
    • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - - <% end%> -
    • -
    • - <% if @homework.homework_type == 1%> - <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% elsif @homework.homework_type == 2%> - <%= link_to "系统",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% end %> - <% if @show_all && @order == "student_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - <% end%> -
    • -
    • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% 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'%> - <% end%> -
    • \ No newline at end of file diff --git a/app/views/student_work/_evaluation_title.html.erb b/app/views/student_work/_evaluation_title.html.erb new file mode 100644 index 000000000..bb1919472 --- /dev/null +++ b/app/views/student_work/_evaluation_title.html.erb @@ -0,0 +1,8 @@ +
        +
      • + 作品信息 +
      • +
      • + 我的评分 +
      • +
      \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb new file mode 100644 index 000000000..8ca855e9b --- /dev/null +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -0,0 +1,37 @@ +
        +
      • + 作品信息 +
      • +
      • + <%= link_to "教师评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml10"%> + <% if @show_all && @order == "teacher_score"%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt19"%> + <% end%> +
      • +
      • + <%= link_to "教辅评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml10"%> + <% if @show_all && @order == "teaching_asistant_score"%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt19"%> + <% end%> +
      • + <% if @homework.homework_type == 2%> +
      • + <%= link_to "系统评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "system_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml10"%> + <% if @show_all && @order == "system_score"%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "system_score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt19"%> + <% end%> +
      • + <% end%> +
      • + <%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml10"%> + <% if @show_all && @order == "student_score"%> + <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt19"%> + <% end%> +
      • +
      • + <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml10"%> + <% 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'} mt19"%> + <% end%> +
      • +
      \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb new file mode 100644 index 000000000..d3bac240d --- /dev/null +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -0,0 +1,76 @@ + +
        +
      • +
          +
        • + <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> + <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14"%> +
        • +
          +
        • +
            +
          • + 姓名:<%= student_work.user.show_name%> +
          • +
          • + 学号: + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
          • +
          • + 时间: + <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %> + 迟交 + <% else%> + <%= format_time student_work.created_at%> + <% end %> +
          • +
          +
        • +
        +
      • +
      • + <%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%> +
      • +
      • + <%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%> +
      • + + <% if @homework.homework_type == 2%> + +
      • + <%= student_work.system_score.nil? ? "--" : format("%.1f",student_work.system_score)%> +
      • + <% end%> +
      • + <%= student_work.student_score.nil? ? "--" : format("%.1f",student_work.student_score)%> + <% unless student_work.student_score.nil?%> + + (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>) + +
        + 现共有 +  <%= student_work.student_works_scores.where(:reviewer_role => 3).count%>  + 名学生进行了匿评,平均分为 +  <%= format("%.1f",student_work.student_score)%> 分。 +
        + <% end%> +
      • + + + <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%> +
      • + <%= score.nil? ? "--" : format("%.1f",score)%> + <% unless score.nil?%> +
        + 作品最终评分为 +  <%= student_work.final_score%> 分。 + 迟交扣分 +  <%= student_work.late_penalty%> 分, + 缺评扣分 +  <%= student_work.absence_penalty%> 分, + 最终成绩为 +  <%= format("%.1f",score)%> 分。 +
        + <% end%> +
      • +
      \ No newline at end of file diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index be07269c3..f8b9addbd 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,29 +1,51 @@ -
        " id="student_work_<%= student_work.id%>"> +
          <% is_my_work = student_work.user == User.current%> -
        • - <% if is_my_work%> - - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> - - <% else%> - -- - <% end%> -
        • -
        • - <% if is_my_work%> - <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02" %> - <% else%> - <%= link_to "匿名","javascript:void(0)", :class => "c_blue02"%> - <% end%> -
        • -
        • - <% student_work_name = student_work.name.nil? || student_work.name.empty? ? '匿名的作品' : student_work.name%> - <%= link_to student_work_name, student_work_path(student_work),:remote => true, :title => student_work.name, :class => "c_blue02"%> +
        • +
            +
          • + <% if is_my_work%> + <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> + <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14"%> + <% else%> + <%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14"%> + <% end%> +
          • +
            +
          • +
              +
            • + 姓名: + <% if is_my_work%> + <%= student_work.user.show_name%> + <% else%> + 匿名 + <% end%> +
            • +
            • + 学号: + <% if is_my_work%> + + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> + + <% else%> + -- + <% end%> +
            • +
            • + 时间: + <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(student_work.created_at.to_s).strftime("%Y-%m-%d") %> + 迟交 + <% else%> + <%= format_time student_work.created_at%> + <% end %> +
            • +
            +
          • +
        • <% my_score = student_work_score(student_work,User.current) %> -
        • - <%= my_score.nil? ? "--" : format("%.2f",my_score.score)%> +
        • + <%= my_score.nil? ? "--" : format("%.1f",my_score.score)%>
        • -
          -
        \ No newline at end of file +
      \ No newline at end of file diff --git a/app/views/student_work/_evaluation_work_title.html.erb b/app/views/student_work/_evaluation_work_title.html.erb deleted file mode 100644 index 0be6228bb..000000000 --- a/app/views/student_work/_evaluation_work_title.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -
    • - 学号 -
    • -
    • - 学生姓名 -
    • -
    • - 作品名称 -
    • -
    • - <%= link_to "我的评分","javascript:void(0)",:class => "c_dark f14 fb fl"%> -
    • \ No newline at end of file diff --git a/app/views/student_work/_jour_replay.html.erb b/app/views/student_work/_jour_replay.html.erb index 77fb476bf..4b594d7f4 100644 --- a/app/views/student_work/_jour_replay.html.erb +++ b/app/views/student_work/_jour_replay.html.erb @@ -6,9 +6,9 @@ <% if jour.user==User.current || User.current.admin? %> <%= link_to(l(:label_bid_respond_delete), destroy_score_reply_student_work_index_path(:jour_id => jour.id), - :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr c_purple") %> + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete), :class => "fr linkBlue mr5") %> <% end %> - + <%=format_time jour.created_on %>
      diff --git a/app/views/student_work/_new_project.html.erb b/app/views/student_work/_new_project.html.erb new file mode 100644 index 000000000..3d9214c7d --- /dev/null +++ b/app/views/student_work/_new_project.html.erb @@ -0,0 +1,31 @@ +
      + <%= labelled_form_for(Project.new,:remote => "true") do |f| %> +

      新建项目

      +
      +
      +
      + + +

      +
      +
      + +

      + +
      + +
      + +
      + + 确定 + + 取消 +
      +
      + <% end%> +
      +
      diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index b259e20a5..b5ff8f064 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -1,78 +1,102 @@
      -
      +
      • - - 上交时间: - + 上交时间: <%=format_time @work.created_at %>
      • - <% if @work.user != User.current%> - + + <% if @work.user == User.current && @homework.homework_detail_manual.comment_status == 1 %> + +
      • + <%= link_to("", student_work_path(@work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %> +
      • +
      • + <%= link_to "",new_student_work_path(:homework => @homework.id),:class => "pic_edit"%> +
      • + <% end%> + <% if @homework.homework_detail_manual.comment_status == 3 && @work.user != User.current%> +
      • <%= render :partial => 'student_work_praise' %>
      • <% end%>
        +
      • - - 编程代码: - -
        - <%= text_format @work.description%> + 编程代码: +
        + <%= text_format(@work.description) if @work.description%>
      • <% if @is_teacher%> -
      • 测试结果: - - - - - - - - <%@homework.homework_tests.each do |test|%> - "> - - - <% student_work_test = StudentWorkTest.where(:homework_test_id => test.id,:student_work_id => @work.id).first%> - - - - <% end%> - <% student_work_test = @work.student_work_test.first%> - <% if student_work_test && student_work_test.error_msg && !student_work_test.error_msg.empty?%> - - - - <% end%> - - -
        输入输出测试结果
        <%= student_work_test.nil? ? "正在编译" : student_work_test.status_to_s%>
        - <%= student_work_test.error_msg%> -
        -
        +
      • + + 测试结果: + +
        + <% @work.student_work_tests.each_with_index do |test, index| %> +
        +

        + 第<%= @work.student_work_tests.count - index%>次测试 +

        + + <%= test.created_at.to_s(:db) %> + +
        +
        + <% if test.status.to_i == -2 %> +
        + <%= test.results.first %> +
        + <% else %> +
        +
          + <% test.results.each_with_index do |x, i| %> +
        • + 测试<%=i+1%> + <% if x["status"].to_i != 0 %> + 测试错误! + 您的输出: + <%=x["result"]%> + 正确输出: + <%=x["output"]%> +
          + <% else %> + 测试正确! +
          + <% end %> +
        • + <% end %> +
        +
        + <% end %> + <% end %> +
      • - -
        - <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> -
        <% end%> + +
      • + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && @work.user != User.current )%> + +
        + <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> +
        + <% end%> +
        +
      -
      - <%@work.student_works_scores.order("updated_at desc").each do |score|%> +
      + <%@student_work_scores.each do |score|%>
      - <%= render :partial => 'student_work_score',:locals => {:score => score}%> + <%= render :partial => 'student_work_score',:locals => {:score => score,:is_last => score == @student_work_scores.last}%>
      <% end%> -
      - 收起 +
      + + 收起
      -
      \ No newline at end of file +
      \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb new file mode 100644 index 000000000..7deed7fb8 --- /dev/null +++ b/app/views/student_work/_set_score_rule.html.erb @@ -0,0 +1,63 @@ +<%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id},:method => "post") do |f|%> +
      + 评分设置 +
      + 迟交扣分 + +
      +
      + 缺评扣分 + +
      + + <% if homework.homework_type == 2%> +
      + 系统评分 + <%= select_tag :sy_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "markPercentage"} %> +
      + + + <% else%> + + <% end%> + +
      + 教辅评分 + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> +
      +
      + 学生匿评 + +
      +
      + 教师优先 + /> + 教师评分为最终评分 +
      +
      +
      + 确定 +
      +
      + 取消 +
      +
      +
      +
      +<% end%> diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index f6580659e..2aa14be71 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -1,72 +1,74 @@
      -
      -
        -
      • - 上交时间: - <%=format_time @work.created_at %> -
      • +
        +
          +
        • + 上交时间: + <%=format_time @work.created_at %> +
        • - <% if !@is_teacher && @work.user == User.current && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1) %> - -
        • - <%= link_to("", student_work_path(@work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %> -
        • -
        • - <%= link_to "",edit_student_work_path(@work),:class => "pic_edit"%> -
        • - <% end%> - <% if (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 3) && @work.user != User.current%> - -
        • - <%= render :partial => 'student_work_praise' %> -
        • - <% end%> -
          - - - - - - <% if @work.project%> -
        • - 关联项目: - <%= link_to( @work.project.name, project_path(@work.project.id), :class => "c_blue02" )%> -
        • - <% end%> -
        • - 内容: -
          - <%= text_format(@work.description) if @work.description%> -
          + <% if @work.user == User.current && @homework.homework_detail_manual.comment_status == 1 %> + +
        • + <%= link_to("", student_work_path(@work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del") %> +
        • +
        • + <%= link_to "",edit_student_work_path(@work),:class => "pic_edit"%> +
        • + <% end%> + <% if @homework.homework_detail_manual.comment_status == 3 && @work.user != User.current%> + +
        • + <%= render :partial => 'student_work_praise' %> +
        • + <% end%>
          - -
        • - 附件: - <% if @work.attachments.empty?%> - 尚未提交附件 - <% else%> -
          - <%= render :partial => 'work_attachments', :locals => {:attachments => @work.attachments} %> -
          + + + + <% if @work.project%> +
        • + 关联项目: + <%= link_to( @work.project.name, project_path(@work.project.id), :class => "linkBlue" )%> +
        • <% end%> - -
          - <% if @is_teacher || (@homework.homework_type == 1 && @homework.homework_detail_manual.comment_status == 2 && @work.user != User.current )%> - -
          - <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> +
        • + 内容: +
          + <%= text_format(@work.description) if @work.description%>
          - <% end%> -
        +
        + +
      • + 附件: + <% if @work.attachments.empty?%> + 尚未提交附件 + <% else%> +
        + <%= render :partial => 'work_attachments', :locals => {:attachments => @work.attachments} %> +
        + <% end%> +
        +
      • +
      • + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && @work.user != User.current )%> + +
        + <%= render :partial => 'add_score',:locals => {:work => @work,:score => @score}%> +
        + <% end%> +
        +
      • +
      -
      - <%@work.student_works_scores.order("updated_at desc").each do |score|%> -
      - <%= render :partial => 'student_work_score',:locals => {:score => score}%> -
      - <% end%> -
      -收起 -
      -
      \ No newline at end of file +
      + <%@student_work_scores.each do |score|%> +
      + <%= render :partial => 'student_work_score',:locals => {:score => score,:is_last => score == @student_work_scores.last}%> +
      + <% end%> +
      + + 收起 +
      +
    \ No newline at end of file diff --git a/app/views/student_work/_student_work_score.html.erb b/app/views/student_work/_student_work_score.html.erb index 8d10853f8..c800ae8d0 100644 --- a/app/views/student_work/_student_work_score.html.erb +++ b/app/views/student_work/_student_work_score.html.erb @@ -1,24 +1,31 @@ -
      +
        <% show_real_name = @is_teacher || score.user == User.current || score.user.allowed_to?(:as_teacher,@course) %> <%= link_to image_tag(url_to_avatar(show_real_name ? score.user : ""), :width => "34", :height => "34"), show_real_name ? user_path(score.user) : "javascript:void(0)",:class => "ping_pic fl" %> -
        - <%= link_to show_real_name ? score.user.show_name : "匿名", show_real_name ? user_path(score.user) : "javascript:void(0)", :title => show_real_name ? score.user.show_name : "匿评用户", :class => "c_blue fl" %> - (<%= student_work_score_role score%>) +
        + <%= link_to show_real_name ? score.user.show_name : "匿名", show_real_name ? user_path(score.user) : "javascript:void(0)", :title => show_real_name ? score.user.show_name : "匿评用户", :class => "linkBlue fl" %> + + (<%= student_work_score_role score%>) + 评分: - <%= score.score%>分 - 回复 - - <%=format_time score.updated_at %> - + + <%= score.score%>分 + + 回复 + + <%=format_time score.updated_at %> +
        +

        <%= score.comment%>

        + <%= render :partial => 'work_attachments', :locals => {:attachments => score.attachments} %>
        +
        - <%= render :partial => 'add_score_reply',:locals => {:score => score}%> + <%= render :partial => 'add_score_reply',:locals => {:score => score,:is_last => is_last}%>
        @@ -27,6 +34,6 @@ <%= render :partial => 'jour_replay',:locals => {:jour => jour}%> <% end%>
        +
        -
        -
      \ No newline at end of file +
    diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb deleted file mode 100644 index 24e6a1b37..000000000 --- a/app/views/student_work/_student_work_title.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -
  • - 学号 -
  • -
  • - <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "name"%> - <%= link_to "",student_work_index_path(:homework => @homework.id,:order => "name", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - <% end%> -
  • -
  • - 作品名称 -
  • -
  • - <%= link_to "时间",@show_all ? student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% 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'%> - <% end%> -
  • -
  • - <%= link_to "教师",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "teacher_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - <% end%> -
  • -
  • - <%= link_to "教辅",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% if @show_all && @order == "teaching_asistant_score"%> - <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name, :group => @group) ,:class => @score == 'desc' ? 'st_up' : 'st_down'%> - - <% end%> -
  • -
  • - <%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%> - <% 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'%> - <% end%> -
  • \ No newline at end of file diff --git a/app/views/student_work/_work_attachments.html.erb b/app/views/student_work/_work_attachments.html.erb index f303897bc..a75f68f70 100644 --- a/app/views/student_work/_work_attachments.html.erb +++ b/app/views/student_work/_work_attachments.html.erb @@ -1,8 +1,8 @@ <% attachments.each_with_index do |attachment,i| %>
    - <%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%> - <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author %> - (<%= number_to_human_size attachment.filesize %>) + <%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%> + <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author %> + (<%= number_to_human_size attachment.filesize %>)
    <% end -%> diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 1de92b51a..6cb5bd6d8 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -2,39 +2,16 @@ $("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :parti $('#score_<%= @work.id%>').peSlider({range: 'min'}); <% if @is_new%> - $("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); + $("#score_list_<%= @work.id%>").find("div:last").find("ul").addClass("ping_line"); + $("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score,:is_last => true}) %>
    "); <% else %> - $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); + $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score,:is_last => @is_last}) %>"); <% end%> $("#score_list_<%= @work.id%>").removeAttr("style"); <% if @is_teacher %> - <% if @homework.homework_type == 1%> - $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); - <% elsif @homework.homework_type == 2%> - $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_student_work',:locals => {:student_work => @work}) %>"); - <% else%> - $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'student_work',:locals => {:student_work => @work}) %>"); - <% end%> + $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_un_work',:locals => {:student_work => @work}) %>"); <% else %> $("#student_work_<%= @work.id%>").replaceWith("<%= escape_javascript(render :partial => 'evaluation_work',:locals => {:student_work => @work}) %>"); <% end%> - - -$(function(){ - //匿评评分提示 - $(".student_score_info").bind("mouseover",function(e){ - $(this).find("div").show(); - }); - $(".student_score_info").bind("mouseout",function(e){ - $(this).find("div").hide(); - }); - //最终成绩提示 - $(".student_final_scor_info").bind("mouseover",function(e){ - $(this).find("div").show(); - }); - $(".student_final_scor_info").bind("mouseout",function(e){ - $(this).find("div").hide(); - }); -}); diff --git a/app/views/student_work/add_score_reply.js.erb b/app/views/student_work/add_score_reply.js.erb index 28704630f..f21870cd5 100644 --- a/app/views/student_work/add_score_reply.js.erb +++ b/app/views/student_work/add_score_reply.js.erb @@ -1,4 +1,4 @@ -$("#add_score_reply_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'add_score_reply', :locals => {:score => @score}) %>"); +$("#add_score_reply_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'add_score_reply', :locals => {:score => @score,:is_last => @is_last}) %>"); <% if @status && @status == 1%> $("#replay_histroy_<%= @score.id%>").prepend("<%= escape_javascript(render :partial => 'jour_replay', :locals => {:jour => @jour}) %>"); $("#add_score_reply_<%= @score.id%>").hide(); diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 6e36447d2..25a65f039 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -1,52 +1,62 @@ -
    -

    编辑作品

    +
    +
    编辑作品
    -
    -
    -
    - <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> -
    -

    - - - 项目信息 - - -

    -

    -

    -
    +
    -

    - - <%= f.select :project,options_for_select(user_projects_option,@work.project_id), {},{:class => "bo02 mb10"} %> -

    -
    +
    -

    - - -

    -

    -
    -

    - - <%= render :partial => 'attachments/new_form',:locals => {:container => @work} %> -

    -
    -

    - 提交作品 - <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> +

    +
    +
    + <%= @homework.name%>(作业名称) +
    + + 截止时间:<%= @homework.end_time%> + +
    + + <%= link_to @homework.user.show_name, user_activities_path(@homework.user_id), :class => "c_blue"%> + +
    +
    + <%= @homework.description.html_safe %> +
    +
    +
    +
    + +
    + <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> +
    + 提示:作品名称和描述中不要出现真实的姓名信息 +
    -

    -
    - <% end%> -
    -
    +
    + +
    +

    +
    +
    + + +
    +

    +
    + +
    + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @work, :has_program=>false} %> +
    + +
    + 确定 + + <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%> +
    +
    + <% end%> +
    -
    -
    diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 0250a7eed..5398b7084 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -1,5 +1,12 @@ -
    - -
    + //设置评分规则 + function set_score_rule(){ + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework}) %>'); + showModal('ajax-modal', '350px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); + } - -
    -
    -
    -
      -
    • 全部作品
    • -
    • 作业信息
    • -
    -
    -
    + -
    -
    -
    - - <%= link_to "所有作品(#{@stundet_works.count})".html_safe,student_work_index_path(:homework => @homework.id), :class => "fl"%> - - <% if @show_all%> - - <%= select_tag(:late_penalty,options_for_select(course_group_list(@course),@group), {:class => "fl h22 w100 ml10"}) if(@is_teacher && course_group_list(@course).count > 0) %> - 搜索 - <%= link_to("缺评情况",student_work_absence_penalty_student_work_index_path(:homework => @homework.id), :class => "student_work_search fl", :target => "_blank") if((@is_teacher || User.current.admin?) && @homework.homework_type == 1) %> - <% end%> +
    +
    +
    + + <% if @is_teacher%> -
    - <% unless @homework.homework_type == 2%> - <% if @homework.student_works.empty?%> - <%= link_to "附件", "javascript:void(0)", class: "down_btn fr zip_download_alert", :onclick => "alert('没有学生提交作业,无法下载附件')" %> - <% else%> - <%= link_to "附件", zipdown_assort_path(obj_class: @homework.class, obj_id: @homework, format: :json), - remote: true, class: "down_btn fr zip_download_alert", :id => "download_homework_attachments" %> - <% end%> -
    - 使用 - winzip - 工具进行解压可能会导致 - 下载文件乱码 - ,建议您使用 - winrar - 工具进行解压 -
    - <% end%> - <%= link_to("匿评", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr') if @homework.homework_type == 1%> - <%= link_to("缺评", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'down_btn fr') if @homework.homework_type == 1%> - <%= link_to l(:label_list), student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'down_btn fr'%> - 导出全部: +
    +
      +
    • + +
        +
      • + <%= link_to "导出作业成绩", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :format => 'xls'),:class=>'hworkExport postTypeGrey'%> +
      • +
      • + <% if @homework.student_works.empty?%> + <%= link_to "导出作业附件", "javascript:void(0)", class: "hworkExport resourcesGrey", :onclick => "alert('没有学生提交作业,无法下载附件')" %> + <% else%> + <%= link_to "导出作业附件", zipdown_assort_path(obj_class: @homework.class, obj_id: @homework, format: :json), + remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %> + <% end%> +
      • +
      • + <%= link_to("导出缺评情况", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> +
      • +
      • + <%= link_to("导出匿评情况", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> +
      • +
      • + 评分设置 +
      • +
      +
    • +
    <% end%>
    -
    -
    - - <% if @is_evaluation%> -
      - <%= render :partial => 'evaluation_work_title'%> -
    -
    - <% @stundet_works.each do |student_work|%> - <%= render :partial => "evaluation_work",:locals => {:student_work => student_work}%> -
    - <% end%> - <% else %> - <% if @homework.homework_type == 1 || @homework.homework_type == 2%> -
      - <%= render :partial => 'evaluation_student_work_title'%> -
    -
    - <% @stundet_works.each do |student_work|%> - <%= render :partial => "evaluation_student_work",:locals => {:student_work => student_work}%> -
    - <% end%> - <% else%> -
      - <%= render :partial => 'student_work_title'%> -
    -
    - <% @stundet_works.each do |student_work|%> - <%= render :partial => "student_work",:locals => {:student_work => student_work}%> -
    - <% end%> - <% end%> - <% end%> -
    -
    - -
    -
    - <%= link_to(image_tag(url_to_avatar(@homework.user), :width => "42", :height => "42"), user_path(@homework.user), :class => "problem_pic fl") %> -
    -

    - <%= @homework.name%> -

    - <% if @is_teacher%> - <%= homework_anonymous_comment(@homework)%> - <%= link_to(l(:button_edit),edit_homework_common_path(@homework), :class => "fr mr10 work_edit") %> - <% else%> - <%= student_anonymous_comment @homework %> - <%= student_new_homework @homework %> - <% end %> -
    - -
    - <%= @homework.description.html_safe %> -
    -
    - - <% if @homework.homework_type == 2 && @homework.homework_detail_programing%> - <% if @is_teacher%> - - - "> - - - - <% @homework.homework_tests.each do |test|%> - "> - - - - <% end%> - -
    - 输入 - - 输出 -
    - <%=test.input%> - - <%= test.output%> -
    -
    +
    +
    +
    +
    +
    + + <%= link_to "所有作品[共#{@stundet_works.count}份]".html_safe,student_work_index_path(:homework => @homework.id),:class => "fl f14"%> + + <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> +
    + + +
    <% end%> - -
    - 开发语言: -
    - <% if @homework.homework_detail_programing.language.to_i == 1%> - C - <% elsif @homework.homework_detail_programing.language.to_i == 2%> - C++ - <% end%> -
    -
    - <% end%> - -
    - <% unless @homework.attachments.empty?%> - 附件: -
    - <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @homework.attachments} %> -
    - <% end%> -
    -
    - -
    - 扣分标准: -
    - <% if @homework.homework_type == 1%> - <%= scoring_rules @homework.late_penalty,@homework.id,@is_teacher,@homework.homework_detail_manual.absence_penalty%> +
    + +
    + <% if @is_evaluation && !@stundet_works.empty?%> + <%= render :partial => "evaluation_title"%> <% else%> - <%= scoring_rules @homework.late_penalty,@homework.id,@is_teacher%> + <%= render :partial => "evaluation_un_title"%> <% end%>
    + +
    + <% @stundet_works.each do |student_work|%> + <% if @is_evaluation%> + <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> + <% else%> + <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> + <% end%> +
    + +
    +
    + <% end%>
    - -
    - 截止时间:<%= @homework.end_time%> -
    - <% if betweentime(@homework.end_time) < 0 %> - - <%= l(:label_commit_limit)%> - - <% else %> - -
    -
    - <% end %> -
    -
    -
    -
    -
    - - -
    -
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index c72f9d422..f9b242443 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,83 +1,104 @@ + -
    -

    创建作品

    + +
    +
    提交作品
    -
    -
    -
    - <%= form_for(@stundet_work, - :html => { :multipart => true }, - :url => {:controller => 'student_work', - :action => 'create', - :homework => @homework.id - }) do |f|%> -
    - <% if @homework.homework_type == 1%> -
    - 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息 -
    - <% end%> -

    - - <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> - <% if @homework.homework_type != 2%> - - 项目信息 - - - <% end%> -

    -

    -

    -
    -

    - - <%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %> -

    -
    -

    - - <% if @homework.homework_type == 2 && @homework.homework_detail_programing%> - <%= f.text_area "description", :class => "w620 hwork_txt h400", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => @homework.homework_detail_programing.language == "1" ? c_stantard_code_student : c_stantard_code_student_%> - <% else %> - <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%> - <% end%> -

    -

    -

    -
    - <% if @homework.homework_type != 2%> -

    - - <%= render :partial => 'attachments/new_form' %> -

    -
    - <% end%> -

    - 提交作品 - <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> -

    -

    -
    - <% end%> +
    + +
    + +
    +
    +
    + <%= @homework.name%>(作业名称) +
    + + 截止时间:<%= @homework.end_time%> + +
    + + <%= link_to @homework.user.show_name, user_activities_path(@homework.user_id), :class => "c_blue"%> + +
    +
    + <%= @homework.description.html_safe %> +
    -
    -
    -
    \ No newline at end of file +
    +
    + +
    + <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :homework => @homework.id + }) do |f|%> +
    + 提示:作品名称和描述中不要出现真实的姓名信息 +
    +
    + +
    + <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %> +
    +

    +
    +
    + <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%> + +
    +

    +
    + +
    + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> +
    + + +
    + +
    + <%= select_tag :project_id, options_for_select(user_projects_option, @student_work.project_id), {:class => "InputBox W680 fl"} %> + <%#=link_to "", new_project_path, :class => "ml5 mt5 SetUpIcon fl", :title => "快速创建"%> + +
    +
    + +
    + 确定 + + <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> +
    +
    + <% end%> +
    +
    \ No newline at end of file diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index 1c8874c2f..e6b99c146 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -1,11 +1,11 @@ -if($("#about_hwork_<%= @work.id%>").children().length > 0) - {$("#about_hwork_<%= @work.id%>").html("");} -else - { - <% if @homework.homework_type == 2%> - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show') %>"); - <% else%> - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); - <% end%> - $('#score_<%= @work.id%>').peSlider({range: 'min'}); - } \ No newline at end of file +if($("#about_hwork_<%= @work.id%>").children().length > 0){ + $("#about_hwork_<%= @work.id%>").html(""); +} +else{ + <% if @homework.homework_type == 2%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show') %>"); + <% else%> + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + <% end%> + $('#score_<%= @work.id%>').peSlider({range: 'min'}); +} \ No newline at end of file diff --git a/app/views/system_messages/index.html.erb b/app/views/system_messages/index.html.erb new file mode 100644 index 000000000..4ed40757b --- /dev/null +++ b/app/views/system_messages/index.html.erb @@ -0,0 +1,3 @@ +<% @system_messages.each do |sm| %> +
    • <%= sm.content %>
    +<% end %> diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index b512f1ef3..49c9b2351 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -2,7 +2,8 @@ <% if @tags.size > 0 %> <% @tags.each do |tag| %> - <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> + <%#= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id %> + <%= tag %> <% case object_flag %> <% when '10' %> diff --git a/app/views/tags/update_tag_name.js.erb b/app/views/tags/update_tag_name.js.erb new file mode 100644 index 000000000..b72b0c33f --- /dev/null +++ b/app/views/tags/update_tag_name.js.erb @@ -0,0 +1,40 @@ +//本js使用的新的tag显示方法 +<% if @obj_flag == '3'%> +$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +//$('#put-tag-form-issue').hide(); +$('#name-issue').val(""); +<% elsif @obj_flag == '1'%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_user_new_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#tags_name3').val(""); +<% elsif @obj_flag == '2'%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_project_new_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#tags_name2').val(""); +<% elsif @obj_flag == '6'%> +<%if @course%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list', + :locals => {:obj => @obj,:object_flag => @obj_flag,:select_tag_name => @select_tag_name}) %>'); +$("#files_tag").html("<%= escape_javascript(render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => @course,:tag_name => @select_tag_name}) %>"); +<%else%> +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); +$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/course_attachment_tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +<%end%> + +$("#tags_name_<%=@obj.id%>").val(""); +$("#add_tag_<%=@obj.id%>").hide(); +<% elsif @obj_flag == '9'%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/new_tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#tags_name').val(""); +<% elsif @obj_flag == '10'%> +//$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide(); +<% else%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#tags_name').val(""); +//$('#put-tag-form').hide(); +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_attachment.html.erb b/app/views/users/_course_attachment.html.erb index e0d04548b..41961f05b 100644 --- a/app/views/users/_course_attachment.html.erb +++ b/app/views/users/_course_attachment.html.erb @@ -1,11 +1,11 @@
    -
    +
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "90", :height => "90"), user_path(activity.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    +
    <% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> @@ -15,7 +15,7 @@ <%= link_to activity.course.name.to_s+"(课程名称)", course_path(activity.container_id), :class => "newsBlue ml15", :style=>"word-break:break-all" %>
    -
    +
    diff --git a/app/views/users/_course_create.html.erb b/app/views/users/_course_create.html.erb index b86f55385..b69e6ee86 100644 --- a/app/views/users/_course_create.html.erb +++ b/app/views/users/_course_create.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index a3d4992c5..58b29696c 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -1,37 +1,30 @@
    -
    +
    - <%= link_to image_tag(url_to_avatar(activity.user), :width => "90", :height => "90"), user_path(activity.user_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
    -
    +
    <% if activity.try(:user).try(:realname) == ' ' %> - <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> + <%= link_to activity.try(:user), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% else %> - <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程作业", course_path(activity.course_id), :class => "newsBlue ml15", :style=>"word-break:break-all" %> + <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%>
    -
    - <%= link_to activity.name.to_s, student_work_index_path(:homework => activity.id), :class => "postGrey", :style=>"word-break:break-all" %> +
    + <%= link_to activity.name.to_s, student_work_index_path(:homework => activity.id,:host=> Setting.host_course), :class => "postGrey"%>
    - <%= link_to "提交("+activity.student_works.count.to_s+")", student_work_index_path(:homework => activity.id), :class=> "c_blue" %> + <%= student_work_activity_submit_status(homework: activity) %>
    -
    截止时间:<%= format_date(activity.end_time) %>
    +
    截止时间:<%= activity.end_time.to_s %>
    -
    - 作业描述:<%= activity.description.html_safe %> +
    + <%= activity.description.html_safe %>
    - - +
    +
    +
    diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index dbeb8d450..90680cf82 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -1,75 +1,54 @@ -
    -
    +
    +
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "90", :height => "90"), user_path(activity.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    +
    <% if @ctivity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程通知", course_path(activity.course), :class => "newsBlue ml15", :style => "word-break:break-all" %> + <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
    -
    - <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey", :style => "word-break:break-all" %> +
    + <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
    -
    -
    发布时间:<%= format_date(activity.created_on) %>
    +
    + 发布时间:<%= format_time(activity.created_on) %>
    -
    通知描述:<%= activity.description.html_safe %>
    - -
    - <% count=activity.comments_count %> -
    回复(<%= count %>)
    + <% count=activity.comments.count %> +
    + 回复(<%= count %>) +
    <%#= format_date(activity.updated_on) %>
    <%if count>2 %> - + <% end %> -
    - <%#= render :partial => 'course_news_reply',:locals => { :contest => @contest, :journals => @jour, :state => false}%> - <% replies_all_i = 0 %> - <% unless activity.comments.empty? %> -
    + <% if count > 0 %> +
      <% activity.comments.reorder("created_on desc").each do |comment| %> - <% replies_all_i=replies_all_i+1 %> -
    • + <% replies_all_i = replies_all_i + 1 %> +
    • - <%= link_to image_tag(url_to_avatar(comment.author), :width => "45", :height => "45"), user_path(comment.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.author_id), :alt => "用户头像" %>
      @@ -78,10 +57,7 @@ <% else %> <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_date(comment.created_on) %> - <%#= link_to_if_authorized_course l(:button_delete), {:controller => 'comments', :action => 'destroy', :id => activity, :comment_id => comment}, - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> - + <%= format_time(comment.created_on) %>
      <%= comment.comments.html_safe %>
      @@ -90,6 +66,23 @@ <% end %>
    - <% end %> + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + + +
    + 发送 +
    +

    + <% end%> +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_course_news_reply.html.erb b/app/views/users/_course_news_reply.html.erb deleted file mode 100644 index c3f8571be..000000000 --- a/app/views/users/_course_news_reply.html.erb +++ /dev/null @@ -1,177 +0,0 @@ - -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> - -<% if @news.commentable? %> -
    -

    <%= l(:label_comment_add) %>

    - <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %> -
    - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%> -
    -

    - - <%= l(:label_cancel_with_space) %> - - - <%= l(:label_comment_with_space) %> - -

    - <% end %> -
    -<% end %> - -
    - - <%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - -

    - <% end %> -
    - -
    - -
    - - - - - diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb index 97b3b759d..0b91a6ed3 100644 --- a/app/views/users/_course_poll.html.erb +++ b/app/views/users/_course_poll.html.erb @@ -1,20 +1,21 @@ <% has_commit = has_commit_poll?(activity.id ,User.current)%> <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> +<% if ( activity.polls_status==2) %>
    -
    +
    - <%= link_to image_tag(url_to_avatar(activity.user), :width => "90", :height => "90"), user_path(activity.user_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
    -
    +
    <% if activity.try(:user).try(:realname) == ' ' %> <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", course_path(activity.polls_group_id), :class => "newsBlue ml15", :style=>"word-break:break-all" %> + <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %>
    @@ -25,11 +26,11 @@ <%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%> <% end %>
    -
    -
    发布时间:<%= format_date(activity.published_at) %>
    +
    + 发布时间:<%= format_time(activity.published_at) %>
    -
    问卷描述:<%=activity.polls_description.html_safe.to_s%>
    - -
    \ No newline at end of file +
    +<% end %> \ No newline at end of file diff --git a/app/views/users/_influence_new_score_index.html.erb b/app/views/users/_influence_new_score_index.html.erb index 505785351..f99cdee19 100644 --- a/app/views/users/_influence_new_score_index.html.erb +++ b/app/views/users/_influence_new_score_index.html.erb @@ -5,4 +5,4 @@
        <%= l('userscore.active.update_issues')%> * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %>
        <%= l('userscore.active.release_issues')%> * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %>
        <%= l('userscore.active.release_messages')%> * 1 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
    -
        <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= active(option_num) %>
    \ No newline at end of file +
        <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= project_active(option_num) %>
    \ No newline at end of file diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb index 731737610..5215e9ccc 100644 --- a/app/views/users/_project_attachment.html.erb +++ b/app/views/users/_project_attachment.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_project_create.html.erb b/app/views/users/_project_create.html.erb index 913aeb3d0..862087e68 100644 --- a/app/views/users/_project_create.html.erb +++ b/app/views/users/_project_create.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_project_document.html.erb b/app/views/users/_project_document.html.erb index 4a7fa1f4d..e6067e860 100644 --- a/app/views/users/_project_document.html.erb +++ b/app/views/users/_project_document.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 4badcff42..07f7c452b 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -1,126 +1,110 @@ -
    -
    +
    +
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "90", :height => "90"), user_path(activity.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    +
    <% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目缺陷", project_path(activity.project), :class => "newsBlue ml15", :style=>"word-break:break-all" %> -
    -
    - <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey", :style=>"word-break:break-all" %> - <%= get_issue_priority(activity.priority_id)[1] %> + <%= link_to activity.project.name.to_s+" | 项目缺陷", project_issues_path(activity.project), :class => "newsBlue ml15"%> +
    +
    + <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> + + <%= get_issue_priority(activity.priority_id)[1] %> +
    指派给   <% unless activity.assigned_to_id.nil? %> - <% if activity.try(:assigned_to).try(:realname) == ' ' %> - <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% end %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> <% end %>
    -
    时间:<%=format_date(activity.created_on) %>
    +
    + 时间: + <%=format_time(activity.created_on) %> +
    +
    +
    + <% if activity.description? %> + <%= textAreailizable activity, :description, :attachments => activity.attachments %> + <% end %> + <%#= activity.description.html_safe %>
    -
    缺陷描述:<%= activity.description.html_safe %>
    <% if activity.attachments.any? %> <% activity.attachments.each do |attachment| %> -
    +
    - <%= link_to_short_attachment attachment, :class => 'homepagePostFileAtt newsBlue', :download => true -%> + <%= link_to_short_attachment attachment,:length=> 58, :class => 'homepagePostFileAtt newsBlue', :download => true -%> - <% if attachment.is_text? %> - <%= link_to image_tag('magnifier.png'), - :controller => 'attachments', - :action => 'show', - :id => attachment, - :filename => attachment.filename %> - <% end %> - ( + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename %> + <% end %> + ( <%= number_to_human_size attachment.filesize %>) -
    +
    <% end %> <% end %>
    - -
    - <% count=activity.journals.count %> -
    回复(<%= count %>)
    + <% count = activity.journals.count %> +
    回复(<%= count %>)
    <%#= format_date(activity.updated_on) %>
    - <% if count>2 %> + <% if count > 2 %> + + 展开更多 + +
    <% end %> -
    - + <% replies_all_i = 0 %> - <% unless activity.journals.empty? %> -
    + <% if count > 0 %> +
      <% activity.journals.reorder("created_on desc").each do |reply| %> - <% replies_all_i=replies_all_i+1 %> -
    • + <% replies_all_i=replies_all_i + 1 %> +
    • - <%= link_to image_tag(url_to_avatar(reply.user), :width => "45", :height => "45"), user_path(reply.user_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33", :class =>"mt8"), user_path(reply.user_id), :alt => "用户头像" %>
      <% if reply.try(:user).try(:realname) == ' ' %> <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> - <% else %> + <% else %> <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_date(reply.created_on) %> - - + <%= format_time(reply.created_on) %> +
      +
      + <% if reply.details.any? %> + <% details_to_strings(reply.details).each do |string| %> +

      <%= string %>

      + <% end %> + <% end %> +

      <%= reply.notes.html_safe %>

      - <% if reply.details.any? %> - <% details_to_strings(reply.details).each do |string| %> -
      <%= string %>
      - <% end %> - <% else %> -
      <%= reply.notes.html_safe %>
      - <% end %>
    • @@ -128,5 +112,37 @@
    <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => add_journal_issue_path(activity.id),:method => "post", :remote => true) do |f|%> + + +
    + 发送 +
    +

    + <% end%> +
    +
    +
    +
    +
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/users/_project_journal.html.erb b/app/views/users/_project_journal.html.erb index cc5036ede..692354f9f 100644 --- a/app/views/users/_project_journal.html.erb +++ b/app/views/users/_project_journal.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index e9fdb87e1..d734ad982 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -1,89 +1,68 @@ -
    -
    +
    +
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "90", :height => "90"), user_path(activity.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    +
    <% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目讨论区",project_path(activity.project), :class => "newsBlue ml15 mr5", :style=>"word-break:break-all"%> + <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%>
    -
    +
    <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey", :style=>"word-break:break-all" %> + <%= link_to activity.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.id, :topic_id => activity.id), :class=> "postGrey" + %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey", :style=>"word-break:break-all"%> + <%= link_to activity.parent.subject.to_s.html_safe, project_boards_path(activity.project,:parent_id =>activity.parent_id, :topic_id => activity.id), :class=> "postGrey" + %> <% end %>
    -
    -
    时间:<%= format_date(activity.created_on) %>
    +
    + 时间:<%= format_time(activity.created_on) %>
    -
    帖子描述: +
    <% if activity.parent_id.nil? %> <%= activity.content.to_s.html_safe%> <% else %> <%= activity.parent.content.to_s.html_safe%> <% end %>
    -
    -
    <% count=0 %> -
    回复( - <% if activity.parent_id.nil? %> - <% count=activity.replies_count%> - <%=count %> +
    + <% count = 0 %> +
    回复( + <% if activity.parent %> + <% count=activity.parent.children.count%> <% else %> - <% count=activity.parent.replies_count%> - <%=count %> + <% count=activity.children.count%> <% end %> + <%=count %> )
    <%#=format_date(activity.updated_on)%>
    <%if count>2 %> - + <% end %> - -
    - + <% activity= activity.parent_id.nil? ? activity : activity.parent %> <% replies_all_i = 0 %> - <% unless activity.children.empty? %> -
    + <% if count > 0 %> +
      <% activity.children.reorder("created_on desc").each do |reply| %> <% replies_all_i=replies_all_i+1 %> -
    • +
    • - <%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33", :class =>"mt8"), user_path(reply.author_id), :alt => "用户头像" %>
      @@ -92,16 +71,7 @@ <% else %> <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_date(reply.created_on) %> - <%#= link_to( - l(:button_delete), - {:controller => 'messages', :action => 'destroy', :id => reply.id, :board_id => reply.board_id, :is_board => 'false'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete), - :class => 'replyGrey fr ml10' - ) if reply.course_destroyable_by?(User.current) %> - + <%= format_time(reply.created_on) %>
      <%= reply.content.html_safe %>
      @@ -111,5 +81,25 @@
    <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
    + 发送 +
    +

    + <% end%> +
    +
    +
    +
    + +
    \ No newline at end of file diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index 9e4dfaf24..a347ffd3a 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -1,11 +1,11 @@
    -
    +
    - 用户头像
    + 用户头像
    -
    尹教授 TO + -
    +
    diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index e5d1732e4..40bbd5e7c 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -30,11 +30,11 @@
    <% if !projects.empty? %> <% projects.each do |project| %> -
      -
    • +
        +
      • -
      • <%= truncate( project.name,:length=>18)%>
      • +
      • <%= project.name%>
      <% end %>
    diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index 2fc515b4a..ed2ed44a6 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -30,11 +30,11 @@
    <% if !courses.empty? %> <% courses.each do |course| %> -
      -
    • +
        +
      • -
      • <%= truncate(course.name,:length=>18)%>
      • +
      • <%= truncate(course.name,:lendght=>25) + '['+course.time.to_s+course.term + ']'%>
      <% end %>
    diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index b41b9f28f..f134e8f42 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,22 +1,25 @@ <% if attachments.nil? || attachments.empty? %> + + + <% else %> <% attachments.each do |attach| %> -
      -
    • - -
    • -
    • - - <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), - :title => attach.filename,:class=>'resourcesBlack'%> -
    • -
    • <%= number_to_human_size(attach.filesize) %>
    • -
    • <%= get_resource_type(attach.container_type)%>
    • -
    • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
    • -
    • <%= attach.author_id %>
    • -
    • <%= format_date(attach.created_on) %>
    • -
    • <%= attach.id %>
    • -
    - <% end %> +
      +
    • + +
    • +
    • + + <%= link_to truncate(attach.filename,:length=>30), download_named_attachment_path(attach.id, attach.filename), + :title => attach.filename,:class=>'resourcesBlack'%> +
    • +
    • <%= number_to_human_size(attach.filesize) %>
    • +
    • <%= get_resource_type(attach.container_type)%>
    • +
    • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
    • +
    • <%= attach.author_id %>
    • +
    • <%= format_date(attach.created_on) %>
    • +
    • <%= attach.id %>
    • +
    + <% end %> <% end %> diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index e50b240fd..c1d23d0ed 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -5,8 +5,8 @@ <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
    = <%= format("%.2f" ,collaboration(option_num)).to_i %> + <%= format("%.2f" , influence(option_num) ).to_i %> - + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" , active(option_num)).to_i %>
    - <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , active(option_num)).to_i) < 0 %> + + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" ,project_active(option_num)).to_i %>
    + <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , project_active(option_num)).to_i) < 0 %>
    <%= l(:label_score_less_than_zero) %>
    <% else %>
    = <%= format("%.2f" ,option_num.total_score).to_i %>
    diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index 2081c38d6..4e89506a6 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -68,7 +68,7 @@
  • <%= link_to l(:label_user_score_of_active), "javascript:void(0)", :onclick => "show_div('influence_new_score_index')" %> : - <%= format("%.2f" , active(option_num)).to_i %> + <%= format("%.2f" , project_active(option_num)).to_i %>
  • diff --git a/app/views/users/_show_user_resource.html.erb b/app/views/users/_show_user_resource.html.erb index a27a51d65..24d81a787 100644 --- a/app/views/users/_show_user_resource.html.erb +++ b/app/views/users/_show_user_resource.html.erb @@ -1,26 +1,67 @@ -
    + +
    -
    资源库
    +
    引用资源库资源
    +
    +
    + +
    + + <%= form_tag(user_ref_resource_search_user_path(user),:method => 'get',:remote=>'true',:class=>'referenceSearchBox') do%> + + + <% end %> + +
    +
    +
    +
    +
      +
    • +
    • 资源名称
    • +
    • 大小
    • +
    • 类别
    • +
    • 上传者
    • +
    • 上传时间
    • +
    +
    + <%= form_tag(import_resources_to_homework_user_path(user),:method => 'post',:remote=>'true') do %> + +
    + <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
    -
    -
    - - -
    +
      + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true%> +
    +
    + - <%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %> -
    - <%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%> -
    -
    -
    - 确定 -
    -
    - 取消 -
    -
    - <% end%>
    -
    \ No newline at end of file + <% end %> + diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b43d0d54e..ba9e970b6 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,105 +1,79 @@ -<% user_activities.each do |user_activity| - unless user_activities.nil? %> - - <% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %> - <% case user_activity.container_type.to_s %> - <% when 'Course' %> - <% if act %> - <% case user_activity.act_type.to_s %> - <% when 'HomeworkCommon' %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %> - <% when 'News' %> - <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %> - <% when 'Message'%> - <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Course'%> - <%#= render :partial => 'course_create', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Attachment' %> - <%#= render :partial => 'course_attachment', :locals => {:activity => act, :user_activity => user_activity} %> - <%# when 'JournalsForMessage' %> - <%#= render :partial => 'course_journalsformessage', :locals => {:activity => act, :user_activity => user_activity} %> - <% when 'Poll' %> - <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %> - <% end %> - <% end %> - <% when 'Project' %> - <% if act %> - <% case user_activity.act_type.to_s %> - <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %> - <% when 'Message' %> - <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Journal' %> - <%#= render :partial => 'project_journal', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'News' %> - <%#= render :partial => 'project_news', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Document' %> - <%#= render :partial => 'project_document', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Attachment' %> - <%#= render :partial => 'project_attachment', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'ProjectCreateInfo' %> - <%#= render :partial => 'project_create', :locals => {:activity => act,:user_activity =>user_activity} %> - <% end %> - <% end %> - <% end %> - <% end %> -<% end %> - \ No newline at end of file +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> + +<% first_user_activity = user_activities.first.id unless user_activities.first.nil? %> +<% user_activities.each do |user_activity| + if user_activities %> + + <% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %> + <% case user_activity.container_type.to_s %> + <% when 'Course' %> + <% if act %> + <% case user_activity.act_type.to_s %> + <% when 'HomeworkCommon' %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% when 'News' %> + <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% when 'Message'%> + <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% when 'Poll' %> + <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% end %> + <% end %> + <% when 'Project' %> + <% if act %> + <% case user_activity.act_type.to_s %> + <% when 'Issue' %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% when 'Message' %> + <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <% end %> + <% end %> + <% end %> + <% end %> +<% end %> + +<% if user_activities.count == 10%> +
    展开更多<%=link_to "", user_activities_path(@user.id,:type => type,:page => page),:id => "more_activities_link",:remote => "true",:class => "none" %>
    + <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> +<% end%> + + \ No newline at end of file diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index 1613b144e..9b7c6c06a 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -46,8 +46,13 @@
    - 上传附件 - <%#= link_to "资源库", user_import_resource_user_path(User.current.id),:class => "FilesBtn fl mr15 mt3",:remote => true%> + + 上传附件 + <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr20",:remote => true%> + <% if defined?(has_program) && has_program %> + 编程 + + <% end %>
    <% content_for :header_tags do %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 8340306e0..6e07e7122 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -1,44 +1,93 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> + <%= javascript_include_tag 'homework','baiduTemplate' %> + +<% end %> +
    - +

    - <%= link_to "导入作业", user_import_homeworks_user_path(User.current.id),:class => "BlueCirBtn fl mr10",:remote => true%> + <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id),:class => "BlueCirBtn fl mr10",:remote => true) unless edit_mode%>
    - + <%= calendar_for('homework_end_time')%>
    +

    +
    +
    +
    + <% if edit_mode %> + <%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> + <%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px" %> + <% end %> +
    +
    + + +
    + <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %> +
    +

    +
    + +
    + + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type == 1)} %> +
    + + +
    + <% if edit_mode %> + 确定 + + <%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> + <% else %> + 发送 + + 取消 + <% end %> +
    +
    + + -
    - <% if edit_mode %> - <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:height => "150px",:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> - <% else %> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:height => "150px" %> - <% end %>
    -
    +
    +
    + -
    - <%= render :partial => 'users/user_homework_attachment', :locals => { :container => homework } %> + -
    - 发送 - - 取消 -
    -
    -
    \ No newline at end of file + + diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index fa9b1537a..c6e827291 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -3,7 +3,7 @@
    - <%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%> + <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%>
    @@ -11,14 +11,36 @@ TO <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
    - + + <% if homework_common.homework_detail_manual.comment_status == 1%> + 未开启匿评 + <% elsif homework_common.homework_detail_manual.comment_status == 2%> + 匿评中 + <% elsif homework_common.homework_detail_manual.comment_status == 3%> + 匿评已结束 + <% end%>
    <%= user_for_homework_common homework_common,is_teacher %>
    + <% if homework_common.homework_type == 2 && is_teacher%> +
    + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
    + <% end %> + <% if homework_common.homework_type == 2%> +
    + 语言: + <% if homework_common.homework_detail_programing.language.to_i == 1%> + C + <% elsif homework_common.homework_detail_programing.language.to_i == 2%> + C++ + <% end%> +
    + <% end %>
    <%= l(:label_end_time)%>:<%= homework_common.end_time%>
    @@ -30,8 +52,8 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
    - <%# if is_teacher%> - <% if false%> + <% if is_teacher%> + <%# if false%>
    • @@ -42,6 +64,9 @@
    • <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
    • +
    • + <%= homework_anonymous_comment homework_common %> +
    @@ -52,5 +77,6 @@
    <% end%> - - \ No newline at end of file +<% if homework_commons.count == 10%> + <%= link_to "加载更多",user_homeworks_user_path(User.current.id,:page => page),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> +<% end%> \ No newline at end of file diff --git a/app/views/users/_user_jours.html.erb b/app/views/users/_user_jours.html.erb index 9d7a601d5..75a7d0fda 100644 --- a/app/views/users/_user_jours.html.erb +++ b/app/views/users/_user_jours.html.erb @@ -8,7 +8,7 @@ div.ke-toolbar .ke-outline{border:none;} div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} - div.recall_con{width:600px;} + div.recall_con{width:570px;} div.recall_con .reply_btn{margin-left:555px;margin-top:5px;} <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> diff --git a/app/views/users/_user_programing_attr.html.erb b/app/views/users/_user_programing_attr.html.erb new file mode 100644 index 000000000..498005010 --- /dev/null +++ b/app/views/users/_user_programing_attr.html.erb @@ -0,0 +1,44 @@ + +

    编程作业的测试集设置

    +
    +
    +
    + +
    + <% if edit_mode && homework.is_program_homework? %> + <% homework.homework_tests.each_with_index do |test, index| %> +
    + + + + <% if index != 0 %> + + <% end %> +
    +
    + <% end %> + <% else %> +
    + + + +
    +
    + <% end %> + +
    + 温馨提示:您可以在发布作业后,在作业“模拟答题”中进行标准代码的检测。 + 确  定 +
    +
    + +
    + + \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index 08737f5ca..c61790c40 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -1,4 +1,9 @@ <% if @flag == true%> +$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +$("#res_all_count").html(<%= @atta_count%>); closePopUp(); <% else%> <% end %> \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb index 08737f5ca..c61790c40 100644 --- a/app/views/users/add_exist_file_to_project.js.erb +++ b/app/views/users/add_exist_file_to_project.js.erb @@ -1,4 +1,9 @@ <% if @flag == true%> +$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +$("#res_all_count").html(<%= @atta_count%>); closePopUp(); <% else%> <% end %> \ No newline at end of file diff --git a/app/views/users/import_resources_to_homework.js.erb b/app/views/users/import_resources_to_homework.js.erb new file mode 100644 index 000000000..b77590095 --- /dev/null +++ b/app/views/users/import_resources_to_homework.js.erb @@ -0,0 +1,16 @@ +<% unless @attachments.empty?%> + <% @attachments.each_with_index do |attachment, i| %> + $("#attachments_fields").append( + ''+ + '<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => "filename link_file", :readonly=>"readonly")%>'+ + '<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => "description", :style=>"display: inline-block;") %>'+ + '<%= l(:field_is_public)%>:'+ + '<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => "is_public")%>'+ + '<%= link_to(" ".html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => "js"), :method => "delete", :remote => true, :class => "remove-upload") unless attachment.id.nil? %>'+ + '<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>'+ + ''+ + '
    ') + + <% end %> + hideModal(); +<% end %> \ No newline at end of file diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb new file mode 100644 index 000000000..19a971ece --- /dev/null +++ b/app/views/users/new_user_commit_homework.html.erb @@ -0,0 +1,134 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> + + + + + +
    + + +
    +
    <%= @is_test ? '模拟答题' : '提交作品' %>
    +
    +
    + +
    +
    +
    +
    + <%= @homework.name %> +
    + + 截止时间:<%= @homework.end_time %> + +
    + <%= @homework.user.show_name %> +

    + <%= @homework.description.html_safe %> +

    +
    + +
    +
    + <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'users', + :action => 'user_commit_homework', + :student_work_id => @student_work.id, + :homework => @homework.id + }, + :method => :post) do |f|%> + +
    + 请使用 <%= @homework.language_name %> 语言编写 +
    +
    + <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %> +
    +
    + <%= f.text_area :description, id: 'program-src', class:"InputBox W700 H150", placeholder:"请贴入你的代码", rows: 10 %> + +
    +
    + 测试代码 + <% unless @is_test %> + 提交代码 + <% end %> +
    +
    + <% end %> +
    +
    + +
    +
    + + <% @student_work.student_work_tests.each_with_index do |test, index| %> +
    +

    第<%= @student_work.student_work_tests.count - index%>次测试

    <%= test.created_at.to_s(:db) %> +
    +
    + <% if test.status.to_i == -2 %> +
    <%= test.results.first %>
    + <% else %> +
    +
      + <% test.results.each_with_index do |x, i| %> +
    • 测试<%=i+1%> + <% if x["status"].to_i != 0 %> + 测试错误! + 您的输出: + <%=x["result"]%> + 正确输出: + <%=x["output"]%> +
      +
    • + <% else %> + 测试正确! +
      + + <% end %> + <% end %> +
    +
    + <% end %> + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 894c1d2fa..d295ce003 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -1,3 +1,5 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html(<%= @atta_count%>); \ No newline at end of file +$("#res_all_count").html(<%= @atta_count%>); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 74ca48595..de166b4e7 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,58 +1,41 @@ - - -
    -
    +
    最新动态
      -
    • -
        -
      • -
          -
        • 课程动态
        • -
        • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> -
        • -
        • <%= link_to "通知动态", {:controller => "users", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> - -
        • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> -
        • <%= link_to "问卷动态", {:controller => "users", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> - - -
        -
      • -
      • -
          -
        • 项目动态
        • -
        • <%= link_to "问题动态", {:controller => "users", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> -
        • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> - -
        -
      • -
      • -
          -
        • 更多
        • -
        • <%= link_to "全部动态", {:controller => "users", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%> -
        -
      • +
      • +
          +
        • +
            +
          • 课程动态
          • +
          • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
          • +
          • <%= link_to "通知动态", {:controller => "users", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> + +
          • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> +
          • <%= link_to "问卷动态", {:controller => "users", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> + + +
          +
        • +
        • +
            +
          • 项目动态
          • +
          • <%= link_to "问题动态", {:controller => "users", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> +
          • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> + +
          +
        • +
        • +
            +
          • 更多
          • +
          • <%= link_to "我的动态", {:controller => "users", :action => "show", :type => "current_user"}, :class =>"homepagePostTypeMine postTypeGrey"%> +
          • <%= link_to "全部动态", {:controller => "users", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
        -
    + +
    -<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0} %> \ No newline at end of file +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> diff --git a/app/views/users/show.js.erb b/app/views/users/show.js.erb index 0ce84cf0e..eb5de9c6a 100644 --- a/app/views/users/show.js.erb +++ b/app/views/users/show.js.erb @@ -1,4 +1,2 @@ -$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>"); -<% if @user_activities.count < 10%> -$(window).off("scroll", scrollHandler); -<% end%> +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>"); + diff --git a/app/views/users/show_chen.erb b/app/views/users/show_chen.erb deleted file mode 100644 index 11c007b39..000000000 --- a/app/views/users/show_chen.erb +++ /dev/null @@ -1,279 +0,0 @@ -
    -
    -
    最新动态
    - -
    - -
    -
    - 用户头像
    -
    - - -
    - -
    截止时间:2015-08-20
    -
    -
    (作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
    - -
    -
    -
    -
    -
    -
    -
    - 用户头像
    -
    - - -
    - -
    截止时间:2015-08-20
    -
    -
    (作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
    - -
    -
    -
    -
    - - - -
    -
    -
    - 用户头像
    -
    - - -
    -
    时间:2015-07-31
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    回复(5)
    -
    2015-07-31
    - -
    -
    - -
    -
    - - - -
    -
    -
    -
    - 用户头像 -
    -
    -
    黄井泉 学生 - 2015-08-01删除 -
    -
    很开心!
    -
    -
    -
    -
    -
    - 用户头像 -
    -
    -
    陈正东 学生 - 2015-08-02删除 -
    -
    假期好热,没出去。
    -
    -
    -
    -
    -
    -
    -
    -
    - 用户头像
    -
    - - -
    -
    指派给  苏稳 -
    -
    时间:2015-08-20
    -
    -
    (缺陷描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
    -
    - 文件附件.zip(123KB) -
    -
    - 图片附件.png(123KB) -
    -
    - -
    -
    -
    -
    -
    -
    -
    回复(5)
    -
    2015-07-26
    - -
    -
    - -
    -
    - - - -
    -
    -
    -
    - 用户头像 -
    -
    -
    尹教授 - 2015-08-01删除 -
    -
    请大家说下软件工程是什么!
    -
    -
    -
    -
    -
    - 用户头像 -
    -
    -
    Tang 学生 - 2015-08-01删除 -
    -
    软件工程是一门研究用工程化方法构建和维护有效的、实用的和高质量的软件的学科。它涉及程序设计语言、数据库、软件开发工具、系统平台、标准、设计模式等方面。
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/app/views/users/user_commit_homework.html.erb b/app/views/users/user_commit_homework.html.erb new file mode 100644 index 000000000..a7416cf40 --- /dev/null +++ b/app/views/users/user_commit_homework.html.erb @@ -0,0 +1,114 @@ + + + + + + +
    +
    +
    +
    提交作品
    +
    +
    +
    +
    <%= @homework.name %>
    截止时间:<%= @homework.end_time %> +
    + <%= @homework.user.show_name %> +

    <%= @homework.description %>
    +输入 2 1 1 4 4 2 3 6 5
    +输出 15
    +

    +
    +

    注:迟交扣2分,缺评一个作品扣2

    +
    +
    + <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :student_work_id => @student_work.id, + :homework => @homework.id + }, + :method => :post) do |f|%> + +
    + 请使用 <%= @homework.language_name %> 语言编写 +
    +
    + <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %> +
    +
    + <%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"请贴入你的代码", rows: 10 %> +
    + + <% end %> +
    +
    +
    + <% @student_work.student_work_tests.each_with_index do |test, index| %> +
    +

    第<%= @student_work.student_work_tests.count - index%>次测试

    <%= test.created_at.to_s(:db) %> +
    +
    + <% if test.status.to_i == -2 %> +
    <%= test.results.first %>
    + <% else %> +
    +
      + <% test.results.each_with_index do |x, i| %> +
    • 测试<%=i+1%> + <% if x["status"].to_i != 0 %> + 测试错误! + 您的输出: + <%=x["result"]%> + 正确输出: + <%=x["output"]%> +
      +
    • + <% else %> + 测试正确! +
      + + <% end %> + <% end %> +
    +
    + <% end %> + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index e232579f9..f375496d1 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,35 +1,24 @@ +
    +
    作业
    +
    +
    -<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> +<% if @is_teacher%> -
    -
    -
    发布作业
    -
    -
    -
    -
    <% homework = HomeworkCommon.new %> <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> @@ -38,14 +27,6 @@
    <% end%>
    - -<%else%> -
    -
    -
    作业
    -
    -
    -
    <% end%> <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %> diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb index a2e778a21..b6703dd43 100644 --- a/app/views/users/user_homeworks.js.erb +++ b/app/views/users/user_homeworks.js.erb @@ -1,4 +1,2 @@ $("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>"); -<% if @homework_commons.count < 10%> - $(window).off("scroll", scrollHandler); -<% end%> + diff --git a/app/views/users/user_import_resource.js.erb b/app/views/users/user_import_resource.js.erb index ce70d68ad..32a2cd697 100644 --- a/app/views/users/user_import_resource.js.erb +++ b/app/views/users/user_import_resource.js.erb @@ -1,7 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>'); -showModal('ajax-modal', '580px'); -$('#ajax-modal').css('height','300px').css("width","580px"); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_resource',:locals => {:user => @user,:homework_id=>@homework_id}) %>'); +showModal('ajax-modal', '730px'); +$('#ajax-modal').css('height','500px').css("width","730px"); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + -""); -$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed"); \ No newline at end of file +$('#ajax-modal').before("
    " + +"
    "); +$('#ajax-modal').parent().css("top","30%").css("left","").css("position","fixed").css("padding-left","16px").css("padding-bottom","16px").css("padding-right","16px"); +$('#ajax-modal').parent().addClass("popbox").addClass("referenceResourcesPopup"); \ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 207572a1c..5ac9f7e8e 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,37 +1,79 @@ -
    -
    -
    消息
    -
      -
    • -
        -
      • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
      • - <%# 课程相关消息 %> -
      • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
      • -
      • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
      • -
      • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
      • - - - - - <%# 项目相关消息 %> -
      • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
      • - - - - - <%# 项目相关消息 %> - - <%# 系统贴吧 %> - - -
      -
    • -
    -
    +
    +
    <%= title_for_message(params[:type]) %>
    +
      +
    • +
        +
      • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
      • +
      • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
      • + <%# 课程相关消息 %> +
      • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
      • + + + + + <%# 项目相关消息 %> +
      • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
      • + + + + + <%# 项目相关消息 %> +
      • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
      • + <%# 系统贴吧 %> +
      • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
      • + <%# 系统消息 %> +
      • <%= link_to "系统消息", user_system_messages_path(User.current), :class => "resourcesGrey" %>
      • +
      +
    • +
    -<% if @message_alls.count >0 %> +<% if @message_alls.count >0 || @user_system_messages.count >0 %> + <% if params[:type].nil? || params[:type] == "unviewed" %> +
    + 有 <%= unviewed_message(@user) %> 条未读 + <% unless (unviewed_message(@user) == 0 || User.current != @user) %> + <%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %> + <% end %> +
    + <% end %> + <%# 系统消息 %> + <% if params[:type] != 'system_messages' %> + <% @user_system_messages.each do |usm| %> +
      +
    • + +
    • +
    • + Trustie平台发布新消息: +
    • + 【系统消息】
    • +
    • + + <%= link_to usm.subject.nil? ? (usm.content.nil? ? usm.description.html_safe : usm.content.html_safe) : usm.subject, user_system_messages_path(User.current), + :id => "content_link_#{usm.id}", + :onmouseover =>"message_titile_show($(this),event);", + :onmouseout => "message_titile_hide($(this));" + %> +
    • + +
    • <%= time_tag(usm.created_at).html_safe %>
    • +
    + <% end %> + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %> @@ -43,7 +85,11 @@
  • <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id }, :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :title => "#{ma.course_message.title}" %>
  • + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -54,16 +100,54 @@
  • <%= link_to ma.course_message.comments.html_safe, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id }, :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :title => "#{ma.course_message.comments.html_safe}" %>
  • + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status != 1 %> + <% end %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的作业:
    • + <% if ma.viewed == 0 %> +
    • + <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
    • + +
    •    截止时间快到了!
    • + <% else %> +
    • + <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))"%> +
    • + + <% end %>
    • <%= time_tag(ma.created_at).html_safe %>
    <% end %> @@ -74,7 +158,11 @@
  • <%= link_to format_activity_title(" #{ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name}"), poll_path(ma.course_message.id), :class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", - :title => "#{ma.course_message.polls_name}" %>
  • + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -82,10 +170,21 @@ @@ -96,23 +195,81 @@
  • <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>"><%= ma.status == 0 ? "评阅了作品:" : "重新评阅了作品:" %>
  • <% unless ma.content.nil? %> - <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ma.content.html_safe}" %>
  • + <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id), + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> + <% end %>
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> <% if ma.course_message_type == "JournalsForMessage" %> + <% if ma.course_message.jour_type == 'Course' %> + + + <% else %> + + <% end %> + <% end %> + <% end %> + + <% if ma.class == ForgeMessage %> + <% if ma.forge_message_type == "AppliedProject" %> <% end %> - <% end %> - - <% if ma.class == ForgeMessage %> <% if ma.forge_message_type == "Issue" %> <% end %> @@ -141,8 +303,14 @@
  • <%= link_to get_issue_des_update(ma.forge_message).html_safe, issue_path(:id => ma.forge_message.journalized_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :title => "#{get_issue_des_update(ma.forge_message).html_safe}" %> + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
  • +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -151,11 +319,27 @@
  • <%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author) %>
  • <%=link_to ma.forge_message.author, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher" %> "><%= ma.forge_message.parent_id.nil? ? "发布了项目帖子:" : "评论了项目帖子:" %>
  • -
  • - <%=link_to ma.forge_message.subject.html_safe, project_boards_path(ma.forge_message.project, - :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, - :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", - :title => "#{ma.forge_message.subject.html_safe}" %>
  • + <% if ma.forge_message.parent_id.nil? %> +
  • + <%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project, + :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, + :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", + :onmouseover => "message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
  • + + <% else %> +
  • + <%= link_to ma.forge_message.content.html_safe, project_boards_path(ma.forge_message.project, + :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, + :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", + :onmouseover => "message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
  • + + <% end %>
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -169,8 +353,15 @@ ">发布了新闻:
  • - <%= link_to ("#{ma.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ma.forge_message.id}, :class => "newsGrey", :title => "#{ma.forge_message.title.html_safe}" %> + <%= link_to ("#{ma.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ma.forge_message.id}, + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover => "message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
  • +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -181,7 +372,13 @@ ">评论了新闻:
  • <%= link_to "#{ma.forge_message.comments.html_safe}", - {:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.forge_message.comments.html_safe}"%>
  • + {:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover => "message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> + +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -197,9 +394,29 @@ <%=link_to ma.memo.author, user_path(ma.memo.author), :class => "newsBlue homepageNewsPublisher" %> " ><%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %> -
  • - <%= link_to ma.memo.subject, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id),:class => "newsGrey" , :title => "#{ma.memo.content.html_safe}" %> -
  • + <% if ma.memo.parent_id.nil? %> +
  • + <%= link_to ma.memo.subject, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
  • + + <% else %> +
  • + <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
  • + + <% end %>
  • <%= time_tag(ma.memo.created_at).html_safe %>
  • <% end %> @@ -216,9 +433,15 @@ "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
  • - <%= link_to ma.journals_for_message.notes.html_safe, feedback_path(ma.journals_for_message.jour_id), :class => "newsGrey", :title => "#{ma.journals_for_message.notes}" %> + <%= link_to ma.journals_for_message.notes.html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
  • +
  • <%= time_tag(ma.journals_for_message.created_on).html_safe %>
  • + <% end %> <% end %> @@ -236,7 +459,34 @@
    + diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 556069a1f..b94e33b16 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,11 +1,6 @@ - - - - - - - +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %> -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> - - - -
    -
    -
    +
    留言
    -
    +
    <%= form_for('new_form',:url => leave_user_message_path(@user.id),:method => "post") do |f|%> - +

    - 取消 - 留言 + 取消 + 留言 <% end%>
    diff --git a/app/views/users/user_ref_resource_search.js.erb b/app/views/users/user_ref_resource_search.js.erb new file mode 100644 index 000000000..52f54bee4 --- /dev/null +++ b/app/views/users/user_ref_resource_search.js.erb @@ -0,0 +1,2 @@ +$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>'); +$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 819bec04d..096d6e8f5 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -4,9 +4,9 @@ <%= stylesheet_link_tag 'leftside' %> <%= javascript_include_tag 'attachments'%> - - - + + + -
    -
    +
    资源库
    • @@ -67,7 +66,7 @@
    -
    +
    @@ -93,24 +92,24 @@
    -
    +
    - <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> + <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> -
    -
    -
    -
    - 全选 - 删除 -
    -
    选择 0 个资源
    -
    - 发送 +
    +
    + +
    + 全选 + 删除 +
    +
    选择 0 个资源
    +
    + 发送 +
    -
    @@ -122,7 +121,7 @@
    - + diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index ba3efbdfb..2d6c4f4d8 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -1,4 +1,7 @@ closeModal(); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -//这里不能将翻页的更新 \ No newline at end of file +//这里不能将翻页的更新 +$("#res_all_count").html(parseInt($("#res_all_count").html())+1); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); \ No newline at end of file diff --git a/app/views/users/user_resource_type.js.erb b/app/views/users/user_resource_type.js.erb new file mode 100644 index 000000000..52f54bee4 --- /dev/null +++ b/app/views/users/user_resource_type.js.erb @@ -0,0 +1,2 @@ +$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>'); +$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file diff --git a/app/views/users/user_select_homework.js.erb b/app/views/users/user_select_homework.js.erb index 945da4c9a..308f74938 100644 --- a/app/views/users/user_select_homework.js.erb +++ b/app/views/users/user_select_homework.js.erb @@ -3,5 +3,9 @@ hideModal('#coursesChoosePopup'); $("#homework_name").val("<%= @homework.name%>"); $("#homework_end_time").val("<%= @homework.end_time%>"); $("#course_id").val("<%= @homework.course_id%>"); -$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework })%>"); +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework,:has_program => true })%>"); homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>"); +$("#BluePopupBox").html("<%=escape_javascript( render :partial => 'users/user_programing_attr', :locals => {:edit_mode => true, :homework => @homework})%>"); +//$("input[name='homework_type']").val("<%#= @homework.homework_type%>"); +$("#homework_editor").show(); +$("#BluePopupBox a.BlueCirBtn").click(); diff --git a/app/views/users/user_system_messages.html.erb b/app/views/users/user_system_messages.html.erb new file mode 100644 index 000000000..cf0130547 --- /dev/null +++ b/app/views/users/user_system_messages.html.erb @@ -0,0 +1,58 @@ +
    +
    系统消息
    +
      +
    • +
        +
      • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
      • +
      • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
      • + <%# 课程相关消息 %> +
      • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
      • +
      • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
      • + + + + + <%# 项目相关消息 %> +
      • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
      • + + + + + <%# 项目相关消息 %> +
      • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
      • + <%# 系统贴吧 %> +
      • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
      • + <%# 系统消息 %> +
      • <%= link_to "系统消息", user_system_messages_path(User.current), :class => "resourcesGrey" %>
      • +
      +
    • +
    +
    + +<% @sytem_messages.each do |system_message| %> +
    +
    +
    + <%= image_tag("/images/logo.png", :width => "42", :height => "42",class: "mt3") %> +
    +
    +
    + Trustie平台 发布了系统消息: + <%= system_message.subject %> +
    +
    +

    + <%= system_message.content.nil? ? system_message.description.html_safe : system_message.content.html_safe %> +

    +
    +

    截止时间:<%= format_time(system_message.created_at) %>

    +
    +
    +
    +
    +<% end %> +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    \ No newline at end of file diff --git a/config/configuration.yml b/config/configuration.yml index ef204a31e..5c58c705a 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -199,9 +199,12 @@ default: repository_root_path: '/tmp/htdocs' + judge_server: 'http://judge.trustie.net/' + # specific configuration options for production environment # that overrides the default ones production: + judge_server: 'http://192.168.80.21:8080/' repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs' cookie_domain: ".trustie.net" rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf @@ -221,9 +224,9 @@ development: email_delivery: delivery_method: :smtp smtp_settings: - address: mail.trustie.net + address: smtp.163.com port: 25 - domain: mail.trustie.net + domain: smtp.163.com authentication: :login - user_name: "mail@trustie.net" - password: "loong2010" + user_name: "huang.jingquan@163.com" + password: "xinhu1ji2qu366" diff --git a/config/locales/admins/en.yml b/config/locales/admins/en.yml index 479d2f0f0..ed23107cb 100644 --- a/config/locales/admins/en.yml +++ b/config/locales/admins/en.yml @@ -11,3 +11,5 @@ en: label_registration_activation_by_email: account activation by email label_registration_manual_activation: manual account activation label_registration_automatic_activation: automatic account activation + + label_system_message: system messages diff --git a/config/locales/admins/zh.yml b/config/locales/admins/zh.yml index 936b3109f..5d857efae 100644 --- a/config/locales/admins/zh.yml +++ b/config/locales/admins/zh.yml @@ -14,3 +14,7 @@ zh: label_registration_manual_activation: 手动激活帐号 label_registration_automatic_activation: 自动激活帐号 + label_system_message: 系统消息 + label_admin_message_fail: 消息内容过长! + label_content_blank_fail: 消息内容不能为空! + diff --git a/config/locales/mailers/zh.yml b/config/locales/mailers/zh.yml index 211f2e62d..fea392421 100644 --- a/config/locales/mailers/zh.yml +++ b/config/locales/mailers/zh.yml @@ -24,3 +24,5 @@ zh: mail_course_title_userin: "在课程" mail_course_homework_active: "中发布了作业" mail_attention: "请您关注!" + mail_homework_endtime: "作业截止时间快到了!" + mail_homework: "作业:" \ No newline at end of file diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index fe26aee1d..599b51c30 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -347,7 +347,7 @@ zh: # # 邀请 # - label_invite_new_user: "发送邮件邀请新用户" + label_invite_new_user: "邀请用户加入项目" label_invite_join: 邀请加入 label_invite_email_tips: 输入好友的邮箱地址,Trustie会自动为该好友注册平台账号! notice_registed_error: 您输入的邮箱地址为空或者该邮箱已被注册! diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 48502f014..69288d933 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -36,6 +36,7 @@ zh: notice_create_failed: 创建失败,请先完善个人信息 notice_failed_create: 创建失败 notice_successful_update: 更新成功 + notice_successful_message: 消息创建成功! notice_successful_edit: 修改成功 notice_failed_edit: 修改失败 notice_successful_delete: 删除成功 @@ -49,7 +50,10 @@ zh: notice_not_contest_setting_authorized: 对不起,您无权配置此竞赛。 notice_not_contest_delete_authorized: 对不起,您无权删除此竞赛。 notice_not_authorized_archived_project: 要访问的项目已经归档。 + notice_not_authorized_message: 您访问的消息不存在! notice_email_sent: "邮件已发送至 %{value}" + notice_email_login_used: 无法自动为该邮箱注册新用户,该邮箱地址已经有人作为登录名使用! + notice_email_invited: 已经向该邮箱发送过邀请,正在等待对方的回复,三小时后您可以再次发送邀请! notice_email_error: "发送邮件时发生错误 (%{value})" notice_feeds_access_key_reseted: 您的RSS存取键已被重置。 notice_api_access_key_reseted: 您的API访问键已被重置。 @@ -2075,7 +2079,8 @@ zh: label_contact_us: 联系我们 label_recruitment_information: 招聘信息 label_surpport_group: 帮助中心 - label_forums: 论坛反馈 + #label_forums: 论坛反馈 + label_forums: 贴吧交流 label_language: 语言 label_license: 湘ICP备09019772 diff --git a/config/routes.rb b/config/routes.rb index 8451b7365..409a04b20 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -119,7 +119,9 @@ RedmineApp::Application.routes.draw do get 'student_work_absence_penalty' get 'absence_penalty_list' get 'evaluation_list' - post 'set_program_score' + # post 'set_program_score' + post 'program_test' + post 'set_score_rule' end end @@ -171,7 +173,7 @@ RedmineApp::Application.routes.draw do resources :contests, only: [:index] do resources :contestnotifications do # get 'preview', on: :collection - resources :notificationcomments + resources :notificationcomments end collection do @@ -232,7 +234,7 @@ RedmineApp::Application.routes.draw do end end end - + resources :shares @@ -259,10 +261,20 @@ RedmineApp::Application.routes.draw do match '/users/search', :via => [:get, :post] #end + # 消息相关路由 + resources :system_messages do + collection do + post 'create', :as => 'system_messages' + get 'index', :as => 'index' + end + end + # match 'system_messages/index', to: 'system_messages#index', :via => :get, :as => 'system_messages' + match 'account/heartbeat', to: 'account#heartbeat', :via => :get match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] match 'agreement',:to => 'account#agreement',:as => 'agreement',:via=>[:get] + match 'about_us',:to=>'account#about_us',:as=>'about_us',:via=>[:get] match 'account/register', :via => [:get, :post], :as => 'register' match 'account/lost_password', :via => [:get, :post], :as => 'lost_password' match 'account/activate', :via => :get @@ -309,8 +321,11 @@ RedmineApp::Application.routes.draw do collection do match "tag_saveEx" , :via => [:get, :post] post "user_new_homework" + get 'new_user_commit_homework' + post "user_commit_homework" post 'user_select_homework' end + member do match 'user_projects_index', :to => 'users#user_projects_index', :via => :get match 'user_projects', :to => 'users#user_projects', :via => :get @@ -365,13 +380,17 @@ RedmineApp::Application.routes.draw do get 'resource_preview' post 'rename_resource' get 'search_user_project' - # end + get 'user_resource_type' + get 'user_ref_resource_search' + post 'import_resources_to_homework' + # end end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get #消息 match 'users/:id/user_messages', :to => 'users#user_messages', :via => :get, :as => "user_message" + match 'users/:id/user_system_messages', :to => 'users#user_system_messages', :via => :get, :as => "user_system_messages" #match 'users/:id/user_messages/:homework', :to => 'users#user_messages_homework', :via => :get, :as => "user_message_homewrok" @@ -428,7 +447,7 @@ RedmineApp::Application.routes.draw do get 'feedback', :action => 'feedback', :as => 'project_feedback' get 'watcherlist', :action=> 'watcherlist' - get 'invite_members', :action=> 'invite_members' + # get 'invite_members', :action=> 'invite_members' get 'invite_members_by_mail', :action=> 'invite_members_by_mail' # get 'dts_repos', :aciton => 'dts_repos' get 'send_mail_to_member', :action => 'send_mail_to_member' @@ -479,7 +498,7 @@ RedmineApp::Application.routes.draw do collection do match "getattachtype" , :via => [:get, :post] match "search_project",:via => [:post,:get] - #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] + #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] end end @@ -509,7 +528,7 @@ RedmineApp::Application.routes.draw do resources :repositories, :except => [:index, :show] do member do get 'newrepo', :via => [:get, :post] - # get 'create', :via=>[:get, :post] + # get 'create', :via=>[:get, :post] end end match 'wiki/index', :via => :get @@ -540,6 +559,9 @@ RedmineApp::Application.routes.draw do match 'bulk_edit', :via => [:get, :post] post 'bulk_update' end + member do + post 'add_journal' + end resources :time_entries, :controller => 'timelog' do collection do get 'report' @@ -596,8 +618,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/statistics', :to => 'repositories#stats' @@ -614,8 +636,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', @@ -691,6 +713,7 @@ RedmineApp::Application.routes.draw do match 'admin/projects', :via => :get get 'admin/courses' match 'admin/users', :via => :get + match 'admin/messages', :via => :get match 'admin/first_page_made', as: :first_page_made match 'admin/course_page_made', as: :course_page_made match 'admin/contest_page_made', as: :contest_page_made @@ -718,7 +741,7 @@ RedmineApp::Application.routes.draw do get 'test_connection', :as => 'try_connection' end collection do - get 'autocomplete_for_new_user' + get 'autocomplete_for_new_user' end end @@ -780,7 +803,7 @@ RedmineApp::Application.routes.draw do collection do match 'chang_read_flag', :via => :get end - end + end end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' @@ -863,6 +886,7 @@ RedmineApp::Application.routes.draw do match 'tags/remove_tag', :as=>"remove_tag" match 'tags/remove_tag_new', :as=>"remove_tag_new" match 'tags/tag_save', :as => "save_tag" + match 'tags/update_tag_name',:as => "update_tag_name" match 'words/add_brief_introdution' diff --git a/db/migrate/20150828011415_change_student_work_tests.rb b/db/migrate/20150828011415_change_student_work_tests.rb new file mode 100644 index 000000000..7d4459ab6 --- /dev/null +++ b/db/migrate/20150828011415_change_student_work_tests.rb @@ -0,0 +1,13 @@ +class ChangeStudentWorkTests < ActiveRecord::Migration + + def change + change_table :student_work_tests do |t| + t.remove :error_msg + t.remove :result + t.remove :homework_test_id + t.integer :status, default: 9 + t.text :results + end + end + +end diff --git a/db/migrate/20150828155329_add_src_to_student_work_tests.rb b/db/migrate/20150828155329_add_src_to_student_work_tests.rb new file mode 100644 index 000000000..89bd80882 --- /dev/null +++ b/db/migrate/20150828155329_add_src_to_student_work_tests.rb @@ -0,0 +1,5 @@ +class AddSrcToStudentWorkTests < ActiveRecord::Migration + def change + add_column :student_work_tests, :src, :text + end +end diff --git a/db/migrate/20150829023459_forge_messages.rb b/db/migrate/20150829023459_forge_messages.rb index c468ad68f..96369a323 100644 --- a/db/migrate/20150829023459_forge_messages.rb +++ b/db/migrate/20150829023459_forge_messages.rb @@ -1,78 +1,78 @@ # encoding: UTF-8 class ForgeMessages < ActiveRecord::Migration def up - Project.all.each do |project| - transaction do - project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id) - - # 新闻 - project.news.each do |new| - new.project.members.each do |m| - if m.user_id != new.author_id - if m.created_on < new.created_on # 在成员加入项目之后 - new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true) - end - end - end - end - - # 新闻回复 - project.news.each do |new| - if new.comments - new.comments.each do |comment| - if comment.author_id != comment.commented.author_id - comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true) - end - end - end - end - - # 讨论区 - if project.boards.first - project.boards.first.messages.each do |message| - if message.parent_id.nil? # 主贴 - message.project.members.each do |m| - if m.user_id != message.author_id - if m.created_on < message.created_on - message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) - end - end - end - else # 回帖 - message.project.members.each do |m| - if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 - if m.created_on < message.created_on - message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) - end - end - end - end - end - end - - # 缺陷 - project.issues.each do |issue| - unless issue.author_id == issue.assigned_to_id - issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true) - end - end - - # 缺陷更新 - project.issues.each do |issue| - if issue.journals - issue.journals.each do |journal| - if journal.user_id != journal.issue.author_id - journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true) - end - if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送 - journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true) - end - end - end - end - - end - end + # Project.all.each do |project| + # transaction do + # project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id) + # + # # 新闻 + # project.news.each do |new| + # new.project.members.each do |m| + # if m.user_id != new.author_id + # if m.created_on < new.created_on # 在成员加入项目之后 + # new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true) + # end + # end + # end + # end + # + # # 新闻回复 + # project.news.each do |new| + # if new.comments + # new.comments.each do |comment| + # if comment.author_id != comment.commented.author_id + # comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true) + # end + # end + # end + # end + # + # # 讨论区 + # if project.boards.first + # project.boards.first.messages.each do |message| + # if message.parent_id.nil? # 主贴 + # message.project.members.each do |m| + # if m.user_id != message.author_id + # if m.created_on < message.created_on + # message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) + # end + # end + # end + # else # 回帖 + # message.project.members.each do |m| + # if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 + # if m.created_on < message.created_on + # message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) + # end + # end + # end + # end + # end + # end + # + # # 缺陷 + # project.issues.each do |issue| + # unless issue.author_id == issue.assigned_to_id + # issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true) + # end + # end + # + # # 缺陷更新 + # project.issues.each do |issue| + # if issue.journals + # issue.journals.each do |journal| + # if journal.user_id != journal.issue.author_id + # journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true) + # end + # if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送 + # journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true) + # end + # end + # end + # end + # + # end + # end end def down diff --git a/db/migrate/20150829024549_course_messages.rb b/db/migrate/20150829024549_course_messages.rb index 666ccdaeb..9d66bf9cd 100644 --- a/db/migrate/20150829024549_course_messages.rb +++ b/db/migrate/20150829024549_course_messages.rb @@ -1,79 +1,80 @@ # encoding: UTF-8 class CourseMessages < ActiveRecord::Migration def up - Course.all.each do |course| - transaction do - course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id) - # 作业 - course.homework_commons.each do |homework_common| - homework_common.course.members.each do |m| - if m.user_id != homework_common.user_id - if m.created_on < homework_common.created_at - homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 通知 - course.news.each do |new| - new.course.members.each do |m| - if m.user_id != new.author_id - if m.created_on < new.created_on # 在成员加入课程之后 - new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 通知的回复 - course.news.each do |new| - if new.comments - new.comments.each do |comment| - if comment.author_id != comment.commented.author_id - comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 讨论区 - if course.boards.first - course.boards.first.messages.each do |message| - if message.parent_id.nil? # 主贴 - message.course.members.each do |m| - if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息 - if m.created_on < message.created_on - message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - else # 回帖 - message.course.members.each do |m| - if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 - if m.created_on < message.created_on - message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - end - end - - # 问卷 - Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll| - if poll.polls_status == 2 #问卷是发布状态 - Course.find(poll.polls_group_id).members.each do |m| - if m.user_id != poll.user_id - if m.created_on < poll.created_at - poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - elsif poll.polls_status == 1 #问卷是新建状态 - poll.course_messages.destroy_all - end - end + # Course.all.each do |course| + # transaction do + # put course.id + # course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id) + # # 作业 + # course.homework_commons.each do |homework_common| + # homework_common.course.members.each do |m| + # if m.user_id != homework_common.user_id + # if m.created_on < homework_common.created_at + # homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 通知 + # course.news.each do |new| + # new.course.members.each do |m| + # if m.user_id != new.author_id + # if m.created_on < new.created_on # 在成员加入课程之后 + # new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 通知的回复 + # course.news.each do |new| + # if new.comments + # new.comments.each do |comment| + # if comment.author_id != comment.commented.author_id + # comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 讨论区 + # if course.boards.first + # course.boards.first.messages.each do |message| + # if message.parent_id.nil? # 主贴 + # message.course.members.each do |m| + # if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息 + # if m.created_on < message.created_on + # message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # else # 回帖 + # message.course.members.each do |m| + # if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 + # if m.created_on < message.created_on + # message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # end + # end + # + # # 问卷 + # Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll| + # if poll.polls_status == 2 #问卷是发布状态 + # Course.find(poll.polls_group_id).members.each do |m| + # if m.user_id != poll.user_id + # if m.created_on < poll.created_at + # poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # elsif poll.polls_status == 1 #问卷是新建状态 + # poll.course_messages.destroy_all + # end + # end # 作品评阅 # course.homework_commons.each do |homework_common| @@ -106,8 +107,8 @@ class CourseMessages < ActiveRecord::Migration # end # 作品讨论 - end - end + # end + # end end def down diff --git a/db/migrate/20150829081822_update_message_time.rb b/db/migrate/20150829081822_update_message_time.rb index fe670e9b8..a5b2457ad 100644 --- a/db/migrate/20150829081822_update_message_time.rb +++ b/db/migrate/20150829081822_update_message_time.rb @@ -1,24 +1,25 @@ class UpdateMessageTime < ActiveRecord::Migration def up - course_count = CourseMessage.all.count / 30 + 1 - transaction do - for i in 1 ... course_count do i - CourseMessage.page(i).per(30).each do |cmessage| - if cmessage.course_message - if cmessage.course_message.respond_to?("created_at") - cmessage.created_at = cmessage.course_message.created_at - elsif cmessage.course_message.respond_to?("created_on") - cmessage.created_at = cmessage.course_message.created_on - end - cmessage.save - - course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first - course_all_message.created_at = cmessage.created_at - course_all_message.save - end - end - end - end + # course_count = CourseMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... course_count do i + # CourseMessage.page(i).per(30).each do |cmessage| + # if cmessage.course_message + # if cmessage.course_message.respond_to?("created_at") + # cmessage.created_at = cmessage.course_message.created_at + # elsif cmessage.course_message.respond_to?("created_on") + # cmessage.created_at = cmessage.course_message.created_on + # end + # cmessage.save + # puts cmessage.id + # + # course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first + # course_all_message.created_at = cmessage.created_at + # course_all_message.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150829130302_update_forge_message_time.rb b/db/migrate/20150829130302_update_forge_message_time.rb index 70811c307..3121278ae 100644 --- a/db/migrate/20150829130302_update_forge_message_time.rb +++ b/db/migrate/20150829130302_update_forge_message_time.rb @@ -1,24 +1,25 @@ class UpdateForgeMessageTime < ActiveRecord::Migration def up - forge_count = ForgeMessage.all.count / 30 + 1 - transaction do - for i in 1 ... forge_count do i - ForgeMessage.page(i).per(30).each do |fmessage| - if fmessage.forge_message - if fmessage.forge_message.respond_to?("created_at") - fmessage.created_at = fmessage.forge_message.created_at - elsif fmessage.forge_message.respond_to?("created_on") - fmessage.created_at = fmessage.forge_message.created_on - end - fmessage.save - - forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first - forge_all_message.created_at = fmessage.created_at - forge_all_message.save - end - end - end - end + # forge_count = ForgeMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... forge_count do i + # ForgeMessage.page(i).per(30).each do |fmessage| + # if fmessage.forge_message + # if fmessage.forge_message.respond_to?("created_at") + # fmessage.created_at = fmessage.forge_message.created_at + # elsif fmessage.forge_message.respond_to?("created_on") + # fmessage.created_at = fmessage.forge_message.created_on + # end + # fmessage.save + # puts fmessage.id + # + # forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first + # forge_all_message.created_at = fmessage.created_at + # forge_all_message.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150831070611_about_memo_message.rb b/db/migrate/20150831070611_about_memo_message.rb new file mode 100644 index 000000000..a6e4a34c1 --- /dev/null +++ b/db/migrate/20150831070611_about_memo_message.rb @@ -0,0 +1,36 @@ +class AboutMemoMessage < ActiveRecord::Migration + def up + # Memo.all.each do |memo| + # transaction do + # # 贴吧帖子 + # receivers = [] + # u = User.find(6) + # receivers << u + # # 主贴 + # if memo.parent_id.nil? + # if memo.author_id != memo.forum.creator_id # 发帖人不是吧主 + # receivers << memo.forum.creator + # end + # else # 回帖 + # # 添加吧主 + # if memo.author_id != memo.forum.creator_id + # receivers << memo.forum.creator + # end + # # 添加发帖人 + # unless memo.parent.nil? + # if memo.author_id != memo.parent.author_id + # receivers << memo.parent.author + # puts memo.id + # end + # end + # end + # receivers.each do |r| + # memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true) + # end + # end + # end + end + + def down + end +end diff --git a/db/migrate/20150831093918_about_user_feedback_message.rb b/db/migrate/20150831093918_about_user_feedback_message.rb new file mode 100644 index 000000000..a76b7c5e3 --- /dev/null +++ b/db/migrate/20150831093918_about_user_feedback_message.rb @@ -0,0 +1,36 @@ +class AboutUserFeedbackMessage < ActiveRecord::Migration + def up + # JournalsForMessage.all.each do |jour_for_message| + # transaction do + # # 主留言 + # if jour_for_message.jour_type == 'Principal' + # receivers = [] + # if jour_for_message.reply_id == 0 + # if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息 + # receivers << jour_for_message.jour + # end + # else # 留言回复 + # reply_to = User.find(jour_for_message.reply_id) + # if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人 + # receivers << reply_to + # end + # unless jour_for_message.parent.nil? + # if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 + # receivers << jour_for_message.parent.jour + # end + # end + # end + # unless receivers.blank? + # receivers.each do |r| + # puts jour_for_message.id + # jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true) + # end + # end + # end + # end + # end + end + + def down + end +end diff --git a/db/migrate/20150901004812_update_memo_message_time.rb b/db/migrate/20150901004812_update_memo_message_time.rb new file mode 100644 index 000000000..8760a50a4 --- /dev/null +++ b/db/migrate/20150901004812_update_memo_message_time.rb @@ -0,0 +1,27 @@ +class UpdateMemoMessageTime < ActiveRecord::Migration + def up + # memo_count = Memo.all.count / 30 + 1 + # transaction do + # for i in 1 ... memo_count do i + # MemoMessage.page(i).per(30).each do |memo_message| + # if memo_message.memo + # if memo_message.memo.respond_to?("created_at") + # memo_message.created_at = memo_message.memo.created_at + # elsif memo_message.memo.respond_to?("created_on") + # memo_message.created_at = memo_message.memo.created_on + # end + # memo_message.save + # puts memo_message.id + # + # memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first + # memo_messages.created_at = memo_message.created_at + # memo_messages.save + # end + # end + # end + # end + end + + def down + end +end diff --git a/db/migrate/20150901004910_update_userfeeback_message_time.rb b/db/migrate/20150901004910_update_userfeeback_message_time.rb new file mode 100644 index 000000000..95bfbd2ac --- /dev/null +++ b/db/migrate/20150901004910_update_userfeeback_message_time.rb @@ -0,0 +1,27 @@ +class UpdateUserfeebackMessageTime < ActiveRecord::Migration + def up + # user_feedback_count = UserFeedbackMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... user_feedback_count do i + # UserFeedbackMessage.page(i).per(30).each do |ufm| + # if ufm.journals_for_message + # if ufm.journals_for_message.respond_to?("created_at") + # ufm.created_at = ufm.journals_for_message.created_at + # elsif ufm.journals_for_message.respond_to?("created_on") + # ufm.created_at = ufm.journals_for_message.created_on + # end + # puts ufm.id + # ufm.save + # + # user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first + # user_feedback_messages.created_at = ufm.created_at + # user_feedback_messages.save + # end + # end + # end + # end + end + + def down + end +end diff --git a/db/migrate/20150906025009_forge_activitues_date.rb b/db/migrate/20150906025009_forge_activitues_date.rb new file mode 100644 index 000000000..b282d1938 --- /dev/null +++ b/db/migrate/20150906025009_forge_activitues_date.rb @@ -0,0 +1,25 @@ +class ForgeActivituesDate < ActiveRecord::Migration + def up + forge_count = ForgeActivity.all.count / 30 + 2 + transaction do + for i in 1 ... forge_count do i + ForgeActivity.page(i).per(30).each do |activity| + unless activity.forge_act_type == "ProjectCreateInfo" + if activity.forge_act + unless activity.forge_act.project + # puts activity.id + activity.destroy + end + else + # puts activity.id.to_s + "----" + activity.destroy + end + end + end + end + end + end + + def down + end +end diff --git a/db/migrate/20150906065702_create_onclick_times.rb b/db/migrate/20150906065702_create_onclick_times.rb new file mode 100644 index 000000000..3922b775e --- /dev/null +++ b/db/migrate/20150906065702_create_onclick_times.rb @@ -0,0 +1,10 @@ +class CreateOnclickTimes < ActiveRecord::Migration + def change + create_table :onclick_times do |t| + t.integer :user_id + t.datetime :onclick_time + + t.timestamps + end + end +end diff --git a/db/migrate/20150906083453_delete_anonymous_jour.rb b/db/migrate/20150906083453_delete_anonymous_jour.rb new file mode 100644 index 000000000..52e5454e5 --- /dev/null +++ b/db/migrate/20150906083453_delete_anonymous_jour.rb @@ -0,0 +1,8 @@ +class DeleteAnonymousJour < ActiveRecord::Migration + def up + Journal.where("user_id = 2").destroy_all + end + + def down + end +end diff --git a/db/migrate/20150906090419_delete_anonymous_feedback.rb b/db/migrate/20150906090419_delete_anonymous_feedback.rb new file mode 100644 index 000000000..771fd4856 --- /dev/null +++ b/db/migrate/20150906090419_delete_anonymous_feedback.rb @@ -0,0 +1,8 @@ +class DeleteAnonymousFeedback < ActiveRecord::Migration + def up + JournalsForMessage.where("user_id = 2").destroy_all + end + + def down + end +end diff --git a/db/migrate/20150906091723_delete_anonymous_message.rb b/db/migrate/20150906091723_delete_anonymous_message.rb new file mode 100644 index 000000000..dc60bc5e4 --- /dev/null +++ b/db/migrate/20150906091723_delete_anonymous_message.rb @@ -0,0 +1,8 @@ +class DeleteAnonymousMessage < ActiveRecord::Migration + def up + Message.where("author_id = 2").destroy_all + end + + def down + end +end diff --git a/db/migrate/20150907064144_add_user_id_to_user_activities.rb b/db/migrate/20150907064144_add_user_id_to_user_activities.rb new file mode 100644 index 000000000..a038f4dab --- /dev/null +++ b/db/migrate/20150907064144_add_user_id_to_user_activities.rb @@ -0,0 +1,5 @@ +class AddUserIdToUserActivities < ActiveRecord::Migration + def change + add_column :user_activities, :user_id, :int + end +end diff --git a/db/migrate/20150907064547_update_user_activities.rb b/db/migrate/20150907064547_update_user_activities.rb new file mode 100644 index 000000000..b4c56c009 --- /dev/null +++ b/db/migrate/20150907064547_update_user_activities.rb @@ -0,0 +1,40 @@ +class UpdateUserActivities < ActiveRecord::Migration + def up + count = UserActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + UserActivity.page(i).per(30).each do |activity| + if activity.container_type.to_s == 'Project' + forge_activity = ForgeActivity.where("forge_act_type = '#{activity.act_type.to_s}' and forge_act_id = #{activity.act_id}").first + if forge_activity + activity.user_id = forge_activity.user_id + else + activity.user_id = 0 + end + + elsif activity.container_type.to_s == 'Course' + course_activity = CourseActivity.where("course_act_type = '#{activity.act_type.to_s}' and course_act_id = #{activity.act_id}").first + if course_activity + activity.user_id = course_activity.user_id + else + activity.user_id = 0 + end + end + activity.save + end + end + end + end + + def down + count = UserActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + UserActivity.page(i).per(30).each do |activity| + activity.user_id = nil + activity.save + end + end + end + end +end diff --git a/db/migrate/20150907152238_add_is_test_to_student_works.rb b/db/migrate/20150907152238_add_is_test_to_student_works.rb new file mode 100644 index 000000000..b58da7c16 --- /dev/null +++ b/db/migrate/20150907152238_add_is_test_to_student_works.rb @@ -0,0 +1,5 @@ +class AddIsTestToStudentWorks < ActiveRecord::Migration + def change + add_column :student_works, :is_test, :boolean, default: false + end +end diff --git a/db/migrate/20150909062619_create_system_messages.rb b/db/migrate/20150909062619_create_system_messages.rb new file mode 100644 index 000000000..a51715ead --- /dev/null +++ b/db/migrate/20150909062619_create_system_messages.rb @@ -0,0 +1,11 @@ +class CreateSystemMessages < ActiveRecord::Migration + def change + create_table :system_messages do |t| + t.integer :id + t.integer :user_id + t.string :content + + t.timestamps + end + end +end diff --git a/db/migrate/20150911031029_about_programing_homework.rb b/db/migrate/20150911031029_about_programing_homework.rb new file mode 100644 index 000000000..50786834b --- /dev/null +++ b/db/migrate/20150911031029_about_programing_homework.rb @@ -0,0 +1,25 @@ +class AboutProgramingHomework < ActiveRecord::Migration + def up + HomeworkCommon.where(:homework_type => 2).each do |homework| + unless homework.homework_detail_manual + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = homework.created_at + homework_detail_manual.evaluation_end = homework.created_at + homework_detail_manual.evaluation_num = 3 + homework_detail_manual.absence_penalty = 2 + homework_detail_manual.homework_common_id = homework.id + homework_detail_manual.save + end + end + end + + def down + HomeworkCommon.where(:homework_type => 2).each do |homework| + if homework.homework_detail_manual + homework.homework_detail_manual.destroy + end + end + end +end diff --git a/db/migrate/20150911064528_alter_user_activities.rb b/db/migrate/20150911064528_alter_user_activities.rb new file mode 100644 index 000000000..b6ede5bdb --- /dev/null +++ b/db/migrate/20150911064528_alter_user_activities.rb @@ -0,0 +1,21 @@ +class AlterUserActivities < ActiveRecord::Migration + def up + UserActivity.all.each do |activity| + if activity.act_type == 'Message' + if activity.act + unless activity.act.parent_id.nil? + parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='Message'").first + parent_act.created_at = activity.act.parent.children.maximum("created_on") + parent_act.save + activity.destroy + end + else + activity.destroy + end + end + end + end + + def down + end +end diff --git a/db/migrate/20150914063751_add_description_to_system_message.rb b/db/migrate/20150914063751_add_description_to_system_message.rb new file mode 100644 index 000000000..9cc9e4172 --- /dev/null +++ b/db/migrate/20150914063751_add_description_to_system_message.rb @@ -0,0 +1,5 @@ +class AddDescriptionToSystemMessage < ActiveRecord::Migration + def change + add_column :system_messages, :description, :text + end +end diff --git a/db/migrate/20150915063302_add_mail_to_invite_list.rb b/db/migrate/20150915063302_add_mail_to_invite_list.rb new file mode 100644 index 000000000..800b5abd4 --- /dev/null +++ b/db/migrate/20150915063302_add_mail_to_invite_list.rb @@ -0,0 +1,5 @@ +class AddMailToInviteList < ActiveRecord::Migration + def change + add_column :invite_lists, :mail, :string + end +end diff --git a/db/migrate/20150917022239_add_teacher_priority_to_homework.rb b/db/migrate/20150917022239_add_teacher_priority_to_homework.rb new file mode 100644 index 000000000..20ab421bc --- /dev/null +++ b/db/migrate/20150917022239_add_teacher_priority_to_homework.rb @@ -0,0 +1,5 @@ +class AddTeacherPriorityToHomework < ActiveRecord::Migration + def change + add_column :homework_commons,:teacher_priority,:integer,:default => 1 + end +end diff --git a/db/migrate/20150917071652_update_user_activities_update_at.rb b/db/migrate/20150917071652_update_user_activities_update_at.rb new file mode 100644 index 000000000..7fbd425f4 --- /dev/null +++ b/db/migrate/20150917071652_update_user_activities_update_at.rb @@ -0,0 +1,16 @@ +class UpdateUserActivitiesUpdateAt < ActiveRecord::Migration + def up + count = UserActivity.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + UserActivity.page(i).per(30).each do |activity| + activity.updated_at = activity.created_at + activity.save + end + end + end + end + + def down + end +end diff --git a/db/migrate/20150917081214_add_subject_to_system_message.rb b/db/migrate/20150917081214_add_subject_to_system_message.rb new file mode 100644 index 000000000..69cdd2a63 --- /dev/null +++ b/db/migrate/20150917081214_add_subject_to_system_message.rb @@ -0,0 +1,5 @@ +class AddSubjectToSystemMessage < ActiveRecord::Migration + def change + add_column :system_messages, :subject, :string + end +end diff --git a/db/migrate/20150918004521_system_score_default.rb b/db/migrate/20150918004521_system_score_default.rb new file mode 100644 index 000000000..6195caad9 --- /dev/null +++ b/db/migrate/20150918004521_system_score_default.rb @@ -0,0 +1,15 @@ +class SystemScoreDefault < ActiveRecord::Migration + def up + change_column :student_works,:system_score,:float,:default => 0 + + + # StudentWork.where("system_score is null").each do |student_work| + # student_work.system_score = 0 + # student_work.save + # end + end + + def down + change_column :student_works,:system_score,:float + end +end diff --git a/db/migrate/20150918005722_about_normal_homework.rb b/db/migrate/20150918005722_about_normal_homework.rb new file mode 100644 index 000000000..8e0ddf00a --- /dev/null +++ b/db/migrate/20150918005722_about_normal_homework.rb @@ -0,0 +1,20 @@ +class AboutNormalHomework < ActiveRecord::Migration + def up + HomeworkCommon.where(:homework_type => 0).each do |homework| + unless homework.homework_detail_manual + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = homework.created_at + homework_detail_manual.evaluation_end = homework.created_at + homework_detail_manual.evaluation_num = 3 + homework_detail_manual.absence_penalty = 5 + homework_detail_manual.homework_common_id = homework.id + homework_detail_manual.save + end + end + end + + def down + end +end diff --git a/db/migrate/20150918063404_normal_homework_type.rb b/db/migrate/20150918063404_normal_homework_type.rb new file mode 100644 index 000000000..def3b0024 --- /dev/null +++ b/db/migrate/20150918063404_normal_homework_type.rb @@ -0,0 +1,8 @@ +class NormalHomeworkType < ActiveRecord::Migration + def up + HomeworkCommon.where("homework_type = 0").update_all(:homework_type => 1) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 05825bd5d..d0c60e724 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150829070453) do +ActiveRecord::Schema.define(:version => 20150917081214) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -497,23 +497,26 @@ ActiveRecord::Schema.define(:version => 20150829070453) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -616,11 +619,12 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.text "description" t.date "publish_time" t.date "end_time" - t.integer "homework_type", :default => 1 + t.integer "homework_type", :default => 1 t.string "late_penalty" t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "teacher_priority", :default => 1 end create_table "homework_detail_manuals", :force => true do |t| @@ -682,6 +686,7 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.integer "user_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "mail" end create_table "issue_categories", :force => true do |t| @@ -936,6 +941,13 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.datetime "updated_at", :null => false end + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" @@ -1296,11 +1308,11 @@ ActiveRecord::Schema.define(:version => 20150829070453) do create_table "student_work_tests", :force => true do |t| t.integer "student_work_id" - t.integer "homework_test_id" - t.integer "result" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "error_msg" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" end create_table "student_works", :force => true do |t| @@ -1313,10 +1325,12 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.float "student_score" t.float "teaching_asistant_score" t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "late_penalty", :default => 0 t.integer "absence_penalty", :default => 0 + t.integer "system_score" + t.boolean "is_test", :default => false end create_table "student_works_evaluation_distributions", :force => true do |t| @@ -1346,6 +1360,15 @@ ActiveRecord::Schema.define(:version => 20150829070453) do add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" + t.string "subject" + end + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -1420,6 +1443,7 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.integer "container_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "user_id" end create_table "user_extensions", :force => true do |t| @@ -1534,7 +1558,6 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.string "identity_url" t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 - t.integer "gid" end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index d5f91ebf8..f30ee2236 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -7,7 +7,10 @@ module RailsKindeditor input_html = input_html.merge(style: 'display:none') output = ActiveSupport::SafeBuffer.new output << text_area_tag(name, content, input_html) - output << javascript_tag(js_replace(id, options.merge(window_onload: 'true'))) + output << javascript_tag(js_replace(id, options.merge(window_onload: 'true', + :autoHeightMode=>true, + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + ))) end def kindeditor(name, method, options = {}) @@ -17,7 +20,9 @@ module RailsKindeditor output_buffer = ActiveSupport::SafeBuffer.new output_buffer << build_text_area_tag(name, method, self, options, input_html) output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true', - afterCreate: 'eval(function(){enablePasteImg(self);})'))) + :autoHeightMode=>true, + afterCreate: 'eval(function(){enablePasteImg(self);this.loadPlugin("autoheight")})' + ))) end def kindeditor_upload_json_path(*args) diff --git a/lib/redmine.rb b/lib/redmine.rb index 99b7ea22f..8ebdacfa6 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -369,6 +369,7 @@ Redmine::MenuManager.map :admin_menu do |menu| menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural + menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural menu.push :first_page_made, {:controller => 'admin',:action => 'first_page_made'},:caption => :label_first_page_made menu.push :mobile_version, {:controller => 'admin',:action => 'mobile_version'},:caption => :label_mobile_version diff --git a/lib/tasks/homework_endtime.rake b/lib/tasks/homework_endtime.rake new file mode 100644 index 000000000..1a400dc32 --- /dev/null +++ b/lib/tasks/homework_endtime.rake @@ -0,0 +1,20 @@ +#coding=utf-8 + +namespace :homework_endtime do + desc "send a message for Job deadline" + task :message => :environment do + current_day = Date.today.day + homework_commons = HomeworkCommon.where("end_time >=?",Date.today) + homework_commons.each do |homework_common| + if CourseMessage.where("course_message_type =? and course_message_id =? and status =?", "HomeworkCommon", homework_common.id, 1).first.nil? + if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year + homework_common.course.student.each do |s| + homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true) + # 发送邮件通知 + Mailer.homework_endtime__added(homework_common, s.student_id).deliver + end + end + end + end + end +end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 98dfc470b..e8c28f678 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -258,16 +258,16 @@ K.options = { fullscreenShortcut : false, bodyClass : 'ke-content', indentChar : '\t', - cssPath : '', + cssPath : K.basePath +'plugins/code/previewcode.css', cssData : '', minWidth : 650, minHeight : 100, minChangeSize : 50, zIndex : 811213, - items : [ 'emoticons', - 'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|', - 'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', - 'italic', 'underline', 'removeformat', '|','imagedirectupload','table', 'media',"more" + items : ['code', 'emoticons','fontname', + 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|', + 'formatblock', 'fontsize', '|','indent', 'outdent', + '|','imagedirectupload','table', 'media', 'preview',"more" ], noDisableItems : ['source', 'fullscreen'], colorTable : [ @@ -3536,8 +3536,8 @@ function _getInitHtml(themesPath, bodyClass, cssPath, cssData) { (_direction === '' ? '' : ''), '', '').appendTo($("head")); - } - var cb = settings.boxClass, cl = settings.listClass, cf = settings.focusClass, cm = settings.markCalss; //插件的class变量 - var z = settings.zIndex, newArr = mailArr = settings.mailArr, hint = settings.textHint, text = settings.hintText, fc = settings.focusColor, bc = settings.blurColor; +// var settings = $.extend({}, defaults, options || {}); +// //页面装载CSS样式 +// if(settings.autoClass && $("#mailListAppendCss").size() === 0){ +// $('').appendTo($("head")); +// } +// var cb = settings.boxClass, cl = settings.listClass, cf = settings.focusClass, cm = settings.markCalss; //插件的class变量 +// var z = settings.zIndex, newArr = mailArr = settings.mailArr, hint = settings.textHint, text = settings.hintText, fc = settings.focusColor, bc = settings.blurColor; //创建邮件内部列表内容 - $.createHtml = function(str, arr, cur){ - var mailHtml = ""; - if($.isArray(arr)){ - $.each(arr, function(i, n){ - if(i === cur){ - mailHtml += '
    '+str+'@'+arr[i]+'
    '; - }else{ - mailHtml += '
    '+str+'@'+arr[i]+'
    '; - } - }); - } - return mailHtml; - }; +// $.createHtml = function(str, arr, cur){ +// var mailHtml = ""; +// if($.isArray(arr)){ +// $.each(arr, function(i, n){ +// if(i === cur){ +// mailHtml += '
    '+str+'@'+arr[i]+'
    '; +// }else{ +// mailHtml += '
    '+str+'@'+arr[i]+'
    '; +// } +// }); +// } +// return mailHtml; +// }; //一些全局变量 var index = -1, s; - $(this).each(function(){ - var that = $(this), i = $(".justForJs").size(); - if(i > 0){ //只绑定一个文本框 - return; - } - var w = that.outerWidth(), h = that.outerHeight(); //获取当前对象(即文本框)的宽高 - //样式的初始化 - that.wrap('') - .before('
    '); - var x = $("#mailListBox_" + i), liveValue; //列表框对象 - that.focus(function(){ - //父标签的层级 - $(this).css("color", fc).parent().css("z-index", z); - //提示文字的显示与隐藏 - if(hint && text){ - var focus_v = $.trim($(this).val()); - if(focus_v === text){ - $(this).val(""); - } - } - //键盘事件 - $(this).keyup(function(e){ - s = v = $.trim($(this).val()); - if(/@/.test(v)){ - s = v.replace(/@.*/, ""); - } - if(v.length > 0){ - //如果按键是上下键 - if(e.keyCode === 38){ - //向上 - if(index <= 0){ - index = newArr.length; - } - index--; - }else if(e.keyCode === 40){ - //向下 - if(index >= newArr.length - 1){ - index = -1; - } - index++; - }else if(e.keyCode === 13){ - //回车 - if(index > -1 && index < newArr.length){ - //如果当前有激活列表 - $(this).val($("#mailList_"+index).text()); - } - }else{ - if(/@/.test(v)){ - index = -1; - //获得@后面的值 - //s = v.replace(/@.*/, ""); - //创建新匹配数组 - var site = v.replace(/.*@/, ""); - newArr = $.map(mailArr, function(n){ - var reg = new RegExp(site); - if(reg.test(n)){ - return n; - } - }); - }else{ - newArr = mailArr; - } - } - x.html($.createHtml(s, newArr, index)).css("left", 0); - if(e.keyCode === 13){ - //回车 - if(index > -1 && index < newArr.length){ - //如果当前有激活列表 - x.css("left", "-6000px"); - } - } - }else{ - x.css("left", "-6000px"); - } - }).blur(function(){ - if(hint && text){ - var blur_v = $.trim($(this).val()); - if(blur_v === ""){ - $(this).val(text); - } - } - $(this).css("color", bc).unbind("keyup").parent().css("z-index",0); - x.css("left", "-6000px"); - - }).keydown(function(event){ - if(event.keyCode == 13){ - return false; - } - }); - //鼠标经过列表项事件 - //鼠标经过 - $(".mailHover").live("mouseover", function(){ - index = Number($(this).attr("id").split("_")[1]); - liveValue = $("#mailList_"+index).text(); - x.children("." + cf).removeClass(cf).addClass(cl); - $(this).addClass(cf).removeClass(cl); - }); - $(".mailHover").live("click", function(){ - $("#mail").val($(this).html()); - }); - - - }); - - x.bind("mousedown", function(){ - that.val(liveValue); - }); - }); +// $(this).each(function(){ +// var that = $(this), i = $(".justForJs").size(); +// if(i > 0){ //只绑定一个文本框 +// return; +// } +// var w = that.outerWidth(), h = that.outerHeight(); //获取当前对象(即文本框)的宽高 +// //样式的初始化 +// that.wrap('') +// .before('
    '); +// var x = $("#mailListBox_" + i), liveValue; //列表框对象 +// that.focus(function(){ +// //父标签的层级 +// $(this).css("color", fc).parent().css("z-index", z); +// //提示文字的显示与隐藏 +// if(hint && text){ +// var focus_v = $.trim($(this).val()); +// if(focus_v === text){ +// $(this).val(""); +// } +// } +// //键盘事件 +// $(this).keyup(function(e){ +// s = v = $.trim($(this).val()); +// if(/@/.test(v)){ +// s = v.replace(/@.*/, ""); +// } +// if(v.length > 0){ +// //如果按键是上下键 +// if(e.keyCode === 38){ +// //向上 +// if(index <= 0){ +// index = newArr.length; +// } +// index--; +// }else if(e.keyCode === 40){ +// //向下 +// if(index >= newArr.length - 1){ +// index = -1; +// } +// index++; +// }else if(e.keyCode === 13){ +// //回车 +// if(index > -1 && index < newArr.length){ +// //如果当前有激活列表 +// $(this).val($("#mailList_"+index).text()); +// } +// }else{ +// if(/@/.test(v)){ +// index = -1; +// //获得@后面的值 +// //s = v.replace(/@.*/, ""); +// //创建新匹配数组 +// var site = v.replace(/.*@/, ""); +// newArr = $.map(mailArr, function(n){ +// var reg = new RegExp(site); +// if(reg.test(n)){ +// return n; +// } +// }); +// }else{ +// newArr = mailArr; +// } +// } +// x.html($.createHtml(s, newArr, index)).css("left", 0); +// if(e.keyCode === 13){ +// //回车 +// if(index > -1 && index < newArr.length){ +// //如果当前有激活列表 +// x.css("left", "-6000px"); +// } +// } +// }else{ +// x.css("left", "-6000px"); +// } +// }).blur(function(){ +// if(hint && text){ +// var blur_v = $.trim($(this).val()); +// if(blur_v === ""){ +// $(this).val(text); +// } +// } +// $(this).css("color", bc).unbind("keyup").parent().css("z-index",0); +// x.css("left", "-6000px"); +// +// }).keydown(function(event){ +// if(event.keyCode == 13){ +// return false; +// } +// }); +// //鼠标经过列表项事件 +// //鼠标经过 +// $(".mailHover").on("mouseover", function(){ +// index = Number($(this).attr("id").split("_")[1]); +// liveValue = $("#mailList_"+index).text(); +// x.children("." + cf).removeClass(cf).addClass(cl); +// $(this).addClass(cf).removeClass(cl); +// }); +// $(".mailHover").on("click", function(){ +// $("#mail").val($(this).html()); +// }); +// +// +// }); +// +// x.bind("mousedown", function(){ +// that.val(liveValue); +// }); +// }); }; })(jQuery); \ No newline at end of file diff --git a/public/javascripts/jquery.autosize.js b/public/javascripts/jquery.autosize.js new file mode 100644 index 000000000..4a7bc8fd2 --- /dev/null +++ b/public/javascripts/jquery.autosize.js @@ -0,0 +1,274 @@ +/*! + Autosize 1.18.13 + license: MIT + http://www.jacklmoore.com/autosize +*/ +(function ($) { + var + defaults = { + className: 'autosizejs', + id: 'autosizejs', + append: '\n', + callback: false, + resizeDelay: 10, + placeholder: true + }, + + // border:0 is unnecessary, but avoids a bug in Firefox on OSX + copy = '