diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 87fe18a96..20811cab7 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -14,7 +14,7 @@ class ChallengesController < ApplicationController def new # 顶部导航 - @st = params[:st] + @st = params[:st].to_i @project_menu_type = 11 respond_to do |format| format.html { render :action => 'new', :layout => 'base_shixun' } @@ -29,17 +29,20 @@ class ChallengesController < ApplicationController @challenge.position = challenge_count + 1 @challenge.shixun = @shixun @challenge.user = User.current - # @challenge.st = params[:st] + @challenge.st = params[:st].to_i if @challenge.save! - # 创建选项 - # params[:question].each do |test| - # ChallengeQuestion.where(:option_name => option_name,:challenges => challenge_id, :positon => 1, :right_key => true) - # end + if params[:st].to_i != 0 + #创建选项 + params[:question][:cnt].each_with_index do |test, index| + answer = params[:choice][:answer][index] == "0" ? false : true + ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) + end + end end redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) rescue Exception => e flash[:error] = "#{e.message}" - redirect_to new_shixun_challenge_path(:shixun_id => @shixun) + redirect_to new_shixun_challenge_path(:shixun_id => @shixun, :st => params[:st].to_i) raise ActiveRecord::Rollback end end @@ -103,6 +106,7 @@ class ChallengesController < ApplicationController end def edit + @st = @challenge.st challenge_num = Challenge.where(:shixun_id => @shixun).count challenge_pos = @challenge.position if challenge_pos < challenge_num @@ -120,39 +124,25 @@ class ChallengesController < ApplicationController end def update - @challenge.update_attributes(params[:challenge]) - redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) -=begin - respond_to do |format| ActiveRecord::Base.transaction do @challenge.update_attributes(params[:challenge]) - begin - @test_sets.delete_all unless @test_sets.blank? - @challenge_tags.delete_all unless @challenge_tags.blank? - if params[:test_set][:hidden].length > 0 - params[:test_set][:input].each_with_index do |input, index| - unless (input[index] == params[:test_set][:output][index] && input[index].nil?) - params[:test_set][:hidden][index].to_i == 0 ? open = 1 : open = 0 - TestSet.create(:challenge_id => @challenge.id, :input => input, :output => params[:test_set][:output][index], :is_public => open, :position => (index + 1)) - end + if (params[:tab] == "1" || params[:tab].nil?) && @challenge.st != 0 + begin + @challenge.challenge_questions.delete_all + params[:question][:cnt].each_with_index do |test, index| + answer = params[:choice][:answer][index] == "0" ? false : true + ChallengeQuestion.create(:option_name => test, :challenge_id => @challenge.id, :position => index, :right_key => answer) end + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) + rescue Exception => e + flash[:error] = "#{e.message}" + format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} + raise ActiveRecord::Rollback end - unless params[:knowledge].blank? - params[:knowledge][:input].each do |input| - ChallengeTag.create(:name => input, :challenge_id => @challenge.id) - end - end - # 向jenkins端发送请求,构建公共测试用例 - add_shixun_modify_status(@shixun, 1) - format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '更新成功!'} - rescue Exception => e - flash[:error] = "#{e.message}" - format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)} - raise ActiveRecord::Rollback + else + redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab]) end end - end -=end end def update_evaluation diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index b53d6979e..00065036c 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -4,7 +4,7 @@ class GamesController < ApplicationController skip_before_filter :verify_authenticity_token, :only => [:file_update] before_filter :find_myshixun, :only => [:index] before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, - :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code] + :game_status, :change_status, :answer, :minus_score, :refresh_game_list, :reset_original_code, :reset_new_code, :evaluating_choice] before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update, :reset_original_code, :reset_new_code] before_filter :allowd_manager before_filter :allowd_view, :only => [:show] @@ -26,6 +26,7 @@ class GamesController < ApplicationController # @praise 判断是否点赞 # @tread 判断是否踩 # git_repository_url @myshixun, "Myshixun" + # @st 0 编程任务 1 多选任务 2 单选任务 def show # 展示全部实训 if @game.status == 1 @@ -38,12 +39,15 @@ class GamesController < ApplicationController @shixun = @myshixun.shixun # @games_count = @games.count @game_challenge = @game.challenge + @st = @game_challenge.st @had_done = @game.had_done @praise = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?", @game_challenge.id, @game_challenge.class.to_s, User.current.id).first @tread = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?", @game_challenge.id, "ChallengeTread", User.current.id).first @rev = @rev.nil? ? "master" : @rev @type = params[:type] challenge_path = @game_challenge.path + # 用户选项 + @user_answer = @game.outputs.first.actual_output.split("") unless @st == 0 || @game.outputs.blank? # 默认打开文件 logger.info("repository id is #{@repository.try(:id)}, repository's shixun_id =#{@repository.try(:myshixun_id)} shixun_id =#{@repository.try(:shixun_id)}, project_id => #{@repository.try(:project_id)}") # 验证challenge文件名的合法性 @@ -262,6 +266,31 @@ class GamesController < ApplicationController had_done: had_done} end + # 选择题评测(选择题不需要重新评测) + def evaluating_choice + @game_challenge = @game.challenge + user_answer = params[:answer] + correct = true + had_done = @game.had_done + if !user_answer.blank? + user_answer.split("").each do |answer| + question = @game_challenge.challenge_questions.where(:position => answer.to_i).first + unless question.right_key + correct = false + break + end + end + else + correct = false + end + @game.update_attributes(:status => 2, :end_time => Time.now) + 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} + end + + def change_status @game.update_attribute(:status, 0) outputs = @game.outputs diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index abab48f3b..e69e9fd9f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -27,7 +27,7 @@ class MyshixunsController < ApplicationController jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] uri = URI("#{jenkins_shixuns}/jenkins-exec/webssh/getConnectInfo") user_id = User.current.id - params = {gameID:@myshixun.id} + params = {gameID:@myshixun.id, operationEnvironment:@myshixun.shixun.try(:language)} res = uri_exec uri, params if res && res['code'].to_i != 0 raise("实训云平台繁忙(繁忙等级:92)") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b2327fc2c..2d85a462d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -164,7 +164,7 @@ module ApplicationHelper # 实训语言的种类 def shixun_language - ["Java", "C", "C++", "Python", "MySQL/Java","JFinal","Docker","Ethoernet","Dynamips"] + ["Java", "C", "C++", "Python", "MySQL/Java","JFinal","Docker","Ethereum","Dynamips"] end # 实训试用专业 diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 6779b345e..3ec4901a2 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -8,6 +8,7 @@ class Challenge < ActiveRecord::Base has_many :test_sets, :dependent => :destroy has_many :challenge_tags, :dependent => :destroy has_many :games, :dependent => :destroy + has_many :challenge_questions, :dependent => :destroy validates_presence_of :subject # validates_presence_of :score @@ -43,4 +44,15 @@ class Challenge < ActiveRecord::Base myshixun = Myshixun.where(:shixun_id => self.shixun.id, :user_id => User.current.id).first game = Game.where(:myshixun_id => myshixun.id, :challenge_id => self.id).first end + + # 正确答案 + def right_answers + answer = "" + self.challenge_questions.each do |ans| + if ans.right_key + answer << (ans.position + 65).chr + end + end + return answer + end end diff --git a/app/models/challenge_question.rb b/app/models/challenge_question.rb index bda6780ce..eb835c32e 100644 --- a/app/models/challenge_question.rb +++ b/app/models/challenge_question.rb @@ -1,3 +1,4 @@ class ChallengeQuestion < ActiveRecord::Base - attr_accessible :challenge_id, :option, :position, :right_key + belongs_to :challenge + attr_accessible :challenge_id, :option_name, :position, :right_key end diff --git a/app/models/output.rb b/app/models/output.rb index b6edbb602..68ba45061 100644 --- a/app/models/output.rb +++ b/app/models/output.rb @@ -1,5 +1,6 @@ class Output < ActiveRecord::Base # attr_accessible :title, :body + # actual_output 编程题:实际输出, 选择题: 用户提交的答案(如: 014 对应用户选择为A B E) default_scope :order => 'test_set_position desc' belongs_to :game end diff --git a/app/views/challenges/_answer_form.html.erb b/app/views/challenges/_answer_form.html.erb index 11007ca74..98f3a8e7b 100644 --- a/app/views/challenges/_answer_form.html.erb +++ b/app/views/challenges/_answer_form.html.erb @@ -47,7 +47,7 @@ saveHTMLToTextarea : true, // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 dialogMaskOpacity : 0.6, - placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息", + placeholder: "<%= @st == 0 ? '' : "请输入各个选项的具体解析或其他相关信息" %>", imageUpload : true, imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url diff --git a/app/views/challenges/_content_list.html.erb b/app/views/challenges/_content_list.html.erb index 0cd13ea7b..ee83bd164 100644 --- a/app/views/challenges/_content_list.html.erb +++ b/app/views/challenges/_content_list.html.erb @@ -5,23 +5,29 @@ <%= @challenges.count %> <% end %> <% if User.current.manager_of_shixun?(@shixun) && @shixun.status == 0 %> - - 新建阶段 + +单选任务 + +多选任务 + +编程任务 + <% end %>
<% @challenges.each_with_index do |challenge, index| -%>

