Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop

This commit is contained in:
huang 2017-10-12 10:51:39 +08:00
commit 37bb1cb749
13 changed files with 158 additions and 35 deletions

View File

@ -106,7 +106,7 @@ class CoursesController < ApplicationController
end
def shixun_statistics
@homeworks = @course.homework_commons.where("homework_type = 4").order("created_at asc")
@homeworks = @course.homework_commons.where("homework_type = 4 and publish_time < '#{Time.now}'").order("publish_time desc")
filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_实训数据报告";
respond_to do |format|
@ -2007,6 +2007,83 @@ class CoursesController < ApplicationController
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
black = Spreadsheet::Format.new :color => :black, :weight => :bold, :size => 10
current_row = 0
sheet = book.create_worksheet :name => "学员统计"
sheet.row(0).default_format = blue
sheet.row(0).concat(["学生id","学生姓名","作业编号","作业/实训名称","关卡"," 经验值","金币","评测历史","评测时间","评测结果"])
course.student.each_with_index do |course, i|
# 总统计
count_exp_score = 0
count_gold_score = 0
count_test = 0
count_time = 0
game_count = 0
# end
user = course.student
current_row += 1
sheet[current_row, 0] = user.login
sheet[current_row, 1] = user.show_real_name
homeworks.each_with_index do |homework, j|
# 关卡统计
count_game_exp_score = 0
count_game_gold_score = 0
count_game_test = 0
count_game_time = 0
# end
sheet[current_row, 2] = "# #{j + 1}"
sheet[current_row, 3] = homework.name
shixun = homework.homework_commons_shixuns.shixun if homework.homework_commons_shixuns
if shixun
shixun.challenges.each_with_index do |challenge, k|
sheet[current_row, 4] = "#{k+1}"
games = Game.where(:challenge_id => challenge.id, :user_id => user.id)
game_count = game_count + games.count
if games.count > 0
games.each do |game|
sheet[current_row, 5] = game.final_score ? "+#{game.final_score.to_s}" : "--"
sheet[current_row, 6] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i}" : "+#{game.final_score.to_i}") : "--"
count_exp_score += (game.final_score ? game.final_score.to_i : 0)
count_gold_score += (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count_game_exp_score += (game.final_score ? game.final_score.to_i : 0)
count_game_gold_score += (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count = game.outputs.count
if count > 0
outputs = game.outputs.where(:test_set_position => 1).reorder("created_at asc")
outputs.each_with_index do |output, k|
count_test += 1
count_game_test += 1
sheet[current_row, 7] = "#{k+1}次评测"
sheet[current_row, 8] = k == 0 ? game_spend_time((output.created_at - game.created_at).to_i) : game_spend_time((output.created_at - outputs[k-1].created_at).to_i)
count_time = count_time + (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
count_game_time += (k == 0 ? (output.created_at - game.created_at).to_i : (output.created_at - outputs[k-1].created_at).to_i)
sheet[current_row, 9] = game.outputs.where(:query_index => output.query_index).select{|ou| ou.result == false}.count > 0 ? "失败" : "成功"
current_row += 1
end
else
current_row += 1
end
end
else
current_row += 1
end
end
end
sheet[current_row,4] = "合计"
sheet[current_row,5] = count_game_exp_score >= 0 ? "+#{count_game_exp_score}" : "-#{count_game_exp_score}"
sheet[current_row,6] = count_game_gold_score >= 0 ? "+#{count_game_gold_score}" : "#{count_game_gold_score}"
sheet[current_row,7] = "#{count_game_test}次评测"
sheet[current_row,8] = game_spend_time((count_game_time == 0 ? 0 : (count_game_time / count_test)).to_i)+"/次"
sheet.row(current_row).default_format = black
current_row += 1
end
sheet[current_row,2] = "合计"
sheet[current_row,4] = "#{game_count}"
sheet[current_row,5] = count_exp_score >= 0 ? "+#{count_exp_score}" : "-#{count_exp_score}"
sheet[current_row,6] = count_gold_score >= 0 ? "+#{count_gold_score}" : "#{count_gold_score}"
sheet[current_row,7] = "#{count_test}次评测"
sheet[current_row,8] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
sheet.row(current_row).default_format = black
end
homeworks.each_with_index do |homework, i|
sheet = book.create_worksheet :name => "#{i+1}次作业"
sheet.row(0).default_format = blue
@ -2043,14 +2120,14 @@ class CoursesController < ApplicationController
user = game.user
sheet[current_row,6] = user.login
sheet[current_row,7] = user.show_real_name
sheet[current_row,8] = game.final_score ? "+#{game.final_score.to_s} 经验值" : "--"
sheet[current_row,8] = game.final_score ? "+#{game.final_score.to_s}" : "--"
count_exp_score = count_exp_score + (game.final_score ? game.final_score.to_i : 0)
sheet[current_row,9] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i} 金币" : "+#{game.final_score.to_i} 金币") : "--"
sheet[current_row,9] = game.final_score ? (game.answer_open? ? "#{-challenge.score.to_i}" : "+#{game.final_score.to_i}") : "--"
count_gold_score = count_gold_score + (game.final_score ? (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) : 0)
count = game.outputs.count
if count > 0
outputs = game.outputs.where(:test_set_position => 1).order("created_at asc")
outputs = game.outputs.where(:test_set_position => 1).reorder("created_at asc")
outputs.each_with_index do |output, k|
count_test = count_test + 1
sheet[current_row,10] = "#{k+1}次评测"
@ -2069,8 +2146,8 @@ class CoursesController < ApplicationController
sheet[current_row,6] = "合计"
sheet[current_row,7] = games.count.to_s + ""
sheet[current_row,8] = count_exp_score >= 0 ? "+#{count_exp_score} 经验值" : "-#{count_exp_score} 经验值"
sheet[current_row,9] = count_gold_score >= 0 ? "+#{count_gold_score} 金币" : "-#{count_gold_score} 金币"
sheet[current_row,8] = count_exp_score >= 0 ? "+#{count_exp_score}" : "-#{count_exp_score}"
sheet[current_row,9] = count_gold_score >= 0 ? "+#{count_gold_score}" : "#{count_gold_score}"
sheet[current_row,10] = "#{count_test}次评测"
sheet[current_row,11] = game_spend_time((count_time == 0 ? 0 : (count_time / count_test)).to_i)+"/次"
sheet.row(current_row).default_format = black

View File

@ -1591,7 +1591,7 @@ end
else #同意
shixun.update_column('status', 2)
apply_action.update_attributes(:status => 1, :dealer_id => User.current.id)
shixun_modify_status_without_publish shixun, 1
add_shixun_modify_status shixun, 1
# 实训发布后则不允许修改代码
# g = Gitlab.client
# shixun.shixun_members.each do |member|

View File

@ -283,6 +283,9 @@ class MessagesController < ApplicationController
#@replies = @replies[@page * @limit..@page * @limit + 9]
@reply = Message.new()
@user_activity_id = params[:user_activity_id].blank? ? @topic.id : params[:user_activity_id].to_i
if !params[:user_activity_id].blank? && params[:user_activity_id].to_i != @topic.id
@topic.update_attributes(:visits => @topic.visits + 1)
end
respond_to do |format|
format.js
end

View File

@ -235,7 +235,19 @@ class MyController < ApplicationController
if @user.save && @se.save
reward_grade(@user, @user.id, 'Account', 500)
# 修改邮箱的时候同步修改到gitlab
if @se.identity == 1
school_ids = School.where(:auto_users_trial => 1).map(&:id)
if !@se.student_id.nil? && @se.student_id != "" && !@se.school.nil? && school_ids.include?(@se.school_id)
apply_action = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization", :status => 0).first
unless apply_action.blank?
@user.update_attributes(:certification => 1)
apply_action.update_attributes(:status => 1)
end
end
end
# 修改邮箱的时候同步修改到gitlab
# if changed_mail || changed_login
# g = Gitlab.client
# s = Trustie::Gitlab::Sync.new

View File

@ -376,16 +376,26 @@ class ShixunsController < ApplicationController
# jenkins回调脚本
# gameID 及实训ID
def publish
@status = 0
@position = ""
begin
@shixun.update_attributes!(:status => 1)
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
if apply && apply.status == 0
@status = 0
else
ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => User.current.id, :status => 0)
notes = User.current.show_name.to_s + " 申请发布实训:<a href='#{shixun_path(@shixun)}'>#{@shixun.name}</a>"
JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0)
@status = 1
@shixun.challenges.each do |challenge|
if challenge.challenge_tags.count == 0
@status = 2
@position = (@position == "" ? @position : (@position + "")) + challenge.position.to_s + ""
end
end
if @status == 0
@shixun.update_attributes!(:status => 1)
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
if apply && apply.status == 0
@status = 0
else
ApplyAction.create(:container_type => "ApplyShixun", :container_id => @shixun.id, :user_id => User.current.id, :status => 0)
notes = User.current.show_name.to_s + " 申请发布实训:<a href='#{shixun_path(@shixun)}'>#{@shixun.name}</a>"
JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0)
@status = 1
end
end
rescue Exception => e
@jenkin_error = true

