diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index bd92c6b9e..0511f8375 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -22,11 +22,16 @@ class ShixunsController < ApplicationController # copy_shixun:复制一个新的实训模块包括版本库 # copy_myshixun自动创建系列game,game中只包含状态等信息,公共信息从Challeges中读取 - # + # 开启过实训的则直接跳入my实训页面 def shixun_exec - if has_exec_cur_shixun(@shixun) || User.current.id == @shixun.user_id + unless allow_shixun_exec(@shixun) render_403 end + myshixun = Myshixun.where(:user_id => User.current.id, :shixun_id => @shixun.id).first + unless myshixun.blank? + redirect_to myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun.id) + return + end repository = @shixun.repository ActiveRecord::Base.transaction do begin diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9de11325..3c5f37db3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -50,6 +50,10 @@ module ApplicationHelper end # 定义实训相关方法 + def sum_final_score + Game.find_by_sql("SELECT sum(final_score) as total_score FROM `games` where user_id=#{User.current.id}").first.try(:total_score) + end + # myshixun 最高分 def top_score shixun, position Game.find_by_sql("SELECT max(final_score) as top_score FROM `games` g, `challenges` c where g.challenge_id = c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:top_score) @@ -276,7 +280,7 @@ module ApplicationHelper end def allow_shixun_exec shixun - (User.current.logged? && User.current.id != shixun.user_id && shixun.status == 1) + (User.current.logged? && User.current.id != shixun.user_id && shixun.challenges.count > 0 && !shixun.repository.blank?) end # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 diff --git a/app/helpers/challenges_helper.rb b/app/helpers/challenges_helper.rb index 86b0183c9..06d71f9bb 100644 --- a/app/helpers/challenges_helper.rb +++ b/app/helpers/challenges_helper.rb @@ -1,2 +1,14 @@ +# encoding: utf-8 module ChallengesHelper + + def difficulty_type difficulty + case difficulty + when 1 + "简单" + when 2 + "中等" + when 3 + "复杂" + end + end end diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index 898539505..4083a1cb7 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -4,7 +4,17 @@ <%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min' %> <%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> - + @@ -70,16 +120,18 @@
  • <%#= f.kindeditor :task_pass, :editor_id => "challenge_task_pass", :width=>'87.5%', :height => 159, :resizeType => 0, :no_label => true %> - <%= f.text_area :task_pass, :class => "panel-form-width-690 panel-box-sizing", :no_label => true %> + <%#= f.text_area :task_pass, :class => "panel-form-width-690 panel-box-sizing", :no_label => true %> +
    + <%#= f.text_area :ready_knowledge, :placeholder => "请输入完成当前任务依赖的知识点或者其它相关信息,指导学员完成任务" %> + +
  • - + <%= select_tag :evaluation_way, options_for_select([["输出输出", 1], ["文件存在", 2]]), :name => 'challenge[evaluation_way]', :class => "ml5", :style => "height: 28px;" %>
  • +
  • <% if params[:action] == "edit" && @challenge.challenge_samples.count > 0 %> @@ -174,8 +226,16 @@ <%= f.text_area :answer, :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :style => "line-height:1.9;" %>
  • +
  • - + + + + +
  • + +
  • + <%= f.text_field :score, :class => "panel-form-height-30 fl", :no_label => true, :style => "padding:5px;", :placeholder => "请输入分值(只能是数字)" %>
    @@ -183,10 +243,10 @@
  • <% if params[:action] == "edit" %> - 保存 + 保存 取消 <% else %> - 保存 + 保存 取消 <% end %> @@ -272,7 +332,7 @@ function challenge_create(){ if($('#challenge_subject').val().trim() == ""){ $("#new_shixun_name").show(); - }else if($("#challenge_task_pass").val().trim() == ""){ + }else if($("#challenge_task_pass textarea").val().trim() == ""){ $("#new_shixun_pass").show(); }else if($("#challenge_score").val().trim()==""){ $("#new_shixun_score").show(); @@ -284,7 +344,7 @@ function challenge_update(){ if($('#challenge_subject').val().trim() == ""){ $("#new_shixun_name").show(); - }else if($("#challenge_task_pass").val().trim() == ""){ + }else if($("#challenge_task_pass textarea").val().trim() == ""){ $("#new_shixun_pass").show(); }else if($("#challenge_score").val().trim()==""){ $("#new_shixun_score").show(); @@ -307,7 +367,7 @@ $('#challenge_answer').val(cMirror.getValue()); }); - challenge_task_pass_editor = KindEditor.create('#challenge_task_pass', + /* challenge_task_pass_editor = KindEditor.create('#challenge_task_pass', {"width":"89.7%", "resizeType":0, "no_label":true, @@ -330,7 +390,7 @@ "fileManagerJson":"/kindeditor/filemanager" }); - +*/ function add_tag(){ var num = $(".task-bd-grey").children('div').length; var val = $(".task-tag-input").val().trim(); diff --git a/app/views/games/_file_edit_form.html.erb b/app/views/games/_file_edit_form.html.erb index b9b7f5f5b..3698837a2 100644 --- a/app/views/games/_file_edit_form.html.erb +++ b/app/views/games/_file_edit_form.html.erb @@ -4,23 +4,25 @@
  • - - +
  • \ No newline at end of file diff --git a/app/views/games/_games_list.html.erb b/app/views/games/_games_list.html.erb index 75605342a..2d23b5076 100644 --- a/app/views/games/_games_list.html.erb +++ b/app/views/games/_games_list.html.erb @@ -1,3 +1,39 @@ +
    +
    +
    +

    全部任务

    +
    +
    +
    + 01

    础入门Python基础入门P

    +
    +
    +
    +
    +
    + 02

    础入门Python基础入门Python基础

    + +
    +
    +
    +
    +
    + 03

    础入门Python基础入门Python基础入thon基础入thon基础入thon基础入thon基础入门

    + 正在解决 +
    +
    +
    +
    +
    + 04

    础入门Python基础入门Python基

    + +
    +
    +
    +
    +
    + +
    diff --git a/app/views/games/_repository.html.erb b/app/views/games/_repository.html.erb index 61de11723..fe72cd3ed 100644 --- a/app/views/games/_repository.html.erb +++ b/app/views/games/_repository.html.erb @@ -1,16 +1,21 @@ -
    - <%= render :partial => 'myshixun_repository' %> +
    +

    + <%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir'} %> +

    +
    + +
    +
    +
    + <% if params[:action] == "entry" || @file_open %> +
    + <%= render :partial => 'games/file_edit_form', :locals => {:filename => @path, :content => @content} %> +
    + <% else %> + <% unless @entries.blank? %> + <%= render :partial => 'tree', :locals => { :extend => false}%> + <% end %> + <% end %>
    -
    - diff --git a/app/views/games/show.html.erb b/app/views/games/show.html.erb index 0b80122f8..c89e4cfd3 100644 --- a/app/views/games/show.html.erb +++ b/app/views/games/show.html.erb @@ -1,51 +1,165 @@ <%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %> <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> -
    - <%= render :partial => "game_show" %> +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + <%= h @game_challenge.task_pass.try(:html_safe) %> +
    +
    +
    +
    +
    +
    +
    +
    + <%= h @game_challenge.ready_knowledge.try(:html_safe) %> +
    +
    +
    +
    +
    +
    +
    +
    + <%= @game_challenge.answer %> +
    +
    +
    +
    +
    +
    + +
    -
    - <%= render :partial => 'desc_full_show'%> +
    +
    +
    +
    +
    +
    +
    + <%= render :partial => 'games/repository' %> +
    +
    +
    + +
    +
    +
    +
    +
    +
    +

    0/11 编译错误

    +
    +
    + + 测试集 1 +
    +
    +
      +
    • 输入:param1:1
    • +
    • 实际输出:
    • +
    • 期望输出:3
    • +
    +
    +
    +
    +
    + + 测试集 2 +
    +
    +
    +
    +
    +
    + + 测试集 3 + +
    +
    +
    +
    +
    +
    + + 测试集 4 + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    11/11 全部通过

    +
    +
    +
      +
    • 样例测试:9/9
    • +
    • 隐藏测试:9/9
    • +
    • 经验值:+ 300
    • +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + 耗时:1天5小时10分钟 + 测评 +
    +
    +
    -
    - <%= render :partial => 'myshixun_extend_repository' %>
    -
    - <%= render :partial => 'extend_test_output' %> -
    - - +
    \ No newline at end of file diff --git a/app/views/layouts/base_myshixun.html.erb b/app/views/layouts/base_myshixun.html.erb index 86be35ea4..2669573e7 100644 --- a/app/views/layouts/base_myshixun.html.erb +++ b/app/views/layouts/base_myshixun.html.erb @@ -9,7 +9,7 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/font-awesome','css/taskstyle','css/structure','scm','css/public', 'css/project','css/popup','repository','css/gantt', 'css/calendar', 'css/moduel', 'css/cssPlus-v.0.2-build' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/font-awesome','css/taskstyle','css/structure','scm','css/public', 'css/project','css/popup','repository','css/gantt', 'css/calendar', 'css/moduel', 'css/cssPlus-v.0.2-build', 'css/bigdata-common','css/bigdata-public', 'css/bigdata-popup' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> @@ -18,39 +18,30 @@
    -
    -
    -
    -
    - - -
    -
    -
    -
    - <%= render :partial => "myshixuns/myshixun_top" %> -
    - - <%= yield %> -
    +
    + +
    + + +
    +<%= yield %>