diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 7d4c4e960..85041be40 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -23,18 +23,18 @@ class MyshixunsController < ApplicationController git_rep = g.delete_project(@myshixun.gpid) logger.info("### delete repository result is #{git_rep}") if git_rep != true - raise("版本库删除异常") + raise("实训云平台繁忙(繁忙等级:87)") end end params = {:jobName => "#{myshixun_job}"} uri = URI("#{jenkins_shixuns}/jenkins-exec/game/deleteJob") res = uri_exec uri, params if (res && res['code'] != 0) - raise("Job删除失败") + raise("实训云平台繁忙(繁忙等级:89)") end redirect_to shixun_exec_shixun_path(shixun) rescue Exception => e - flash[:error] = "实训重置失败,请稍后重试}" + flash[:error] = "实训云平台繁忙(繁忙等级:89)" redirect_to myshixun_path(@myshixun) logger.error("myshixun reset failed #{e}") raise ActiveRecord::Rollback diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d2820559a..7e90a11d7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -354,6 +354,7 @@ class UsersController < ApplicationController case @type when 'HomeworkCommon' @root = HomeworkCommon.find reply.jour_id + @homework = @root options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => User.current.id,:m_parent_id => params[:reply_id].to_i,:m_reply_id => params[:reply_id].to_i, :root_id => reply.root_id} comment = HomeworkCommon.add_homework_jour(User.current, params[:reply_message], reply.jour_id, reply.root_id, options) @root.update_column('updated_at', Time.now) diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index f322fdb8c..b5c8ce236 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -205,6 +205,38 @@ module ApiHelper end + # 获取当前时间 + def time_from_future time + lastUpdateTime = time.to_i*1000 + + currentTime = Time.now.to_i*1000 + timePassed = lastUpdateTime - currentTime; + timeIntoFormat = 0 + updateAtValue = "" + if timePassed < 0 + updateAtValue = "马上" + elsif timePassed < ONE_MINUTE + updateAtValue = "1分钟" + elsif timePassed < ONE_HOUR + timeIntoFormat = timePassed / ONE_MINUTE + updateAtValue = timeIntoFormat.to_s + "分钟" + elsif (timePassed < ONE_DAY) + timeIntoFormat = timePassed / ONE_HOUR + updateAtValue = timeIntoFormat.to_s + "小时" + elsif (timePassed < ONE_MONTH) + timeIntoFormat = timePassed / ONE_DAY + updateAtValue = timeIntoFormat.to_s + "天" + elsif (timePassed < ONE_YEAR) + timeIntoFormat = timePassed / ONE_MONTH + updateAtValue = timeIntoFormat.to_s + "个月" + else + timeIntoFormat = timePassed / ONE_YEAR + updateAtValue = timeIntoFormat.to_s + "年" + end + updateAtValue + + end + #日期转换为时间 def convert_to_time date, num if num == 0 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f76bb6e04..8353edd29 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -283,32 +283,109 @@ module ApplicationHelper end end + # 作业不同状态的不同样式 + def homework_status_color status + style = "" + case status + when '挂起' + style = 'edu-filter-btn-yellow' + when '提交中' + style = 'edu-filter-btn-blue' + when '补交中' + style = 'edu-filter-btn-orange' + when '匿评中' + style = 'edu-filter-btn-green' + when '申诉中' + style = 'edu-filter-btn-red' + when '评阅中' + style = 'edu-filter-btn-green' + when '已结束' + style = 'edu-filter-btn' + end + end + # 判断作业有多少人提交了 # def had_commit_studentwork_count homework_common - if homework_common.homework_type == 3 - homework_common.student_works.count - else - StudentWork.where("work_status !=? and homework_common_id=?",0, homework_common.id).count - end + StudentWork.where("work_status !=? and homework_common_id=?",0, homework_common.id).count end # 未提交作品数统计 def had_uncommit_studentwork_count homework_common - if homework_common.homework_type == 3 - homework_common.course.student.count - homework_common.student_works.count - else - StudentWork.where(:homework_common_id => homework_common.id, :work_status => 0).count - end + homework_common.course.student.count - homework_common.student_works.where("work_status !=?", 0).count end # 未评阅 def had_unevaluate_count homework_common - count = StudentWorksScore.find_by_sql("SELECT distinct student_work_id as count FROM student_works_scores sws, student_works sw, homework_commons hc where hc.id =#{homework_common.id} and sw.homework_common_id=hc.id and sws.student_work_id = sw.id and sws.user_id=#{User.current.id};").first.try(:count).to_i + count = StudentWorksScore.find_by_sql("SELECT count(distinct student_work_id) as count FROM student_works_scores sws, student_works sw, homework_commons hc where hc.id =#{homework_common.id} and sw.homework_common_id=hc.id and sws.student_work_id = sw.id and sws.user_id=#{User.current.id};").first.try(:count).to_i student_count = homework_common.course.student.count return student_count - count end + # 该阶段还有多长时间结束/距下一阶段还有多长时间 + def homework_curr_time homework_common + result = {} + status = "" + time = "" + ho_detail_manual = homework_common.homework_detail_manual + case ho_detail_manual.comment_status + when 0 + status = "挂起" + if homework_common.publish_time && homework_common.publish_time > Time.now + time = time_from_future(homework_common.publish_time).to_s + "后发布" + end + when 1 + status = "提交中" + if homework_common.end_time && homework_common.end_time > Time.now + time = time_from_future(homework_common.end_time).to_s + "后结束" + elsif !homework_common.allow_late && homework_common.anonymous_comment == 0 + if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now + status = "匿评中" + time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始" + end + elsif !homework_common.allow_late && homework_common.anonymous_comment == 1 + if homework_common.archive_time && homework_common.archive_time >= Time.now + status = "评阅中" + time = time_from_future(homework_common.archive_time).to_s + "后结束" + end + end + when 2 + status = "补交中" + if homework_common.late_time && homework_common.late_time >= Time.now + time = time_from_future(homework_common.late_time).to_s + "后结束" + elsif homework_common.anonymous_comment == 0 + if ho_detail_manual.evaluation_start && ho_detail_manual.evaluation_start >= Time.now + status = "匿评中" + time = time_from_future(ho_detail_manual.evaluation_start).to_s + "后开始" + end + end + when 3 + status = "匿评中" + if ho_detail_manual.evaluation_end && ho_detail_manual.evaluation_end > Time.now + time = time_from_future(ho_detail_manual.evaluation_end).to_s + "后结束" + elsif homework_common.anonymous_appeal && ho_detail_manual.appeal_time && ho_detail_manual.appeal_time >= Time.now + status = "申诉" + time = time_from_future(ho_detail_manual.appeal_time).to_s + "后开始" + end + when 4 + status = "申诉中" + if ho_detail_manual.appeal_time && ho_detail_manual.appeal_time > Time.now + time = time_from_future(ho_detail_manual.appeal_time).to_s + "后结束" + end + when 5 + status = "评阅中" + if homework_common.archive_time && homework_common.archive_time > Time.now + time = time_from_future(homework_common.archive_time).to_s + "后结束" + end + when 6 + status = "已结束" + time = format_time homework_common.archive_time + end + result[:status] = status + result[:time] = time + result + end + # 公共分页 def paginator_list objs, objs_count, limit, is_remote @is_remote = is_remote @@ -2652,7 +2729,7 @@ module ApplicationHelper # Returns the javascript tags that are included in the html layout head def javascript_heads - tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min') + tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min', 'baiduTemplate') unless User.current.pref.warn_on_leaving_unsaved == '0' tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 3df296aac..ecda55cd7 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -60,6 +60,8 @@ class HomeworkCommon < ActiveRecord::Base type = "编程" when 3 type = "分组" + when 4 + type = "实训" end type end diff --git a/app/models/shixun.rb b/app/models/shixun.rb index cdbbff68e..9af1fc08b 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,7 +1,7 @@ # status 控制实训的状态,0:未开启;1: 已开启(TPM); 2:已认证 # 实训云平台繁忙(繁忙等级:116) # 繁忙等级参数:80发布实训失败,返回code为-1;81:实训开启的时候fork失败;83:job创建失败;84:jenkins系统异常,post数据不成功 -# 85:challenge创建的时候Jenkins处理异常;86:实训评测失败,jenkins返回错误结果; 88:点击评测失败 +# 85:challenge创建的时候Jenkins处理异常;86:实训评测失败,jenkins返回错误结果; 87:版本库删除异常;88:点击评测失败;89:重置失败 class Shixun < ActiveRecord::Base attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :myshixun_count, :propaedeutics diff --git a/app/views/courses/settings/_members.html.erb b/app/views/courses/settings/_members.html.erb index 55123c375..5e872e4ee 100644 --- a/app/views/courses/settings/_members.html.erb +++ b/app/views/courses/settings/_members.html.erb @@ -49,15 +49,20 @@
- <% @teachers.each do |teacher| %> + <% @teachers.each_with_index do |teacher, index| %> + <% user = teacher.user %>- 序号 - 姓名 - 用户ID - 角色 - 操作 -
-- # <%= index + 1 %> - 创建于<%=time_from_now homework_common.created_at %> - <% if [1,2,4,5,6].include?(homework_common.homework_detail_manual.try(:comment_status)) %> - <%= had_commit_studentwork_count homework_common %>已交 - <%= had_uncommit_studentwork_count homework_common %>未交 + # <%= index + 1 %> + 创建于<%=time_from_now homework_common.created_at %> + <%=homework_common.homework_type_ch %> + <% if [1,2,3,4,5,6].include?(homework_common.homework_detail_manual.try(:comment_status)) %> + <%= had_commit_studentwork_count homework_common %>已交 + <%= had_uncommit_studentwork_count homework_common %>未交 <% if @is_teacher %> - <%= had_unevaluate_count homework_common %>未评 + <%= had_unevaluate_count homework_common %>未评 <% end %> - + <%= homework_curr_status[:time] %> <% end %>
+ + <%=render :partial=> "praise_tread/edu_praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + <%= link_to('回复'.html_safe, + {:controller => 'users', + :action => 'reply_to_comment', + :reply_id => comment.id, + :type => type, + :user_activity_id => user_activity_id, + :parent_id => parent_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> +
+ + \ No newline at end of file diff --git a/app/views/student_work/_student_work_replies.html.erb b/app/views/student_work/_student_work_replies.html.erb index 67d0b9082..cfb21818a 100644 --- a/app/views/student_work/_student_work_replies.html.erb +++ b/app/views/student_work/_student_work_replies.html.erb @@ -1,9 +1,10 @@ <% count=@homework.journals_for_messages.count %> <% comments = @homework.journals_for_messages.reorder("created_on desc") %> <% no_children_comments = get_no_children_comments_all comments %> +<% is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? %>
<%= render :partial => 'praise_tread/edu_praise', :locals => {:activity=>@homework, :user_activity_id=>@homework.id,:type=>"activity"} %>
@@ -37,9 +38,9 @@
<% parents_rely = [] %>
<% parents_rely = get_reply_parents parents_rely, comment %>
<% length = parents_rely.length %>
-
+ <% if is_teacher || comment.user == User.current%> + 删除 + <% end %> + + <%=render :partial=> "praise_tread/edu_praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + <%= link_to( + '回复'.html_safe, + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :user_activity_id => @homework.id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> +
+ + +