View File

@ -39,7 +39,7 @@ class StagesController < ApplicationController
@stage.name = params[:stage_name]
@stage.description = params[:stage_des]
ActiveRecord::Base.transaction do
if @stage.save && params[:shixun_id]
if @stage.save
begin
@stage.stage_shixuns.destroy_all
params[:shixun_id].each do |shixun_id|

View File

@ -400,6 +400,9 @@ class UsersController < ApplicationController
comment.root_id = reply.root_id
reply.children << comment
@is_project = params[:is_project] if params[:is_project]
redirect_to message_replies_board_message_path(@root, :board_id => @root.board_id, :user_activity_id => params[:user_activity_id])
return
when 'BlogComment'
@root = reply.root
comment = BlogComment.new

View File

@ -16,13 +16,31 @@
<p class="color-grey font-12 mt20">
<span>创建于<%=time_from_now exercise.created_at %></span>
<span class="ml25">更新于<%=time_from_now exercise.updated_at %></span>
<span class="ml50"><a href="javascript:void(0)" class="color-orange05 mr3"><%= exercise.exercise_users.where("commit_status = 1").count %></a>已答</span>
<span class="ml50"><a href="javascript:void(0)" class="color-orange05 mr3"><%= exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count %></a>未答</span>
<%# count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %>
<span class="ml50"><a href="javascript:void(0)" class="color-orange05 mr3"><%= un_commit_num exercise %></a>未评</span>
<span class="ml50 <%= exercise.try(:exercise_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= ex_curr_status[:time] %></span>
<% if exercise.try(:exercise_status) == 0 && exercise.publish_time %>
<% if exercise.try(:exercise_status) > 1 %>
<% if @is_teacher %>
<span class="ml50">
<%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise, :ex_status => ['1']), :class => "color-orange05 mr3", :target =>"_blank" %>
已答</span>
<span class="ml50">
<%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise, :ex_status => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %>
未答</span>
<%# count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %>
<span class="ml50">
<%= link_to un_commit_num(exercise), student_exercise_list_exercise_path(exercise, :ex_comment => ['0']), :class => "color-orange05 mr3", :target =>"_blank" %>
未评</span>
<% else %>
<span class="ml50">
<%= link_to exercise.exercise_users.where("commit_status = 1").count, student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %>
已答</span>
<span class="ml50">
<%= link_to (exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count), student_exercise_list_exercise_path(exercise), :class => "color-orange05 mr3", :target =>"_blank" %>
未答</span>
<% end %>
<% end %>
<% if exercise.try(:exercise_status) == 1 && exercise.publish_time %>
<span class="ml50 color-grey">将于&nbsp;<span class="color-orange"><%= format_time(exercise.publish_time).to_s %></span>&nbsp;发布</span>
<% else %>
<span class="ml50 <%= exercise.try(:exercise_status) == 3 ? 'color-grey' : 'color-orange' %>"><%= ex_curr_status[:time] %></span>
<% end %>
</p>
</div>
@ -42,7 +60,7 @@
</li>
<% end %>
<!--<li><a href="javascript:void(0)">加入题库</a></li>-->
<li><a href="javascript:void(0)" onclick="delete_confirm_box_3('<%= exercise_path(exercise) %>', '确定要删除该试卷吗?')">删除</a></li>
<li><a href="javascript:void(0)" onclick="delete_confirm_box_3('<%= exercise_path(exercise) %>', '删除后,学生的答题情况将全部丢失,无法恢复<br/>确定要删除该试卷吗?')">删除</a></li>
</ul>
</div>
<% end %>

