From 5e6f4e37995db93840621fb57deb6ee5f8f33086 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 8 Aug 2017 14:00:49 +0800 Subject: [PATCH 01/40] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPI=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_myshixun.html.erb | 2 +- public/javascripts/edu/edu_tpi.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 public/javascripts/edu/edu_tpi.js diff --git a/app/views/layouts/base_myshixun.html.erb b/app/views/layouts/base_myshixun.html.erb index 4f3a2a245..f5e59cbfa 100644 --- a/app/views/layouts/base_myshixun.html.erb +++ b/app/views/layouts/base_myshixun.html.erb @@ -10,7 +10,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/font-awesome','css/taskstyle', 'css/project','css/popup','repository','css/gantt','css/cssPlus-v.0.2-build', 'css/edu-common','css/edu-public', 'css/edu-popup', 'css/edu-tooltipster' %> - <%= javascript_include_tag 'edu/application' %> + <%= javascript_include_tag 'edu/application', 'edu/edu_tpi' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js new file mode 100644 index 000000000..1f7d358f0 --- /dev/null +++ b/public/javascripts/edu/edu_tpi.js @@ -0,0 +1,5 @@ +// 实训游戏需要的js功能 + +$(function(){ + +}); \ No newline at end of file From a9519a51e4fd4bed6086de911f5dda3873224f36 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 8 Aug 2017 16:25:11 +0800 Subject: [PATCH 02/40] =?UTF-8?q?=E4=BC=98=E5=8C=96tpi=E7=9A=84js=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 2 +- app/views/games/_choice_question.html.erb | 17 +-- app/views/games/_code_actions.html.erb | 7 -- app/views/games/_game_results.html.erb | 15 +-- app/views/games/_game_show.html.erb | 118 +----------------- app/views/games/show.html.erb | 18 --- app/views/shixuns/shixun_discuss.js.erb | 10 +- public/javascripts/edu/edu_tpi.js | 141 +++++++++++++++++++++- 8 files changed, 151 insertions(+), 177 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 1bb5dfaeb..c39298968 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -300,7 +300,7 @@ class GamesController < ApplicationController if @game.outputs.blank? Output.create(:game_id => @game.id, :actual_output => user_answer, :result => correct) end - render :json => {correct: correct, had_done: had_done, :grade => User.current.grade} + render :json => {correct: correct, had_done: had_done, grade: User.current.grade} end diff --git a/app/views/games/_choice_question.html.erb b/app/views/games/_choice_question.html.erb index dec6a00d3..e65ade9ff 100644 --- a/app/views/games/_choice_question.html.erb +++ b/app/views/games/_choice_question.html.erb @@ -29,19 +29,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 3afd18044..e5d0ed3df 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -76,13 +76,6 @@ $("#time-consuming").html("耗时:" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "); } - /* -----------------下一关增加loading效果--------------------- */ - $("#next_step").live("click", function(){ - nNext = $("#code_estimate"); - html = "下一关"; - nNext.html(html); - }); - // 选择题提交评测 // answer 选择的答案 function choice_submmit(){ diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index c18486db3..7d69d3d5a 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -143,20 +143,7 @@ $("#blacktab_nav_1").trigger("click"); }); - // 公开的测试集允许展开与隐藏 - function toggle_test_case(t_case, id){ - if(true){ - var nTest = $("#test_case_"+id).prev(".-task-ces-top").children("i:first-child"); //图标节点 - if (nTest.hasClass("fa-caret-down")){ - nTest.addClass("fa-caret-right"); - nTest.removeClass("fa-caret-down"); - }else if( nTest.hasClass("fa-caret-right") ){ - nTest.addClass("fa-caret-down"); - nTest.removeClass("fa-caret-right"); - } - $("#test_case_"+id).toggle(); - } - } + function g_new(o){return document.getElementById(o);} function HoverLi(n){ for(var i=1;i<=3;i++){ diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index a0fa4bff3..2d00901ba 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -120,117 +120,6 @@ \ No newline at end of file diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 74a8fca4d..55a9bd559 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -68,22 +68,4 @@ control_1 = 0; } } - - /* --------------------------------点击全部任务向右侧展开-----------------------------------------*/ - $("#all_task_show").on("click", function(e){ - c = 0; - $("#all_task_tab").removeClass('leftnav-active'); - $("#all_task_show").css("background","rgba(0,0,0,0)"); - $("#all_task_index").css("left", 0).stop().animate({ - left: "-505px" - }, 400, function(){ - $("#all_task_show").hide(); - fadein = 0; - }); - }); - // 列表区域阻止事件冒泡 - $("#all_task_index").on("click", function(e){ - e.stopPropagation(); - }); - \ No newline at end of file diff --git a/app/views/shixuns/shixun_discuss.js.erb b/app/views/shixuns/shixun_discuss.js.erb index 6c916820f..fac26ce2e 100644 --- a/app/views/shixuns/shixun_discuss.js.erb +++ b/app/views/shixuns/shixun_discuss.js.erb @@ -2,4 +2,12 @@ $("#shixun_comment_block").replaceWith("<%= j(render :partial => "games/shixun_c $(".-tab-nav li").removeClass("tab_hover"); $('#tab_nav_4').addClass("tab_hover"); $(".tab-info").hide(); -$('#tab_con_4').show().html("<%= j(render :partial => "games/shixun_comment_list") %>"); \ No newline at end of file +$('#tab_con_4').show().html("<%= j(render :partial => "games/shixun_comment_list") %>"); + +// 评论区域的回复按钮 +function reply_to_dis(id, name){ + $("#comment_news").attr("placeholder", "回复"+name+":"); + $("#dis_reply_id").val(id); + $("#comment_news").focus(); +} +// end \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 1f7d358f0..ac26c9931 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -1,5 +1,140 @@ // 实训游戏需要的js功能 - +var EXPAND = 0; // 放大 +var SHRINK = 1; // 缩小 $(function(){ - -}); \ No newline at end of file + // TPI拖拽功能 begin + var doc = $(document); + var lab = $(".b-label"); + var cen = $(".h-center"); + var nextW2,nextW1; + var dragging = false; + var flag = false; + var wrapWidth; + var wrapHeight; + lab.bind('mousedown',function(){ + dragging = true; + leftOffset = $(".labelN").offset().left; + wrapWidth = $(".labelN").width(); + return false; + } + ); + cen.bind('mousedown',function(){ + flag = true; + topOffset = $(".centerH").offset().top; + wrapHeight = $(".centerH").height(); + return false; + } + ); + doc.bind('mousemove',function(e){ + + $(".-brother").show();// 代码行的遮罩显示 + if(dragging) { + clickX = e.pageX; + if(clickX > leftOffset+300&&clickX topOffset+100) { + cen.css('top', clickY - 7 - topOffset + 'px'); + cen.prev().height( clickY-topOffset + 'px'); + nextW1 = clickY-topOffset; + cen.next().height( wrapHeight - nextW1 + 'px'); + var h = $("#games_repository_contents").height() - $("#top_repository").height() - 50; + $("#game_webssh").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("min-height", h); + $("#file_entry_content").find(".CodeMirror-scroll").css("max-height", h); + } else { + cen.css('top', '0px'); + } + } + }); + + doc.mouseup(function(e) { + flag = false; + dragging = false; + e.cancelBubble = true; + $(".-brother").hide(); // 代码行的遮罩隐藏 + }); + // end; + + // 过关任务、背景知识的editorMD渲染成HTML begin + editormd.loadKaTeX(function() { + var wordsView; + task_md = editormd.markdownToHTML("game_task_pass", { + htmlDecode: "style,script,iframe", // you can filter tags decode + taskList: true, + tex: true, // 数学公式 + flowChart: true, // 默认不解析 + sequenceDiagram: true // 默认不解析 + }); + var wordsView; + knowledge_md = editormd.markdownToHTML("game_ready_knowledge", { + htmlDecode: "style,script,iframe", // you can filter tags decode + taskList: true, + tex: true, // 数学公式 + flowChart: true, // 默认不解析 + sequenceDiagram: true // 默认不解析 + }); + }); + // end + + // 评论区域的回复按钮 + function reply_to_dis(id, name){ + $("#comment_news").attr("placeholder", "回复"+name+":"); + $("#dis_reply_id").val(id); + $("#comment_news").focus(); + } + // end + + // 点击全部任务向右侧展开 + $("#all_task_show").on("click", function(e){ + c = 0; + $("#all_task_tab").removeClass('leftnav-active'); + $("#all_task_show").css("background","rgba(0,0,0,0)"); + $("#all_task_index").css("left", 0).stop().animate({ + left: "-505px" + }, 400, function(){ + $("#all_task_show").hide(); + fadein = 0; + }); + }); + // end + + // 列表区域阻止事件冒泡 + $("#all_task_index").on("click", function(e){ + e.stopPropagation(); + }); + // end + + // 选择题选择答案 + function choice_answer(st, nThis){ + if(st == "1"){ + //$(nThis).hasClass("card-check") ? $(nThis).removeClass("card-check") : $(nThis).addClass("card-check"); + $(nThis).toggleClass("card-check"); + $(nThis).toggleClass("color_white"); + } else if (st == "2"){ + var choice = $(".color_white"); + choice.removeClass("card-check"); + choice.removeClass("color_white"); + $(nThis).addClass("card-check"); + $(nThis).toggleClass("color_white"); + } + } + // end + + /* -----------------下一关增加loading效果--------------------- */ + $("#next_step").live("click", function(){ + nNext = $("#code_estimate"); + html = "下一关"; + nNext.html(html); + }); +}); From 0e4287710e35fd0880b6afd0ba5a146bb64fc60f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 8 Aug 2017 17:13:50 +0800 Subject: [PATCH 03/40] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_game_show.html.erb | 10 ++---- app/views/games/_repository.html.erb | 43 +---------------------- public/javascripts/edu/edu_tpi.js | 51 +++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 51 deletions(-) diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 2d00901ba..54ec33729 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -20,7 +20,7 @@ 背景知识 <% unless @game_challenge.answer.blank? %> -
  • +
  • 参考答案
  • <% end %> @@ -92,7 +92,7 @@ <% if @st != 0 %> <%= render :partial => "games/choice_question" %> - <% else %> + <% else %>
    @@ -120,12 +120,6 @@
    \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index ac26c9931..4236758f7 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -131,10 +131,59 @@ $(function(){ } // end - /* -----------------下一关增加loading效果--------------------- */ + // 下一关增加loading效果 $("#next_step").live("click", function(){ nNext = $("#code_estimate"); html = "下一关"; nNext.html(html); }); + // end }); + +// 查看参考答案 +function open_answer(game, myshixun){ + $.ajax({ + url: "/myshixuns/" + myshixun + "/stages/" + game + "/answer", + dataType: "script" + }) +} + +// 代码/webssh的tab点击事件 +function g_l(o){return document.getElementById(o);} +function HoverLi_new(n){ + for(var i=1;i<=2;i++){ + g_l('codetab_nav_'+i).className='blacktab_nomal'; + g_l('codetab_con_'+i).className='undis'; + + } + if(n==2){ + $("#games_repository_contents").removeClass("-bg-black").addClass("-bg-weightblack"); + $("#-bg-change-color").removeClass("-bg-black").addClass("-bg-weightblack"); + }else{ + $("#games_repository_contents").removeClass("-bg-weightblack").addClass("-bg-black"); + $("#-bg-change-color").removeClass("-bg-weightblack").addClass("-bg-black"); + } + g_l('codetab_con_'+n).className='dis -relative'; + g_l('codetab_nav_'+n).className='blacktab_hover'; +}; + +// webssh连接 +function webssh_connect(myshixun){ + $.ajax({ + url: "/myshixuns/" + myshixun + '/open_webssh', + success: function(data){ + if(data.error){ + return; + }else{ + // 测试版 + var html = "
    "; + // 本地版 + var html_local ="
    "; + $("#codotab_con_2").html(html); + HoverLi_new(2); + } + } + }) +} +// end + From f5551c78f47d129a4940ce3181eec410d747f016 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Aug 2017 09:09:51 +0800 Subject: [PATCH 04/40] =?UTF-8?q?=E5=AE=9E=E8=AE=ADTPI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_repository.html.erb | 7 ++----- public/javascripts/edu/edu_tpi.js | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/games/_repository.html.erb b/app/views/games/_repository.html.erb index c2064b257..39179090c 100644 --- a/app/views/games/_repository.html.erb +++ b/app/views/games/_repository.html.erb @@ -2,7 +2,7 @@
  • 代码
  • -
  • +
  • <% if @myshixun.shixun.try(:webssh) %> 命令行 <% end %> @@ -61,7 +61,4 @@
  • - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 4236758f7..d5d731b73 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -168,7 +168,7 @@ function HoverLi_new(n){ }; // webssh连接 -function webssh_connect(myshixun){ +function webssh_connect(myshixun, url){ $.ajax({ url: "/myshixuns/" + myshixun + '/open_webssh', success: function(data){ @@ -176,7 +176,7 @@ function webssh_connect(myshixun){ return; }else{ // 测试版 - var html = "
    "; + var html = "
    "; // 本地版 var html_local ="
    "; $("#codotab_con_2").html(html); From cf7cba97b3c7851bd1b43e1e8304076e8cf19c46 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Aug 2017 16:38:08 +0800 Subject: [PATCH 05/40] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index d5d731b73..0234e3bd8 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -138,6 +138,22 @@ $(function(){ nNext.html(html); }); // end + + // 公开的测试集允许展开与隐藏 + function toggle_test_case(t_case, id){ + if(true){ + var nTest = $("#test_case_"+id).prev(".-task-ces-top").children("i:first-child"); //图标节点 + if (nTest.hasClass("fa-caret-down")){ + nTest.addClass("fa-caret-right"); + nTest.removeClass("fa-caret-down"); + }else if( nTest.hasClass("fa-caret-right") ){ + nTest.addClass("fa-caret-down"); + nTest.removeClass("fa-caret-right"); + } + $("#test_case_"+id).toggle(); + } + } + // end }); // 查看参考答案 From b0991d4685308d3cf2d2de9f3bd6cc537d430a14 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Wed, 9 Aug 2017 16:47:43 +0800 Subject: [PATCH 06/40] js --- public/javascripts/edu/edu_tpi.js | 159 ++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 4236758f7..5d6407de6 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -185,5 +185,164 @@ function webssh_connect(myshixun){ } }) } + + + +//动态加载评测区域 +/** + * Created by wang on 2017/8/9. + */ +var $a ,$b,$c,$d,$e,$f,$g,$h,$m,$n; +$a = "
    "; +$b = "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "; + +if(language == "Html"){ + $a.html($b); +} + +//第二块 + +$c = + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + + "
    "+ + "
    "+ + "
    "+ + "
    "; +if(had_test_count != "0"){ + if(had_passed_testsests_error_count != "0"){ + $d = "

    "+ + ""+ + " "+ had_passed_testsests_error_count / test_sets_count +""+ + " latest_output "+ + "

    "; + }else{ + $d = "

    "+ + ""+ + ""+ test_sets_count / test_sets_count +" 全部通过

    "; + } + $("#evaluating_contents").append($d); +} + +for(var i = 0; i < test_sets.length; i++ ){ + $e = "
    "; + $f = "
    "+ + ""+ + "测试集 "+ i +"+ 1"+ + "
    "; + if(test_sets[i].result == 0){ + $g = "" + } + if(test_sets[i].result == 1){ + $g = "" + } + if(test_sets[i].is_public == 0){ + $g = "" + } + $("#evaluating_contents").append($e); + $("#evaluating_contents").append($f); + $(".-task-ces-top").append($g); + + if(test_sets[i].is_public == 1){ + $h = "
    "+ + ""+ + "
    "; + } + if(test_sets[i].is_public == 0){ + $h = "
    "+ + " "+ + "
    "; + + } + $(".-task-ces-box").append($h); +} + +//第三块 +$m = "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + + "
    "+ + "
    "+ + "
      "+ + "
    • "+ + "公开测试:"+ + ""+ had_passed_testsests_public_count / test_sets_public_count +""+ + "
    • "+ + "
    • "+ + " 隐藏测试:"+ + ""+ had_passed_testsests_hidden_count / test_sets_hidden_count+""+ + "
    • "+ + "
    • "+ + " 经验值:"+ + "+ "+ final_score+" "+ + "
    • "+ + "
    • "+ + "金币:"+ + "+ "+ final_score +""+ + "
    • "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "; + + + + +if(had_test_count != "0"){ + if(had_passed_testsests_error_count != "0"){ + $n = "

    "+ + ""+ + ""+had_passed_testsests_error_count / test_sets_count +" "+ latest_output +"

    "; + + }else{ + $n = "

    "+ + ""+ + ""+ test_sets_count / test_sets_count +" 全部通过

    "; + } + $("#evaluating_info").append($n); +} + + // end From d2eaff399954a5efb4cbe58fe07212e5774e73c7 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Wed, 9 Aug 2017 17:02:27 +0800 Subject: [PATCH 07/40] =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 6dadd829a..cdd99caf6 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -204,6 +204,10 @@ function webssh_connect(myshixun, url){ +function code_evaluation(language, had_done_test, had_passed_testsests_error_count,test_sets_count,test_sets,had_passed_testsests_public_count,test_sets_public_count,had_passed_testsests_hidden_count,test_sets_hidden_count,final_score,latest_output,test_sets_count){ + +} + //动态加载评测区域 /** * Created by wang on 2017/8/9. From f31b92a2cb4bb730050891b0d08ba20997d695ec Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 9 Aug 2017 17:03:25 +0800 Subject: [PATCH 08/40] =?UTF-8?q?TPiJS=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_game_results.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 7d69d3d5a..931ccea6b 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -117,6 +117,12 @@ \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 0900c8e08..61aa2584c 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -202,6 +202,19 @@ function webssh_connect(myshixun, url){ }) } +// 评测区域点击TAB切换样式 +function check_tab(allClassName,addClassName,item){ + //点击tab添加样式 + $("."+allClassName).removeClass(addClassName); + $(item).addClass(addClassName); + //获取当前点击的tab的索引位置 + var index=$(item).index()+1; + //显示或隐藏对应的内容块 + $("#"+allClassName+"_"+index).siblings().addClass("undis"); + $("#"+allClassName+"_"+index).removeClass("undis"); +} +// end + // test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数 // test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数 // final_score:最终得分;latest_output:最新的输出;language:实训的语言 From dca686ef3aceb92541f6d70fd82ab37c3c9825ff Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 10 Aug 2017 10:12:08 +0800 Subject: [PATCH 16/40] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_game_results.html.erb | 1 - public/javascripts/edu/edu_tpi.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 99c46310e..2321bda0b 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -134,7 +134,6 @@ [<%= @latest_output.html_safe unless @latest_output.blank? %>], '<%= @language %>' ); - $("#game_test_set_results").html(html); $("#blacktab_nav_1").trigger("click"); }); diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 5937a6cc8..b16cca0df 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -279,6 +279,11 @@ function code_evaluation(test_sets, } for (var i = 0; i < test_sets.length; i++) { + console.log("test_sets: " + test_sets[i].result); + console.log("test_sets: " + test_sets[i].is_public); + console.log("test_sets: " + test_sets[i].actual_output); + console.log("test_sets: " + test_sets[i].output); + console.log("test_sets: " + test_sets[i].input); $e = "
    "; $f = "
    " + "" + @@ -385,6 +390,18 @@ function code_evaluation(test_sets, $("#evaluating_info").html($n); } var $html = $EffectDisplay + $TestResult + $EvaluationInformation; + console.log("第一块区域:" + $EffectDisplay); + console.log("第二块区域:" + $TestResult); + console.log("第三块区域:" + $EvaluationInformation); + console.log("had_test_count: " + had_test_count); + console.log("test_sets_count: " + test_sets_count); + console.log("had_passed_testsests_error_count: " + had_passed_testsests_error_count); + console.log("test_sets_hidden_count: " + test_sets_hidden_count); + console.log("test_sets_public_count: " + test_sets_public_count); + console.log("had_passed_testsests_hidden_count: " + had_passed_testsests_hidden_count); + console.log("had_passed_testsests_public_count: " + had_passed_testsests_public_count); + console.log("final_score: " + final_score); + console.log("language: " + language); $("#game_test_set_results").html($html); } // end From 460be95e0ec0828531a73ae69cf692525f84530c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 10 Aug 2017 11:17:16 +0800 Subject: [PATCH 17/40] =?UTF-8?q?=E8=AF=84=E6=B5=8B=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index b16cca0df..4fff6f170 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -252,8 +252,7 @@ function code_evaluation(test_sets, //第二块 测试结果 - $TestResult = - "
    " + + $TestResult = "
    " + "
    " + "
    " + "
    " + @@ -267,9 +266,8 @@ function code_evaluation(test_sets, if (had_passed_testsests_error_count != "0") { $d = "

    " + "" + - " " + had_passed_testsests_error_count / test_sets_count + "" + - " latest_output " + - "

    "; + " " + had_passed_testsests_error_count / test_sets_count + "" + latest_output + "

    "; + } else { $d = "

    " + "" + @@ -277,13 +275,13 @@ function code_evaluation(test_sets, } $("#evaluating_contents").html($d); } - + console.log(test_sets.length); for (var i = 0; i < test_sets.length; i++) { - console.log("test_sets: " + test_sets[i].result); - console.log("test_sets: " + test_sets[i].is_public); - console.log("test_sets: " + test_sets[i].actual_output); - console.log("test_sets: " + test_sets[i].output); - console.log("test_sets: " + test_sets[i].input); + console.log("test_sets[" +i+"]" + test_sets[i].result); + console.log("test_sets[" +i+"]" + test_sets[i].is_public); + console.log("test_sets[" +i+"]" + test_sets[i].actual_output); + console.log("test_sets[" +i+"]" + test_sets[i].output); + console.log("test_sets[" +i+"]" + test_sets[i].input); $e = "

    "; $f = "
    " + "" + From 03180ed0a9be7d29c77634cf8eddfa76546c8199 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Thu, 10 Aug 2017 15:41:19 +0800 Subject: [PATCH 18/40] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 119 ++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 37 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 4fff6f170..ab0806cff 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -251,17 +251,6 @@ function code_evaluation(test_sets, } //第二块 测试结果 - - $TestResult = "
    " + - "
    " + - "
    " + - "
    " + - "
    " + - - "
    " + - "
    " + - "
    " + - "
    "; if (had_test_count != "0") { if (had_passed_testsests_error_count != "0") { $d = "

    " + @@ -273,20 +262,14 @@ function code_evaluation(test_sets, "" + "" + test_sets_count / test_sets_count + " 全部通过

    "; } - $("#evaluating_contents").html($d); + } - console.log(test_sets.length); for (var i = 0; i < test_sets.length; i++) { console.log("test_sets[" +i+"]" + test_sets[i].result); console.log("test_sets[" +i+"]" + test_sets[i].is_public); console.log("test_sets[" +i+"]" + test_sets[i].actual_output); console.log("test_sets[" +i+"]" + test_sets[i].output); console.log("test_sets[" +i+"]" + test_sets[i].input); - $e = "
    "; - $f = "
    " + - "" + - "测试集 " + i + "+ 1" + - "
    "; if (test_sets[i].result == 0) { $g = "" } @@ -296,9 +279,57 @@ function code_evaluation(test_sets, if (test_sets[i].is_public == 0) { $g = "" } - $("#evaluating_contents").append($e); - $("#evaluating_contents").append($f); - $(".-task-ces-top").html($g); + if (test_sets[i].is_public == 1) { + $h = "
    " + + "
      " + + "
    • " + + "
      " + + "测试输入:" + + "

      " + test_sets[i].input == null ? "+空+" : test_sets[i].input.replace(/\r\n/g, "
      ") + "

      " + + "
      " + + "
    • " + + "
    • " + + "
      " + + " 预期输出:" + + "

      " + test_sets[i].output == null ? "+空+" : test_sets[i].output.replace(/\r\n/g, "
      ") + "

      " + + "
      " + + "
    • " + + "
    • " + + "
      " + + "实际输出:" + + "

      " + test_sets[i].actual_output == null ? "+空+" : test_sets[i].actual_output.replace(/\r\n/g, "
      ") + "

      " + + "
      " + + "
    • " + + "
    " + + "
    "; + } + if (test_sets[i].is_public == 0) { + $h = "
    " + + "
      " + + "
    • " + + "
      " + + "

      此为隐藏测试项,暂不支持查看

      " + + "
      " + + "
    • " + + "
    " + + "
    "; + + } + $e = "
    "+$h+"
    "; + $f = "
    " + + "" + + "测试集 " + i + "+ 1" +$g+"
    "; + if (test_sets[i].result == 0) { + $g = "" + } + if (test_sets[i].result == 1) { + $g = "" + } + if (test_sets[i].is_public == 0) { + $g = "" + } + + //$(".-task-ces-top").html($g); if (test_sets[i].is_public == 1) { $h = "
    " + @@ -336,17 +367,39 @@ function code_evaluation(test_sets, "
    "; } - $(".-task-ces-box").append($h); + //$(".-task-ces-box").append($h); } + $TestResult = "
    " + + "
    " + + "
    " + + "
    " + + "
    " +$d+$e+$f+"
    " + + "
    " + + "
    " + + "
    "; + + console.log(test_sets.length); + //第三块 评测信息 + if (had_test_count != "0") { + if (had_passed_testsests_error_count != "0") { + $n = "

    " + + "" + + "" + had_passed_testsests_error_count / test_sets_count + " " + latest_output + "

    "; + + } else { + $n = "

    " + + "" + + "" + test_sets_count / test_sets_count + " 全部通过

    "; + } + // $("#evaluating_info").html($n); + } $EvaluationInformation = "
    " + "
    " + "
    " + "
    " + - "
    " + - - "
    " + + "
    " +$n+"
    " + "
    " + "
      " + "
    • " + @@ -374,23 +427,13 @@ function code_evaluation(test_sets, "
    "; - if (had_test_count != "0") { - if (had_passed_testsests_error_count != "0") { - $n = "

    " + - "" + - "" + had_passed_testsests_error_count / test_sets_count + " " + latest_output + "

    "; - } else { - $n = "

    " + - "" + - "" + test_sets_count / test_sets_count + " 全部通过

    "; - } - $("#evaluating_info").html($n); - } var $html = $EffectDisplay + $TestResult + $EvaluationInformation; console.log("第一块区域:" + $EffectDisplay); console.log("第二块区域:" + $TestResult); console.log("第三块区域:" + $EvaluationInformation); + console.log($("#evaluating_info")); + console.log($(".-task-ces-box")); console.log("had_test_count: " + had_test_count); console.log("test_sets_count: " + test_sets_count); console.log("had_passed_testsests_error_count: " + had_passed_testsests_error_count); @@ -402,5 +445,7 @@ function code_evaluation(test_sets, console.log("language: " + language); $("#game_test_set_results").html($html); } +console.log($("#evaluating_info")); +console.log($(".-task-ces-box")); // end From a0c2282fba6a4e2b05e06d26709baeaddd3f47ed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 10 Aug 2017 15:42:27 +0800 Subject: [PATCH 19/40] =?UTF-8?q?tpi=E8=AF=84=E6=B5=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 4fff6f170..5437de04c 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -115,22 +115,6 @@ $(function(){ }); // end - // 选择题选择答案 - function choice_answer(st, nThis){ - if(st == "1"){ - //$(nThis).hasClass("card-check") ? $(nThis).removeClass("card-check") : $(nThis).addClass("card-check"); - $(nThis).toggleClass("card-check"); - $(nThis).toggleClass("color_white"); - } else if (st == "2"){ - var choice = $(".color_white"); - choice.removeClass("card-check"); - choice.removeClass("color_white"); - $(nThis).addClass("card-check"); - $(nThis).toggleClass("color_white"); - } - } - // end - // 下一关增加loading效果 $("#next_step").live("click", function(){ nNext = $("#code_estimate"); @@ -202,6 +186,22 @@ function webssh_connect(myshixun, url){ }) } +// 选择题选择答案 +function choice_answer(st, nThis){ + if(st == "1"){ + //$(nThis).hasClass("card-check") ? $(nThis).removeClass("card-check") : $(nThis).addClass("card-check"); + $(nThis).toggleClass("card-check"); + $(nThis).toggleClass("color_white"); + } else if (st == "2"){ + var choice = $(".color_white"); + choice.removeClass("card-check"); + choice.removeClass("color_white"); + $(nThis).addClass("card-check"); + $(nThis).toggleClass("color_white"); + } +} +// end + // 评测区域点击TAB切换样式 function check_tab(allClassName,addClassName,item){ //点击tab添加样式 From e2c9a094ff39b50b9069f5ee87c88491fe97bfa0 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Thu, 10 Aug 2017 16:23:12 +0800 Subject: [PATCH 20/40] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 56 ++++--------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index ab0806cff..35c3941bc 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -264,6 +264,8 @@ function code_evaluation(test_sets, } } + var $forHtml = ""; + var $Bear = ""; for (var i = 0; i < test_sets.length; i++) { console.log("test_sets[" +i+"]" + test_sets[i].result); console.log("test_sets[" +i+"]" + test_sets[i].is_public); @@ -318,62 +320,16 @@ function code_evaluation(test_sets, $e = "
    "+$h+"
    "; $f = "
    " + "" + - "测试集 " + i + "+ 1" +$g+"
    "; - if (test_sets[i].result == 0) { - $g = "" - } - if (test_sets[i].result == 1) { - $g = "" - } - if (test_sets[i].is_public == 0) { - $g = "" - } + "测试集 "+ i+1 +"" +$g+"
    "; - //$(".-task-ces-top").html($g); - - if (test_sets[i].is_public == 1) { - $h = "
    " + - "
      " + - "
    • " + - "
      " + - "测试输入:" + - "

      " + test_sets[i].input == null ? "+空+" : test_sets[i].input.replace(/\r\n/g, "
      ") + "

      " + - "
      " + - "
    • " + - "
    • " + - "
      " + - " 预期输出:" + - "

      " + test_sets[i].output == null ? "+空+" : test_sets[i].output.replace(/\r\n/g, "
      ") + "

      " + - "
      " + - "
    • " + - "
    • " + - "
      " + - "实际输出:" + - "

      " + test_sets[i].actual_output == null ? "+空+" : test_sets[i].actual_output.replace(/\r\n/g, "
      ") + "

      " + - "
      " + - "
    • " + - "
    " + - "
    "; - } - if (test_sets[i].is_public == 0) { - $h = "
    " + - "
      " + - "
    • " + - "
      " + - "

      此为隐藏测试项,暂不支持查看

      " + - "
      " + - "
    • " + - "
    " + - "
    "; - - } - //$(".-task-ces-box").append($h); + $forHtml = $e + $f; + $Bear += $forHtml; } $TestResult = "
    " + "
    " + "
    " + "
    " + - "
    " +$d+$e+$f+"
    " + + "
    " +$d+$Bear+"
    " + "
    " + "
    " + "
    "; From 8c4b647a04e10109eaff3b4509202650805c5dba Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 10 Aug 2017 16:32:50 +0800 Subject: [PATCH 21/40] =?UTF-8?q?TPI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index dcb302aa3..194b82b7d 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -123,21 +123,6 @@ $(function(){ }); // end - // 公开的测试集允许展开与隐藏 - function toggle_test_case(t_case, id){ - if(true){ - var nTest = $("#test_case_"+id).prev(".-task-ces-top").children("i:first-child"); //图标节点 - if (nTest.hasClass("fa-caret-down")){ - nTest.addClass("fa-caret-right"); - nTest.removeClass("fa-caret-down"); - }else if( nTest.hasClass("fa-caret-right") ){ - nTest.addClass("fa-caret-down"); - nTest.removeClass("fa-caret-right"); - } - $("#test_case_"+id).toggle(); - } - } - // end }); // 查看参考答案 @@ -215,6 +200,22 @@ function check_tab(allClassName,addClassName,item){ } // end +// 公开的测试集允许展开与隐藏 +function toggle_test_case(t_case, id){ + if(true){ + var nTest = $("#test_case_"+id).prev(".-task-ces-top").children("i:first-child"); //图标节点 + if (nTest.hasClass("fa-caret-down")){ + nTest.addClass("fa-caret-right"); + nTest.removeClass("fa-caret-down"); + }else if( nTest.hasClass("fa-caret-right") ){ + nTest.addClass("fa-caret-down"); + nTest.removeClass("fa-caret-right"); + } + $("#test_case_"+id).toggle(); + } +} +// end + // test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数 // test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数 // final_score:最终得分;latest_output:最新的输出;language:实训的语言 @@ -316,9 +317,9 @@ function code_evaluation(test_sets, } $e = "
    "+$h+"
    "; - $f = "
    " + + $f = "
    " + "" + - "测试集 " + i + "+ 1" +$g+"
    "; + "测试集 " + i + "" +$g+"
    "; if (test_sets[i].result == 0) { $g = "" } @@ -332,7 +333,7 @@ function code_evaluation(test_sets, //$(".-task-ces-top").html($g); if (test_sets[i].is_public == 1) { - $h = "
    " + + $h = "
    " + "
      " + "
    • " + "
      " + @@ -356,7 +357,7 @@ function code_evaluation(test_sets, "
      "; } if (test_sets[i].is_public == 0) { - $h = "
      " + + $h = "
      " + "
        " + "
      • " + "
        " + From 9c120d9ff20a75ad845bab7f3fba37216882c869 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Thu, 10 Aug 2017 17:05:42 +0800 Subject: [PATCH 22/40] iiii --- public/javascripts/edu/edu_tpi.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 9dd61d173..c003b82fe 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -317,10 +317,11 @@ function code_evaluation(test_sets, "
        "; } - $e = "
        "+$h+"
        "; + $e = "
        "+$g+"
        "; $f = "
        " + "" + - "测试集 "+ i+1 +"" +$g+"
        "; + "测试集 "+ i+1 +"" +$h+"
      "; + $forHtml = $e + $f; $Bear += $forHtml; From 0f5a29fbb4055047885b5c5b9dbb29a65ac510e6 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 10 Aug 2017 17:05:44 +0800 Subject: [PATCH 23/40] =?UTF-8?q?TPI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 46b0bc184..c5dd11e93 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -283,7 +283,7 @@ function code_evaluation(test_sets, $g = "" } if (test_sets[i].is_public == 1) { - $h = "
      " + + $h = "
      " + "
        " + "
      • " + "
        " + @@ -307,7 +307,7 @@ function code_evaluation(test_sets, "
        "; } if (test_sets[i].is_public == 0) { - $h = "
        " + + $h = "
        " + "
          " + "
        • " + "
          " + From e6af828a81476bd74147e3c9ec0b618326fd0410 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Fri, 11 Aug 2017 09:24:37 +0800 Subject: [PATCH 24/40] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/edu/edu_tpi.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index c5dd11e93..4ac3167de 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -248,7 +248,7 @@ function code_evaluation(test_sets, "
          "; if (language == "Html") { - $EffectDisplay.html($b); + $EffectDisplay = "
          "+$b+"
          "; } //第二块 测试结果 @@ -256,12 +256,12 @@ function code_evaluation(test_sets, if (had_passed_testsests_error_count != "0") { $d = "

          " + "" + - " " + had_passed_testsests_error_count / test_sets_count + "" + latest_output + "

          "; + " " + had_passed_testsests_error_count + '/' + test_sets_count + "" + latest_output + "

          "; } else { $d = "

          " + "" + - "" + test_sets_count / test_sets_count + " 全部通过

          "; + "" + test_sets_count + "/" + test_sets_count + " 全部通过

          "; } } @@ -288,19 +288,19 @@ function code_evaluation(test_sets, "
        • " + "
          " + "测试输入:" + - "

          " + test_sets[i].input == null ? "+空+" : test_sets[i].input.replace(/\r\n/g, "
          ") + "

          " + + "

          " + ( test_sets[i].input == null ? "+空+" : test_sets[i].input.replace(/\r\n/g, "
          ") ) + "

          " + "
          " + "
        • " + "
        • " + "
          " + " 预期输出:" + - "

          " + test_sets[i].output == null ? "+空+" : test_sets[i].output.replace(/\r\n/g, "
          ") + "

          " + + "

          " + ( test_sets[i].output == null ? "+空+" : test_sets[i].output.replace(/\r\n/g, "
          ") ) + "

          " + "
          " + "
        • " + "
        • " + "
          " + "实际输出:" + - "

          " + test_sets[i].actual_output == null ? "+空+" : test_sets[i].actual_output.replace(/\r\n/g, "
          ") + "

          " + + "

          " + (test_sets[i].actual_output == null ? "+空+" : test_sets[i].actual_output.replace(/\r\n/g, "
          ")) + "

          " + "
          " + "
        • " + "
        " + @@ -330,7 +330,7 @@ function code_evaluation(test_sets, "
        " + "
        " + "
        " + - "
        " +$d+$Bear+"
        " + + "
        " +$d + $Bear + "
        " + "
        " + "
        " + "
        "; @@ -343,12 +343,12 @@ function code_evaluation(test_sets, if (had_passed_testsests_error_count != "0") { $n = "

        " + "" + - "" + had_passed_testsests_error_count / test_sets_count + " " + latest_output + "

        "; + "" + had_passed_testsests_error_count + "/" + test_sets_count + " " + latest_output + "

        "; } else { $n = "

        " + "" + - "" + test_sets_count / test_sets_count + " 全部通过

        "; + "" + test_sets_count + "/" + test_sets_count + " 全部通过

        "; } // $("#evaluating_info").html($n); } @@ -361,11 +361,11 @@ function code_evaluation(test_sets, "
          " + "
        • " + "公开测试:" + - "" + had_passed_testsests_public_count / test_sets_public_count + "" + + "" + had_passed_testsests_public_count + "/" + test_sets_public_count + "" + "
        • " + "
        • " + " 隐藏测试:" + - "" + had_passed_testsests_hidden_count / test_sets_hidden_count + "" + + "" + had_passed_testsests_hidden_count + "/" + test_sets_hidden_count + "" + "
        • " + "
        • " + " 经验值:" + From a7a97089794757eb483cff859a9e18fc17a20a82 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 11 Aug 2017 10:01:23 +0800 Subject: [PATCH 25/40] =?UTF-8?q?=E9=9A=90=E8=97=8F=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_game_results.html.erb | 1 + public/javascripts/edu/edu_tpi.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index 2321bda0b..b7abcf273 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -20,6 +20,7 @@
          \ No newline at end of file diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 54ec33729..ab0c8c441 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -68,10 +68,10 @@ <%= render :partial => "games/shixun_comment_block" %>
        • 发送
        • - " onclick="game_praise()" id="game_praise_tread" class="pt5 color-grey mr20"> + " onclick="game_praise('<%= @game_challenge.id %>', '<%= @game_challenge.class %>')" id="game_praise_tread" class="pt5 color-grey mr20"> " alt="赞" ><%= @praise_count %> - " onclick="game_tread()" id="game_tread" class="color-grey" style="padding-top:7px;"> + " onclick="game_tread('<%= @game_challenge.id %>')" id="game_tread" class="color-grey" style="padding-top:7px;"> " ><%= @tread_count %>
        • @@ -129,56 +129,4 @@ // 点赞/取消点赞功能 var praiseStatus = <%= @praise.nil? ? false : true %>; // 是否点赞 var treadStatus = <%= @tread.nil? ? false : true %>; // 是否踩 - var h = true; - function game_praise(){ - if(treadStatus){ - return; - } - $.ajax({ - url: '<%= praise_tread_praise_plus_path({:obj_id => @game_challenge.id, :obj_type => @game_challenge.class}) %>', - data: {horizontal: h, game_praise: true}, - success:function(data){ - h = !h; - var praise_count = $("#game_praise_count"); - if(data.praise){ - praiseStatus = true; //已赞 - praise_count.html(data.praise_tread_count); - $("#game_praise_tread").children("i").addClass("color-light-green"); - $("#game_praise_tread").attr("title", "取消点赞") - }else{ - praiseStatus = false; //取消赞 - praise_count.html(data.praise_tread_count); - $("#game_praise_tread").children("i").removeClass("color-light-green"); - $("#game_praise_tread").attr("title", "点赞") - } - } - }); - } - // 踩/取消踩功能 - var d = true; - function game_tread(){ - if(praiseStatus){ - return; - } - $.ajax({ - url: '<%= praise_tread_praise_plus_path({:obj_id => @game_challenge.id, :obj_type => "ChallengeTread"}) %>', - data: {horizontal: d, game_praise: true}, - success:function(data){ - d = !d; - var tread_count = $("#game_tread_count"); - if(data.praise){ - treadStatus = true; // 取消踩 - tread_count.html(data.praise_tread_count); - $("#game_tread").children("i").addClass("color-orange"); - $("#game_tread").attr("title", "取消踩") - }else{ - treadStatus = false; // 已踩 - tread_count.html(data.praise_tread_count); - $("#game_tread").children("i").removeClass("color-orange"); - $("#game_tread").attr("title", "踩"); - } - } - }); - } - \ No newline at end of file diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 55a9bd559..cc68d75b0 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -19,53 +19,4 @@ notice_sure_box("实训更新啦,系统已自动为您重置"); <% end %> }); - var control = 0; // 版本库控制 0表示点击放大 1表示点击缩小 - var control_1 = 0; // 测评控制 0表示点击放大 1表示点击缩小 - var nGameRes = $("#games_repository_contents"); // 版本库区域 - var nGameEva = $("#games_valuation_contents"); // 评测区域 - var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮 - var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域 - var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小 - var nMove = $(".h-center"); - -/* --------------------------------版本库的放大与缩小---------------------------------------------*/ - function repository_extend_and_zoom(){ - if(control == 0){ - nGameRes.addClass("-flex-basic100"); - nGameEva.addClass("-flex-basic0"); - nRIcon.addClass("fa-compress"); - nRIcon.removeClass("fa-arrows-alt"); - nMove.hide(); - control = 1; - }else if(control == 1){ - nGameRes.removeClass("-flex-basic100"); - nGameEva.removeClass("-flex-basic0"); - nRIcon.removeClass("fa-compress"); - nRIcon.addClass("fa-arrows-alt"); - nMove.show(); - control = 0; - } - editor_CodeMirror.setSize("auto", "auto"); - var h = nGameRes.height() - $("#top_repository").height() - 50; - nCode.css("min-height", h); - } - -/* --------------------------------测评的扩大与缩小---------------------------------------------*/ - function valuation_extend_and_zoom(){ - if(control_1 == 0){ - nGameRes.addClass("-flex-basic0"); - nGameEva.addClass("-flex-basic100"); - nVIcon.removeClass("fa-expand"); - nVIcon.addClass("fa-compress"); - nMove.hide(); - control_1 = 1; - }else if(control_1 == 1){ - nGameRes.removeClass("-flex-basic0"); - nGameEva.removeClass("-flex-basic100"); - nVIcon.addClass("fa-expand"); - nVIcon.removeClass("fa-compress"); - nMove.show(); - control_1 = 0; - } - } \ No newline at end of file diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index 202e3378f..f3f0d3c20 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -217,6 +217,137 @@ function toggle_test_case(t_case, id){ } // end +// codemirror渲染textarea +function CodeMirror_fromTextArea(id){ + var Code = CodeMirror.fromTextArea(document.getElementById(id), { + /* mode: {name: "text/x-c++src", + // version: 2, + singleLineStringErrors: false},*/ // 目前补全js是引入的javascript-hint,因此目前不能指定语言 + lineNumbers: true, + theme: "railscasts", + // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 + indentUnit: 4, //代码缩进为一个tab的距离 + matchBrackets: true, + autoRefresh: true, + smartIndent: true,//智能换行 + extraKeys: {"Ctrl-Q": "autocomplete"}, + autofocus: true, + styleActiveLine: true, + lint: true, + gutters: ["CodeMirror-linenumbers", "breakpoints"] + }); + return Code; +} +// end + +var control = 0; // 版本库控制 0表示点击放大 1表示点击缩小 +var control_1 = 0; // 测评控制 0表示点击放大 1表示点击缩小 +// 版本库的放大与缩小 +function repository_extend_and_zoom(){ + var nGameRes = $("#games_repository_contents"); // 版本库区域 + var nGameEva = $("#games_valuation_contents"); // 评测区域 + var nRIcon = $("#extend_and_zoom").children("i"); // 版本库放大缩小按钮 + var nCode = $("#file_entry_content").find(".CodeMirror-scroll"); // 版本库代码区域 + var nMove = $(".h-center"); + if(control == 0){ + nGameRes.addClass("-flex-basic100"); + nGameEva.addClass("-flex-basic0"); + nRIcon.addClass("fa-compress"); + nRIcon.removeClass("fa-arrows-alt"); + nMove.hide(); + control = 1; + }else if(control == 1){ + nGameRes.removeClass("-flex-basic100"); + nGameEva.removeClass("-flex-basic0"); + nRIcon.removeClass("fa-compress"); + nRIcon.addClass("fa-arrows-alt"); + nMove.show(); + control = 0; + } + editor_CodeMirror.setSize("auto", "auto"); + var h = nGameRes.height() - $("#top_repository").height() - 50; + nCode.css("min-height", h); +} +// end + +// 测评的扩大与缩小 +function valuation_extend_and_zoom(){ + var nGameRes = $("#games_repository_contents"); // 版本库区域 + var nGameEva = $("#games_valuation_contents"); // 评测区域 + var nVIcon = $("#valuation_extend_and_zoom").children("i"); // 评测放大缩小 + var nMove = $(".h-center"); + if(control_1 == 0){ + nGameRes.addClass("-flex-basic0"); + nGameEva.addClass("-flex-basic100"); + nVIcon.removeClass("fa-expand"); + nVIcon.addClass("fa-compress"); + nMove.hide(); + control_1 = 1; + }else if(control_1 == 1){ + nGameRes.removeClass("-flex-basic0"); + nGameEva.removeClass("-flex-basic100"); + nVIcon.addClass("fa-expand"); + nVIcon.removeClass("fa-compress"); + nMove.show(); + control_1 = 0; + } +} +// end + +// 点赞与取消点赞 +var h = true; +function game_praise(obj_id, obj_type){ + if(treadStatus){ + return; + } + $.ajax({ + url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=" + obj_type, + data: {horizontal: h, game_praise: true}, + success:function(data){ + h = !h; + var praise_count = $("#game_praise_count"); + if(data.praise){ + praiseStatus = true; //已赞 + praise_count.html(data.praise_tread_count); + $("#game_praise_tread").children("i").addClass("color-light-green"); + $("#game_praise_tread").attr("title", "取消点赞") + }else{ + praiseStatus = false; //取消赞 + praise_count.html(data.praise_tread_count); + $("#game_praise_tread").children("i").removeClass("color-light-green"); + $("#game_praise_tread").attr("title", "点赞") + } + } + }); +} +// 踩/取消踩功能 +var d = true; +function game_tread(obj_id){ + if(praiseStatus){ + return; + } + $.ajax({ + url: "/praise_tread/praise_plus?obj_id=" + obj_id + "&obj_type=ChallengeTread", + data: {horizontal: d, game_praise: true}, + success:function(data){ + d = !d; + var tread_count = $("#game_tread_count"); + if(data.praise){ + treadStatus = true; // 取消踩 + tread_count.html(data.praise_tread_count); + $("#game_tread").children("i").addClass("color-orange"); + $("#game_tread").attr("title", "取消踩") + }else{ + treadStatus = false; // 已踩 + tread_count.html(data.praise_tread_count); + $("#game_tread").children("i").removeClass("color-orange"); + $("#game_tread").attr("title", "踩"); + } + } + }); +} +// end + // test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数 // test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数 // final_score:最终得分;latest_output:最新的输出;language:实训的语言 @@ -403,7 +534,5 @@ function code_evaluation(test_sets, $("#game_test_set_results").html($html); } -console.log($("#evaluating_info")); -console.log($(".-task-ces-box")); // end From 7463dab246d00b6e613019e81cacf5ae9d3ca454 Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Fri, 11 Aug 2017 15:17:33 +0800 Subject: [PATCH 30/40] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_code_actions.html.erb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 94ea207d1..e00cb2f28 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -134,18 +134,18 @@ /* ----------------- 评测 -------------------- */ function training_task_submmit(){ // 加载页面 - nEvalContent = $("#evaluating_contents"); - nEvalInfo = $("#evaluating_info"); - nAjaxLoading = $("#evaluating_ajax_loading"); - nInfoAjaxLoading = $("#info_ajax_loading"); - nAjaxLoading.css("display","flex"); - nInfoAjaxLoading.css("display","flex"); - nEvalContent.hide(); - nEvalInfo.hide(); - nAjaxLoading.show(); - nInfoAjaxLoading.show(); - nAjaxLoading.html(""); - nInfoAjaxLoading.html(""); + nEvalContent = $("#evaluating_contents").hide(); + nEvalInfo = $("#evaluating_info").hide(); + nAjaxLoading = $("#evaluating_ajax_loading").css("display","flex").show().html(""); + nInfoAjaxLoading = $("#info_ajax_loading").css("display","flex").show().html(""); +// nAjaxLoading.css("display","flex"); +// nInfoAjaxLoading.css("display","flex"); +// nEvalContent.hide(); +// nEvalInfo.hide(); +// nAjaxLoading.show(); +// nInfoAjaxLoading.show(); +// nAjaxLoading.html(""); +// nInfoAjaxLoading.html(""); $("#code_test").html("评测中.."); $(".blacktab_con").eq(1).trigger("click"); // 回到测试结果页面 // 保存版本库代码 From 1aacb457e798cf40f38bbd7080281e8de767454a Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Fri, 11 Aug 2017 19:02:52 +0800 Subject: [PATCH 31/40] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_code_actions.html.erb | 4 ++-- app/views/games/_game_results.html.erb | 8 ++++++-- app/views/layouts/base_myshixun.html.erb | 2 +- public/javascripts/application.js | 6 +++--- public/javascripts/edu/edu_tpi.js | 25 ++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 8e1edbfe6..d09224b1f 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -136,8 +136,8 @@ // 加载页面 nEvalContent = $("#evaluating_contents").hide(); nEvalInfo = $("#evaluating_info").hide(); - nAjaxLoading = $("#evaluating_ajax_loading").css("display","flex").show().html(""); - nInfoAjaxLoading = $("#info_ajax_loading").css("display","flex").show().html(""); + /* nAjaxLoading = $("#evaluating_ajax_loading").css("display","flex").show().html(""); + nInfoAjaxLoading = $("#info_ajax_loading").css("display","flex").show().html("");*/ // nAjaxLoading.css("display","flex"); // nInfoAjaxLoading.css("display","flex"); // nEvalContent.hide(); diff --git a/app/views/games/_game_results.html.erb b/app/views/games/_game_results.html.erb index b7abcf273..9fdf304f3 100644 --- a/app/views/games/_game_results.html.erb +++ b/app/views/games/_game_results.html.erb @@ -34,7 +34,9 @@
          -
          +
          + +
          @@ -87,7 +89,9 @@
          -
          +
          + +
          diff --git a/app/views/layouts/base_myshixun.html.erb b/app/views/layouts/base_myshixun.html.erb index f5e59cbfa..e33dac307 100644 --- a/app/views/layouts/base_myshixun.html.erb +++ b/app/views/layouts/base_myshixun.html.erb @@ -16,7 +16,7 @@ <%= yield :header_tags -%> - +
          diff --git a/public/javascripts/application.js b/public/javascripts/application.js index de92bd57f..090d0fd19 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -671,7 +671,7 @@ function setupHeartBeat(){ setInterval(function(){$.getJSON('/account/heartbeat');},time); } -function setupAjaxIndicator() { +/*function setupAjaxIndicator() { $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){ return; @@ -691,7 +691,7 @@ function setupAjaxIndicator() { } }); -} +}*/ function hideOnLoad() { $('.hol').hide(); @@ -729,7 +729,7 @@ function transpotUrl (scope) { }); } -$(document).ready(setupAjaxIndicator); +//$(document).ready(setupAjaxIndicator); $(document).ready(setupHeartBeat); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); diff --git a/public/javascripts/edu/edu_tpi.js b/public/javascripts/edu/edu_tpi.js index f3f0d3c20..d4e9c052e 100644 --- a/public/javascripts/edu/edu_tpi.js +++ b/public/javascripts/edu/edu_tpi.js @@ -348,6 +348,31 @@ function game_tread(obj_id){ } // end + + +function setupAjaxIndicator() { + //alert($('#evaluating_ajax_loading')[0]); + $('#evaluating_ajax_loading').bind('ajaxSend', function(event, xhr, settings) { + if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){ + return; + } + if (settings.contentType != 'application/octet-stream') { + console.log("样式"); + $('#evaluating_ajax_loading').css("display","flex").show().html(""); + } + }); + + $('#evaluating_ajax_loading').bind('ajaxStop', function() { + $('#evaluating_ajax_loading').hide(); + if(MathJax && MathJax.Hub) + MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话,手动执行MathJax的公式显示 + try{ + prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化 + }catch (e){ + + } + }); +} // test_sets:测试集;had_test_count:输出集的个数;test_sets_count:测试集的个数;had_passed_testsests_error_count:测试集报错数;test_sets_hidden_count:隐藏测试集的个数 // test_sets_public_count:公开测试集的个人;had_passed_testsests_hidden_count:通过的隐藏集个数;had_passed_testsests_public_count:通过的公开测试集个数 // final_score:最终得分;latest_output:最新的输出;language:实训的语言 From eabdc8c8ccdf480d69aeb220dfd4793d53d5357b Mon Sep 17 00:00:00 2001 From: miss <994230062@qq.com> Date: Wed, 16 Aug 2017 08:56:49 +0800 Subject: [PATCH 32/40] =?UTF-8?q?=E6=A0=B7=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/views/challenges/_skill_form.html.erb | 2 +- app/views/games/_code_actions.html.erb | 4 +- app/views/layouts/base_myshixun.html.erb | 7 ++-- public/javascripts/application.js | 10 ++--- public/javascripts/edu/edu_tpi.js | 47 ++++++++++++----------- public/stylesheets/css/edu-common.css | 9 +++-- public/stylesheets/css/public.css | 4 +- public/stylesheets/public.css | 14 +++---- 8 files changed, 51 insertions(+), 46 deletions(-) diff --git a/app/views/challenges/_skill_form.html.erb b/app/views/challenges/_skill_form.html.erb index 8fe6bb0ae..0efbdd47a 100644 --- a/app/views/challenges/_skill_form.html.erb +++ b/app/views/challenges/_skill_form.html.erb @@ -22,7 +22,7 @@
            <% if @st == 0 %> -
          1. 学员为参考答案通过了本阶段的评测时将获得技能,否则不能获得技能
          2. +
          3. 学员未参考答案通过了本阶段的评测时将获得技能,否则不能获得技能
          4. <% else %>
          5. 学员答题正确将获得技能,否则不能获得技能
          6. <% end %> diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index d09224b1f..8e1edbfe6 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -136,8 +136,8 @@ // 加载页面 nEvalContent = $("#evaluating_contents").hide(); nEvalInfo = $("#evaluating_info").hide(); - /* nAjaxLoading = $("#evaluating_ajax_loading").css("display","flex").show().html(""); - nInfoAjaxLoading = $("#info_ajax_loading").css("display","flex").show().html("");*/ + nAjaxLoading = $("#evaluating_ajax_loading").css("display","flex").show().html(""); + nInfoAjaxLoading = $("#info_ajax_loading").css("display","flex").show().html(""); // nAjaxLoading.css("display","flex"); // nInfoAjaxLoading.css("display","flex"); // nEvalContent.hide(); diff --git a/app/views/layouts/base_myshixun.html.erb b/app/views/layouts/base_myshixun.html.erb index e33dac307..ad7798911 100644 --- a/app/views/layouts/base_myshixun.html.erb +++ b/app/views/layouts/base_myshixun.html.erb @@ -52,11 +52,12 @@
          <%= yield %>
          -
          ---> + @@ -58,8 +71,9 @@ <%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %> <%= f.text_area :subject, :id=>"subject", :class => "feedbackText mb5", :placeholder => "请在此输入平台的问题和建议,您也可以通过QQ留言,谢谢!" %> <%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %> + 留言不能为空    还能输入50个字符 - 留  言 + 留  言 取  消
          <% end %>