Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
huang 2015-11-17 20:24:44 +08:00
commit 9cf5a92a44
6 changed files with 23 additions and 25 deletions

View File

@ -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
@ -77,7 +77,6 @@ class ExerciseController < ApplicationController
end
def edit
@exercise = Exercise.find params[:id]
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@ -88,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
@ -104,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'}
@ -114,7 +114,7 @@ class ExerciseController < ApplicationController
# 添加题目
# question_type 1单选 2多选 3填空题
def create_exercise_question
question_title = params[:exercise_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title]
option = {
:question_title => question_title,
:question_type => params[:question_type] || 1,
@ -128,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
@ -138,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
@ -185,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
@ -203,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

View File

@ -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));">
保存

View File

@ -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();}
}
//修改标题时确定按钮

View File

@ -9,7 +9,7 @@
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="1" type="hidden">
<input name="questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
<input name="question_title" id="question_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
</div>
<div class="ur_editor_content">
<ul>

View File

@ -1,2 +1 @@
<%#= render :partial => 'exercise_form'%>
111
<%= render :partial => 'exercise_form'%>

View File

@ -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();