View File

@ -53,10 +53,11 @@
</span>
<% end %>
<% end %>
<span class="ml50 <%= homework_common.homework_detail_manual.try(:comment_status) == 6 ? 'color-grey' : 'color-orange' %>"><%= homework_curr_status[:time] %></span>
<% if homework_common.homework_detail_manual.try(:comment_status) == 0 && homework_common.publish_time %>
<span class="ml50 color-grey">将于&nbsp;<span class="color-orange"><%= format_time(homework_common.publish_time).to_s %></span>&nbsp;发布</span>
<% end %>
<% else %>
<span class="ml50 <%= homework_common.homework_detail_manual.try(:comment_status) == 6 ? 'color-grey' : 'color-orange' %>"><%= homework_curr_status[:time] %></span>
<% end %>
</p>
</div>
<% if @is_teacher %>

View File

@ -8,9 +8,12 @@
<% if result %>
<% if @status == 0 %>
已发布过申请,请等待管理员审核
<% else %>
<% elsif @status == 1 %>
发布申请已提交,请等待管理员的审核<br/>
<span class="font-12 color-grey"> • 我们将在1-2个工作日内完成审核</span>
<% else %>
每一个关卡至少需要一个技能标签<br/>
第<%= @position %>尚未设置技能标签,请补充
<% end %>
<% else %>
实训云平台繁忙繁忙等级80

