dev_local
cxt 6 years ago
parent 0c1622264c
commit e2fef849e2

@ -179,9 +179,11 @@ class ExerciseController < ApplicationController
ex_question = @exercise.exercise_questions.where(shixun_id: shixun.id).first
if ex_question.present?
ex_question.update_attributes(question_score: params[:ques_scores][index])
ex_question.exercise_shixun_challenges.update_all(question_score: params[:ques_scores][index])
else
ex_question = ExerciseQuestion.create(exercise_id: @exercise.id, question_score: arams[:ques_scores][index],
shixun_id: shixun.id, question_title: shixun.name, question_type: 5, question_number: 0)
shixun_id: shixun.id, question_title: shixun.name, question_type: 5,
question_number: 0, exercise_level_setting_id: level_setting.id)
shixun.challenges.each_with_index do |challenge, index|
ex_shixun_challenge = ExerciseShixunChallenge.new(challenge_id: challenge.id, shixun_id: shixun.id, exercise_question_id: ex_question.id,
question_score: params[:ques_scores][index], position: index + 1)
@ -206,9 +208,7 @@ class ExerciseController < ApplicationController
if exercise.save
create_exercises_list exercise
@exercise = exercise
respond_to do |format|
format.js
end
redirect_to edit_exercise_path(@exercise)
end
end
end

@ -1,5 +1,18 @@
# encoding: utf-8
module ExerciseHelper
def shixun_question_level level
case level
when 1
"初级题"
when 2
"中级题"
when 3
"高级题"
when 4
"顶级题"
end
end
def exercise_shixun_json_data shixuns
shixuns.map do |shixun|
shixun_owner = shixun.owner.try(:show_name)

@ -51,4 +51,8 @@ class Exercise < ActiveRecord::Base
pluck(:exercise_question_id))
end
end
def level_setting level
self.exercise_level_settings.where(level: level).first
end
end

@ -1,4 +1,4 @@
<% @exercise.exercise_questions.each do |eq| %>
<% @exercise.exercise_questions.where("question_type != 5").each do |eq| %>
<div id='poll_questions_<%= eq.id %>' class="exercise_question">
<% case eq.question_type %>
<% when 1 %>

@ -4,7 +4,7 @@
:action => 'create',
:course_id => @course.id
},
:method => :post, :remote => true) do |f| %>
:method => :post) do |f| %>
<div class="ml15 mr15 mb15">
<input class="panel-box-sizing panel-form-width-100" name="exercise[exercise_name]" maxlength="100" id="exercise_name" value="<%= @exercise.try(:exercise_name) %>" placeholder="试卷标题" style="text-align: center;"/>
</div>

@ -6,7 +6,9 @@
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_MCQ();">+&nbsp;多选题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_single();">+&nbsp;填空题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_multi();">+&nbsp;简答题</a>
<% if @exercise.try(:id).nil? || @exercise.exercise_questions.where(question_type: 5).count == 0 %>
<a href="javascript:void(0);" class="fl add_item_part" onclick="add_shixun();">+&nbsp;实训题</a>
<% end %>
<div id="hidden_div_block" class="undis">
<textarea style="display: none" id="hidden_textarea"></textarea>

@ -2,7 +2,7 @@
<div nhname="new_exercise_mc_q">
<%= form_for(ExerciseQuestion.new,
:html => { :multipart => true, :id => "new_exercise_question"},
:url=>create_exercise_question_exercise_path(exercise.id)) do |f| %>
:url=>update_shixun_block_exercise_path(exercise.id)) do |f| %>
<!-- <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 answer_Temp" id="answer_Temp">-->
<!-- <p class="fl mt15 font-16 mb10">实训题</p>-->
<!-- <input name="question_type" value="5" type="hidden">-->
@ -39,18 +39,22 @@
<% end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="answer_Temp">
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="shixun_question_block">
<div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">实训题</div>
<% second_questions = @exercise.level_setting(2).try(:exercise_questions) %>
<% third_questions = @exercise.level_setting(3).try(:exercise_questions) %>
<% fourth_questions = @exercise.level_setting(4).try(:exercise_questions) %>
<% for i in 1..5 %>
<% questions_list = @exercise.level_setting(i).try(:exercise_questions) %>
<div class="<%= questions_list.try(:count).to_i > 0 ? '' : 'none' %>" id="edit_first_block">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<span class="Titlefont"><%= shixun_question_level i %></span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121"/> 分/题
<span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121" value=""/> 分/题
<div class="colorFF8121sum">*大于等于0且不能大于100</div>
<div class="colorFF8121sum">*不能为空</div>
<div class="colorFF8121sum">*必须大于等于0</div>
@ -96,6 +100,8 @@
</div>
</div>
</div>
<% end %>
<div class="fl mb10 shixunsboxs">
<div class="newshixunbox">

@ -61,7 +61,7 @@
if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
msg_list_loading = true;
$.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>&page="+page, function(json) {
$.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>?page="+page, function(json) {
if (json) {
msg_list_loading = false;
var str = "";

Loading…
Cancel
Save