This commit is contained in:
parent
2c9c87c3c6
commit
452cf1c854
|
@ -1,7 +1,7 @@
|
|||
class ExerciseController < ApplicationController
|
||||
layout "base_courses"
|
||||
|
||||
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit]
|
||||
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit,:update]
|
||||
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
|
||||
|
||||
def index
|
||||
|
@ -26,12 +26,12 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
# 已提交问卷的用户不能再访问该界面
|
||||
if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?)
|
||||
redirect_to poll_index_url(:course_id=> @course.id)
|
||||
redirect_to exercise_index_url(:course_id=> @course.id)
|
||||
else
|
||||
@can_edit_poll = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin?
|
||||
@percent = get_percent(@exercise,User.current)
|
||||
poll_questions = @poll.poll_questions
|
||||
@poll_questions = paginateHelper poll_questions,5 #分页
|
||||
exercise_questions = @exercise.exercise_questions
|
||||
@exercise_questions = paginateHelper exercise_questions,5 #分页
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'base_courses'}
|
||||
end
|
||||
|
@ -44,9 +44,9 @@ class ExerciseController < ApplicationController
|
|||
:course_id => @course.id,
|
||||
:exercise_status => 1,
|
||||
:user_id => User.current.id,
|
||||
:time => Time.now,
|
||||
:end_time => Time.now,
|
||||
:publish_time => Time.now,
|
||||
:time => "",
|
||||
:end_time => "",
|
||||
:publish_time => "",
|
||||
:exercise_description => ""
|
||||
}
|
||||
@exercise = Exercise.create option
|
||||
|
@ -87,6 +87,7 @@ class ExerciseController < ApplicationController
|
|||
@exercise.exercise_description = params[:exercise][:exercise_description]
|
||||
@exercise.time = params[:exercise][:time]
|
||||
@exercise.end_time = params[:exercise][:end_time]
|
||||
@exercise.publish_time = params[:exercise][:publish_time]
|
||||
if @exercise.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -103,7 +104,7 @@ class ExerciseController < ApplicationController
|
|||
# 统计结果
|
||||
def statistics_result
|
||||
@exercise = Exercise.find(params[:id])
|
||||
exercise_questions = @exercise.poll_questions
|
||||
exercise_questions = @exercise.exercise_questions
|
||||
@exercise_questions = paginateHelper exercise_questions, 5
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses'}
|
||||
|
@ -127,7 +128,7 @@ class ExerciseController < ApplicationController
|
|||
:answer_position => i,
|
||||
:answer_text => answer
|
||||
}
|
||||
@exercise_questions.poll_answers.new question_option
|
||||
@exercise_questions.exercise_answers.new question_option
|
||||
end
|
||||
end
|
||||
# 如果是插入的话,那么从插入的这个id以后的question_num都将要+1
|
||||
|
@ -137,7 +138,7 @@ class ExerciseController < ApplicationController
|
|||
# @exercise_question_num = params[:quest_num].to_i
|
||||
@exercise_questions.question_number = params[:quest_num].to_i + 1
|
||||
end
|
||||
if @poll_questions.save
|
||||
if @exercise_questions.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -184,7 +185,7 @@ class ExerciseController < ApplicationController
|
|||
@exercise_question = ExerciseQuestion.find params[:exercise_question]
|
||||
@exercise = @exercise_question.exercise
|
||||
exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}")
|
||||
poll_questions.each do |question|
|
||||
exercise_questions.each do |question|
|
||||
question.question_number -= 1
|
||||
question.save
|
||||
end
|
||||
|
@ -202,7 +203,7 @@ class ExerciseController < ApplicationController
|
|||
@exercise.publish_time = Time.now
|
||||
if @exercise.save
|
||||
if params[:is_remote]
|
||||
redirect_to poll_index_url(:course_id => @course.id)
|
||||
redirect_to exercise_index_url(:course_id => @course.id)
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
<%= form_for(@exercise,
|
||||
:html => { :multipart => true },
|
||||
:url => {:controller => 'exercise',
|
||||
:action => 'update',
|
||||
:course_id => @course.id
|
||||
},:remote=>true ) do |f| %>
|
||||
<%= form_for @exercise, :remote=>true do |f| %>
|
||||
<div class="testContainer">
|
||||
<div>
|
||||
<input name="exercise[exercise_name]" maxlength="100" id="exercise_name" class="testTitle mb10" type="text" placeholder="测验标题" value="<%=@exercise.exercise_name%>" />
|
||||
|
@ -24,7 +19,7 @@
|
|||
</div>
|
||||
<div class="fl ml10 f14 fontGrey2"><span class="mr5">考试时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" value="<%=exercise.time %>" />分钟</div>
|
||||
<div class="cl"></div>
|
||||
<textarea class="testDes mt10" name="exercise[exercise_description]" id="exercise_description" value="<%=exercise.exercise_description %>" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。您可以在此处填写测验相关说明。" ></textarea>
|
||||
<textarea class="testDes mt10" name="exercise[exercise_description]" id="exercise_description" placeholder="发布须知:试题类型有选择和填空两种,其中选择题包括单选题和多选题。您可以在此处填写测验相关说明。" ><%=exercise.exercise_description %></textarea>
|
||||
<div class="ur_editor_footer" style="padding-top: 10px;">
|
||||
<a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));">
|
||||
保存
|
||||
|
|
|
@ -231,7 +231,7 @@
|
|||
//添加标题时确定按钮
|
||||
function add_poll_question(doc)
|
||||
{
|
||||
var title = $.trim($("#poll_questions_title").val());
|
||||
var title = $.trim($("#question_title").val());
|
||||
if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();}
|
||||
}
|
||||
//修改标题时确定按钮
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
<%#= render :partial => 'exercise_form'%>
|
||||
111
|
||||
<%= render :partial => 'exercise_form'%>
|
|
@ -0,0 +1,4 @@
|
|||
$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>");
|
||||
$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>");
|
||||
$("#polls_head_edit").hide();
|
||||
$("#polls_head_show").show();
|
Loading…
Reference in New Issue