View File

@ -1,4 +1,4 @@
<% unless @status && @status = 1 %>
<% unless @status && @status == 1 %>
$("#apply_publish_shixun").attr("data-option", 1);
$("#apply_publish_shixun").removeClass("disabled-grey-bg");
<% end %>

View File

@ -11,8 +11,8 @@
<a href="<%= edit_subject_path(@subject) %>"><i class="fa fa-pencil fr mt10 mr5 color-grey-c edit-produce"data-tip-down="编辑"></i></a>
<% end %>
</p>
<div class="color-grey3 <%= @subject.description.blank? ? 'color-light-grey' : '' %> ">
<div id="shixuns_propaedeutics" class="new_li fl" style="margin-bottom: 20px;padding: 0px;text-align: justify;">
<div class="color-grey3 clearfix <%= @subject.description.blank? ? 'color-light-grey' : '' %> ">
<div id="shixuns_propaedeutics" class="new_li fl" style="padding: 0px;text-align: justify;">
<textarea name="subject[description]" style="display: none"><%= @subject.description.blank? ? "暂未填写" : (@subject.description) %></textarea>
</div>
</div>

View File

@ -63,8 +63,4 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
$("#discusses_count").html("<%= @discusses_count %>");
<% end %>
<% end %>
<% if @discusses_count > 0 %>
$("#discusses_count").html("<%= @discusses_count %>");
//window.location.href = "<%#= myshixun_game_path(@challenge.current_user_game, :myshixun_id => @challenge.current_user_game.try(:myshixun)) %>";
<% end %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");