From 7c024985bf37c4f7b3a1bd313c2bafe0b5fc77b2 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 25 Sep 2017 11:16:16 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89?=
=?UTF-8?q?=E9=A2=98=E7=AD=94=E9=A2=98=E6=A8=A1=E5=BC=8F=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/games_controller.rb | 16 ++---
app/controllers/shixuns_controller.rb | 4 +-
app/views/games/_choice_question.html.erb | 2 +-
app/views/games/_game_choose_results.html.erb | 8 ++-
app/views/games/_pass_game_show.html.erb | 60 +++++--------------
public/stylesheets/css/edu-popup.css | 6 +-
6 files changed, 36 insertions(+), 60 deletions(-)
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 69194f1f8..72d476c49 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -316,9 +316,8 @@ class GamesController < ApplicationController
answer_right = []
@game_challenge.challenge_chooses.each_with_index do |choose, index|
correct = (params[:answer][index] == choose.standard_answer) ? true : false
- if choose.current_choose_outputs.blank?
- ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
- end
+ choose.current_choose_outputs.delete if choose.current_choose_outputs.present?
+ ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
if @shixun.status > 1 && !@game.answer_open
if correct
score += choose.score
@@ -332,12 +331,13 @@ class GamesController < ApplicationController
end
answer_right << correct
end
- @game.update_attributes(:status => 2, :end_time => Time.now)
@had_done = @game.had_done
- reward_grade(@game.user, @game.id, 'Game', score)
- reward_experience(@game.user, @game.id, 'Game', score)
- @game.update_attribute(:final_score, score)
-
+ if @right
+ @game.update_attributes(:status => 2, :end_time => Time.now)
+ reward_grade(@game.user, @game.id, 'Game', score)
+ reward_experience(@game.user, @game.id, 'Game', score)
+ @game.update_attribute(:final_score, score)
+ end
respond_to do |format|
format.js{redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun, :choose => 1)}
end
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index d11285bc7..170349350 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -254,9 +254,9 @@ class ShixunsController < ApplicationController
# 确定 sort 1升序 2 降序
@order = params[:order] || "myshixun_count"
bsort = params[:sort] || "desc"
- @sort = bsort == "desc" ? "asc" : "desc"
+ @sort = bsort == "asc" ? "desc" : "asc"
if @order == "updated_at"
- order_str = "#{Shixun.table_name}.updated_at #{bsort}"
+ order_str = "#{Shixun.table_name}.updated_at #{@sort}"
else
order_str = "myshixun_count #{bsort}, #{Shixun.table_name}.updated_at #{bsort}"
end
diff --git a/app/views/games/_choice_question.html.erb b/app/views/games/_choice_question.html.erb
index 8330ad846..486fa2317 100644
--- a/app/views/games/_choice_question.html.erb
+++ b/app/views/games/_choice_question.html.erb
@@ -31,7 +31,7 @@
<% end %>
-
+
<% end %>
- <%= link_to image_tag(url_to_avatar(statistics.owner), :width => "36", :height => "36", :alt => "头像"), user_path(statistics.owner), :target => '_blank', :class => "", :style => "border-radius:18px;"%>
+ <%= link_to image_tag(url_to_avatar(statistics.owner), :width => "36", :height => "36", :alt => "头像", :style => "border-radius:18px;padding-top:15px;"), user_path(statistics.owner), :target => '_blank', :class => ""%>
-
+
<%= link_to statistics.owner.try(:show_name), user_path(statistics.owner), :class => "panel-table-name hide fl color-grey" %>
<%= format_time(statistics.created_at) %> 开启
-
-
+
+
diff --git a/app/views/users/user_fanslist.html.erb b/app/views/users/user_fanslist.html.erb
index edc5bb134..45d3a81a4 100644
--- a/app/views/users/user_fanslist.html.erb
+++ b/app/views/users/user_fanslist.html.erb
@@ -13,7 +13,7 @@
<%= str %>的粉丝 <%= @user_fanlist_count %>
-
+
<%= render :partial => "user_watcher_or_fans_list", :locals => {:users => @user_fanlist, :user_count => @user_fanlist_count, :user_pages => @fans_pages} %>
diff --git a/app/views/users/user_watchlist.html.erb b/app/views/users/user_watchlist.html.erb
index 26ddf5bab..64cfeecef 100644
--- a/app/views/users/user_watchlist.html.erb
+++ b/app/views/users/user_watchlist.html.erb
@@ -13,7 +13,7 @@
<%= str %>的粉丝 <%= @user_fanlist_count %>
-
+
<%= render :partial => "user_watcher_or_fans_list", :locals => {:users => @user_watchlist, :user_count => @user_watchlist_count, :user_pages => @watchlist_pages} %>
diff --git a/public/stylesheets/css/edu-common.css b/public/stylesheets/css/edu-common.css
index 9d0f98b32..be4283974 100644
--- a/public/stylesheets/css/edu-common.css
+++ b/public/stylesheets/css/edu-common.css
@@ -328,7 +328,7 @@ html>body #ajax-indicator { position: fixed; }
background-image: url(/images/loading.gif);
padding-left: 26px;
vertical-align: bottom;
- z-index:999;
+ z-index:100000;
}
From 859bcd3c8e81be5286178d08b7eb8cf3dcbe0891 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Sep 2017 09:00:30 +0800
Subject: [PATCH 5/9] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E7=9A=84?=
=?UTF-8?q?=E5=8F=82=E8=80=83=E7=AD=94=E6=A1=88=E9=9C=80=E8=A6=81=E9=BB=98?=
=?UTF-8?q?=E8=AE=A4=E7=94=9F=E6=88=901=E4=B8=AA+=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E9=A2=98=E6=B2=A1=E6=9C=89=E8=AF=84=E6=B5=8B=E6=97=B6=EF=BC=8C?=
=?UTF-8?q?=E7=82=B9=E5=87=BB=E8=AF=84=E6=B5=8B=E7=BB=93=E6=9E=9C=E7=9A=84?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/games_controller.rb | 2 +-
app/views/games/_game_choose_results.html.erb | 2 +-
app/views/games/_game_show.html.erb | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 78d7dd120..885ff73d2 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -407,7 +407,7 @@ class GamesController < ApplicationController
if(params[:choose] == "true")
challenge.challenge_chooses.each_with_index do |choose, index|
@answer += "第"+ ((index + 1).to_s) +"题:
"
- @answer += choose.answer
+ @answer += (choose.answer.blank? ? choose.standard_answer : choose.answer)
@answer += "
"
end
else
diff --git a/app/views/games/_game_choose_results.html.erb b/app/views/games/_game_choose_results.html.erb
index c1ea40b5d..fba69efed 100644
--- a/app/views/games/_game_choose_results.html.erb
+++ b/app/views/games/_game_choose_results.html.erb
@@ -41,7 +41,7 @@
- <% if choose.choose_outputs.blank? %>
+ <% if choose.current_choose_outputs.blank? %>
尚未提交,暂不支持查看
<% else %>
<% if choose.current_choose_outputs.try(:answer) == choose.standard_answer || @game.status == 2 %>
diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb
index c30f163b9..b4e5f660a 100644
--- a/app/views/games/_game_show.html.erb
+++ b/app/views/games/_game_show.html.erb
@@ -43,7 +43,6 @@
<% else %>
经验值:<%= @game_challenge.choose_score.to_i %>
<% end %>
-
From 016741ed3590c8edc68f470bd15dc1fdf42f63f3 Mon Sep 17 00:00:00 2001
From: cxt
Date: Tue, 26 Sep 2017 14:31:04 +0800
Subject: [PATCH 6/9] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?=
=?UTF-8?q?=E5=91=98=E7=9A=84=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 92 ++++++++++++++++++++++++
app/views/homework_common/index.html.erb | 3 +
config/routes.rb | 1 +
3 files changed, 96 insertions(+)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index ed81fd98a..e8fc3956c 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -104,6 +104,17 @@ class CoursesController < ApplicationController
@import_attachments = Attachment.where(:container_id => @course.id, :container_type => "ImportStudent")
end
+ def shixun_statistics
+ @homeworks = @course.homework_commons.where("homework_type = 4").order("created_at asc")
+ filename="#{format_date(Time.now)}_#{@course.teacher.show_real_name.to_s}_#{@course.name}_实训数据报告";
+
+ respond_to do |format|
+ format.xls {
+ send_data(shixun_xls(@homeworks,@course), :type => 'application/octet-stream', :filename => filename_for_content_disposition("#{filename}.xls"))
+ }
+ end
+ end
+
# REDO:性能需要优化,这块是管理员后台任务,不影响用户使用
def sync_students
school_id = User.find(@course.tea_id).try(:user_extensions).try(:school_id)
@@ -1989,6 +2000,87 @@ class CoursesController < ApplicationController
@results = paginateHelper @results, @limit
end
+ def shixun_xls homeworks, course
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ black = Spreadsheet::Format.new :color => :black, :weight => :bold, :size => 10
+ current_row = 0
+ homeworks.each_with_index do |homework, i|
+ sheet = book.create_worksheet :name => "第#{i+1}次作业"
+ sheet.row(0).default_format = blue
+ sheet[0,0] = "课堂编号"
+ sheet[0,1] = "主讲老师"
+ sheet[0,2] = "课堂名称"
+ sheet[0,3] = "作业编号"
+ sheet[0,4] = "作业/实训名称"
+ sheet[0,5] = "关卡"
+ sheet[0,6] = "学生id"
+ sheet[0,7] = "学生姓名"
+ sheet[0,8] = "经验值"
+ sheet[0,9] = "金币"
+ sheet[0,10] = "评测历史"
+ sheet[0,11] = "评测时间"
+ sheet[0,12] = "评测结果"
+ sheet[1,0] = course.id
+ sheet[1,1] = course.teacher.show_real_name
+ sheet[1,2] = course.name
+ sheet[1,3] = "# #{i + 1}"
+ sheet[1,4] = homework.name
+ current_row = 1
+ shixun = homework.homework_commons_shixuns.shixun if homework.homework_commons_shixuns
+ if shixun
+ shixun.challenges.each_with_index do |challenge, j|
+ sheet[current_row,5] = "第#{j+1}关"
+ games = Game.where(:challenge_id => challenge.id, :user_id => homework.student_works.where("work_status != 0").map(&:user_id))
+ count_exp_score = 0
+ count_gold_score = 0
+ count_test = 0
+ count_time = 0
+ if games.count > 0
+ games.each do |game|
+ 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} 经验值" : "--"
+ 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} 金币") : "--"
+ 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)
+ outputs.order("created_at asc").each_with_index do |output, k|
+ count_test = count_test + 1
+ sheet[current_row,10] = "第#{k+1}次评测"
+ sheet[current_row,11] = k == 0 ? 0 : (output.created_at - outputs[k-1].created_at).to_i
+ count_time += count_time + (k == 0 ? 0 : (output.created_at - outputs[k-1].created_at).to_i)
+ sheet[current_row,12] = output.result.nil? ? "--" : (output.result ? "成功" : "失败")
+ current_row = current_row + 1
+ end
+ else
+ current_row = current_row + 1
+ end
+ end
+ else
+ current_row = current_row + 1
+ end
+
+ 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,10] = "共#{count_test}次评测"
+ sheet[current_row,11] = count_time
+ sheet.row(current_row).default_format = black
+ current_row = current_row + 1
+ end
+ end
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
def member_to_xls homeworks, course, members,groups
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb
index e7fca0de0..9e77b7116 100644
--- a/app/views/homework_common/index.html.erb
+++ b/app/views/homework_common/index.html.erb
@@ -8,6 +8,9 @@
<%= link_to("题库选用", user_import_homeworks_user_path(User.current.id, :select_course => @course.id, :homework_type =>@homework_type), :class => "white-btn orange-btn fr mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") %>
<% else %>
<%= link_to '选用实训', shixuns_homework_common_index_path(:course => @course.id), :remote => true, :class => "white-btn orange-btn fr mr20", :title => "新建作业" %>
+ <% if User.current.admin? %>
+ <%= link_to("实训统计", shixun_statistics_course_path(@course, :format => "xls"), :class => "white-btn orange-btn fr mr10",:title=>"实训作业统计") %>
+ <% end %>
<% end %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 700d20d6a..0e6481557 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1767,6 +1767,7 @@ RedmineApp::Application.routes.draw do
post 'choose_course_group'
match 'update_position', :via => [:get, :post]
post 'delete_course_students'
+ get 'shixun_statistics'
end
collection do
match 'join_private_courses', :via => [:get, :post]
From ae2be013275205c3cf6d8b03fe4242c39e6f69f1 Mon Sep 17 00:00:00 2001
From: miss <994230062@qq.com>
Date: Tue, 26 Sep 2017 14:45:19 +0800
Subject: [PATCH 7/9] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E5=B7=A6tab=E7=9A=84tip=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/courses/settings.html.erb | 12 ++++++++++++
.../courses/settings/_all_student_list.html.erb | 12 +++++++++++-
.../courses/settings/_all_teacher_list_ul.erb | 15 ++++++++++++---
.../settings/_has_group_student_list.html.erb | 16 +++++++++++++---
.../settings/_no_group_student_list.html.erb | 13 ++++++++++++-
app/views/layouts/_group_children_list.html.erb | 12 +++++++++++-
app/views/student_work/show.html.erb | 2 +-
7 files changed, 72 insertions(+), 10 deletions(-)
diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb
index 4f72975ec..fe69cbbd1 100644
--- a/app/views/courses/settings.html.erb
+++ b/app/views/courses/settings.html.erb
@@ -152,4 +152,16 @@
timepicker:false,
validateOnBlur:false
});
+ function addtip(){
+ console.log("<%= @course.course_groups%>");
+ <% unless @course.course_groups.empty? %>
+ <% @course.course_groups.each do |group| %>
+ if($(".setting_group_<%= group.id %> span").width() == 115){
+ $(".setting_group_<%= group.id %>").attr("data-tip-left","<%= group.name %>");
+ }
+ <% end %>
+ <% end %>
+
+ }
+
\ No newline at end of file
diff --git a/app/views/courses/settings/_all_student_list.html.erb b/app/views/courses/settings/_all_student_list.html.erb
index 5c2fd729e..ad54ce938 100644
--- a/app/views/courses/settings/_all_student_list.html.erb
+++ b/app/views/courses/settings/_all_student_list.html.erb
@@ -16,7 +16,7 @@
<% @course.course_groups.each do |group| %>
- <%= group.name %>
+ <%= group.name %>
<%= group.members.count %>
@@ -27,3 +27,13 @@
<%= render :partial => "courses/settings/all_student_list_block" %>
+
+
\ No newline at end of file
diff --git a/app/views/courses/settings/_all_teacher_list_ul.erb b/app/views/courses/settings/_all_teacher_list_ul.erb
index db3e22090..9886dbec3 100644
--- a/app/views/courses/settings/_all_teacher_list_ul.erb
+++ b/app/views/courses/settings/_all_teacher_list_ul.erb
@@ -12,11 +12,20 @@
<% unless @course.course_groups.empty? %>
<% @course.course_groups.each do |group| %>
-
+
<%= group.name %>
<%= group.members.count %>
-
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/courses/settings/_has_group_student_list.html.erb b/app/views/courses/settings/_has_group_student_list.html.erb
index 465e05525..5116e46e2 100644
--- a/app/views/courses/settings/_has_group_student_list.html.erb
+++ b/app/views/courses/settings/_has_group_student_list.html.erb
@@ -14,8 +14,8 @@
<% end %>
<% unless @course.course_groups.empty? %>
<% @course.course_groups.each do |group| %>
-
-
+
+
<%= group.name %>
<%= group.members.count %>
@@ -26,4 +26,14 @@
<%= render :partial => "courses/settings/has_group_student_list_block" %>
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/app/views/courses/settings/_no_group_student_list.html.erb b/app/views/courses/settings/_no_group_student_list.html.erb
index 42eae5fb0..96cf02f3f 100644
--- a/app/views/courses/settings/_no_group_student_list.html.erb
+++ b/app/views/courses/settings/_no_group_student_list.html.erb
@@ -14,7 +14,7 @@
<% unless @course.course_groups.empty? %>
<% @course.course_groups.each do |group| %>
-
+
<%= group.name %>
<%= group.members.count %>
@@ -26,3 +26,14 @@
<%= render :partial => "courses/settings/no_group_student_list_block" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/layouts/_group_children_list.html.erb b/app/views/layouts/_group_children_list.html.erb
index 486e0aa76..75a026afe 100644
--- a/app/views/layouts/_group_children_list.html.erb
+++ b/app/views/layouts/_group_children_list.html.erb
@@ -18,4 +18,14 @@
<% end %>
-<% end %>
\ No newline at end of file
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/student_work/show.html.erb b/app/views/student_work/show.html.erb
index b5e9958a7..90ca59999 100644
--- a/app/views/student_work/show.html.erb
+++ b/app/views/student_work/show.html.erb
@@ -3,7 +3,7 @@
<%= @course.name %> > <%= @homework.homework_type_ch %>作业 >
<%#= link_to get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1, student_work_index_path(:homework => @homework.id) %>
- #<%= get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1 %>
+ #<%= get_hw_index(@homework, @is_teacher, @homework.homework_type) + 1 %> >
<% if @is_teacher || @work.user == User.current || (@homework.homework_detail_manual.comment_status != 3 && @homework.homework_detail_manual.comment_status != 4) %>
<%= link_to @work.user.try(:show_real_name), user_path(@work.user) %>
<% else %>
From a1a045b135ece6674e25da4000647c7ce1ad4a57 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 26 Sep 2017 15:03:28 +0800
Subject: [PATCH 8/9] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E7=BB=93?=
=?UTF-8?q?=E6=9E=84=E6=9B=B4=E6=94=B9=EF=BC=8C=E4=BF=9D=E7=95=99=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E5=A4=9A=E6=AC=A1=E8=AF=84=E6=B5=8B=E7=9A=84=E7=BB=93?=
=?UTF-8?q?=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/games_controller.rb | 5 +++--
app/controllers/myshixuns_controller.rb | 2 --
app/helpers/application_helper.rb | 2 +-
app/models/challenge_choose.rb | 1 +
app/models/game.rb | 14 ++++++++++++++
app/models/output.rb | 2 +-
app/views/games/_choice_question.html.erb | 9 +++++----
app/views/games/_game_choose_results.html.erb | 17 +++++++++--------
8 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb
index 885ff73d2..23d8a220a 100644
--- a/app/controllers/games_controller.rb
+++ b/app/controllers/games_controller.rb
@@ -316,8 +316,9 @@ class GamesController < ApplicationController
answer_right = []
@game_challenge.challenge_chooses.each_with_index do |choose, index|
correct = (params[:answer][index] == choose.standard_answer) ? true : false
- choose.current_choose_outputs.delete if choose.current_choose_outputs.present?
- ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
+ #choose.current_choose_outputs.delete if choose.current_choose_outputs.present?
+ #ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
+ Output.create(:game_id => @game.id, :test_set_position => choose.position, :actual_output => params[:answer][index], :result => correct, :query_index => @game.query_index)
if @shixun.status > 1 && !@game.answer_open
if correct
score += choose.score
diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index 813c790b4..a2aadf706 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -127,7 +127,6 @@ class MyshixunsController < ApplicationController
compile_success = jsonTestDetails['compileSuccess']
# message = Base64.decode64(params[:msg]) unless params[:msg].blank?
logger.info(outPut)
- logger.info("##################"+ compile_success)
game = Game.find(game_id)
challenge = game.challenge
unless jenkins_testsets.blank?
@@ -135,7 +134,6 @@ class MyshixunsController < ApplicationController
actual_output = tran_base64_decode64(j_test_set['output'])
game_outputs = Output.create(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'],
:actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => game.query_index, :compile_success => compile_success.to_i)
- logger.info("compile_success:"+ compile_success)
# output = Output.where(:game_id => game.id, :test_set_position => j_test_set['caseId'].to_i).first
# logger.info("#############{outPut}")
# if output.nil?
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1d2d2cb00..d8e58790d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -830,7 +830,7 @@ module ApplicationHelper
end
# 项目issue列表导出Excel功能
- def issue_list_xls issues
+ def issue_list_xls issues
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "issues"
diff --git a/app/models/challenge_choose.rb b/app/models/challenge_choose.rb
index c14a0c02d..9ea356870 100644
--- a/app/models/challenge_choose.rb
+++ b/app/models/challenge_choose.rb
@@ -7,6 +7,7 @@ class ChallengeChoose < ActiveRecord::Base
has_many :challenge_tags, :dependent => :destroy
has_many :challenge_questions, :dependent => :destroy
has_one :choose_outputs, :dependent => :destroy
+ has_many :outputs, :dependent => :destroy
validates_presence_of :subject
diff --git a/app/models/game.rb b/app/models/game.rb
index 7c0e913ae..62f0c24ad 100644
--- a/app/models/game.rb
+++ b/app/models/game.rb
@@ -66,4 +66,18 @@ class Game < ActiveRecord::Base
challenge = self.challenge
challenge.try(:position).to_i == challenge.shixun.challenges.count ? true : false
end
+
+ def choose_correct_num
+ num = 0
+ self.challenge.challenge_chooses.each do |choose|
+ outputs = Output.where(:game_id => self.id, :test_set_position => choose.position).first
+ if outputs.nil?
+ num = nil
+ else
+ num += (outputs.result ? 1 : 0)
+ end
+ end
+ return num
+ end
+
end
diff --git a/app/models/output.rb b/app/models/output.rb
index 4ce462eff..fe82c2a07 100644
--- a/app/models/output.rb
+++ b/app/models/output.rb
@@ -4,5 +4,5 @@ class Output < ActiveRecord::Base
# compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错!
default_scope :order => 'query_index desc'
belongs_to :game
-
+ belongs_to :challenge_choose
end
diff --git a/app/views/games/_choice_question.html.erb b/app/views/games/_choice_question.html.erb
index 486fa2317..2255f8cad 100644
--- a/app/views/games/_choice_question.html.erb
+++ b/app/views/games/_choice_question.html.erb
@@ -13,6 +13,7 @@