- - + + <% if challenge.st == 0 %> + + <% elsif challenge.st == 1 %> + + <% elsif challenge.st == 2 %> + + <% end%> + + 第<%= challenge.position %>关 <%#= link_to challenge.subject, shixun_challenge_path(@shixun.id, challenge), :target => "_blank" %> <% if User.current.manager_of_shixun?(@shixun) %> - <%= link_to challenge.subject, shixun_challenge_path(@shixun, challenge), :target => "_blank" %> + <%= link_to challenge.subject, edit_shixun_challenge_path(challenge, :shixun_id => @shixun), :target => "_blank" %> <% else %> <% if allow_to_view_challenge(challenge, @shixun) %> <%= link_to challenge.subject, myshixun_game_path(challenge.current_user_game, :myshixun_id => challenge.current_user_game.try(:myshixun)), :target => "_blank" %> diff --git a/app/views/challenges/_edit_answer.html.erb b/app/views/challenges/_edit_answer.html.erb index 4dc249b46..1fd0f9522 100644 --- a/app/views/challenges/_edit_answer.html.erb +++ b/app/views/challenges/_edit_answer.html.erb @@ -3,7 +3,7 @@

- <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>

diff --git a/app/views/challenges/_edit_propaedeutics.html.erb b/app/views/challenges/_edit_propaedeutics.html.erb new file mode 100644 index 000000000..d3a5af201 --- /dev/null +++ b/app/views/challenges/_edit_propaedeutics.html.erb @@ -0,0 +1,44 @@ +
+ <% if @editor.blank? && !@challenge.ready_knowledge.blank? %> +
+
+

+ <% if User.current.manager_of_shixun?(@shixun) %> + 编辑 + <% end %> +

+
+
    +
  • + +
    + +
    + +
  • +
+
+ <% end %> + <% if @challenge.ready_knowledge.blank? || !@editor.blank? %> +
    + <%= labelled_form_for @challenge, :url => shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6), :html => {:id => "challenge_shixun_propaedeutics"} do |f| %> + <%= render :partial => "propaedeutics_form", :locals => {:f => f} %> + <% end %> +
+ <% end %> +
+ \ No newline at end of file diff --git a/app/views/challenges/_edit_scoring.html.erb b/app/views/challenges/_edit_scoring.html.erb index 307f8d74c..3eab2d79b 100644 --- a/app/views/challenges/_edit_scoring.html.erb +++ b/app/views/challenges/_edit_scoring.html.erb @@ -3,7 +3,7 @@
">

- <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>

diff --git a/app/views/challenges/_edit_skill.html.erb b/app/views/challenges/_edit_skill.html.erb index 2a00676bd..64c4556b6 100644 --- a/app/views/challenges/_edit_skill.html.erb +++ b/app/views/challenges/_edit_skill.html.erb @@ -2,7 +2,7 @@
">

- <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>

diff --git a/app/views/challenges/_edit_task_pass.html.erb b/app/views/challenges/_edit_task_pass.html.erb index e859c0763..75473897c 100644 --- a/app/views/challenges/_edit_task_pass.html.erb +++ b/app/views/challenges/_edit_task_pass.html.erb @@ -3,7 +3,7 @@

- <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> + <% if User.current.manager_of_shixun?(@shixun) %> 编辑 <% end %>

@@ -23,6 +23,31 @@
+ <% if @challenge.st == 1 %> +
    + <% @challenge.challenge_questions.each_with_index do |question, index| %> +
  • + +
    + + +
    +
  • + <% end %> +
+ <% elsif @challenge.st == 2 %> +
    + <% @challenge.challenge_questions.each_with_index do |question, index| %> +
  • + +
    + + +
    +
  • + <% end %> +
+ <% end %> <% end %> <% if @challenge.subject.blank? || !@editor.blank? %>
    @@ -31,42 +56,8 @@ <% end %>
<% end %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ <%# if @challenge.st == 1 %> <%# end %> diff --git a/app/views/challenges/_propaedeutics_form.html.erb b/app/views/challenges/_propaedeutics_form.html.erb new file mode 100644 index 000000000..3e1732bb2 --- /dev/null +++ b/app/views/challenges/_propaedeutics_form.html.erb @@ -0,0 +1,79 @@ +<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %> +<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> + +
+
  • + +
    + +
    +
  • +
  • + 保存 + <% if@challenge.ready_knowledge %> + 取消 + <% end %> +
  • +
    + \ No newline at end of file diff --git a/app/views/challenges/_score_form.html.erb b/app/views/challenges/_score_form.html.erb index 8dbcd49d3..989eb74ce 100644 --- a/app/views/challenges/_score_form.html.erb +++ b/app/views/challenges/_score_form.html.erb @@ -29,8 +29,13 @@
      -
    1. 如果学员查看了参考答案,则不能得到相应的经验值
    2. -
    3. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币
    4. + <% if @st == 0 %> +
    5. 如果学员查看了参考答案,则不能得到相应的经验值
    6. +
    7. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币
    8. + <% else %> +
    9. 如果学员答题错误,则不能得到相应的经验值
    10. +
    11. 如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币
    12. + <% end %>
    @@ -44,40 +49,41 @@ @@ -31,16 +32,66 @@
    - - + <% if @st != 0 %> + <% if params[:action] == "edit" && @challenge.challenge_questions.count > 0 %> + <% @challenge.challenge_questions.each_with_index do |question, index| %> +
  • + + + + +
  • + <% end %> + <% elsif @st == 2 %> +
  • + + + + +
  • +
  • + + + + +
  • + <% else %> +
  • + + + + +
  • +
  • + + + + +
  • +
  • + + + + +
  • +
  • + + + + +
  • + <% end %> +
      +
    • + + +
    • + +
    • +
    + <% end %>
  • - 保存 + 保存 <% if params[:action] == "new" %> 取消 <% else %> @@ -72,7 +123,7 @@ saveHTMLToTextarea : true, // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 dialogMaskOpacity : 0.6, - placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息", + placeholder: "<%= @st == 0 ? "请输入完成当前任务依赖的知识点或者其它相关信息" : "请输入选择题的题干内容" %>", imageUpload : true, imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url @@ -85,7 +136,7 @@ $("#shixun_form").on('click', 'a.option_icon_add', function () { var html = bt('t:set-option-list', null); $(this).parent().parent('.clearfix').before(html); - var inputs = document.getElementsByName("option_inputs_label"); + var inputs = document.getElementsByName("question[cnt][]"); var inputs_spans = document.getElementsByName("option_span"); for (var j = 0; j < inputs_spans.length; j++) { if(j >= 0 && j <= 26){ @@ -107,15 +158,23 @@ } } } + $("#current-option").html(""); + if($(".check-option-bg").length>0){ + for(var i=0;i<$(".check-option-bg").length;i++){ + $("#current-option").html($("#current-option").html()+$(".check-option-bg").eq(i).html()); + } + }else{ + $("#current-option").html("请点击正确选项"); + } }); }); //设置选项答案 - function selectchoice(item){ + function selectchoice(item, st){ //判断是否选中,如果选中,再次点击的时候取消选中 if($(item).hasClass('check-option-bg')){ $(item).removeClass('check-option-bg'); }else{ - if(true){ + if(st == 2){ //单选 $(".select-choice").removeClass('check-option-bg'); $(item).addClass('check-option-bg'); @@ -133,6 +192,52 @@ $("#current-option").html("请点击正确选项"); } } + // 判断选择题的答案 + function set_choice_answer(){ + var answer = document.getElementsByName("choice[answer][]"); + var choice = document.getElementsByName("option_span"); + for(var o = 0; o < choice.length; o++){ + if($(choice[o]).hasClass("check-option-bg")){ + $(answer[o]).val(String.fromCharCode(65 + o)); + }else{ + $(answer[o]).val(0); + } + } + } + + // 判断选择题内容是否为空 + function judge_choice_contents(){ + var answer = document.getElementsByName("choice[answer][]"); + var contents = document.getElementsByName("question[cnt][]"); + var lens = contents.length; + for(var i = 0; i < lens; i++){ + if($(contents[i]).val().trim() == ""){ + return true; + } + } + return false; + } + + // 判断选择题选择答案的个数 + function judge_choice_answer(){ + var answer = document.getElementsByName("choice[answer][]"); + var lens = answer.length; + var num = 0; + for(var i= 0; i < lens; i++){ + if($(answer[i]).val() != "0"){ + num += 1; + } + } + return num; + } + + // 选择题选项的个数 + function choice_num(){ + var answer = document.getElementsByName("choice[answer][]"); + var lens = answer.length; + return lens; + } + window.onload = function(){ $("#challenge_task_pass [type=\"latex\"]").bind("click", function(){ taskpass_editormd.cm.replaceSelection("```latex"); @@ -164,15 +269,41 @@ $("#task_pass_show").show(); $("#task_pass_edit").hide(); }); - function challenge_update(){ + function challenge_update(st){ + set_choice_answer(); + var error = $("#choice_error_tip"); if($('#challenge_subject').val().trim() == ""){ $("#challenge_subject").focus(); $("#new_shixun_name").show(); }else if($("#challenge_task_pass textarea").val().trim() == ""){ $("#challenge_task_pass textarea").focus(); $("#new_shixun_pass").show(); + }else if(judge_choice_contents()){ + error.html("选项不能为空").show(); }else{ - $('#challenge_shixun_update').submit(); + if(st == "2"){ + if(judge_choice_contents()) { + error.html("选项内容不能为空").show(); + }else if(choice_num() < 2){ + error.html("单选题选项不能少于2个").show(); + }else if(judge_choice_answer() == 0){ + error.html("请设置答案").show(); + }else{ + $('#challenge_shixun_update').submit(); + } + }else if(st == "1"){ + if(judge_choice_contents()) { + error.html("选项内容不能为空").show(); + }else if(choice_num() < 3){ + error.html("多选题选项不能少于3个").show(); + }else if(judge_choice_answer() < 2){ + error.html("答案不能少于2个").show(); + }else{ + $('#challenge_shixun_update').submit(); + } + }else{ + $('#challenge_shixun_update').submit(); + } } } diff --git a/app/views/challenges/edit.html.erb b/app/views/challenges/edit.html.erb index a415faf65..f369011ed 100644 --- a/app/views/challenges/edit.html.erb +++ b/app/views/challenges/edit.html.erb @@ -17,13 +17,29 @@
    -
    +
    + <% if @st == 0 %> + + + + <% elsif @st == 1 %> + + + + <% elsif @st == 2%> + + + + <% end %>

    阶段详情(第<%= @challenge.position %>关)

    <% unless @next_challenge.blank? %> 下一阶段 <% end %> <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> - 新建阶段 + + +编程任务 + +多选任务 + +单选任务 <% end %>
    @@ -31,14 +47,17 @@
  • "> 本关任务
  • - <%# if @challenge.st == 0 %> + <% if @challenge.st == 0 %>
  • "> 评测设置
  • - <%# end %> + <% end %>
  • "> 参考答案
  • +
  • "> + 预备知识 +
  • "> 评分设置
  • @@ -57,6 +76,8 @@ <%= render :partial => "edit_scoring" %> <% elsif @tab == 5 %> <%= render :partial => "edit_skill" %> + <% elsif @tab == 6 %> + <%= render :partial => "edit_propaedeutics" %> <% end %>
    diff --git a/app/views/challenges/show.html.erb b/app/views/challenges/show.html.erb index 2901d38cc..738370551 100644 --- a/app/views/challenges/show.html.erb +++ b/app/views/challenges/show.html.erb @@ -25,7 +25,10 @@ 下一阶段 <% end %> <% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %> - 新建阶段 + + +单选任务 + +多选任务 + +编程任务 <% end %>
    diff --git a/app/views/games/_choice_question.html.erb b/app/views/games/_choice_question.html.erb new file mode 100644 index 000000000..d222597c6 --- /dev/null +++ b/app/views/games/_choice_question.html.erb @@ -0,0 +1,44 @@ +
    +
    + +
    +
    +
    +

    " id="correct_tip"> + 正确 +

    +

    " id="error_tip"> + 错误 +

    + <% @game_challenge.challenge_questions.each_with_index do |question, i| %> +
    " onclick="choice_answer('<%= @st %>', this)"> + +
    + <%= (question.position + 65).chr %>. +
    +

    <%= question.option_name %>

    +
    +
    +
    + <% end %> +

    +
    +
    +
    +
    + \ 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 9b2dd486e..ece5c0a42 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -1,9 +1,15 @@ +<% if @st == 0 %> +<% end %>
    - 评测 + <% if @st == 0 %> + 评测 + <% elsif @game.status != 2 %> + 评测 + <% end %>
    <% if @game.status == 1 %> @@ -11,11 +17,11 @@ <% elsif @game.status == 2 %> <% if @had_done == 0 %> <%= link_to "下一关 ", {:controller => 'games', - :action => "next_step", :id => @game, - :myshixun_id => @myshixun}, - :class => "shixun-task-btn task-btn-blue mr15 mt8", - :id => "next_step", - :remote => true %> + :action => "next_step", :id => @game, + :myshixun_id => @myshixun}, + :class => "shixun-task-btn task-btn-blue mr15 mt8", + :id => "next_step", + :remote => true %> <% else %> 退出实训 @@ -23,13 +29,13 @@ <% end %>
    \ 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 529a766f5..11432cb52 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -19,9 +19,11 @@
  • 预备知识
  • -
  • - 参考答案 -
  • + <% unless @game_challenge.answer.blank? %> +
  • + 参考答案 +
  • + <% end %>
  • <%= link_to '评论', shixun_discuss_shixun_path(@shixun), :class => "tab_type", :style => "font-size: 16px", :remote => true %>
  • @@ -42,7 +44,7 @@
    - +
    @@ -61,8 +63,8 @@
    -