实训任务通关展示

This commit is contained in:
daiao 2017-03-30 10:05:55 +08:00
parent eea8939c49
commit b070292b45
4 changed files with 40 additions and 31 deletions

View File

@ -126,7 +126,7 @@ class GamesController < ApplicationController
else
outputs = outputs.map{|result| [result.code, result.id]}
end
had_done = 1 if (@myshixun.games.count == game_challenge.position && @game.status ==2)
(@myshixun.games.count == game_challenge.position && @game.status ==2) ? had_done = 1 : had_done = 0
latest_output = @game.latest_output.try(:out_put)
render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done}
end

View File

@ -111,6 +111,7 @@
data:'test',
success:function(data){
//如果查到了,就退出
// i变量用来统计setInterval执行了多少次便于统计访问时间
i = i + 1;
if(data.status == 2 || data.status == 0){
clearInterval(intId);
@ -119,11 +120,16 @@
var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done});
$("#code_results").html(html);
if(data.status == 2){
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun}) %>";
if( data.had_done == 0 ) {
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>";
}else{
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>";
}
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight);
}
}
// 访问30次即60s后后台还未改变状态即执行
if(i == 30){
$.ajax({
url: '<%= change_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',

View File

@ -1,12 +1,15 @@
<%= stylesheet_link_tag 'css/bigdata-common', 'css/bigdata-popup' %>
<div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);">
<div class="task-popup-box task-box1">
<div class="task-popup-box <%= had_done == 0 ? "task-box1" : "task-box2" %>">
<a href="javascript:void(0)" class="task-popup-close" onclick="hideModal();"></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", :remote => true %>
<% else %>
<a href="#" class="task-su-btn-white mt50">查看光辉历史</a>
<% end %>
</div>
</div>
</div>

View File

@ -20,22 +20,22 @@
<div class="task-container EXTENDER">
<div class="COLS">
<div class="leftbar CELL">
<div class="leftbar CELL" style="width: 120px;">
<div class="CELL">
<div class="user-info">
<%= link_to image_tag(url_to_avatar(@myshixun.owner), :width => "100", :height => "100"), user_path(@myshixun.owner), :alt => "用户头像", :class => "user-info-img" %>
<div class="user-info" style="width: 120px;height:120px;padding-top: 10px;">
<%= link_to image_tag(url_to_avatar(@myshixun.owner), :width => "100", :height => "100"), user_path(@myshixun.owner), :alt => "用户头像", :class => "user-info-img", :style => "border-radius: 100px;margin-left: 5px;" %>
<!--<a href="#" class="user-info-img"><img src="images/user/male.jpg" width="100" height="" alt="100"></a>-->
<%= link_to @myshixun.owner.try(:show_name), user_path(@myshixun.owner), :class => "user-info-name" %>
<%#= link_to @myshixun.owner.try(:show_name), user_path(@myshixun.owner), :class => "user-info-name" %>
</div>
<div class="leftnav">
<ul>
<li class="leftnav-box">
<a href="<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>" class="leftnav-box-inner leftnav-active" id="current_task_tab" data-remote="true">
<li class="leftnav-box" style="width: 120px">
<a href="<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>" class="leftnav-box-inner leftnav-active" style="width: 120px" id="current_task_tab" data-remote="true">
<i class="fa fa-gamepad font-28"></i><br/><span class="font-16">当前任务</span>
</a>
</li>
<li class="leftnav-box">
<a href="<%= myshixun_games_path(@myshixun) %>" class="leftnav-box-inner" id="all_task_tab" data-remote="true">
<li class="leftnav-box" style="width: 120px">
<a href="<%= myshixun_games_path(@myshixun) %>" class="leftnav-box-inner" style="width: 120px" id="all_task_tab" data-remote="true">
<i class="fa fa-qrcode font-28"></i><br/><span class="font-16">全部任务</span><span class="btn-cir ml5"><%= @myshixun.games.count %></span>
</a>
</li>