Merge branch 'dev_daiao' into dev_cs
Conflicts: app/views/challenges/edit.html.erb public/stylesheets/css/edu-common.css
This commit is contained in:
commit
efd402bed5
|
@ -2,13 +2,16 @@
|
|||
class ChallengesController < ApplicationController
|
||||
layout "base_shixun"
|
||||
before_filter :check_authentication
|
||||
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation]
|
||||
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation]
|
||||
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose]
|
||||
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy, :update_evaluation, :add_choose_question, :new_choose_question, :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose]
|
||||
before_filter :build_challege_from_params, :only => [:new, :create]
|
||||
before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :edit, :new, :create]
|
||||
before_filter :allowed_view, :only => [:show]
|
||||
before_filter :query_challeges, :only => [:show, :edit, :update, :update_evaluation]
|
||||
before_filter :find_shixun_language, :only => [:show, :new, :edit]
|
||||
#before_filter :default_format_js, only: :new_or_edit_choose_question
|
||||
|
||||
#skip_before_filter :verify_authenticity_token, :only => [:new_or_edit_choose_question]
|
||||
|
||||
include ApplicationHelper
|
||||
|
||||
|
@ -94,9 +97,117 @@ class ChallengesController < ApplicationController
|
|||
if challenge_pos < challenge_num
|
||||
@next_challenge = Challenge.where(:shixun_id => @shixun, :position => challenge_pos+1).first
|
||||
end
|
||||
@prev_challenge = Challenge.where(:shixun_id => @shixun, :position => challenge_pos - 1).first if challenge_pos - 1 > 0
|
||||
@prev_challenge = Challenge.where(:shixun_id => @shixun, :position => challenge_pos - 1).first if (challenge_pos - 1) > 0
|
||||
@tab = params[:tab].blank? ? 1 : params[:tab].to_i
|
||||
@editor = params[:editor] # 编辑模式
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def new_choose_question
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@challenge_choose = ChallengeChoose.new
|
||||
@challenge_choose.challenge_id = @challenge.id
|
||||
@challenge_choose.subject = params[:choose][:subject]
|
||||
@challenge_choose.answer = params[:choose][:answer]
|
||||
@challenge_choose.standard_answer = params[:standard_answer]
|
||||
@challenge_choose.score = params[:challenge][:score].to_i
|
||||
@challenge_choose.difficult = params[:challenge][:difficulty].to_i
|
||||
@challenge_choose.position = params[:position].to_i
|
||||
@challenge_choose.category = params[:category].to_i
|
||||
if @challenge_choose.save!
|
||||
# 创建选项
|
||||
params[:question][:cnt].each_with_index do |test, index|
|
||||
answer = params[:choice][:answer][index] == "0" ? false : true
|
||||
ChallengeQuestion.create(:option_name => test, :challenge_choose_id => @challenge_choose.id, :position => index, :right_key => answer)
|
||||
end
|
||||
# 创建单选多选的技能标签
|
||||
unless params[:knowledge].blank?
|
||||
params[:knowledge][:input].each do |input|
|
||||
ChallengeTag.create(:name => input, :challenge_choose_id => @challenge_choose.id, :challenge_id => @challenge.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@index = params[:position].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
rescue Exception => e
|
||||
flash[:error] = "#{e.message}"
|
||||
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_choose_question
|
||||
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
|
||||
ActiveRecord::Base.transaction do
|
||||
@challenge_choose.update_attributes(:subject => params[:choose][:subject],
|
||||
:answer => params[:choose][:answer],
|
||||
:standard_answer => params[:standard_answer],
|
||||
:score => params[:challenge][:score].to_i,
|
||||
:difficult => params[:challenge][:difficulty].to_i)
|
||||
begin
|
||||
@challenge_choose.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_choose_id => @challenge_choose.id, :position => index, :right_key => answer)
|
||||
end
|
||||
@challenge_choose.challenge_tags.delete_all unless @challenge_choose.challenge_tags.blank?
|
||||
unless params[:knowledge].blank?
|
||||
params[:knowledge][:input].each do |input|
|
||||
ChallengeTag.create(:name => input, :challenge_choose_id => @challenge_choose.id, :challenge_id => @challenge.id)
|
||||
end
|
||||
end
|
||||
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
|
||||
@index = params[:index].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
rescue Exception => e
|
||||
flash[:error] = "#{e.message}"
|
||||
format.html{redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)}
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit_choose_question
|
||||
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
|
||||
@category = @challenge_choose.category
|
||||
@position = @challenge_choose.position.to_i
|
||||
@index = params[:index].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def choose_type_show
|
||||
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
|
||||
@index = params[:index].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_challenge_choose
|
||||
@challenge_choose = ChallengeChoose.where(:id => params[:choose_id]).first
|
||||
@challenge_choose.destroy
|
||||
|
||||
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun)
|
||||
end
|
||||
|
||||
def add_choose_question
|
||||
@category = params[:category].to_i
|
||||
@position = params[:position]
|
||||
#@challenge_choose = @challenge.challenge_chooses
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -111,22 +222,22 @@ class ChallengesController < ApplicationController
|
|||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
@challenge.update_attributes(params[:challenge])
|
||||
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
|
||||
else
|
||||
#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
|
||||
#else
|
||||
redirect_to edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => params[:tab])
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -275,4 +386,8 @@ class ChallengesController < ApplicationController
|
|||
@language = language_switch language
|
||||
end
|
||||
|
||||
def default_format_js
|
||||
response.headers['content--type'] = 'text/javascript'
|
||||
request.format = 'js'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class GamesController < ApplicationController
|
|||
@type = params[:type]
|
||||
challenge_path = @game_challenge.path
|
||||
# 用户选项
|
||||
@user_answer = @game.outputs.first.actual_output.split("") unless @st == 0 || @game.outputs.blank?
|
||||
#@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文件名的合法性
|
||||
|
@ -300,53 +300,42 @@ class GamesController < ApplicationController
|
|||
end
|
||||
|
||||
# 选择题评测(选择题不需要重新评测)
|
||||
# score 获得金币数 tag_count 技能数 right用户是否全对 answer_right全部选择题的正确性
|
||||
def evaluating_choice
|
||||
@game_challenge = @game.challenge
|
||||
user_answer = params[:answer]
|
||||
correct = true
|
||||
@challenges = Challenge.where(:shixun_id => @myshixun.shixun_id)
|
||||
@shixun = @myshixun.shixun
|
||||
score = 0
|
||||
tag_count = 0
|
||||
if !user_answer.blank?
|
||||
if user_answer.split("").count != @game_challenge.challenge_questions.where(:right_key => true).count
|
||||
correct = false
|
||||
else
|
||||
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
|
||||
@right = true
|
||||
answer_right = []
|
||||
@game_challenge.challenge_chooses.each_with_index do |choose, index|
|
||||
correct = (params[:answer][index] == choose.standard_answer) ? true : false
|
||||
if choose.choose_outputs.blank?
|
||||
ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct)
|
||||
end
|
||||
else
|
||||
correct = false
|
||||
if @shixun.status > 1 && !@game.answer_open
|
||||
if correct
|
||||
score += choose.score
|
||||
tag_count += choose.challenge_tags.count
|
||||
end
|
||||
elsif @shixun.status > 1 && @game.answer_open
|
||||
score -= choose.score
|
||||
end
|
||||
unless correct
|
||||
@right = false
|
||||
end
|
||||
answer_right << correct
|
||||
end
|
||||
@game.update_attributes(:status => 2, :end_time => Time.now)
|
||||
had_done = @game.had_done
|
||||
shixun = @myshixun.shixun
|
||||
if shixun.status > 1 && !@game.answer_open
|
||||
if correct
|
||||
#User.current.update_attributes(:grade => (User.current.grade + @game.challenge.score), :experience => (User.current.experience + @game.challenge.score))
|
||||
reward_grade(@game.user, @game.id, 'Game', @game_challenge.score)
|
||||
reward_experience(@game.user, @game.id, 'Game', @game_challenge.score)
|
||||
@game.update_attribute(:final_score, @game_challenge.score)
|
||||
score = @game_challenge.score
|
||||
tag_count = @game_challenge.challenge_tags.count
|
||||
else
|
||||
score = "+0"
|
||||
tag_count = 0
|
||||
end
|
||||
elsif shixun.status > 1 && @game.answer_open
|
||||
score = -@game_challenge.score.to_i
|
||||
tag_count = 0
|
||||
else
|
||||
score = "+0"
|
||||
tag_count = 0
|
||||
@had_done = @game.had_done
|
||||
reward_grade(@game.user, @game.id, 'Game', score)
|
||||
reward_experience(@game.user, @game.id, 'Game', score)
|
||||
@game.update_attribute(:final_score, score)
|
||||
|
||||
respond_to do |format|
|
||||
format.js{redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun, :choose => 1)}
|
||||
end
|
||||
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.where(:id => User.current.id).first.grade, score: score, tag_count: tag_count, position: @game_challenge.position}
|
||||
end
|
||||
|
||||
|
||||
|
@ -407,9 +396,19 @@ class GamesController < ApplicationController
|
|||
def answer
|
||||
challenge = @game.challenge
|
||||
@challenge_score = challenge.score.to_i
|
||||
@answer = ""
|
||||
# 已经开启过
|
||||
@score = User.current.grade.to_i - @challenge_score
|
||||
@answer = challenge.answer
|
||||
if(params[:choose] == "true")
|
||||
challenge.challenge_chooses.each_with_index do |choose, index|
|
||||
@answer += "第"+ ((index + 1).to_s) +"题:<br />"
|
||||
@answer += choose.answer
|
||||
@answer += "<br /><br /><br />"
|
||||
end
|
||||
else
|
||||
@answer = challenge.answer
|
||||
end
|
||||
|
||||
if challenge.shixun.status < 2 || @game.answer_open
|
||||
@viewed = 1
|
||||
else
|
||||
|
|
|
@ -28,6 +28,35 @@ class Challenge < ActiveRecord::Base
|
|||
str
|
||||
end
|
||||
|
||||
def choose_correct_num
|
||||
num = 0
|
||||
self.challenge_chooses.each do |choose|
|
||||
outputs = ChooseOutputs.where(:challenge_choose_id => choose.id).first
|
||||
if outputs.nil?
|
||||
num = nil
|
||||
else
|
||||
num += (outputs.correct ? 1 : 0)
|
||||
end
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
def choose_score
|
||||
score = 0
|
||||
self.challenge_chooses.each do |choose|
|
||||
score += choose.score
|
||||
end
|
||||
return score
|
||||
end
|
||||
|
||||
def choose_tags_num
|
||||
num = 0
|
||||
self.challenge_chooses.each do |choose|
|
||||
num += choose.challenge_tags.count
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
def next_challenge
|
||||
challenge_count = Challenge.where(:shixun_id => self.shixun_id).count
|
||||
render_404 if self.position ==challenge_count
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class ChallengeChoose < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
# type 1 单选, 2,多选
|
||||
# category 1 单选, 2,多选
|
||||
# standard_answer 正确答案 answer: 答题的思路
|
||||
default_scope :order => 'position'
|
||||
belongs_to :challenge
|
||||
|
|
|
@ -2,5 +2,5 @@ class ChallengeQuestion < ActiveRecord::Base
|
|||
# 选择题的选项内容
|
||||
belongs_to :challenge_choose
|
||||
# right_key 选项是否是答案, position 选项的位置
|
||||
attr_accessible :challenge_choose_id, :option_name, :position
|
||||
attr_accessible :challenge_choose_id, :option_name, :position, :right_key
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ChallengeTag < ActiveRecord::Base
|
||||
attr_accessible :challenge_id, :name
|
||||
attr_accessible :challenge_id, :name, :challenge_choose_id
|
||||
belongs_to :challenge
|
||||
belongs_to :challenge_choose
|
||||
end
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<li class="fl <%= @index.nil? ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" class="color-black">本关任务</a>
|
||||
</li>
|
||||
<% @challenge.challenge_chooses.each_with_index do |choose, index| %>
|
||||
<li class="fl <%= @index == index ? "check_nav" : "" %>">
|
||||
<a href="<%= choose_type_show_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => choose.id, :index => index) %>" class="color-black" data-remote="true">
|
||||
<%= (index + 1).to_s + (choose.category == 1 ? ".单选题" : ".多选题") %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
|
@ -1,21 +1,18 @@
|
|||
<div class="stage-part-2 mt20">
|
||||
<div class="stage-part-2 mt20" id="">
|
||||
<ul class="nav_check_item border-bottom-orange clearfix">
|
||||
<li class="fl check_nav">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 1) %>" class="color-black">本关任务</a>
|
||||
</li>
|
||||
<!-- <li class="fl check_nav">
|
||||
<a href="javascript:void(0)" class="color-black">1.<span>单选题</span></a>
|
||||
</li>-->
|
||||
<div id="challenge_choose_tab">
|
||||
<%= render :partial => "challenges/choose_tab" %>
|
||||
</div>
|
||||
<a href="javascript:void(0)" class="fr white-btn green-btn white_bg addoption-btn">+ 多选题</a>
|
||||
<a href="javascript:void(0)" class="fr mr10 white-btn green-btn white_bg addoption-btn">+ 单选题</a>
|
||||
</ul>
|
||||
<div id="task_content" class="task-pm-box mh550 user_bg_shadow">
|
||||
<div class="panel-form">
|
||||
<div class="panel-form" id="task_show_page">
|
||||
<div id="task_pass_show">
|
||||
<div class="clearfix mb20">
|
||||
<p class="fr">
|
||||
<% if User.current.manager_of_shixun?(@shixun) %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :editor => 1) %>" class="shixun-task-btn task-btn-green fr">编辑</a>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" class="shixun-task-btn task-btn-green fr" data-remote="true">编辑</a>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -36,195 +33,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="set_content" class="task-pm-box mh550 user_bg_shadow undis">
|
||||
<li class="clearfix pt30 pr30">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >编辑</a>
|
||||
<a href="javascript:void(0)" class="task-btn fr mr10 deloption-btn" id="skill_cancel">删除</a>
|
||||
</li>
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>题干:</label>
|
||||
<div id="challenge_task_pass" class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li">
|
||||
<textarea name="challenge[task_pass]"></textarea>
|
||||
</div>
|
||||
</li>
|
||||
<script id="t:set-option-list" type="text/html">
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
</script>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">B</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">C</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">D</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<ul>
|
||||
<li class="clearfix mb10" >
|
||||
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%#= params[:action] == "edit" ? (@challenge.challenge_questions.count + 65).chr : (@st == 1 ? "E" : "C") %></span></label>
|
||||
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" class="option_icon_add">新增选项</a></div>
|
||||
</li>
|
||||
<span style="display: none" class="c_red ml95" id="choice_error_tip"></span>
|
||||
<li class="clearfix" ><label class="fl" style="margin-left: 10%">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange"><%#= @challenge.right_answers.blank? ? "请点击正确选项" : @challenge.right_answers %></span></label></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--参考答案-->
|
||||
<div class="panel-form">
|
||||
<div id="edit_answer_show">
|
||||
<ul>
|
||||
<li class="clearfix">
|
||||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li" id="tpm_answer_show" style="width: 90%;background: #fff!important;">
|
||||
<textarea style="display:none;"><%= @challenge.answer.blank? ? "无" : (@challenge.answer) %></textarea>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--经验值设置-->
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>难易度:</label>
|
||||
<span class="fl mt3 mr10">
|
||||
<input id="challenge_difficulty_1" class="magic-radio" name="challenge[difficulty]" type="radio" value="1" <%= (@challenge.difficulty == 1 ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_1">简单</label>
|
||||
</span>
|
||||
<span class="fl mt3 mr10">
|
||||
<input id="challenge_difficulty_2" class="magic-radio" name="challenge[difficulty]" type="radio" value="2" <%= (@challenge.difficulty == 2 ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_2">中等</label>
|
||||
</span>
|
||||
<span class="fl mt3">
|
||||
<input id="challenge_difficulty_3" class="magic-radio" name="challenge[difficulty]" type="radio" value="3" <%= (@challenge.difficulty == 3 ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_3">困难</label>
|
||||
</span></li>
|
||||
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>奖励经验值:</label>
|
||||
<%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %>
|
||||
<div class="clear"></div>
|
||||
<span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span>
|
||||
</li>
|
||||
|
||||
<div class="prop-notice-info mb10" style="margin-left: 10%">
|
||||
<ol>
|
||||
<% if @st == 0 %>
|
||||
<li>如果学员查看了参考答案,则不能得到相应的经验值</li>
|
||||
<li>如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+100经验值、+100金币</li>
|
||||
<% else %>
|
||||
<li>如果学员答题错误,则不能得到相应的经验值</li>
|
||||
<li>如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币</li>
|
||||
<% end %>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--技能标签-->
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix" style="margin-bottom: 0;">
|
||||
<label class=" panel-form-label fl"> 技能标签:</label>
|
||||
<div class="fl task-bd-grey">
|
||||
<% if params[:action] == "edit" && @challenge_tags.count > 0 %>
|
||||
<% @challenge_tags.each do |tag| %>
|
||||
<div class="task-tag tag-grey mt5 mr10 fl">
|
||||
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="close_tag(this)">×</button>
|
||||
<input class='knowledge_frame' name='knowledge[input][]' value="<%= tag.try(:name)%>" />
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="task-tag tag-grey mt5 mr10 fl <%#= @challenge_tags.count > 0 ? "undis" : "" %>" id="add_shixun_skill">
|
||||
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
|
||||
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入技能标签" />
|
||||
</div>
|
||||
<a href="javascript:void(0);" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge" style="color: #627bfd;float: left;margin-top: 5px">+添加</a>
|
||||
</div>
|
||||
</li>
|
||||
<p class="color-red" style="height: 25px;margin-left: 10%"><span id="stage_name_notice" style="display: none;"><i class="fa fa-exclamation-circle color-red mr5"></i>技能标签不能为空</span></p>
|
||||
<div class="prop-notice-info mb10" style="margin-left: 10%">
|
||||
<ol>
|
||||
<% if @st == 0 %>
|
||||
<li>学员未参考答案通过了本阶段的评测时将获得技能,否则不能获得技能</li>
|
||||
<% else %>
|
||||
<li>学员答题正确将获得技能,否则不能获得技能</li>
|
||||
<% end %>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<li class="clearfix pr30 pb30">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >保存</a>
|
||||
<a href="javascript:void(0)" class="task-btn fr mr10" id="skill_cancel">取消</a>
|
||||
</li>
|
||||
<div id="set_content" class="task-pm-box mh550 user_bg_shadow undis">
|
||||
<%#= render :partial => "single_or_multiple_question" %>
|
||||
</div>
|
||||
|
||||
<%#= render :partial => 'single_or_multiple_question_show'%>
|
||||
</div>
|
||||
<script>
|
||||
function editor_tigan(){
|
||||
taskpass_editormd = editormd("challenge_task_pass", {
|
||||
width : "89.6%",
|
||||
height : 400,
|
||||
syncScrolling : "single",
|
||||
//你的lib目录的路径,我这边用JSP做测试的
|
||||
path : "/editormd/lib/",
|
||||
tex : true,
|
||||
autoFocus: false,
|
||||
toolbarIcons : function() {
|
||||
// Or return editormd.toolbarModes[name]; // full, simple, mini
|
||||
// Using "||" set icons align right.
|
||||
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
|
||||
},
|
||||
toolbarCustomIcons : {
|
||||
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
|
||||
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
|
||||
},
|
||||
//这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
|
||||
saveHTMLToTextarea : true,
|
||||
// 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
|
||||
dialogMaskOpacity : 0.6,
|
||||
placeholder: "请输入选择题的题干内容" ,
|
||||
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
|
||||
});
|
||||
}
|
||||
//参考答案的编辑器
|
||||
$(document).ready(function() {
|
||||
editormd.loadKaTeX(function() {
|
||||
var answerMD = editormd.markdownToHTML("tpm_answer_show", {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
tex: true, // 默认不解析
|
||||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
editormd.loadKaTeX(function() {
|
||||
var taskPassMD = editormd.markdownToHTML("challenge_task_pass_show", {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
tex: true, // 默认不解析
|
||||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
});
|
||||
//添加单选、多选tab
|
||||
|
@ -232,6 +55,7 @@
|
|||
var length= $(".stage-part-2").find(".nav_check_item li").length;
|
||||
if(length<11){
|
||||
var title=$(this).html();
|
||||
var category = title.indexOf("多选")>0 ? 2 : 1;
|
||||
if(title.indexOf("多选")>0){//多选
|
||||
title="多选题";
|
||||
}else{
|
||||
|
@ -241,11 +65,16 @@
|
|||
var html="<li class=\"fl check_nav\"><a href=\"javascript:void(0)\" class=\"color-black\">"+li_con+"</a></li>";
|
||||
$(".stage-part-2").find(".nav_check_item li").removeClass("check_nav");
|
||||
$(".stage-part-2").find(".nav_check_item li").eq(length-1).after(html);
|
||||
$("#set_content").show();
|
||||
$("#task_content").hide();
|
||||
$.ajax({
|
||||
url: "<%= add_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>",
|
||||
dateType: "script",
|
||||
data: {category: category, position: length},
|
||||
success: function(){
|
||||
}
|
||||
})
|
||||
}
|
||||
editor_tigan();
|
||||
})
|
||||
// editor_tigan();
|
||||
});
|
||||
//删除单选、多选tab
|
||||
$(".deloption-btn").on("click",function(){
|
||||
var index=0;
|
||||
|
@ -266,173 +95,11 @@
|
|||
}
|
||||
})
|
||||
//第二个ul tab的切换事件
|
||||
$(".stage-part-2").find(".nav_check_item li").live("click",function(){
|
||||
$(".stage-part-2").find(".nav_check_item li a").live("click",function(){
|
||||
if($(".nav_check_item li").length>1){
|
||||
$(".nav_check_item li").removeClass("check_nav");
|
||||
$(this).addClass("check_nav");
|
||||
$(this).parent().addClass("check_nav");
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
//技能标签
|
||||
var SnSkill = $(".knowledge_frame").length;
|
||||
|
||||
function add_tag(){
|
||||
var num = $(".task-bd-grey").children('div').length;
|
||||
var val = $(".task-tag-input").val().trim();
|
||||
if (val != ""){
|
||||
testLength = $(".task-tag-input").val().trim().length;
|
||||
$("#add_shixun_skill").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" +
|
||||
"<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" +
|
||||
"<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" +
|
||||
" </div>");
|
||||
$(".task-tag-input").attr("value","");
|
||||
}
|
||||
$("#shixun_skill_input").val("");
|
||||
$("#add_shixun_skill").hide();
|
||||
var nSkill = $(".knowledge_frame");
|
||||
console.log(nSkill.length);
|
||||
if (nSkill.length > 0){
|
||||
$("#challenge_skill_update").submit(); //当增加或者保存技能标签以后执行保存操作
|
||||
}else{
|
||||
$("#stage_name_notice").show();
|
||||
}
|
||||
}
|
||||
|
||||
function close_tag(thisObj){
|
||||
// 获取父节点的id
|
||||
var obj = $(thisObj).parent();
|
||||
$(obj).remove();
|
||||
$("#challenge_skill_update").submit();
|
||||
}
|
||||
|
||||
|
||||
$(function(){
|
||||
var bt = baidu.template;
|
||||
bt.LEFT_DELIMITER = '<!';
|
||||
bt.RIGHT_DELIMITER = '!>';
|
||||
$(".option_icon_add").on('click', function () {
|
||||
var html = bt('t:set-option-list', null);
|
||||
$(this).parent().parent('.clearfix').before(html);
|
||||
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){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
autoTextarea(inputs[i], 0, 140);
|
||||
}
|
||||
$(inputs[inputs.length - 1]).focus();
|
||||
});
|
||||
$(".option_icon_add").on('click', function () {
|
||||
$(this).parent('.clearfix').remove();
|
||||
var inputs_spans = document.getElementsByName("option_span");
|
||||
for (var j = 0; j < inputs_spans.length; j++) {
|
||||
if(j >= 0 && j <= 26){
|
||||
if(j >= 0 && j <= 26){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#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("请点击正确选项");
|
||||
}
|
||||
});
|
||||
$("#shixun_form").on('click', 'a.option_icon_remove', function () {
|
||||
$(this).parent('.clearfix').remove();
|
||||
var inputs_spans = document.getElementsByName("option_span");
|
||||
for (var j = 0; j < inputs_spans.length; j++) {
|
||||
if(j >= 0 && j <= 26){
|
||||
if(j >= 0 && j <= 26){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#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, st){
|
||||
//判断是否选中,如果选中,再次点击的时候取消选中
|
||||
if($(item).hasClass('check-option-bg')){
|
||||
$(item).removeClass('check-option-bg');
|
||||
}else{
|
||||
if(st == 2){
|
||||
//单选
|
||||
$(".select-choice").removeClass('check-option-bg');
|
||||
$(item).addClass('check-option-bg');
|
||||
}else{
|
||||
//多选
|
||||
$(item).addClass('check-option-bg');
|
||||
}
|
||||
}
|
||||
$("#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 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;
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,510 @@
|
|||
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
|
||||
<%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %>
|
||||
<script id="t:set-option-list" type="text/html">
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
</script>
|
||||
<%= form_for("", :url => "", :html => {:id => 'challenge_choose_update'}) do |f| %>
|
||||
<%#= form_tag(url_for(new_or_edit_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :type => @type, :position => @position)), :remote => true, :id => 'challenge_choose_update') do |f| %>
|
||||
<li class="clearfix pt30 pr30">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" >编辑</a>
|
||||
<a href="javascript:void(0)" class="task-btn fr mr10 deloption-btn" id="skill_cancel">删除</a>
|
||||
</li>
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>题干:</label>
|
||||
<div id="challenge_choose_subject" class="fl task-bg-grey panel-box-sizing panel-form-width-690 new_li">
|
||||
<textarea name="choose[subject]"><%= @challenge_choose.try(:subject) %></textarea>
|
||||
</div>
|
||||
<span style="display: none;margin-left: 10%;" class="c_red" id="new_shixun_pass">题干不能为空</span>
|
||||
</li>
|
||||
<% if @challenge_choose.blank? %>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">B</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">C</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @category %>);" name="option_span" title="点击设置答案">D</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<% else%>
|
||||
<% @challenge_choose.challenge_questions.each_with_index do |question, index| %>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice <%= question.right_key ? "check-option-bg" : "" %>" onclick="selectchoice(this, <%= @challenge_choose.category %>);" name="option_span" title="点击设置答案"><%= (question.try(:position) + 65).chr %></span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"><%= question.try(:option_name) %></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<ul>
|
||||
<li class="clearfix mb10" >
|
||||
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%= @challenge_choose.blank? ? "E" : (@challenge_choose.challenge_questions.count + 65).chr %></span></label>
|
||||
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" class="option_icon_add">新增选项</a></div>
|
||||
</li>
|
||||
<span style="display: none" class="c_red ml95" id="choice_error_tip"></span>
|
||||
<li class="clearfix" ><label class="fl" style="margin-left: 10%">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange"><%= @challenge_choose.blank? ? "请点击正确选项" : @challenge_choose.try(:standard_answer) %></span></label></li>
|
||||
<input type="hidden" name="standard_answer" value="<%= @challenge_choose.try(:standard_answer) %>">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--参考答案-->
|
||||
<li class="clearfix" style="line-height:1.9;">
|
||||
<label class=" panel-form-label fl"> 参考答案:</label>
|
||||
<div id="challenge_choose_answer" class="new_li">
|
||||
<textarea name="choose[answer]"><%= @challenge_choose.try(:answer) %></textarea>
|
||||
</div>
|
||||
<p id="e_tip_in" style="margin-left: 10%" class="c_grey"></p>
|
||||
<p id="e_tips_in" style="margin-left: 10%" class="c_grey"></p>
|
||||
</li>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--经验值设置-->
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>难易度:</label>
|
||||
<span class="fl mt3 mr10">
|
||||
<input id="challenge_difficulty_1" class="magic-radio" name="challenge[difficulty]" type="radio" value="1" <%= ((@challenge_choose.try(:difficult) == 1 || @challenge_choose.nil?) ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_1">简单</label>
|
||||
</span>
|
||||
<span class="fl mt3 mr10">
|
||||
<input id="challenge_difficulty_2" class="magic-radio" name="challenge[difficulty]" type="radio" value="2" <%= (@challenge_choose.try(:difficult)== 2 ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_2">中等</label>
|
||||
</span>
|
||||
<span class="fl mt3">
|
||||
<input id="challenge_difficulty_3" class="magic-radio" name="challenge[difficulty]" type="radio" value="3" <%= (@challenge_choose.try(:difficult) == 3 ? "checked" : "")%> >
|
||||
<label for="challenge_difficulty_3">困难</label>
|
||||
</span>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl"><span class="c_red mr5">*</span>奖励经验值:</label>
|
||||
<%= select_tag :challenge_score, options_for_select([100, 200]), :name => 'challenge[score]', :class => " fl", :style => "height: 40px; width:170px;" %>
|
||||
<div class="clear"></div>
|
||||
<span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span>
|
||||
</li>
|
||||
|
||||
<div class="prop-notice-info mb10" style="margin-left: 10%">
|
||||
<ol>
|
||||
<li>如果学员答题错误,则不能得到相应的经验值</li>
|
||||
<li>如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<!--技能标签-->
|
||||
<div class="panel-form">
|
||||
<div id="shixun_form">
|
||||
<li class="clearfix" style="margin-bottom: 0;">
|
||||
<label class=" panel-form-label fl"> 技能标签:</label>
|
||||
<div class="fl task-bd-grey">
|
||||
<% unless @challenge_choose.blank? %>
|
||||
<% @challenge_choose.challenge_tags.each do |tag| %>
|
||||
<div class="task-tag tag-grey mt5 mr10 fl">
|
||||
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="close_tag(this)">×</button>
|
||||
<input class='knowledge_frame' name='knowledge[input][]' value="<%= tag.try(:name)%>" />
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="task-tag tag-grey mt5 mr10 fl <%= @challenge_choose.blank? ? "undis" : "" %>" id="add_shixun_skill">
|
||||
<button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button>
|
||||
<input type="text" class="task-tag-input" onblur="add_tag();" id="shixun_skill_input" placeholder="请输入技能标签" />
|
||||
</div>
|
||||
<a href="javascript:void(0);" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge" style="color: #627bfd;float: left;margin-top: 5px">+添加</a>
|
||||
</div>
|
||||
</li>
|
||||
<p class="color-red" style="height: 25px;margin-left: 10%"><span id="stage_name_notice" style="display: none;"><i class="fa fa-exclamation-circle color-red mr5"></i>技能标签不能为空</span></p>
|
||||
<div class="prop-notice-info mb10" style="margin-left: 10%">
|
||||
<ol>
|
||||
<li>学员答题正确将获得技能,否则不能获得技能</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<li class="clearfix pr30 pb30">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="challenge_choose_update(<%= @category %>, '<%= @challenge_choose.blank? ? "new" : 'edit' %>')">保存</a>
|
||||
<a href="javascript:void(0)" class="task-btn fr mr10" id="skill_cancel">取消</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<script>
|
||||
subject_editormd = editormd("challenge_choose_subject", {
|
||||
width : "89.6%",
|
||||
height : 400,
|
||||
syncScrolling : "single",
|
||||
//你的lib目录的路径,我这边用JSP做测试的
|
||||
path : "/editormd/lib/",
|
||||
tex : true,
|
||||
autoFocus: false,
|
||||
toolbarIcons : function() {
|
||||
// Or return editormd.toolbarModes[name]; // full, simple, mini
|
||||
// Using "||" set icons align right.
|
||||
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
|
||||
},
|
||||
toolbarCustomIcons : {
|
||||
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
|
||||
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
|
||||
},
|
||||
//这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
|
||||
saveHTMLToTextarea : true,
|
||||
// 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
|
||||
dialogMaskOpacity : 0.6,
|
||||
placeholder: "请输入选择题的题干内容" ,
|
||||
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
|
||||
});
|
||||
|
||||
choose_answer_editormd = editormd("challenge_choose_answer", {
|
||||
width : "89.6%",
|
||||
height : 400,
|
||||
syncScrolling : "single",
|
||||
//你的lib目录的路径,我这边用JSP做测试的
|
||||
path : "/editormd/lib/",
|
||||
tex : true,
|
||||
autoFocus: false,
|
||||
toolbarIcons : function() {
|
||||
// Or return editormd.toolbarModes[name]; // full, simple, mini
|
||||
// Using "||" set icons align right.
|
||||
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear" ]
|
||||
},
|
||||
toolbarCustomIcons : {
|
||||
testIcon : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
|
||||
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
|
||||
},
|
||||
//这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。
|
||||
saveHTMLToTextarea : true,
|
||||
// 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标
|
||||
dialogMaskOpacity : 0.6,
|
||||
placeholder: "请输入各个选项的具体解析或其他相关信息",
|
||||
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
|
||||
});
|
||||
//技能标签
|
||||
var SnSkill = $(".knowledge_frame").length;
|
||||
function add_tag(){
|
||||
var num = $(".task-bd-grey").children('div').length;
|
||||
var val = $(".task-tag-input").val().trim();
|
||||
if (val != ""){
|
||||
testLength = $(".task-tag-input").val().trim().length;
|
||||
$("#add_shixun_skill").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" +
|
||||
"<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" +
|
||||
"<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" +
|
||||
" </div>");
|
||||
$(".task-tag-input").attr("value","");
|
||||
}
|
||||
$("#shixun_skill_input").val("");
|
||||
$("#add_shixun_skill").hide();
|
||||
var nSkill = $(".knowledge_frame");
|
||||
console.log(nSkill.length);
|
||||
if (nSkill.length > 0){
|
||||
//$("#challenge_skill_update").submit(); //当增加或者保存技能标签以后执行保存操作
|
||||
}else{
|
||||
$("#stage_name_notice").show();
|
||||
}
|
||||
}
|
||||
|
||||
function close_tag(thisObj){
|
||||
// 获取父节点的id
|
||||
var obj = $(thisObj).parent();
|
||||
$(obj).remove();
|
||||
//$("#challenge_skill_update").submit();
|
||||
}
|
||||
|
||||
|
||||
$(function(){
|
||||
var bt = baidu.template;
|
||||
bt.LEFT_DELIMITER = '<!';
|
||||
bt.RIGHT_DELIMITER = '!>';
|
||||
$(".option_icon_add").on('click', function () {
|
||||
var html = bt('t:set-option-list', null);
|
||||
$(this).parent().parent('.clearfix').before(html);
|
||||
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){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
autoTextarea(inputs[i], 0, 140);
|
||||
}
|
||||
$(inputs[inputs.length - 1]).focus();
|
||||
});
|
||||
$(".option_icon_add").on('click', function () {
|
||||
$(this).parent('.clearfix').remove();
|
||||
var inputs_spans = document.getElementsByName("option_span");
|
||||
for (var j = 0; j < inputs_spans.length; j++) {
|
||||
if(j >= 0 && j <= 26){
|
||||
if(j >= 0 && j <= 26){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#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("请点击正确选项");
|
||||
}
|
||||
});
|
||||
$("#shixun_form").on('click', 'a.option_icon_remove', function () {
|
||||
$(this).parent('.clearfix').remove();
|
||||
var inputs_spans = document.getElementsByName("option_span");
|
||||
for (var j = 0; j < inputs_spans.length; j++) {
|
||||
if(j >= 0 && j <= 26){
|
||||
if(j >= 0 && j <= 26){
|
||||
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#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, st){
|
||||
//判断是否选中,如果选中,再次点击的时候取消选中
|
||||
if($(item).hasClass('check-option-bg')){
|
||||
$(item).removeClass('check-option-bg');
|
||||
}else{
|
||||
if(st == 1){
|
||||
//单选
|
||||
$(".select-choice").removeClass('check-option-bg');
|
||||
$(item).addClass('check-option-bg');
|
||||
}else{
|
||||
//多选
|
||||
$(item).addClass('check-option-bg');
|
||||
}
|
||||
}
|
||||
$("#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());
|
||||
$("input[name='standard_answer']").val($("#current-option").html())
|
||||
}
|
||||
}else{
|
||||
$("#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;
|
||||
}
|
||||
// 根据难易程度设置不同的奖励经验值(适用新建与编辑模式)
|
||||
var list = $('input:radio[name="challenge[difficulty]"]:checked').val(); // 获取select的索引值
|
||||
var index = parseInt(<%= @st == 0 ? 1 : 10 %>); // 单选 与 多选分数系数
|
||||
if(list == 1){
|
||||
$("#challenge_score").empty();
|
||||
for(var i = 100; i <= 200; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
}else if(list == 2){
|
||||
$("#challenge_score").empty();
|
||||
for(var i = 300; i <= 600; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
}else if(list == 3){
|
||||
$("#challenge_score").empty();
|
||||
for(var i= 700; i <= 1000; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
}
|
||||
$("#challenge_score").find("option[value='<%= @challenge.score %>']").attr("selected",true); // 设置option默认值
|
||||
$("#challenge_difficulty_1").click(function(){
|
||||
$("#challenge_score").empty();
|
||||
for(var i = 100; i <= 200; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
});
|
||||
$("#challenge_difficulty_2").click(function(){
|
||||
$("#challenge_score").empty();
|
||||
for(var i = 300; i <= 600; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
});
|
||||
$("#challenge_difficulty_3").click(function(){
|
||||
$("#challenge_score").empty();
|
||||
for(var i= 700; i <= 1000; i += 100){
|
||||
$("#challenge_score").append("<option value="+ i/index + ">"+ i/index +"</option>");
|
||||
}
|
||||
});
|
||||
/* function challenge_score_update(){
|
||||
if($("#challenge_score").val().trim()==""){
|
||||
$("#challenge_score").focus();
|
||||
$("#new_shixun_score").show();
|
||||
}else{
|
||||
$('#challenge_score_update').submit();
|
||||
}
|
||||
}*/
|
||||
|
||||
$("#score_cancel").click(function(){
|
||||
$("#scoring_edit").hide();
|
||||
$("#scroe_show").show();
|
||||
});
|
||||
|
||||
function challenge_choose_update(st, action){
|
||||
set_choice_answer();
|
||||
var error = $("#choice_error_tip");
|
||||
if($('#challenge_choose_subject textarea').val().trim() == ""){
|
||||
$("#challenge_choose_subject textarea").focus();
|
||||
$("#new_shixun_name").show();
|
||||
}else if($("#challenge_choose_answer textarea").val().trim() == ""){
|
||||
$("#challenge_choose_answer textarea").focus();
|
||||
$("#new_shixun_pass").show();
|
||||
}else if(judge_choice_contents()){
|
||||
error.html("选项不能为空").show();
|
||||
}else{
|
||||
if(st == "1"){
|
||||
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{
|
||||
if(action == "new"){
|
||||
$.ajax({
|
||||
url: "<%= new_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :category => @category, :position => @position) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ajax({
|
||||
url: "<%= update_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.try(:id), :index => @position ) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}else if(st == "2"){
|
||||
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{
|
||||
if(action == "new"){
|
||||
$.ajax({
|
||||
url: "<%= new_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :category => @category, :position => @position) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ajax({
|
||||
url: "<%= update_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.try(:id), :index => @position) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(action == "new"){
|
||||
$.ajax({
|
||||
url: "<%= new_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :category => @category, :position => @position) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ajax({
|
||||
url: "<%= update_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.try(:id), :index => @position) %>",
|
||||
data: $("#challenge_choose_update").serialize(),
|
||||
type: 'POST',
|
||||
dataType: "script",
|
||||
success: function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,109 @@
|
|||
<div class="white_bg">
|
||||
<div class="panel-form">
|
||||
<li class="clearfix pr30">
|
||||
<a href="<%= edit_choose_question_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id, :index => @index) %>" data-remote="true" class="task-btn task-btn-green fr">编辑</a>
|
||||
<a href="<%= destroy_challenge_choose_shixun_challenge_path(@challenge, :shixun_id => @shixun, :choose_id => @challenge_choose.id) %>" data-method="delete" class="task-btn fr mr10 deloption-btn">删除</a>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">题干: </label>
|
||||
<div class="fl panel-box-sizing panel-form-width-690 new_li white_bg bor-grey-e" id="challenge_choose_subject_show" style="width: 90%;">
|
||||
<textarea name="choose[subject]"><%= @challenge_choose.subject %></textarea>
|
||||
</div>
|
||||
</li>
|
||||
<% @challenge_choose.challenge_questions.each_with_index do |option, index| %>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl <%= option.right_key ? 'color-orange03' : '' %>"><%= (option.position+ 65).chr %>: </label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 color-grey3">
|
||||
<%= option.option_name %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<div class="panel-form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">参考答案: </label>
|
||||
<div class="fl panel-box-sizing panel-form-width-690 new_li white_bg bor-grey-e" id="choose_task_pass_show" style="width: 90%;">
|
||||
<textarea name="choose[subject]"><%= @challenge_choose.answer %></textarea>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<div class="panel-form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">难易度: </label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 color-grey3">
|
||||
<%= difficulty_type @challenge_choose.difficult %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">奖励经验值: </label>
|
||||
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690 color-grey3">
|
||||
<%= @challenge_choose.score.nil? ? 0 : @challenge_choose.score %>分
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
<p class="bor-bottom-greyE"></p>
|
||||
<div class="panel-form">
|
||||
<li class="clearfix">
|
||||
<label class="panel-form-label fl">技能标签: </label>
|
||||
<div class="fl task-inputs">
|
||||
<% if @challenge_choose.challenge_tags.blank? %>
|
||||
无
|
||||
<% else %>
|
||||
<% @challenge_choose.challenge_tags.each do |tag| %>
|
||||
<div class="task-tag tag-grey mb10 mr10 fl">
|
||||
<%= tag.name %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
editormd.loadKaTeX(function() {
|
||||
var taskPassMD = editormd.markdownToHTML("challenge_choose_subject_show", {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
tex: true, // 默认不解析
|
||||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
var taskPassMD = editormd.markdownToHTML("choose_task_pass_show", {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
tex: true, // 默认不解析
|
||||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
});
|
||||
});
|
||||
/* //技能标签
|
||||
var SnSkill = $(".knowledge_frame").length;
|
||||
|
||||
function add_tag(){
|
||||
var num = $(".task-inputs").children('div').length;
|
||||
var val = $(".tags").val().trim();
|
||||
if (val != ""){
|
||||
testLength = $(".tags").val().trim().length;
|
||||
$("#add_shixuns_skill").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" +
|
||||
"<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" +
|
||||
"<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" +
|
||||
" </div>");
|
||||
$(".tags").attr("value","");
|
||||
}
|
||||
$("#shixuns_skill_input").val("");
|
||||
$("#add_shixuns_skill").hide();
|
||||
var nSkill = $(".knowledge_frame");
|
||||
console.log(nSkill.length);
|
||||
}
|
||||
|
||||
function close_tag(thisObj){
|
||||
// 获取父节点的id
|
||||
var obj = $(thisObj).parent();
|
||||
$(obj).remove();
|
||||
}*/
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
<ul class="" id="task_pass_edit">
|
||||
<%= labelled_form_for @challenge, :url => shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 1), :html => {:id => "challenge_shixun_update"} do |f| %>
|
||||
<%= render :partial => "task_pass_form", :locals => {:f => f} %>
|
||||
<% end %>
|
||||
</ul>
|
|
@ -34,66 +34,6 @@
|
|||
<p id="e_tips_in" style="margin-left: 10%" class="c_grey"></p>
|
||||
<span style="display: none;margin-left: 10%;" class="c_red" id="new_shixun_pass">过关任务不能为空</span>
|
||||
</li>
|
||||
<% if false %>
|
||||
<% if @st != 0 %>
|
||||
<% if params[:action] == "edit" && @challenge.challenge_questions.count > 0 %>
|
||||
<% @challenge.challenge_questions.each_with_index do |question, index| %>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice <%= question.right_key ? "check-option-bg" : "" %>" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案"><%= (question.position+ 65).chr %></span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"><%= question.option_name %></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% elsif @st == 2 %>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">B</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">A</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">B</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">C</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<li class="clearfix pr">
|
||||
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this, <%= @st %>);" name="option_span" title="点击设置答案">D</span></label>
|
||||
<input type="hidden" name="choice[answer][]">
|
||||
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="question[cnt][]" placeholder="请输入选项内容"></textarea>
|
||||
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<ul>
|
||||
<li class="clearfix mb10" >
|
||||
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey border-dash-orange" name="option_span"><%= params[:action] == "edit" ? (@challenge.challenge_questions.count + 65).chr : (@st == 1 ? "E" : "C") %></span></label>
|
||||
<div class="fl panel-box-sizing add-option-input border-dash-orange"><a title="新增" class="option_icon_add">新增选项</a></div>
|
||||
</li>
|
||||
<span style="display: none" class="c_red ml95" id="choice_error_tip"></span>
|
||||
<li class="clearfix" ><label class="fl" style="margin-left: 46px">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange"><%= @challenge.right_answers.blank? ? "请点击正确选项" : @challenge.right_answers %></span></label></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li class="clearfix">
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="challenge_update()">保存</a>
|
||||
<% if params[:action] == "new" %>
|
||||
|
@ -130,7 +70,26 @@
|
|||
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
|
||||
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>",//url
|
||||
onload: function(){
|
||||
$("#challenge_task_pass [type=\"latex\"]").bind("click", function(){
|
||||
taskpass_editormd.cm.replaceSelection("```latex");
|
||||
taskpass_editormd.cm.replaceSelection("\n");
|
||||
taskpass_editormd.cm.replaceSelection("\n");
|
||||
taskpass_editormd.cm.replaceSelection("```");
|
||||
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
|
||||
taskpass_editormd.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
$("#challenge_task_pass [type=\"inline\"]").bind("click", function(){
|
||||
taskpass_editormd.cm.replaceSelection("$$$$");
|
||||
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
|
||||
taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
taskpass_editormd.cm.focus();
|
||||
});
|
||||
$("[type=\"inline\"]").attr("title", "行内公式");
|
||||
$("[type=\"latex\"]").attr("title", "多行公式");
|
||||
}
|
||||
});
|
||||
|
||||
var bt = baidu.template;
|
||||
|
@ -252,27 +211,6 @@
|
|||
var lens = answer.length;
|
||||
return lens;
|
||||
}
|
||||
|
||||
window.onload = function(){
|
||||
$("#challenge_task_pass [type=\"latex\"]").bind("click", function(){
|
||||
taskpass_editormd.cm.replaceSelection("```latex");
|
||||
taskpass_editormd.cm.replaceSelection("\n");
|
||||
taskpass_editormd.cm.replaceSelection("\n");
|
||||
taskpass_editormd.cm.replaceSelection("```");
|
||||
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
|
||||
taskpass_editormd.cm.setCursor(__Cursor.line-1, 0);
|
||||
});
|
||||
|
||||
$("#challenge_task_pass [type=\"inline\"]").bind("click", function(){
|
||||
taskpass_editormd.cm.replaceSelection("$$$$");
|
||||
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
|
||||
taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
|
||||
taskpass_editormd.cm.focus();
|
||||
});
|
||||
$("[type=\"inline\"]").attr("title", "行内公式");
|
||||
$("[type=\"latex\"]").attr("title", "多行公式");
|
||||
|
||||
};
|
||||
$("#challenge_subject").keydown(function(){
|
||||
$("#new_shixun_name").hide();
|
||||
});
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#task_content").html("<%= j(render :partial => "single_or_multiple_question") %>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#task_content").html("<%= j(render :partial => 'single_or_multiple_question_show')%>");
|
||||
$("#challenge_choose_tab").html("<%= j(render :partial => "challenges/choose_tab") %>");
|
|
@ -22,13 +22,9 @@
|
|||
<span class="panel-inner-icon mr10 fl mt5">
|
||||
<i class="fa fa-code font-16 color_white" data-tip-down="实践任务"></i>
|
||||
</span>
|
||||
<% elsif @st == 1 %>
|
||||
<% else %>
|
||||
<span class="panel-inner-icon mr10 fl mt5">
|
||||
<i class="fa fa-th-list color_white" data-tip-down="多选任务"></i>
|
||||
</span>
|
||||
<% elsif @st == 2%>
|
||||
<span class="panel-inner-icon mr10 fl mt5">
|
||||
<img src="/images/bigdata/singel.png" style="margin-bottom: 3px" data-tip-down="单选任务">
|
||||
<i class="fa fa-th-list color_white" data-tip-down="选择题任务"></i>
|
||||
</span>
|
||||
<% end %>
|
||||
<h3 class="fl mt3">阶段详情(第<%= @challenge.position %>关)</h3>
|
||||
|
@ -40,53 +36,55 @@
|
|||
<% end %>
|
||||
<% if @shixun.status == 0 && User.current.manager_of_shixun?(@shixun) %>
|
||||
<!-- <a href="<%#= new_shixun_challenge_path(@shixun) %>" class="shixun-task-btn task-btn-green fr">新建阶段</a>-->
|
||||
<a href="<%= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr">+实践任务</a>
|
||||
<a href="<%= new_shixun_challenge_path(@shixun, :st => 1) %>" class="shixun-task-btn task-btn-green fr mr10">+多选任务</a>
|
||||
<a href="<%= new_shixun_challenge_path(@shixun, :st => 2) %>" class="shixun-task-btn task-btn-green fr mr10">+单选任务</a>
|
||||
<a href="<%= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr" data-tip-down="新增代码编辑类型的任务">+实践任务</a>
|
||||
<!--<a href="<%#= new_shixun_challenge_path(@shixun, :st => 1) %>" class="shixun-task-btn task-btn-green fr mr10">+多选任务</a>
|
||||
<a href="<%#= new_shixun_challenge_path(@shixun, :st => 2) %>" class="shixun-task-btn task-btn-green fr mr10">+单选任务</a>-->
|
||||
|
||||
<a href="<%= new_shixun_challenge_path(@shixun, :st => 1) %>" class="shixun-task-btn task-btn-green fr mr10" data-tip-down="新增选择题类型的任务">+选择题任务</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="nav_check_item clearfix mt30" style="margin-bottom: 0;">
|
||||
<li class="fl <%= @tab == 1 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 1) %>" class="color-black">本关任务</a>
|
||||
</li>
|
||||
<% if @challenge.st == 0 %>
|
||||
<li class="fl <%= @tab == 2 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 2) %>" class="color-black">评测设置</a>
|
||||
<% if @challenge.st == 0 %>
|
||||
<div class="stage-part mt20">
|
||||
<ul class="nav_check_item border-bottom-orange clearfix">
|
||||
<li class="fl <%= @tab == 1 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 1) %>" class="color-black">本关任务</a>
|
||||
</li>
|
||||
<li class="fl <%= @tab == 2 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 2) %>" class="color-black">评测设置</a>
|
||||
</li>
|
||||
<li class="fl <%= @tab == 3 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 3) %>" class="color-black">参考答案</a>
|
||||
</li>
|
||||
<li class="fl <%= @tab == 6 ? "check_nav" : "" %>
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6) %>" class="color-black">预备知识</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="fl <%= @tab == 3 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 3) %>" class="color-black">参考答案</a>
|
||||
</li>
|
||||
<% unless @challenge.ready_knowledge.blank? %>
|
||||
<li class="fl <%= @tab == 6 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 6) %>" class="color-black">背景知识</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="fl <%= @tab == 4 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 4) %>" class="color-black">评分设置</a>
|
||||
</li>
|
||||
<li class="fl <%= @tab == 5 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 5) %>" class="color-black">技能标签</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="task-pm-box mh550 user_bg_shadow">
|
||||
<% if @tab == 1 || @tab.blank? %>
|
||||
<%= render :partial => "edit_task_pass" %>
|
||||
<% elsif @tab == 2 %>
|
||||
<%= render :partial => "edit_evaluating" %>
|
||||
<% elsif @tab == 3 %>
|
||||
<%= render :partial => "edit_answer" %>
|
||||
<% elsif @tab == 4 %>
|
||||
<%= render :partial => "edit_scoring" %>
|
||||
<% elsif @tab == 5 %>
|
||||
<%= render :partial => "edit_skill" %>
|
||||
<% elsif @tab == 6 %>
|
||||
<%= render :partial => "edit_propaedeutics" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<%#= render :partial => "choose_type" %>
|
||||
<li class="fl <%= @tab == 4 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 4) %>" class="color-black">评分设置</a>
|
||||
</li>
|
||||
<li class="fl <%= @tab == 5 ? "check_nav" : "" %>">
|
||||
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun, :tab => 5) %>" class="color-black">技能标签</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="task-pm-box mh550 user_bg_shadow">
|
||||
<% if @tab == 1 || @tab.blank? %>
|
||||
<%= render :partial => "edit_task_pass" %>
|
||||
<% elsif @tab == 2 %>
|
||||
<%= render :partial => "edit_evaluating" %>
|
||||
<% elsif @tab == 3 %>
|
||||
<%= render :partial => "edit_answer" %>
|
||||
<% elsif @tab == 4 %>
|
||||
<%= render :partial => "edit_scoring" %>
|
||||
<% elsif @tab == 5 %>
|
||||
<%= render :partial => "edit_skill" %>
|
||||
<% elsif @tab == 6 %>
|
||||
<%= render :partial => "edit_propaedeutics" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render :partial => "choose_type" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="save-tip">
|
||||
<div class="save-tip-content">已保存</div>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#task_show_page").html('<%= j(render :partial => "task_edit_page") %>');
|
|
@ -0,0 +1,2 @@
|
|||
$("#task_content").html("<%= j(render :partial => "single_or_multiple_question") %>");
|
||||
$("#challenge_choose_tab").html("<%= j(render :partial => "challenges/choose_tab") %>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#task_content").html("<%= j(render :partial => 'single_or_multiple_question_show')%>");
|
||||
$("#challenge_choose_tab").html("<%= j(render :partial => "challenges/choose_tab") %>");
|
|
@ -0,0 +1 @@
|
|||
$("#task_content").html("<%= j(render :partial => 'single_or_multiple_question_show')%>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#task_content").html("<%= j(render :partial => 'single_or_multiple_question_show')%>");
|
||||
$("#challenge_choose_tab").html("<%= j(render :partial => "challenges/choose_tab") %>");
|
|
@ -1,37 +1,142 @@
|
|||
<!-- 编程题 -->
|
||||
<div class="-layout -stretch -fit -vertical centerH">
|
||||
<div class="-layout -vertical -flex -relative -bg-black -flex-basic70" id="games_repository_contents" style="overflow:hidden;">
|
||||
<ul id="blacktab_nav">
|
||||
<li id="codetab_nav_1" class="blacktab_hover" onclick="HoverLi_new(1);">
|
||||
<a href="javascript:void(0);" class="tab_type tab_color" >答题</a>
|
||||
</li>
|
||||
<div class="fr mt5 -horizontal mr15">
|
||||
<a href="javascript:void(0);" onclick="repository_extend_and_zoom();" id="extend_and_zoom"><i class="fa fa-expand font-16"></i></a>
|
||||
</div>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div id="codotab_con_1" class="white_bg" style="overflow-y: auto;height: 100%">
|
||||
<div class="panel-header clearfix" id="top_repository" style="border-bottom:0;padding:15px;">
|
||||
<% @game_challenge.challenge_chooses.each_with_index do |choose, index| %>
|
||||
<p class="font-bd font-18 color-grey3"><%= (index + 1).to_s + "." + (choose.category == 1 ? "单选题" : "多选题") %></p>
|
||||
<div class="font-15 color-grey3 mb10 new_li read_only" unselectable="on" id="choose_subject_<%= index + 1 %>" style="padding: 10px 0px 10px 10px">
|
||||
<textarea style="display:none;"><%= choose.subject %></textarea>
|
||||
</div>
|
||||
<div class="problem_single">
|
||||
<% choose.challenge_questions.each_with_index do |question, i| %>
|
||||
<p class="ml10 mb10 ">
|
||||
<span>
|
||||
<% if choose.category == 1 %>
|
||||
<input type="radio" <%= (choose.choose_outputs.try(:answer) == (i + 65).chr) ? "checked" : "" %> name="answer[<%= index + 1 %>]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-radio ml5">
|
||||
<% else %>
|
||||
<!--多选-->
|
||||
<input type="checkbox" <%= (!choose.choose_outputs.try(:answer).nil? && (choose.choose_outputs.try(:answer).include? ((i + 65).chr))) ? "checked" : "" %> name="answer[]" category="<%= choose.category %>" value="<%= (question.position + 65).chr %>" id="result_<%= index %>_<%= i %>" class="ml-3 mr5 magic-checkbox ml5">
|
||||
<% end %>
|
||||
<label for="result_<%= index %>_<%= i %>" style="top: 0px"><span><%= (question.position + 65).chr %></span>.<%= question.option_name %></label>
|
||||
</span>
|
||||
</p>
|
||||
<% end %>
|
||||
<input type="hidden" name="user_answer">
|
||||
</div>
|
||||
<% end %>
|
||||
<!--<div class="pl5 pr5 pt10 pb10 bor-grey-e">
|
||||
<div for="result_<%#= question.position %>" class="card -elevation-1 mt10 mb5 <%#= (@user_answer.nil? || @user_answer.index(i.to_s).nil?) ? "" : "card-check color_white" %>" onclick="">
|
||||
<!–单选–>
|
||||
<%# if choose.category == 1 %>
|
||||
<input type="radio" name="answer[]" value="<%#= (question.position + 65).chr %>" id="result_<%#= question.position %>" class="ml-3 mr5 magic-radio ml5">
|
||||
<%# else %>
|
||||
<!–多选–>
|
||||
<input type="checkbox" name="answer[]" value="<%#= (question.position + 65).chr %>" id="result_<%#= question.position %>" class="ml-3 mr5 magic-checkbox ml5">
|
||||
<%# end %>
|
||||
<div class="-layout-h -center break_word" for="result_<%#= question.position %>">
|
||||
<span class="mr10"><%#= (question.position + 65).chr %>.</span>
|
||||
<div class="markdown">
|
||||
<p><code class="font-16"><%#= question.option_name %></code></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<h3 id="save_status" class="ml15 fl" style="font-weight: normal"></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--拖拽增加结构---------------------------------------->
|
||||
<div class="h-center">
|
||||
<div class="-changebg -bg-black" id="-bg-change-color"></div>
|
||||
</div>
|
||||
<!------------------------------------------------------>
|
||||
<div class="split-panel--second -layout -vertical -flex -relative -bg-black -flex-basic60" id="games_valuation_contents">
|
||||
<%= render :partial => 'games/game_choose_results', :locals => { :game_challenge => @game_challenge} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
editormd.loadKaTeX(function() {
|
||||
var lens = $("#top_repository .read_only").length;
|
||||
for(i = 1; i <= lens; i++){
|
||||
editormd.markdownToHTML("choose_subject_" + i, {
|
||||
htmlDecode: "style,script,iframe", // you can filter tags decode
|
||||
taskList: true,
|
||||
tex: true, // 数学公式
|
||||
flowChart: true, // 默认不解析
|
||||
sequenceDiagram: true // 默认不解析
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$(".problem_single p input").live("change",function(event){
|
||||
var $this=$(this).parents(".problem_single").find("input[name='user_answer']");
|
||||
var value="";
|
||||
if($(this).attr("category")=="1"){
|
||||
value="";
|
||||
//alert($(this).siblings("label").find("span").html());
|
||||
if($(this).attr("checked")=="checked"){
|
||||
value=$(this).siblings("label").find("span").html();
|
||||
}
|
||||
}else{
|
||||
var p=$(this).parents(".problem_single").find("p");
|
||||
value="";
|
||||
for(var i=0;i< p.length;i++){
|
||||
if(p.eq(i).find("input").attr("checked")=="checked"){
|
||||
//alert(p.eq(i).find("input").siblings("label").find("span").html());
|
||||
value+=p.eq(i).find("input").siblings("label").find("span").html();
|
||||
}
|
||||
}
|
||||
}
|
||||
$this.val(value);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<% if false %>
|
||||
<div class="-layout -stretch -fit -vertical centerH">
|
||||
<div class="split-panel--second -layout -vertical -flex -relative -bg-black" id="answer">
|
||||
<ul id="blacktab_nav">
|
||||
<li id="codetab_nav_1" class="blacktab_hover" onclick="HoverLi_new(1);">
|
||||
<a href="javascript:void(0);" class="tab_type tab_color" >答题选项</a>
|
||||
<a href="javascript:void(0);" class="tab_type tab_color" >答题</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div id="codotab_con_1" class="white_bg" style="overflow-y: auto;height: 100%">
|
||||
<div class="panel-header clearfix" id="top_repository" style="border-bottom:0;padding:15px;">
|
||||
<p class="mb10 color-light-green font-16 <%= @game.outputs.blank? || !@game.outputs.first.result ? "undis" : "" %>" id="correct_tip">
|
||||
<i class="fa fa-check-circle font-16"></i> 正确
|
||||
</p>
|
||||
<p class="mb10 color-red font-16 <%= @game.outputs.blank? || @game.outputs.first.result ? "undis" : "" %>" id="error_tip">
|
||||
<i class="fa fa-exclamation-circle font-16"></i> 错误
|
||||
</p>
|
||||
<p class="font-bd font-18 color-grey3">1.单选题</p>
|
||||
<p class="font-15 color-grey3 mb10">应在下列程序划线处填入的语句是()</p>
|
||||
<pre class="mb10 back-f6-grey"></pre>
|
||||
<div class="pl5 pr5 pt10 pb10 bor-grey-e">
|
||||
<% @game_challenge.challenge_questions.each_with_index do |question, i| %>
|
||||
<div for="result_<%= question.position %>" class="card -elevation-1 mt10 mb5 <%= (@user_answer.nil? || @user_answer.index(i.to_s).nil?) ? "" : "card-check color_white" %>" onclick="choice_answer('<%= @st %>', this)">
|
||||
<!--单选-->
|
||||
<input type="radio" name="answer[]" value="<%= question.position %>" id="result_<%= question.position %>" class="ml-3 mr5 magic-radio ml5">
|
||||
<!--多选-->
|
||||
<input type="checkbox" name="answer[]" value="<%= question.position %>" id="result_<%= question.position %>" class="ml-3 mr5 magic-checkbox ml5">
|
||||
<input type="hidden" name="answer" value="<%= question.position %>">
|
||||
<div class="-layout-h -center break_word">
|
||||
<span class="mr10"><%= (question.position + 65).chr %>.</span>
|
||||
<div class="markdown">
|
||||
<p><code class="font-16"><%= question.option_name %></code></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% @game_challenge.challenge_chooses.each do |choose| %>
|
||||
<% choose.challenge_questions.each_with_index do |question, i| %>
|
||||
<div for="result_<%= question.position %>" class="card -elevation-1 mt10 mb5 <%= (@user_answer.nil? || @user_answer.index(i.to_s).nil?) ? "" : "card-check color_white" %>" onclick="choice_answer('<%= @st %>', this)">
|
||||
<!--单选-->
|
||||
<input type="radio" name="answer[]" value="<%= question.position %>" id="result_<%= question.position %>" class="ml-3 mr5 magic-radio ml5">
|
||||
<!--多选-->
|
||||
<input type="checkbox" name="answer[]" value="<%= question.position %>" id="result_<%= question.position %>" class="ml-3 mr5 magic-checkbox ml5">
|
||||
<div class="-layout-h -center break_word">
|
||||
<span class="mr10"><%= (question.position + 65).chr %>.</span>
|
||||
<div class="markdown">
|
||||
<p><code class="font-16"><%= question.option_name %></code></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<h3 id="save_status" class="ml15 fl" style="font-weight: normal"></h3>
|
||||
|
@ -39,3 +144,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -22,15 +22,15 @@
|
|||
<% if @game.status == 1 %>
|
||||
<a class="shixun-task-btn mt8 mr15" id="code_testing">评测中..</a>
|
||||
<% end %>
|
||||
<% if show_next_stage?(@game, @myshixun.shixun.try(:status)) %>
|
||||
<% if @had_done == 0 %>
|
||||
<% if show_next_stage?(@game, @myshixun.shixun.try(:status)) %>
|
||||
<%= 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 %>
|
||||
<!--<a href="javascript:void(0);" onclick="shixun_next_step();" class="task-btn task-btn-blue mr15 mt8">下 一 步</a>-->
|
||||
<% end %>
|
||||
<% else %>
|
||||
<a href="<%= shixun_path(@myshixun.shixun) %>" id="exit_shixun" class="shixun-task-btn task-btn-blue mt8 mr15">退出实训</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<script>
|
||||
// 如果是HTML实训,则在效果显示栏实时渲染code
|
||||
|
@ -81,57 +81,25 @@
|
|||
// 选择题提交评测
|
||||
// answer 选择的答案
|
||||
function choice_submmit(){
|
||||
var answer = "";
|
||||
var nBtn = $(".card-check");
|
||||
var choice = nBtn.find("input[name='answer']");
|
||||
for(var i = 0; i < choice.length; i++){
|
||||
answer += $(choice[i]).val();
|
||||
}
|
||||
if(answer == ""){
|
||||
notice_sure_box("答案不能为空!");
|
||||
return;
|
||||
var user_answer = [];
|
||||
var input_answer = $("input[name='user_answer']");
|
||||
var lens = input_answer.length;
|
||||
for(i = 0; i < lens; i++ ){
|
||||
var answer = $(input_answer[i]).val();
|
||||
if(answer == ""){
|
||||
notice_sure_box("第"+ (i+1) + "题未答,请确认!");
|
||||
return;
|
||||
}
|
||||
user_answer.push(answer)
|
||||
}
|
||||
console.log(user_answer);
|
||||
$("#code_test").html("<a class='task-btn mt8 mr15'>评测中..</a>");
|
||||
$.ajax({
|
||||
type: "post",
|
||||
type: "POST",
|
||||
url: '<%= evaluating_choice_myshixun_game_path(@game, :myshixun_id => @myshixun) %>',
|
||||
data: {answer: answer},
|
||||
dataType: "json",
|
||||
data: {answer:user_answer},
|
||||
dataType: "script",
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
clearInterval(cm);
|
||||
var icon = $("#game_status_<%= @game_challenge.id %>"); // 实训列表的icon
|
||||
icon.find("i").attr("class", "fa fa-unlock fr font-18 mt5 color-light-green w20_center");
|
||||
icon.find("a:last").attr("title", "已完成");
|
||||
$("#code_test").remove();
|
||||
if(data.correct){
|
||||
$("#correct_tip").show();
|
||||
$("#user_grade").html(data.grade);
|
||||
$("#shixun_exp_<%=@game_challenge.id %>").html("经验值<span class='color-light-green mr5'>+"+ data.score + "</span>");
|
||||
$("#shixun_grade_<%=@game_challenge.id %>").html("金币<span class='color-light-green mr5'>+"+ data.score + "</span>");
|
||||
$("#shixun_tag_<%=@game_challenge.id %>").html("技能标签<span class='color-light-green mr5'>+"+ data.tag_count + "</span>");
|
||||
if( data.had_done == 0 ) {
|
||||
$("#code_estimate").html("<a href='<%= next_step_myshixun_game_path(@game, :myshixun_id => @myshixun) %>' class='task-btn task-btn-blue mr15 mt8' id='next_step' data-remote='true'>下一关</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 0}) %>";
|
||||
}else{
|
||||
$("#code_estimate").html("<a href='<%= shixun_path(@myshixun.shixun) %>' class='task-btn task-btn-blue mt8 mr15' >退出实训</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game => @game, :myshixun => @myshixun, :had_done => 1}) %>";
|
||||
}
|
||||
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
|
||||
pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight);
|
||||
}else{
|
||||
$("#error_tip").show();
|
||||
var span_class = parseInt(data.score) < 0 ? "u-color-light-red" : "color-light-green";
|
||||
$("#shixun_exp_<%=@game_challenge.id %>").html("经验值<span class='color-light-green mr5'>+0</span>");
|
||||
$("#shixun_grade_<%=@game_challenge.id %>").html("金币<span class='"+ span_class +" mr5'>"+ data.score + "</span>");
|
||||
$("#shixun_tag_<%=@game_challenge.id %>").html("技能标签<span class='color-light-green mr5'>+0</span>");
|
||||
if(0 == data.had_done){
|
||||
$("#code_estimate").html("<a href='<%= next_step_myshixun_game_path(@game, :myshixun_id => @myshixun) %>' class='task-btn task-btn-blue mr15 mt8' id='next_step' data-remote='true'>下一关</a>");
|
||||
}else if(1 == data.had_done ){
|
||||
$("#code_estimate").html("<a href='<%= shixun_path(@myshixun.shixun) %>' class='task-btn task-btn-blue mt8 mr15' >退出实训</a>");
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
console.log("错了");
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<ul id="blacktab_nav">
|
||||
<li class="blacktab_con blacktab_hover">
|
||||
<a href="javascript:void(0);" class="tab_type tab_color">测试结果</a>
|
||||
</li>
|
||||
<a href="javascript:void(0);" onclick="valuation_extend_and_zoom();" id="valuation_extend_and_zoom"><i class="fa fa-expand font-16 color-grey fr mt10 mr15 fa-arrows-alt" ></i></a>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div id="game_test_set_results" class="-flex -relative blacktab-inner">
|
||||
<div id="blacktab_con_1" class="" >
|
||||
<div class="fit -scroll">
|
||||
<div class="-layout-v -fit">
|
||||
<div class="-flex -scroll task-padding16">
|
||||
<% unless game_challenge.choose_correct_num == nil %>
|
||||
<% if game_challenge.choose_correct_num != game_challenge.challenge_chooses.count %>
|
||||
<p class="-text-danger mb10">
|
||||
<i class="fa fa-exclamation-circle font-16" ></i><span class="ml5 mr5 -text-danger"><%= game_challenge.choose_correct_num %>/<%= game_challenge.challenge_chooses.count %></span>错误
|
||||
</p>
|
||||
<% else %>
|
||||
<p class="color-light-green mb10">
|
||||
<i class="fa fa-check-circle font-16" ></i><span class="ml5 mr5"><%= game_challenge.challenge_chooses.count %>/<%= game_challenge.challenge_chooses.count %></span> 全部通过
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% game_challenge.challenge_chooses.each_with_index do |choose, index| %>
|
||||
<div class="-task-ces-box mb15 clearfix">
|
||||
<div class="-task-ces-top" onclick="toggle_test_case('0', '<%= index %>')" style="cursor:pointer">
|
||||
<i class="fa fa-caret-right mr5 font-16" ></i>
|
||||
<span class="font-14">题目<%= index + 1 %></span>
|
||||
<%# outputs = ChooseOutputs.where(:challenge_choose_id => choose.id).first %>
|
||||
<% unless choose.choose_outputs.blank? %>
|
||||
<% if choose.choose_outputs.try(:answer) != choose.standard_answer %>
|
||||
<i class="fa fa-exclamation-circle -text-danger fr mt8 ml5" ></i>
|
||||
<% else %>
|
||||
<i class="fa fa-check-circle color-light-green fr mt8 ml5 f14" ></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="fa fa-lock fr mt8" ></i>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="-task-ces-info undis" id="test_case_<%= index %>">
|
||||
<ul class=" font-14">
|
||||
<% if choose.choose_outputs.blank? %>
|
||||
<li><span class="ml30">尚未提交,暂不支持查看</span></li>
|
||||
<% else %>
|
||||
<li><span class="-task-ces-info-left color-blue">正确选项:</span><span><%= choose.standard_answer %></span></li>
|
||||
<li><span class="-task-ces-info-left color-blue">你的选项:</span><span class="color-orange"><%= choose.choose_outputs.try(:answer).nil? ? "无" : choose.choose_outputs.try(:answer) %></span></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -17,19 +17,30 @@
|
|||
<a href="javascript:void(0);" class="tab_type" style="font-size: 16px">过关任务</a>
|
||||
</li>
|
||||
<% unless @myshixun.shixun.try(:propaedeutics).blank? %>
|
||||
<li id="tab_nav_2" onclick="HoverLi1(2);">
|
||||
<a href="javascript:void(0);" class="tab_type" style="font-size: 16px">背景知识</a>
|
||||
</li>
|
||||
<li id="tab_nav_2" onclick="HoverLi1(2);">
|
||||
<a href="javascript:void(0);" class="tab_type" style="font-size: 16px">背景知识</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% unless @game_challenge.answer.blank? %>
|
||||
<li id="tab_nav_3" onclick="open_answer('<%= @game.identifier %>', '<%= @myshixun.identifier %>')">
|
||||
<% if @st == 0 %>
|
||||
<% unless @game_challenge.answer.blank? %>
|
||||
<li id="tab_nav_3" onclick="open_answer('<%= @game.identifier %>', '<%= @myshixun.identifier %>', false)">
|
||||
<a href="javascript:void(0);" class="tab_type" style="font-size: 16px">参考答案</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<li id="tab_nav_3" onclick="open_answer('<%= @game.identifier %>', '<%= @myshixun.identifier %>', true)">
|
||||
<a href="javascript:void(0);" class="tab_type" style="font-size: 16px">参考答案</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li id="tab_nav_4">
|
||||
<%= link_to '评论', shixun_discuss_shixun_path(@myshixun.shixun), :class => "tab_type", :style => "font-size: 16px", :remote => true %>
|
||||
</li>
|
||||
<span class="btn-cir-big fr mt8 mr15" >经验值:<%= @game_challenge.score %></span>
|
||||
<% if @st == 0 %>
|
||||
<span class="btn-cir-big fr mt8 mr15" >经验值:<%= @game_challenge.score %></span>
|
||||
<% else %>
|
||||
<span class="btn-cir-big fr mt8 mr15" >经验值:<%= @game_challenge.choose_score %></span>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div class="-flex -relative greytab-inner" >
|
||||
|
@ -94,7 +105,7 @@
|
|||
<% if @st != 0 %>
|
||||
<!-- 单选多选题 -->
|
||||
<%= render :partial => "games/choice_question" %>
|
||||
<% else %>
|
||||
<% else %>
|
||||
<!-- 编程题 -->
|
||||
<div class="-layout -stretch -fit -vertical centerH">
|
||||
<div class="-layout -vertical -flex -relative -bg-black -flex-basic70" id="games_repository_contents" style="overflow:hidden;">
|
||||
|
|
|
@ -37,10 +37,16 @@
|
|||
|
||||
<div class="cl"></div>
|
||||
<div style="display: flex;" class="with80 ml30">
|
||||
<% if game.try(:status) == 0 || game.try(:status) == 1 || game.try(:status) == 3 %>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_exp_<%=challenge.id %>">经验值<span class="ml5"><%= challenge.score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_grade_<%=challenge.id %>">金币<span class="ml5"><%= challenge.score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_tag_<%=challenge.id %>">技能标签<span class="ml5"><%= challenge.challenge_tags.count %></span></span>
|
||||
<% if game.try(:status) != 2 %>
|
||||
<% if challenge.st == 0 %>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_exp_<%=challenge.id %>">经验值<span class="ml5"><%= challenge.score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_grade_<%=challenge.id %>">金币<span class="ml5"><%= challenge.score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_tag_<%=challenge.id %>">技能标签<span class="ml5"><%= challenge.challenge_tags.count %></span></span>
|
||||
<% else %>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_exp_<%=challenge.id %>">经验值<span class="ml5"><%= challenge.choose_score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_grade_<%=challenge.id %>">金币<span class="ml5"><%= challenge.choose_score %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_tag_<%=challenge.id %>">技能标签<span class="ml5"><%= challenge.choose_tags_num %></span></span>
|
||||
<% end %>
|
||||
<% elsif game.try(:status) == 2 %>
|
||||
<% final_score = (game.answer_open? || @myshixun.shixun.status <= 1) ? 0 : game.final_score.to_i %>
|
||||
<% gold_score = @myshixun.shixun.status <= 1 ? 0 : (game.answer_open? ? -challenge.score.to_i : game.final_score.to_i) %>
|
||||
|
@ -48,6 +54,7 @@
|
|||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_grade_<%=challenge.id %>">金币<span class="<%= gold_score < 0 ? "u-color-light-red" : "color-light-green" %> ml5"><%= gold_score < 0 ? gold_score : "+"+gold_score.to_s %></span></span>
|
||||
<span class="color-dark-grey font-12 mr15 info-partly" id="shixun_tag_<%=challenge.id %>">技能标签<span class="color-light-green ml5">+<%= (game.answer_open? || @myshixun.shixun.status <= 1) ? 0 : challenge.challenge_tags.count %></span></span>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,18 @@
|
|||
$("#all_task_show").html("<%= j (render :partial => "games_list") %>");
|
||||
$("#all_task_show").hide();
|
||||
fadein = 0;
|
||||
// 选择题
|
||||
<% if params[:choose] == "1" %>
|
||||
<% if @had_done == 0 %>
|
||||
$("#code_estimate").html("<a href='<%= next_step_myshixun_game_path(@game, :myshixun_id => @myshixun) %>' class='task-btn task-btn-blue mr15 mt8' id='next_step' data-remote='true'>下一关</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 0}) %>";
|
||||
<% else %>
|
||||
$("#code_estimate").html("<a href='<%= shixun_path(@myshixun.shixun) %>' class='task-btn task-btn-blue mt8 mr15' >退出实训</a>");
|
||||
var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game => @game, :myshixun => @myshixun, :had_done => 1}) %>";
|
||||
<% end %>
|
||||
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
|
||||
pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight);
|
||||
<% end %>
|
||||
<% else %>
|
||||
$("#all_task_show").html("<%= j (render :partial => "games_list") %>");
|
||||
$("#all_task_tab").trigger("click"); // 模拟全部任务点击事件
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<%= favicon %>
|
||||
<%= 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' %>
|
||||
<%= 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', 'css/magic-check' %>
|
||||
<%= javascript_include_tag 'edu/application', 'edu/edu_tpi' %>
|
||||
<%= call_hook :view_layouts_base_html_head %>
|
||||
<!-- page specific tags -->
|
||||
|
|
|
@ -118,6 +118,12 @@ RedmineApp::Application.routes.draw do
|
|||
get 'index_up'
|
||||
get 'index_down'
|
||||
match 'update_evaluation', :via => [:get, :post, :put]
|
||||
match 'add_choose_question', :via => [:get, :post]
|
||||
post 'new_choose_question'
|
||||
match 'choose_type_show', :via => [:get, :post]
|
||||
match 'edit_choose_question', :via => [:get, :post]
|
||||
match 'update_choose_question', :via => [:get, :post]
|
||||
delete 'destroy_challenge_choose'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddChallengeChooseIdToChallengeTags < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :challenge_tags, :challenge_question_id, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class ModifyChallengeQuestionIdForChallengeTags < ActiveRecord::Migration
|
||||
def up
|
||||
rename_column :challenge_tags, :challenge_question_id, :challenge_choose_id
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class ModifyTypeForChallengeChooses < ActiveRecord::Migration
|
||||
def up
|
||||
rename_column :challenge_chooses, :type, :category
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class ModifyCorrectTypeForChooseOutputs < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :choose_outputs, :correct, :boolean
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -121,9 +121,10 @@ $(function(){
|
|||
});
|
||||
|
||||
// 查看参考答案
|
||||
function open_answer(game, myshixun){
|
||||
function open_answer(game, myshixun, choose){
|
||||
$.ajax({
|
||||
url: "/myshixuns/" + myshixun + "/stages/" + game + "/answer",
|
||||
data:{choose: choose},
|
||||
dataType: "script"
|
||||
})
|
||||
}
|
||||
|
@ -150,11 +151,11 @@ function open_answer(game, myshixun){
|
|||
|
||||
// 选择题选择答案
|
||||
function choice_answer(st, nThis){
|
||||
if(st == "1"){
|
||||
if(st == "2"){
|
||||
//$(nThis).hasClass("card-check") ? $(nThis).removeClass("card-check") : $(nThis).addClass("card-check");
|
||||
$(nThis).toggleClass("card-check");
|
||||
$(nThis).toggleClass("color_white");
|
||||
} else if (st == "2"){
|
||||
} else if (st == "1"){
|
||||
var choice = $(".color_white");
|
||||
choice.removeClass("card-check");
|
||||
choice.removeClass("color_white");
|
||||
|
|
Loading…
Reference in New Issue