单选多选题答题模式修改
This commit is contained in:
parent
b7ce7e214e
commit
7c024985bf
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
</span>
|
||||
</p>
|
||||
<% end %>
|
||||
<input type="hidden" name="user_answer">
|
||||
<input type="hidden" name="user_answer" value="<%= choose.current_choose_outputs.try(:answer) %>">
|
||||
</div>
|
||||
<% end %>
|
||||
<!--<div class="pl5 pr5 pt10 pb10 bor-grey-e">
|
||||
|
|
|
|||
|
|
@ -44,8 +44,12 @@
|
|||
<% if choose.choose_outputs.blank? %>
|
||||
<li><span class="ml30">尚未提交,暂不支持查看</span></li>
|
||||
<% else %>
|
||||
<li><span class="-task-ces-info-left color-blue">正确选项:</span><span><%= choose.standard_answer %></span></li>
|
||||
<li><span class="-task-ces-info-left color-blue">你的选项:</span><span class="color-orange"><%= choose.current_choose_outputs.try(:answer).nil? ? "无" : choose.current_choose_outputs.try(:answer) %></span></li>
|
||||
<% if choose.current_choose_outputs.try(:answer) == choose.standard_answer %>
|
||||
<li><span class="-task-ces-info-left color-blue">正确选项:</span><span><%= choose.standard_answer %></span></li>
|
||||
<li><span class="-task-ces-info-left color-blue">你的选项:</span><span class="color-orange"><%= choose.current_choose_outputs.try(:answer).nil? ? "无" : choose.current_choose_outputs.try(:answer) %></span></li>
|
||||
<% else %>
|
||||
<li><span class="-text-danger ml30">错误,不支持查看</span></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,53 +1,25 @@
|
|||
<%= stylesheet_link_tag 'css/edu-common', 'css/edu-popup' %>
|
||||
|
||||
<% if game.challenge.st != 0 %>
|
||||
<div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);top: 0px;left: 0px;">
|
||||
<div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);">
|
||||
<div class="task-popup-box <%= had_done == 0 ? "task-box1" : "task-box2" %>">
|
||||
<a href="javascript:void(0)" class="task-popup-close" onclick="refresh_game_list();"></a>
|
||||
<% if had_done == 0 %>
|
||||
<div class="task-su-con">
|
||||
<div class="task-su-con">
|
||||
<% if had_done == 0 %>
|
||||
<p class="task-su-p">恭喜您通过本关</p>
|
||||
<p class="mt8"><i class="fa fa-check-circle color-light-green mr5"></i>本题正确:<span class="color-orange03"> <%= game.challenge.choose_correct_num.to_i %> </span>道</p>
|
||||
<p><i class="fa fa-exclamation-circle color-orange mr5"></i>本题错误:<span class="color-orange03"> <%= game.challenge.challenge_chooses.count - game.challenge.choose_correct_num.to_i %> </span>道</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="task-su-con" style="position: absolute;width: 100%;z-index:3;padding-top: 63px;">
|
||||
<img src="/images/task/task-success02.png"/>
|
||||
<a href="<%= myshixun_game_path(myshixun, :index => 1) %>" class="task-su-btn-white mt30" onclick="hideModal();" data-remote="true">查看光辉历史</a>
|
||||
</div>
|
||||
<div style="text-align:center;background-color: #fff;border-radius: 0px 0px 8px 8px;width: 200px;position:absolute;z-index:2;height:100px;bottom:-30px;left:50%;margin-left:-100px;">
|
||||
<p class="mt25"><i class="fa fa-check-circle color-light-green mr5"></i>本题正确:<span class="color-orange03"> <%= game.challenge.choose_correct_num.to_i %> </span>道</p>
|
||||
<p><i class="fa fa-exclamation-circle color-orange mr5"></i>本题错误:<span class="color-orange03"> <%= game.challenge.challenge_chooses.count - game.challenge.choose_correct_num.to_i %> </span>道</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if had_done == 0 %>
|
||||
<%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :onclick => "hideModal();", :remote => true %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);">
|
||||
<div class="task-popup-box <%= had_done == 0 ? "task-box1" : "task-box2" %>">
|
||||
<a href="javascript:void(0)" class="task-popup-close" onclick="refresh_game_list();"></a>
|
||||
<div class="task-su-con">
|
||||
<% if had_done == 0 %>
|
||||
<p class="task-su-p">恭喜您通过本关</p>
|
||||
<%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :onclick => "hideModal();", :remote => true %>
|
||||
<% else %>
|
||||
<a href="<%= myshixun_game_path(myshixun, :index => 1) %>" class="task-su-btn-white mt50" onclick="hideModal();" data-remote="true">查看光辉历史</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :onclick => "hideModal();", :remote => true %>
|
||||
<% else %>
|
||||
<a href="<%= myshixun_game_path(myshixun, :index => 1) %>" class="task-su-btn-white mt50" onclick="hideModal();" data-remote="true">查看光辉历史</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function refresh_game_list(){
|
||||
$.ajax({
|
||||
url: "<%= refresh_game_list_myshixun_game_path(game, :myshixun_id => myshixun) %>",
|
||||
dataType: "script"
|
||||
});
|
||||
function refresh_game_list(){
|
||||
$.ajax({
|
||||
url: "<%= refresh_game_list_myshixun_game_path(game, :myshixun_id => myshixun) %>",
|
||||
dataType: "script"
|
||||
});
|
||||
|
||||
//$("#all_task_show").css("display","none");
|
||||
}
|
||||
//$("#all_task_show").css("display","none");
|
||||
}
|
||||
</script>
|
||||
|
|
@ -13,13 +13,13 @@
|
|||
.task-popup-warp{ width: 100%; height:100%; background:black; position:fixed;}
|
||||
.task-popup-box{ position: relative; margin:150px auto 0px; }
|
||||
.task-box1{ width:428px; height:420px;background:url(/images/task/task-success.png) 0px 0px no-repeat;}
|
||||
.task-box2{ width:496px; height:373px;position: relative;}/*background:url(/images/task/task-success02.png) 0px 50px no-repeat;*/
|
||||
.task-box2{ width:496px; height:373px;background:url(/images/task/task-success02.png) 0px 50px no-repeat;}
|
||||
a.task-popup-close{ display: block; background:url(/images/task/task-close.png) 0px 0px no-repeat; width: 31px; height: 31px; position:absolute; right:5px; top:100px;}
|
||||
a:hover.task-popup-close{background:url(/images/task/task-close.png) -40px 0px no-repeat; }
|
||||
.task-su-con{ text-align: center; padding-top:285px;}
|
||||
.task-su-p{ font-size: 20px; color:#ee4a1f; font-weight: bold;}
|
||||
a.task-su-btn{display: block;background:url(/images/task/task-su-btn-jie.png) 0px -64px no-repeat; width: 138px; height: 53px;color:#ee4a1f; line-height: 50px; text-align: center; font-size: 16px; margin:20px auto;}
|
||||
a:hover.task-su-btn{background:url(/images/task/task-su-btn-jie.png) 0px 0px no-repeat;height: 53px;}
|
||||
a.task-su-btn{display: block;background:url(/images/task/task-su-btn.png) 0px -64px no-repeat; width: 138px; height: 57px;color:#ee4a1f; line-height: 50px; text-align: center; font-size: 16px; margin:20px auto;}
|
||||
a:hover.task-su-btn{background:url(/images/task/task-su-btn.png) 0px 0px no-repeat; }
|
||||
a.task-su-btn-white{ display: inline-block; padding:8px 25px; border:1px solid #fff; color:#fff; text-align: center; border-radius:5px; font-size:14px;}
|
||||
a:hover.task-su-btn-white{ color: #ee4a1f; border:1px solid #ee4a1f; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue