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 @@
+
+
+