在线测验改版

This commit is contained in:
cxt 2017-03-03 14:43:51 +08:00
parent baabce13b2
commit f30507b6f0
39 changed files with 953 additions and 302 deletions

View File

@ -3,7 +3,8 @@ class ExerciseController < ApplicationController
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy,
:commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,
:show_student_result,:student_exercise_list]
:show_student_result,:student_exercise_list, :update_question_num,
:send_to_course, :get_student_uncomplete_question, :edit_question_score]
before_filter :find_course, :only => [:index,:new,:create]
include ExerciseHelper
@ -68,8 +69,8 @@ class ExerciseController < ApplicationController
eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
end
score = calculate_student_score(@exercise, User.current)
@exercise_user.update_attributes(:score => score)
#score = calculate_student_score(@exercise, User.current)
#@exercise_user.update_attributes(:objective_score => score, :score => (score + (@exercise_user.subjective_score > 0 ? @exercise_user.subjective_score : 0)))
end
# @percent = get_percent(@exercise,User.current)
@exercise_questions = @exercise.exercise_questions
@ -133,8 +134,8 @@ class ExerciseController < ApplicationController
@exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1)
@exercise.publish_time = params[:exercise][:publish_time]
@exercise.show_result = params[:show_result].blank? ? 1 : params[:show_result]
@exercise.question_random = params[:question_random]
@exercise.choice_random = params[:choice_random]
@exercise.question_random = params[:question_random] ? 0 : 1
@exercise.choice_random = params[:choice_random] ? 0 : 1
if @exercise.save
respond_to do |format|
format.js
@ -314,6 +315,7 @@ class ExerciseController < ApplicationController
answer_standart.save
end
@exercise_question.save
@exercise = @exercise_question.exercise
respond_to do |format|
format.js
end
@ -330,8 +332,10 @@ class ExerciseController < ApplicationController
#@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1")
elsif @exercise_question.question_type == 2
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1")
else
elsif @exercise_question.question_type == 3
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1")
else
ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 4).update_all(" question_number = question_number - 1")
end
# @exercise_question_num = params[:quest_num].to_i
# @exercise_questions.question_number = params[:quest_num].to_i - 1
@ -348,6 +352,88 @@ class ExerciseController < ApplicationController
end
end
#题目上移/下移
def update_question_num
@exercise_question = ExerciseQuestion.find params[:ques_id]
exercise_questions = @exercise.exercise_questions
if @exercise_question
if params[:opr] == 'up' && @exercise_question.question_number > 1
@before_que = exercise_questions.where("question_type = #{@exercise_question.question_type} and question_number = #{@exercise_question.question_number - 1}").first
if @before_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number - 1)
@before_que.update_attribute('question_number', @before_que.question_number + 1)
end
elsif params[:opr] == 'down' && @exercise_question.question_number < exercise_questions.count
@after_que = exercise_questions.where("question_type = #{@exercise_question.question_type} and question_number = #{@exercise_question.question_number + 1}").first
if @after_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number + 1)
@after_que.update_attribute('question_number', @after_que.question_number - 1)
end
end
respond_to do |format|
format.js
end
end
end
# 发送试卷
def send_to_course
params[:course_ids].each do |course|
option = {
:exercise_name => @exercise.exercise_name,
:exercise_status => 1,
:user_id => User.current.id,
:show_result => 1,
:course_id => course.to_i,
:time => @exercise.time,
:exercise_description => @exercise.exercise_description
}
exercise = Exercise.create option
@exercise.exercise_questions.each do |q|
option = {
:question_title => q[:question_title],
:question_type => q[:question_type] || 1,
:question_number => q[:question_number],
:question_score => q[:question_score]
}
exercise_question = exercise.exercise_questions.new option
for i in 1..q.exercise_choices.count
choice_option = {
:choice_position => i,
:choice_text => q.exercise_choices[i-1][:choice_text]
}
exercise_question.exercise_choices.new choice_option
end
for i in 1..q.exercise_standard_answers.count
standard_answer_option = {
:exercise_choice_id => q.exercise_standard_answers[i-1][:exercise_choice_id],
:answer_text => q.exercise_standard_answers[i-1][:answer_text]
}
exercise_question.exercise_standard_answers.new standard_answer_option
end
end
exercise.save
end
respond_to do |format|
format.js
end
end
# 搜索当前用户任教的班级(不包含该试卷所在的班级)
def search_courses
@user = User.current
if !params[:name].nil?
search = "%#{params[:name].to_s.strip.downcase}%"
@courses = @user.courses.not_deleted.where("courses.id != #{params[:course].to_i} and (#{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p)",:p=>search).reorder("created_at desc").select {|course| @user.allowed_to?(:as_teacher,course)}
else
@courses = @user.courses.not_deleted.where("courses.id != #{params[:course].to_i}").reorder("created_at desc").select {|course| @user.allowed_to?(:as_teacher,course)}
end
respond_to do |format|
format.js
end
end
# 发布试卷
def publish_exercise
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
@ -400,12 +486,12 @@ class ExerciseController < ApplicationController
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc")
student_id = @course.student.blank? ? "(-1)" : "(" + @course.student.map{|student| student.student_id}.join(",") + ")"
@exercise_count = @exercise.exercise_users.where("score is not NULL and user_id in #{student_id}").count
@exercise_count = @exercise.exercise_users.where("commit_status = 1 and user_id in #{student_id}").count
if @is_teacher || (!@exercise.exercise_users.where("user_id = #{User.current.id} and user_id in #{student_id}").empty? && @exercise.end_time <= Time.now)
@exercise_users_list = @exercise.exercise_users.where("score is not NULL and user_id in #{student_id}")
@exercise_users_list = @exercise.exercise_users.where("user_id in #{student_id}")
@show_all = true;
elsif !@exercise.exercise_users.where("user_id = #{User.current.id} and user_id in #{student_id}").empty? && @exercise.end_time > Time.now
@exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL and user_id in #{student_id}",User.current.id)
@exercise_users_list = @exercise.exercise_users.where("user_id = ? and user_id in #{student_id}",User.current.id)
else
@exercise_users_list = []
end
@ -469,21 +555,23 @@ class ExerciseController < ApplicationController
else
complete = 0;
end
is_answer = User.current.exercise_answer.where(:exercise_question_id => params[:exercise_question_id].to_i).count > 0
@percent = get_percent(@exercise,User.current)
render :json => {:text => "ok",:complete => complete,:percent => format("%.2f" ,@percent)}
render :json => {:text => "ok",:complete => complete,:percent => format("%.2f" ,@percent),:is_answer => is_answer}
else
render :json => {:text => "failure"}
end
else
#pv不为空则当前选项之前已被选择再次点击则是不再选择该项故删除该答案
if ea.delete
is_answer = User.current.exercise_answer.where(:exercise_question_id => params[:exercise_question_id].to_i).count > 0
@percent = get_percent(@exercise, User.current)
render :json => {:text => "false" ,:percent => format("%.2f" , @percent)}
render :json => {:text => "false" ,:percent => format("%.2f" , @percent),:is_answer => is_answer}
else
render :json => {:text => "failure"}
end
end
elsif eq.question_type == 3
elsif eq.question_type == 3 || eq.question_type == 4
#单行文本,多行文本题
ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id], User.current.id)
if ea.nil?
@ -511,6 +599,7 @@ class ExerciseController < ApplicationController
render :json => {:text => "failure"}
end
end
else
# ea不为空说明用户之前已作答
if params[:answer_text].nil? || params[:answer_text].blank?
@ -542,60 +631,84 @@ class ExerciseController < ApplicationController
def commit_exercise
# 老师不需要提交
if User.current.allowed_to?(:as_teacher,@course)
if @exercise.publish_time.nil? || @exercise.publish_time <= Time.now
@exercise.update_attributes(:show_result => params[:show_result])
@exercise.update_attributes(:exercise_status => 2)
@exercise.update_attributes(:publish_time => Time.now)
course = @exercise.course
course.members.each do |m|
@exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
end
redirect_to exercise_url(@exercise)
return
elsif @exercise.publish_time > Time.now
@exercise.update_attributes(:show_result => params[:show_result])
redirect_to exercise_url(@exercise)
return
end
@exercise.update_attributes(:show_result => params[:show_result])
redirect_to exercise_url(@exercise)
# if @exercise.publish_time.nil? || @exercise.publish_time <= Time.now
# @exercise.update_attributes(:exercise_status => 2)
# @exercise.update_attributes(:publish_time => Time.now)
# course = @exercise.course
# course.members.each do |m|
# @exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
# end
# redirect_to exercise_url(@exercise)
# return
# elsif @exercise.publish_time > Time.now
# redirect_to exercise_url(@exercise)
# return
# end
# redirect_to exercise_url(@exercise)
# REDO: 提示提交成功
else
# 更新提交状态
cur_exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current, @exercise.id).first
cur_exercise_user.update_attributes(:status => 1, :commit_status => 1)
# 答题过程中需要统计完成量
@uncomplete_question = get_uncomplete_question(@exercise, User.current)
#@uncomplete_question = get_uncomplete_question(@exercise, User.current)
# 获取改学生的考试得分
@score = calculate_student_score(@exercise, User.current)
#@score = calculate_student_score(@exercise, User.current)
# @score = 100
if @uncomplete_question.count < 1
# 查看是否有已提交记录
cur_exercise_user.score = @score
if cur_exercise_user.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
else
@status = 2 #未知错误
end
else
@status = 1 #有未做得必答题
end
@save = params[:save].to_i if params[:save]
# if @uncomplete_question.count < 1
# # 查看是否有已提交记录
# cur_exercise_user.score = @score
# if cur_exercise_user.save
# #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
# @status = 0 #提交成功
# else
# @status = 2 #未知错误
# end
# else
# @status = 1 #有未做得必答题
# end
# @save = params[:save].to_i if params[:save]
respond_to do |format|
format.js
end
end
end
# 获取学生未答情况
def get_student_uncomplete_question
time_limit = @exercise.time == -1 || @exercise.time.nil?
uncomplete_count = get_uncomplete_question(@exercise, User.current).count
render :json => {:time_limit => time_limit, :uncomplete_count => uncomplete_count}
end
# 主观题打分
def edit_question_score
exercise_user = @exercise.exercise_users.where(:user_id => params[:user_id].to_i).first
exercise_answer = ExerciseAnswer.where(:user_id => params[:user_id].to_i, :exercise_question_id => params[:exercise_question_id].to_i).first
exercise_question = ExerciseQuestion.where(:id => params[:exercise_question_id].to_i).first
if exercise_user && exercise_answer && exercise_question
score = params[:score].to_i
unless score > exercise_question.question_score || score < 0
exercise_answer.update_attributes(:score => score)
exercise_user.update_attributes(:subjective_score => calculate_subjective_score(@exercise, exercise_user.user))
exercise_user.update_attributes(:score => ((exercise_user.objective_score > 0 ? exercise_user.objective_score : 0) + (exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
render :json => {:status => 1, :score => score, :total_score => exercise_user.score}
else
render :json => {:status => 2}
end
else
render :json => {:status => 0}
end
end
#查看学生的答卷情况
def show_student_result
@user = User.find params[:user_id]
@can_edit_excercise = false
@exercise_questions = @exercise.exercise_questions
score = calculate_student_score(@exercise, @user)
eu = get_exercise_user(@exercise.id, @user.id)
eu.update_attributes(:score => score)
#score = calculate_student_score(@exercise, @user)
#eu = get_exercise_user(@exercise.id, @user.id)
#eu.update_attributes(:score => score)
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
@left_nav_type = 8
respond_to do |format|
@ -644,6 +757,19 @@ class ExerciseController < ApplicationController
score = score1 + score2 + score3
end
# 计算主观题总分
def calculate_subjective_score exercise, user
score = 0
exercise_questions = exercise.exercise_questions.where(:question_type => 4)
exercise_answers = user.exercise_answer.where(:exercise_question_id => exercise_questions.map(&:id))
exercise_answers.each do |ea|
if ea.score != -1
score += ea.score
end
end
score
end
#导入试卷的弹框
def other_exercise
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的试卷 进行导入
@ -741,7 +867,7 @@ class ExerciseController < ApplicationController
sheet1 = book.create_worksheet :name => "exercise"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)])
sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_objective_score),l(:excel_subjective_score),l(:excel_f_score),l(:excel_answer_time)])
count_row = 1
items.each do |exercise|
sheet1[count_row,0]=exercise.user.id
@ -749,9 +875,10 @@ class ExerciseController < ApplicationController
sheet1[count_row,2] = exercise.user.login
sheet1[count_row,3] = exercise.user.user_extensions.student_id
sheet1[count_row,4] = exercise.user.mail
sheet1[count_row,5] = ""
sheet1[count_row,6] = exercise.score
sheet1[count_row,7] = format_time(exercise.created_at)
sheet1[count_row,5] = exercise.objective_score == -1 ? "0.0" : format("%.1f",exercise.objective_score)
sheet1[count_row,6] = exercise.subjective_score == -1 ? "0.0" : format("%.1f",exercise.subjective_score)
sheet1[count_row,7] = exercise.score
sheet1[count_row,8] = exercise.commit_status == 0 ? l(:excel_no_answer) : format_time(exercise.created_at)
count_row += 1
end
book.write xls_report

View File

@ -4,27 +4,25 @@
function resetQuestion<%=exercise_question.id%>()
{
$("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>");
$("#poll_answers_<%=exercise_question.id%>").html("<label name='candiate_items'>参考答案<span class='ur_index'></span>&nbsp;&nbsp;&nbsp;</label>" +
"<textarea class='candiate_answer' style='width: 600px; height: 90px;' name='exercise_choice' placeholder='如有参考答案,请输入参考答案' type='text'><%=exercise_question.exercise_standard_answers.empty? ? '' : exercise_question.exercise_standard_answers.first.answer_text %></textarea>");
}
</script>
<div class="questionContainer" style="width: 680px;">
<div class="mb10 ur_item">
<label class="ml25">分值<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input id="poll_question_score_<%=exercise_question.id %>" value="<%=exercise_question.question_score %>" type="text" name="question_score" style="width:60px; text-align:center; padding-left:0px;">分
<input id="poll_question_score_<%=exercise_question.id %>" value="<%=exercise_question.question_score %>" name="question_score" style="width:60px; text-align:center; padding-left:0px;">分
<div class="cl"></div>
</div>
<div class="ur_editor_title">
<label class="questionLabel mt8 ml25">问题:&nbsp;&nbsp;</label>
<input name="question_type" value="<%=exercise_question.question_type %>" type="hidden">
<textarea name="question_title" style="width: 600px;" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入问答题的题干" type="text" onfocus="autoHeight('#poll_questions_title_<%=exercise_question.id %>',30)"><%=exercise_question.question_title %></textarea>
<textarea name="question_title" style="width: 600px;" id="poll_questions_title_<%=exercise_question.id %>" class="questionTitle" placeholder="请输入问答题的题干" onfocus="autoHeight('#poll_questions_title_<%=exercise_question.id %>',30)"><%=exercise_question.question_title %></textarea>
</div>
<div class="ur_editor_content" id="edit_multi">
<div id="poll_answers_<%=exercise_question.id%>" class="multi_input">
<label name='candiate_items'>参考答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<textarea class="candiate_answer" style="width: 600px; height: 90px;" name="exercise_choice" placeholder="如有参考答案,请输入参考答案" type="text"><%=exercise_question.exercise_standard_answers.empty? ? '' : exercise_question.exercise_standard_answers.first.answer_text %></textarea>
<textarea class="candiate_answer" style="width: 600px; height: 90px;" name="exercise_choice" id="poll_questions_answer_<%=exercise_question.id %>" placeholder="如有参考答案,请输入参考答案" type="text"><%=exercise_question.exercise_standard_answers.empty? ? '' : exercise_question.exercise_standard_answers.first.answer_text %></textarea>
</div>
<div class="cl"></div>
</div>

View File

@ -1,10 +1,10 @@
<%# has_commit = has_commit_poll?(poll.id ,User.current)%>
<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%>
<% if @is_teacher%>
<div>
<div title="<%= exercise.exercise_name %>">
<div style="width: 500px;float: left;">
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue mw450", :title => "#{exercise_name}" %>
<div class="pr">
<div title="<%= exercise.exercise_name %>">
<div style="width: 640px;float: left;">
<%= link_to (index.to_i+1).to_s+". "+exercise_name, student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "polls_title polls_title_w fl c_dblue mw450", :title => "#{exercise_name}" %>
<% if exercise.exercise_status == 1 %>
<span class="exercise_status_nop fl mt3"></span>
<% elsif exercise.exercise_status == 2 %>
@ -12,23 +12,34 @@
<% else %>
<span class="exercise_status_end fl mt3"></span>
<% end%>
</div>
</div>
</div>
<% if exercise.exercise_status == 1 %>
<% end_time_status = exercise.end_time.nil? ? 1 : (exercise.end_time <= Time.now ? 2 : 3) %>
<div><a href="javascript:" class="pollsbtn btn_pu fr mr10 ml5" onclick="exercise_submit(<%=end_time_status %>,<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></div>
<% elsif exercise.exercise_status == 2%>
<div><a href="javascript:" class="pollsbtn btn_de fr mr10 ml5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></div>
<% else%>
<div class="pollsbtn fr mr10 pollsbtn_grey ml5">发布试卷</div>
<% end%>
<% if exercise.exercise_status == 1%>
<div class="pollsbtn fr mr10 pollsbtn_grey">统计结果</div>
<% else %>
<div><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%></div>
<% end%>
<div class="homepagePostSetting" id="exercise_opr_<%=exercise.id %>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<% if exercise.exercise_status == 1 %>
<li><a href="<%= edit_exercise_path(exercise.id) %>" class="postOptionLink" title="编辑试卷">编&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;辑</a></li>
<% end%>
<li><a href="<%= exercise_path(exercise.id) %>" class="postOptionLink" title="查看试卷">查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;看</a></li>
<% if exercise.exercise_status == 1 %>
<% end_time_status = exercise.end_time.nil? ? 1 : (exercise.end_time <= Time.now ? 2 : 3) %>
<li><a href="javascript:" class="postOptionLink" onclick="exercise_submit(<%=end_time_status %>,<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li>
<% elsif exercise.exercise_status == 2%>
<li><a href="javascript:" class="postOptionLink" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li>
<% else%>
<% end%>
<% if exercise.exercise_status == 1%>
<% else %>
<li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "postOptionLink"%></li>
<% end%>
<li><a href="javascript:void(0)" onClick="delete_exercise(<%=exercise.id %>);" title="删除试卷" class="postOptionLink">删&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;除</a></li>
</ul>
</li>
</ul>
</div>
<div class="clear"></div>
</div>
<div class="cl"></div>
@ -39,15 +50,11 @@
<% if exercise.exercise_status > 1 %>
<span class="c_grey fl mr15">已提交:<span class="c_blue"><%= exercise.exercise_users.where("commit_status = 1").count %></span></span>
<span class="c_grey fl mr15">未提交:<span class="c_blue"><%= exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count %></span></span>
<% if exercise.exercise_status == 3 %>
<% count = exercise.exercise_users.where("commit_status = 1 and subjective_score = -1").count %>
<span class="c_grey fl mr15">未批:<span class="<%= count > 0 ? 'c_red' : '' %>"><%= count %></span></span>
<% end %>
<% end %>
<div id="exercise_opr_<%=exercise.id %>" class="none fr">
<a href="javascript:void(0)" onClick="delete_exercise(<%=exercise.id %>);" title="删除试卷" class="ex_icon_de mt0"></a>
<% if exercise.exercise_status == 1 %>
<%= link_to '', edit_exercise_path(exercise.id), :title => "编辑试卷", :class => "ex_icon_edit mt0"%>
<% end%>
</div>
<div class="clear"></div>
</div>
<% else%>

View File

@ -0,0 +1,10 @@
<% if !courses.empty? %>
<% courses.each do |course| %>
<ul class="courseSend" style="width: 370px;">
<li>
<input id="course_id_<%= course.id %>" name="course_ids[]" type="checkbox" value="<%= course.id %>" class="courseSendCheckbox"/>
<label for="course_id_<%= course.id %>" class="chooseCourseName" title="<%=course.name + ''+ (current_time_and_term_short course) + ''%>"><%=course.name + ''+ (current_time_and_term_short course) + ''%></label>
</li>
</ul>
<% end %>
<% end %>

View File

@ -286,13 +286,8 @@
</div>
<% current_score = get_current_score @exercise %>
<div class="" style="display: <%= current_score[0] == 0 ? "none" : "" %>" id="current_score_div">
<span class="mr20">单选题&nbsp;<%= @exercise.exercise_questions.where("question_type=1").count %>&nbsp;题,共<%= current_score[1] %>分</span>
<span class="mr20">多选题&nbsp;<%= @exercise.exercise_questions.where("question_type=2").count %>&nbsp;题,共<%= current_score[2] %>分</span>
<span class="mr20">填空题&nbsp;<%= @exercise.exercise_questions.where("question_type=3").count %>&nbsp;题,共<%= current_score[3] %>分</span>
<span class="mr20">问答题&nbsp;<%= @exercise.exercise_questions.where("question_type=4").count %>&nbsp;题,共<%= current_score[4] %>分</span>
<span class="fr">合计&nbsp;<font class="c_red"><%= @exercise.exercise_questions.count %></font>&nbsp;题,共<font class="c_red"><%= current_score[0] %></font>分</span>
<div class="cl"></div>
<div id="total_questions_score" style="display: <%= @exercise.exercise_questions.count != 0 ? '' : 'none' %>">
<%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score} %>
</div>
<div id="exercise_submit">

View File

@ -57,26 +57,40 @@
<span class="fr">剩余时长:<span class="c_red" id="rest_hours"></span>&nbsp;小时&nbsp;<span class="c_red" id="rest_minutes"></span>&nbsp;分钟&nbsp;<span class="c_red" id="rest_seconds"></span>&nbsp;秒</span>
-->
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
<div class="cl"></div>
</div>
<% mc_question_list = exercise.exercise_questions.where("question_type=1").shuffle %>
<% mcq_question_list = exercise.exercise_questions.where("question_type=2").shuffle %>
<% single_question_list = exercise.exercise_questions.where("question_type=3").shuffle %>
<% current_score = get_current_score exercise %>
<div id="total_questions_score" style="display: <%= exercise.exercise_questions.count != 0 ? '' : 'none' %>">
<%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => exercise, :current_score => current_score} %>
</div>
<% mc_question_list = exercise.exercise_questions.where("question_type=1") %>
<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %>
<% single_question_list = exercise.exercise_questions.where("question_type=3") %>
<% multi_question_list = exercise.exercise_questions.where("question_type=4") %>
<% if exercise.question_random == 1 %>
<% mc_question_list = mc_question_list.shuffle %>
<% mcq_question_list = mcq_question_list.shuffle %>
<% single_question_list = single_question_list.shuffle %>
<% multi_question_list =multi_question_list.shuffle %>
<% end %>
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<div class="exercise_title">
第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<% exercise_choices = exercise.choice_random == 1 ? exercise_question.exercise_choices.shuffle : exercise_question.exercise_choices.reorder("choice_position") %>
<% exercise_choices.each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
@ -95,6 +109,7 @@
if(dataObj.text == "ok")
{
obj.checked = true;
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
}
else
{
@ -102,7 +117,7 @@
}
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
@ -125,15 +140,17 @@
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each_with_index do |exercise_question,list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mcq_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<div class="exercise_title">
第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<% exercise_choices = exercise.choice_random == 1 ? exercise_question.exercise_choices.shuffle : exercise_question.exercise_choices.reorder("choice_position") %>
<% exercise_choices.each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
@ -157,9 +174,17 @@
{
obj.checked = false;
}
if(dataObj.is_answer)
{
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
}
else
{
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
}
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
@ -182,9 +207,10 @@
<h3 class="fontGrey3">填空题</h3>
<% single_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == single_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<div class="exercise_title">
第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
</div>
<div class="cl"></div>
<div>
@ -196,18 +222,22 @@
type: "post",
url: "<%= commit_answer_exercise_path(exercise) %>",
data: {
exercise_question_id: <%= exercise_question.id %> ,
answer_text: obj.value
exercise_question_id: <%= exercise_question.id %>,
answer_text: $(obj).val().trim()
},
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
if(dataObj.text != ""){
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
} else{
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
}
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %>" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>>
@ -217,16 +247,122 @@
</div>
<% end %>
</div>
<div class="ur_buttons">
<% if exercise.time == -1 %>
<%= link_to "保存",commit_exercise_exercise_path(exercise,:save => 1),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:format => 'js',:remote=>true %>
<%= link_to "提交",commit_exercise_exercise_path(exercise), :data => {:confirm => "您确定要提交吗?"},:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:20px;",:format => 'js',:remote=>true %>
<% else %>
<%= link_to "提交",commit_exercise_exercise_path(exercise), :data => {:confirm => "您确定要提交吗?"},:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:84px;",:format => 'js',:remote=>true %>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">问答题</h3>
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == multi_question_list.count ? '' : 'border_b' %>">
<div>
<div class="exercise_title">
第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
</div>
<div class="cl"></div>
<div>
<script>
function onblur_<%= exercise_question.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_exercise_path(exercise) %>",
data: {
exercise_question_id: <%= exercise_question.id %>,
answer_text: $(obj).val().trim()
},
success: function (data) {
var dataObj = eval(data);
obj.text = dataObj.text;
if(dataObj.text != ""){
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
} else{
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
}
},
error: function () {
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<textarea style="width: 693px; height: 90px; line-height: 30px; border: 1px solid #CBCBCB;" name="exercise_choice" placeholder="在此填入答案" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="testStatus">
<p class="f14 fontGrey3">答题情况</p>
<div class="mt5">
<span class="f14 mr10 fl">单选题:</span>
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
<% end %>
<div class="cl"></div>
</div>
<div class="mt5">
<span class="f14 mr10 fl">多选题:</span>
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
<% end %>
<div class="cl"></div>
</div>
<div class="mt5">
<span class="f14 mr10 fl">填空题:</span>
<% single_question_list.each_with_index do |exercise_question, list_index| %>
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
<% end %>
<div class="cl"></div>
</div>
<div class="mt5">
<span class="f14 mr10 fl">问答题:</span>
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
<% end %>
<div class="cl"></div>
</div>
</div>
<div class="ur_buttons">
<a href="javascript:void(0)" onclick="commit_exercise_f();" class="btn_blue_64_width" style="margin-left:105px;">马上提交</a>
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
<!--RSide end-->
</div>
</div>
<script>
function commit_exercise_f(){
var str = "";
$.ajax({
type: "get",
url: "<%= get_student_uncomplete_question_exercise_path(exercise) %>",
data: {},
success: function (data) {
var dataObj = eval(data);
if(dataObj.time_limit){
if(dataObj.uncomplete_count == 0){
str = "截止日期前您还可以继续答题<br/>是否确定提交";
} else{
str = "您还有 " + dataObj.uncomplete_count + " 题没有完成,截止日期前您还可以继续答题<br/>是否确定提交";
}
} else{
if(dataObj.uncomplete_count == 0){
str = "提交后将不能继续答题<br/>是否确定提交";
} else{
str = "您还有 " + dataObj.uncomplete_count + " 题没有完成,提交后将不能继续答题<br/>是否确定提交";
}
}
var htmlvalue = '<div id="muban_popup_box" style="width:380px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="<%= commit_exercise_exercise_path(exercise) %>" class="fr sy_btn_blue mt20" data-remote="true" style="margin-right: 132px;">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt20 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 380, 140);
},
error: function () {
long_notice_box("网络异常,提交失败,请确认网络正常连接后再提交。");
}
});
}
</script>

View File

@ -8,7 +8,7 @@
<div class="homepageRight mt0 ml10">
<div class="resources">
<div class="testStatus"><!--头部显示 start-->
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
<h1 class="ur_page_title text_c" id="polls_name_h"><%= exercise.exercise_name%></h1>
<div class="fontGrey2">
<span class="mr100">开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S") %></span>
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%></span>
@ -17,39 +17,48 @@
<% end %>
<%# time = exercise_user.end_at - exercise_user.start_at %>
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
<div class="cl"></div>
</div>
<div>
<div class="fl mb5">得分:<span class="c_red"><%=exercise_user.score %></span></div>
<div class="fl mb5">得分:<span class="c_red" id="exercise_user_score"><%=exercise_user.score %></span></div>
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,exercise.course) || (exercise.exercise_status == 3 && exercise.show_result == 1) %>
<%= link_to '返回统计列表>>',student_exercise_list_exercise_path(exercise.id,:course_id => exercise.course.id) , :class => "fr linkBlue" %>
<%= link_to '返回统计结果>>',student_exercise_list_exercise_path(exercise.id,:course_id => exercise.course.id) , :class => "fr linkBlue" %>
<% end %>
</div>
<div class="cl"></div>
<% mc_question_list = exercise.exercise_questions.where("question_type=1") %>
<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %>
<% single_question_list = exercise.exercise_questions.where("question_type=3") %>
<% multi_question_list = exercise.exercise_questions.where("question_type=4") %>
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% if !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %>
<% else %>
×
<% end %></span><br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="fr" id="menu_div_<%= exercise_question.id %>">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% is_correct = !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %>
<div class="fr">
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
</div>
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
</div>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
@ -69,26 +78,34 @@
</div>
<% end %>
</div>
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% if !standard_answer.empty? && get_mulscore(exercise_question, user).to_i == standard_answer.first.exercise_choice_id %>
<% else %>
×
<% end %></span><br />
标准答案:<%= convert_to_char(standard_answer.first.exercise_choice_id.to_s) if !standard_answer.empty? %>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="fr" id="menu_div_<%= exercise_question.id %>">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% is_correct = !standard_answer.empty? && get_mulscore(exercise_question, user).to_i == standard_answer.first.exercise_choice_id %>
<div class="fr">
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
</div>
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
</div>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
@ -108,26 +125,34 @@
</div>
<% end %>
</div>
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">填空题</h3>
<% single_question_list.each_with_index do |exercise_question,list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<span class="ml15 c_red">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% if !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %>
<% else %>
×
<% end %></span>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="fr" id="menu_div_<%= exercise_question.id %>">
<% answer = get_user_answer(exercise_question, user)%>
<% standard_answer = get_user_standard_answer(exercise_question, user)%>
<% is_correct = !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %>
<div class="fr">
得分:<div class="c_red fr mr10 ml10"><%= is_correct ? exercise_question.question_score : 0 %></div>
</div>
<span class="fr mt-4 f16 mr20"><i class="<%= is_correct ? 'icon-ok c_green' : 'icon-remove c_red' %>"></i></span>
</div>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div>
<div class="mb10">
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
参考答案:<%= exercise_choice.answer_text%><br />
参考答案<%= convert_to_chi_num(index+1) %><%= exercise_choice.answer_text%><br />
<% end %>
</div>
<div>
@ -138,8 +163,94 @@
</div>
<% end %>
</div>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">问答题</h3>
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == multi_question_list.count ? '' : 'border_b' %>">
<div>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="fr" id="menu_div_<%= exercise_question.id %>">
<% answer = get_user_answer(exercise_question, user)%>
<div class="fr">
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,exercise.course) %>
得分:
<% if answer.empty? %>
<div id="exercise_question_score_<%= exercise_question.id %>" title="未答题系统自动打0分" class="c_red fr mr10 ml10">
0
</div>
<% else %>
<div id="exercise_question_score_<%= exercise_question.id %>" title="双击批阅" ondblclick="edit_question_score('<%= exercise_question.id %>', <%= exercise_question.question_score %>, <%= exercise_user.user_id %>)" class="c_red fr mr10 ml10">
<%= answer.first.score == -1 ? "双击批阅" : answer.first.score %>
</div>
<% end %>
<% else %>
得分:<div class="c_red fr mr10 ml10"><%= answer.empty? ? 0 : (answer.first.score == -1 ? "未批" : answer.first.score) %></div>
<% end %>
</div>
</div>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<% if exercise_question.exercise_standard_answers.count > 0 %>
<div class="mb10">
参考答案:<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise_question.exercise_standard_answers.first.answer_text%></pre>
</div>
<% end %>
<div>
<textarea style="width: 693px; height: 90px; line-height: 30px; border: 1px solid #CBCBCB; color: #888888;" name="exercise_choice" placeholder="在此填入答案" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,exercise_user.user_id).html_safe %></textarea>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
<!--RSide end-->
</div>
</div>
<script>
// 在线测验的主观题打分
function edit_question_score(id, score, user_id){
$("#exercise_question_score_"+id).html("<input type='text' id='edit_score_input' onblur='edit_question_score_submit(this, "+ id +", "+ score +", "+ user_id +")' class='score_input' placeholder='0-"+ score +"'></input>");
}
function edit_question_score_submit(obj, id, score, user_id){
$.ajax({
type: "post",
url: "<%= edit_question_score_exercise_path(exercise) %>",
data: {
exercise_question_id: id,
user_id: user_id,
score: $(obj).val().trim()
},
success: function (data) {
var dataObj = eval(data);
if(dataObj.status == 2){
$("#ajax_notice_p").html("请输入0-"+score);
$("#ajax-notice").css('top', $(window).scrollTop()+200);
$("#ajax-notice").show();
} else if(dataObj.status == 1){
$("#exercise_question_score_"+id).html(dataObj.score);
$("#exercise_user_score").html(dataObj.total_score);
$("#ajax_notice_p").html("分数已保存");
$("#ajax-notice").css('top', $(window).scrollTop()+200);
$("#ajax-notice").show();
}
setTimeout(function(){
$("#ajax-notice").hide();
},2000);
},
error: function () {
long_notice_box("网路异常,请重新批阅。");
}
});
}
</script>

View File

@ -1,40 +1,33 @@
<%= form_for('',
:html => { :multipart => true },
:url => {:controller => 'exercise',
:action => 'commit_exercise',
:id => exercise.id
},:remote=>true ) do |f| %>
<div class="ur_buttons">
<a class="ur_button_submit" onclick="poll_submit();"> 提交 </a>
<div class="polls_cha">
<%= f.check_box 'show_result', :value => exercise.show_result%>
<%= label_tag '_show_result', '允许学生查看测验结果' %>
<!--<input name="exercise[show_result]" value="<%#exercise.show_result %>" type="checkbox" checked="true">
<label for="">允许学生查看测验结果</label>-->
</div>
<div class="ur_buttons" style="width: 143px;">
<a class="btn_blue_64_width mr10" onclick="exercise_submit();">保存</a>
<a class="btn_blue_64_width" onclick="exercise_save();">立即发布</a>
</div>
<% end %>
<script type="text/javascript">
function poll_submit() {
function exercise_submit() {
var question_form = $("form.new_exercise_question");
if($("#polls_head_edit").is(":visible")){
alert("请先保存测验标题及测验基本信息。");
notice_box("请先保存测验标题及测验基本信息。");
} else if($("#show_exercise_time").html().trim() == ""){
notice_box("请先设置测验的截止时间");
}
else if(question_form.length > 0) {
alert("请先保存正在编辑的题目。");
notice_box("请先保存正在编辑的题目。");
} else{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'exercise_submit_info', locals: { :exercise => exercise}) %>');
showModal('ajax-modal', '400px');
//$('#ajax-modal').css('height','120px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("popbox_polls");
window.location.href = '<%= exercise_url(@exercise) %>';
}
}
function exercise_save() {
var question_form = $("form.new_exercise_question");
if($("#polls_head_edit").is(":visible")){
notice_box("请先保存测验标题及测验基本信息。");
} else if($("#show_exercise_time").html().trim() == ""){
notice_box("请先设置测验的截止时间");
}
else if(question_form.length > 0) {
notice_box("请先保存正在编辑的题目。");
} else{
$.get('<%= publish_exercise_exercise_path(@exercise) %>');
}
}
</script>

View File

@ -20,25 +20,30 @@
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
<% end %>
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
<div class="cl"></div>
</div>
<% mc_question_list = exercise.exercise_questions.where("question_type=1") %>
<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %>
<% single_question_list = exercise.exercise_questions.where("question_type=3") %>
<% multi_question_list = exercise.exercise_questions.where("question_type=4") %>
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
@ -62,15 +67,19 @@
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mcq_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first%>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<div class="exercise_inputs">
<table class="" style="width:100%;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
@ -94,14 +103,19 @@
<h3 class="fontGrey3">填空题</h3>
<% single_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == single_question_list.count ? '' : 'border_b' %>">
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<div>
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
参考答案:<%= exercise_choice.answer_text%><br />
参考答案<%= convert_to_chi_num(index+1) %><%= exercise_choice.answer_text%><br />
<% end %>
</div>
</div>
@ -109,17 +123,54 @@
</div>
<% end %>
</div>
<div class="ur_buttons">
<%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => "ur_button_submit" %>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">问答题</h3>
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == multi_question_list.count ? '' : 'border_b' %>">
<div>
<div class="exercise_title">
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="cl"></div>
</div>
<p class="formatContainer break_word"><%= exercise_question.question_title %></p>
</div>
<div class="cl"></div>
<% if exercise_question.exercise_standard_answers.count > 0 %>
<div>
参考答案:<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise_question.exercise_standard_answers.first.answer_text%></pre>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<% current_score = get_current_score exercise %>
<div id="total_questions_score" style="display: <%= exercise.exercise_questions.count != 0 ? '' : 'none' %>">
<%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => exercise, :current_score => current_score} %>
</div>
<div class="ur_buttons" style="width: 220px;">
<%= link_to "返回", exercise_index_path(:course_id => @course.id),:class => "btn_grey_64_width" %>
<a href="javascript:void(0)" onclick="send_exercise_to_course();" class="btn_green_64_width ml10 mr10">发送</a>
<% if exercise.exercise_status == 1 %>
<%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "ur_button_submit", :style => "float:right"%>
<%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "btn_blue_64_width" %>
<% else %>
<span class="ur_button_submit" style="float:right; background:#a3a3a3" title="测验已发布,不可再编辑">编辑</span>
<%#= link_to l(:button_edit), '', :class => "ur_button_submit", :style => "float:right; background:#a3a3a3"%>
<span class="btn_grey_64_width" title="测验已发布,不可再编辑">编辑</span>
<% end %>
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
<!--RSide end-->
</div>
</div>
<script>
function send_exercise_to_course(){
var htmlvalue = "<%= escape_javascript(render :partial => 'exercise/send_to_course', :locals => {:exercise => exercise}) %>";
pop_box_new(htmlvalue, 450, 325);
}
</script>

View File

@ -1,4 +1,4 @@
<div class="polls_head" style="width:730px;">
<div class="polls_head" style="width:730px;">
<h2>所有试卷
<span><%= @obj_count%></span>
</h2>

View File

@ -4,7 +4,7 @@
:remote=>true ) do |f| %>
<div class="questionContainer">
<div class="mb10 ur_item">
<% score = exercise.exercise_questions.where("question_type=4").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %>
<% score = exercise.exercise_questions.where("question_type=4").last.nil? ? "": exercise.exercise_questions.where("question_type=4").last.question_score %>
<label class="ml25">分值<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input id="question_score" value="<%=score %>" type="text" name="question_score" style="width:60px; text-align:center; padding-left:0px;">分
<div class="cl"></div>

View File

@ -22,7 +22,7 @@
</div>
<div class="clear">
<p class="none c_red" id="choose_exercise_notice"></p>
<div class="clear fl mt10">
<div class="clear mr15 mt10">
<a href="javascript:void(0)" class="btn btn-blue fr" onclick="submit_import_form();">确定</a>
<a href="javascript:void(0)" class="btn fr mr5" onclick="hideModal();">取消</a>
</div>

View File

@ -0,0 +1,81 @@
<div style="width:450px;">
<div class="muban_popup_top">
<h3 class="fl">发送</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con clear">
<div class="clear mt15 ml30 mb10">
<div class="alert alert-orange mb10" style="margin-right: 33px;">
试卷将被发送到班级的在线测验
</div>
<div class="mb10 fl">
<input type="text" id="search_course_input" value="<%= @search %>" name="search" placeholder="输入班级ID或者名称搜索" style="height: 28px; border: 1px solid #d8d3d3; width: 380px;" />
</div>
<div>
<%= form_tag send_to_course_exercise_path(exercise),:remote=>true,:id=>'course_list_form' do %>
<div>
<ul class="courseReferContainer" id="exercise_course_list" style="max-height: 170px;">
<%= render :partial => 'exercise/exercise_course_list', :locals => {:courses => []} %>
</ul>
</div>
<div class="cl"></div>
<div>
<p class="c_red mb10" id="choose_course_notice"></p>
<div class="cl"></div>
<a href="javascript:void(0);" class="fr sy_btn_blue" style="margin-right: 33px;" onclick="submit_course_form();">发送</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr5" onclick="hideModal();">取消</a>
</div>
<div class="cl"></div>
<% end %>
</div>
</div>
</div>
</div>
<script>
function submit_course_form(){
var checkboxs = $("input[name='course_ids[]']:checked");
if(checkboxs.length > 0) {
$("#choose_course_notice").html("");
$('#course_list_form').submit();
hideModal();
} else{
$("#choose_course_notice").html("请至少选择一个班级");
}
}
var lastSearchCondition = '';
var count = 0;
function search_exs(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'exercise', :action => 'search_courses') %>'+'?name='+ e.target.value+'&course=<%=exercise.course_id %>',
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='search']").on('input', function (e) {
throttle(search_exs,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'exercise', :action => 'search_courses') %>'+'?course='+<%=exercise.course_id %>,
type:'get'
});
});
</script>

View File

@ -4,10 +4,18 @@
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="fr none" id="menu_div_<%= exercise_question.id %>">
<% type = exercise_question.question_type %>
<% exercise = exercise_question.exercise %>
<% count = exercise.exercise_questions.where(:question_type => type).count %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
<a href="javascript:void(0)" class="ur_icon_de" title="删除" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"></a>
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<% if exercise_question.question_number < count %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down up_and_down", :title => '下移') %>
<% end %>
<% unless exercise_question.question_number == 1 %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up up_and_down", :title => '上移') %>
<% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -4,10 +4,18 @@
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分&nbsp;&nbsp;
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %></span>
<div class="fr none" id="menu_div_<%= exercise_question.id %>">
<% type = exercise_question.question_type %>
<% exercise = exercise_question.exercise %>
<% count = exercise.exercise_questions.where(:question_type => type).count %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
<a href="javascript:void(0)" class="ur_icon_de" title="删除" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"></a>
<a class='ur_icon_add' title='向下插入' id="add_mcq_<%=exercise_question.id%>" onclick="dismiss('mcq',<%=exercise_question.id%>);insert_MCQ('mcq',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<% if exercise_question.question_number < count %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down up_and_down", :title => '下移') %>
<% end %>
<% unless exercise_question.question_number == 1 %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up up_and_down", :title => '上移') %>
<% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -3,10 +3,18 @@
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="fr none" id="menu_div_<%= exercise_question.id %>">
<% type = exercise_question.question_type %>
<% exercise = exercise_question.exercise %>
<% count = exercise.exercise_questions.where(:question_type => type).count %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
<a href="javascript:void(0)" class="ur_icon_de" title="删除" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"></a>
<a class='ur_icon_add' title='向下插入' id="add_multi_<%=exercise_question.id%>" onclick="dismiss('multi',<%=exercise_question.id%>);insert_MULTI('multi',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<% if exercise_question.question_number < count %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down up_and_down", :title => '下移') %>
<% end %>
<% unless exercise_question.question_number == 1 %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up up_and_down", :title => '上移') %>
<% end %>
</div>
<div class="cl"></div>
</div>
@ -15,7 +23,7 @@
<% if exercise_question.exercise_standard_answers.count > 0 %>
<div>
参考答案:<%= exercise_question.exercise_standard_answers.first.answer_text%>
参考答案:<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise_question.exercise_standard_answers.first.answer_text%></pre>
</div>
<% end %>
</div>

View File

@ -3,10 +3,18 @@
<div>
<span class="fl lh27">第<%= exercise_question.question_number%>题.&nbsp;&nbsp;<%= exercise_question.question_score %>分</span>
<div class="fr none" id="menu_div_<%= exercise_question.id %>">
<% type = exercise_question.question_type %>
<% exercise = exercise_question.exercise %>
<% count = exercise.exercise_questions.where(:question_type => type).count %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %>
<a href="javascript:void(0)" class="ur_icon_de" title="删除" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"></a>
<a class='ur_icon_add' title='向下插入' id="add_single_<%=exercise_question.id%>" onclick="dismiss('single',<%=exercise_question.id%>);insert_SINGLE('single',<%=exercise_question.question_number%>,<%=exercise_question.id%>);"></a>
<% if exercise_question.question_number < count %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down up_and_down", :title => '下移') %>
<% end %>
<% unless exercise_question.question_number == 1 %>
<%= link_to('', {:controller => 'exercise', :action => 'update_question_num', :id => exercise.id, :ques_id => exercise_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up up_and_down", :title => '上移') %>
<% end %>
</div>
<div class="cl"></div>
</div>

View File

@ -1,14 +1,9 @@
<div class="fl" style="padding-bottom:10px; width:720px;">
<div class="fl pr" style="padding-bottom:10px; width:720px;">
<span class="c_dark f14 fb fl mr30">
测验
<font class="f12 c_red">
(<%= @exercise_count%>人已)
(<%= @exercise_count%>人已)
</font>
<% if !@is_teacher && @exercise_users_list.empty?%>
<span class="f12 c_red">您尚未提交</span>
<% elsif !@is_teacher && !@exercise_users_list.empty?%>
<span class="f12 c_red">您已提交</span>
<% end %>
</span>
<%#if @is_teacher || @exercise.exercise_status == 3%>
<!--<div class="hworkSearchBox">
@ -18,6 +13,14 @@
<%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %>
<%# end%>
<span class="fr c_grey"> <a href="javascript:void(0);" class="linkGrey2" id="homework_info_show" onclick="show_or_hide_info();" style="display: none">[ 显示测验信息 ]</a> </span>
<div class="group_work_tip_box fontGrey2">
<em></em>
<span></span>
<p class="mt5 mb5 break_word">客观题由系统自动评分:<br/>
单选题、多选题、填空题<br/><br/>主观题需要人工评分,但未作答时系统<br/>自动评零分:<br/>问答题
</p>
</div>
</div>
<div class="cl"></div>

View File

@ -1,44 +1,45 @@
<table class="hwork-table-wrap" style="border-bottom:1px solid #eaeaea;">
<tr class="b_grey hworkH30">
<th class="hworkList30 pl5 pr5"><span class="c_dark f14 fb">序号</span></th>
<th class="hworkList40 pl5 pr5"><span class="c_dark f14 fb">序号</span></th>
<th class="hworkList50">&nbsp;&nbsp;</th>
<th class="hworkList130"><span class="c_dark f14 fb">姓名</span></th>
<th class="hworkList130"><span class="c_dark f14 fb">学号</span></th>
<th class="hworkList130"><span class="c_dark f14 fb">班级</span></th>
<th width="60">&nbsp;&nbsp;</th>
<th class="hworkList130">
<%= link_to "时间",'',:class => "c_dark f14 fb" ,:remote => true%>
</th>
<th class="hworkList50">
<th class="hworkList130"><span class="c_dark f14 fb">答题时间</span></th>
<th class="hworkList80">客观题</th>
<th class="hworkList80">主观题</th>
<th class="hworkList80">
<%= link_to "成绩",'',:class => "c_dark f14 fb",:remote => true%>
</th>
</tr>
<% @exercise_users_list.each_with_index do |exercise, index|%>
<tr class="hworkListRow" id="student_work_<%= exercise.id%>">
<td class="pl5 pr5" style="text-align:center;"><%=index + 1 %></td>
<tr class="hworkListRow" id="student_work_<%= exercise.id%>" style="cursor:pointer;">
<td class="hworkList40 pl5 pr5" style="text-align:center; cursor: default;"><%=index + 1 %></td>
<td class="hworkPortrait float-none">
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40",:style => "display:block;", :class => "mt15"),user_activities_path(exercise.user)) %>
</td>
<td class="hworkStName130 pr10 student_work_<%= exercise.id%>" title="姓名" id="student_name_<%= exercise.id%>" style="cursor:pointer;">
<td class="hworkStName130 pr10 student_work_<%= exercise.id%>" title="姓名" id="student_name_<%= exercise.id%>">
<%=exercise.user.show_name %>
</td>
<td class="hworkStID130 pr10 student_work_<%= exercise.id%> float-none" title="学号" id="student_id_<%= exercise.id%>" style="cursor:pointer;">
<td class="hworkStID130 pr10 student_work_<%= exercise.id%> float-none" title="学号" id="student_id_<%= exercise.id%>">
<span class="hidden fl" style="width:130px;"><%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%></span>
</td>
<td class="hworkStID130 student_work_<%= exercise.id%> float-none" title="班级" id="student_class_<%= exercise.id%>" style="cursor:pointer;">
--
</td>
<td width="60">&nbsp;</td>
<td class="hworkList130 c_grey">
<% if exercise.created_at%>
<%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>&nbsp;
<% if exercise.commit_status == 0 %>
<span class="c_red">[未答]</span>
<td class="hworkList130 c_grey student_work_<%= exercise.id%>">
<% if exercise.commit_status == 0 %>
<span class="c_red">未答</span>
<% else %>
<% if exercise.created_at%>
<%= format_time(exercise.created_at) %>&nbsp;
<% end %>
<% end %>
</td>
<td class="hworkList50 <%= score_color exercise.score%> student_final_scor_info">
<td class="hworkList80 <%= score_color exercise.objective_score %> student_work_<%= exercise.id%>">
<%= exercise.objective_score == -1 ? "0.0" : format("%.1f",exercise.objective_score)%>
</td>
<td class="hworkList80 <%= score_color(exercise.subjective_score == -1 ? nil : exercise.subjective_score) %> student_work_<%= exercise.id%>">
<%= exercise.subjective_score == -1 ? "未批" : format("%.1f",exercise.subjective_score)%>
</td>
<td class="hworkList80 <%= score_color exercise.score%> student_final_scor_info student_work_<%= exercise.id%>">
<%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%>
</td>
<td><div style="position:relative;"><div class="hworkTip" style="display: none" id="work_click_<%= exercise.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></div></div></td>
@ -52,14 +53,14 @@
}).mouseleave(function(){
$("#work_click_<%= exercise.id%>").hide();
}).mouse;
$("#student_name_<%= exercise.id%>,#student_id_<%= exercise.id%>,#student_class_<%= exercise.id%>").on('click',function() {
$(".student_work_<%= exercise.id%>").on('click',function() {
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user_id) %>';
});
<% else %>
//$("#show_student_result_div_<%#= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$(".student_work_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
//$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
//$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
<% end %>
});
/*function show_result(id) {

View File

@ -0,0 +1,8 @@
<div class="" style="display: <%= current_score[0] == 0 ? "none" : "" %>" id="current_score_div">
<span class="mr20">单选题&nbsp;<%= exercise.exercise_questions.where("question_type=1").count %>&nbsp;题,共<%= current_score[1] %>分</span>
<span class="mr20">多选题&nbsp;<%= exercise.exercise_questions.where("question_type=2").count %>&nbsp;题,共<%= current_score[2] %>分</span>
<span class="mr20">填空题&nbsp;<%= exercise.exercise_questions.where("question_type=3").count %>&nbsp;题,共<%= current_score[3] %>分</span>
<span class="mr20">问答题&nbsp;<%= exercise.exercise_questions.where("question_type=4").count %>&nbsp;题,共<%= current_score[4] %>分</span>
<span class="fr">合计&nbsp;<font class="c_red"><%= exercise.exercise_questions.count %></font>&nbsp;题,共<font class="c_red"><%= current_score[0] %></font>分</span>
<div class="cl"></div>
</div>

View File

@ -1,8 +1 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>');
showModal('ajax-modal', '270px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='hidden_atert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("alert_box");
notice_box_redirect("<%= exercise_index_path(:course_id => @course.id) %>", "提交成功");

View File

@ -1,13 +1,14 @@
<% if @is_insert %>
$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>');
$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>");
$("#current_score_div").show();
$("#current_score").html("<%=get_current_score @exercise %>分");
<% current_score = get_current_score @exercise %>
$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>");
<% else %>
$("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>');
$("#new_poll_question").html("");
$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>");
<%if @exercise_questions.question_type == 1%>
$("#mc_question_list>div").last().children().first().addClass("border_b");
$("#mc_question_list").show().append("<div id='poll_questions_<%= @exercise_questions.id%>'>" +
"<div id='show_poll_questions_<%= @exercise_questions.id %>'>" +
"<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" +
@ -47,6 +48,7 @@
"</div>" +
"</div>");
<% end %>
$("#current_score_div").show();
$("#current_score").html("<%=get_current_score @exercise %>分");
$("#total_questions_score").show();
<% current_score = get_current_score @exercise %>
$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>");
<% end %>

View File

@ -1,3 +1,5 @@
hideModal();
$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>");
$("#current_score").html("<%=get_current_score @exercise %>分");
<% current_score = get_current_score @exercise %>
$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>");
$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>");

View File

@ -1,5 +1,6 @@
<% if params[:index] %>
$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>");
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear muban_popup_con"><div class="newupload_conbox newupload_tishi"><p>发布成功</p>' +
'<a href="javascript:void(0);" class="btn btn-blue mt10" onclick="hideModal();">知道了</a></div></div></div>';
pop_box_new(htmlvalue, 400, 152);
notice_box("发布成功");
<% else %>
notice_box_redirect('<%= exercise_url(@exercise) %>', '发布成功');
<% end %>

View File

@ -0,0 +1 @@
$("#exercise_course_list").html("<%= escape_javascript(render :partial => 'exercise/exercise_course_list', :locals => {:courses => @courses}) %>");

View File

@ -0,0 +1,4 @@
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">试卷已发送<br/>但需要您设置发布时间和截止时间,以激活相应的试卷</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt20 mr10" onclick="hideModal();" style="margin-right: 174px;">确定</a></div></div>';
pop_box_new(htmlvalue, 300, 162);

View File

@ -68,17 +68,8 @@
</div>
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
<% if @is_teacher%>
<div class="fr mt5">
<ul class="resourcesSelect">
<li class="resourcesSelected">
<a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="hworkMenu">
<li>
<%= link_to "导出测验成绩", student_exercise_list_exercise_path(@exercise.id,:course_id => @course.id, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>
</li>
</ul>
</li>
</ul>
<div class="fr mt10 mr5">
<%= link_to "导出成绩", student_exercise_list_exercise_path(@exercise.id,:course_id => @course.id, :format => 'xls'),:class=>'linkBlue', :id => "export_student_work"%>
</div>
<% end%>
<div class="cl"></div>
@ -86,7 +77,7 @@
<div class="homeworkInfo mb10" id="homeworkInformation">
<div class="">
<div class="homepagePostTitle fl hidden m_w460" title="<%= @exercise.exercise_name %>"><%= @exercise.exercise_name %></div>
<%= link_to @exercise.exercise_name, exercise_path(@exercise), :class => 'homepagePostTitle fl hidden m_w460', :title => "#{@exercise.exercise_name}", :target => '_blank' %>
<% if @exercise.exercise_status == 1 %>
<span class="grey_homework_btn_cir ml5">未发布</span>
<% elsif @exercise.exercise_status == 2 %>
@ -114,7 +105,7 @@
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
<% else %>
<div class="fontGrey2 db fr c_red">提交已截止</div>
<div class="db fr c_red">提交已截止</div>
<% end %>
<div class="cl"></div>
</div>

View File

@ -20,5 +20,6 @@ $("#poll_questions_<%= @exercise_question.id%>").html("<div id='show_poll_questi
"<%= escape_javascript(render :partial => 'edit_multi', :locals => {:exercise_question => @exercise_question}) %>" +
"<% end%>" +
"</div>");
$("#current_score").html("<%=get_current_score @exercise_question.exercise %>分");
<% current_score = get_current_score @exercise %>
$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>");
$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>");

View File

@ -0,0 +1,32 @@
<% if @before_que %>
$("#poll_questions_<%= @exercise_question.id%>").insertBefore($("#poll_questions_<%= @before_que.id%>"));
<% if @before_que.question_type == 1%>
$("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @before_que}) %>");
<% elsif @before_que.question_type == 2%>
$("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @before_que}) %>");
<% elsif @before_que.question_type == 3%>
$("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @before_que}) %>");
<% elsif @before_que.question_type == 4%>
$("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @before_que}) %>");
<% end%>
<% elsif @after_que %>
$("#poll_questions_<%= @exercise_question.id%>").insertAfter($("#poll_questions_<%= @after_que.id%>"));
<% if @after_que.question_type == 1%>
$("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @after_que}) %>");
<% elsif @after_que.question_type == 2%>
$("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @after_que}) %>");
<% elsif @after_que.question_type == 3%>
$("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @after_que}) %>");
<% elsif @after_que.question_type == 4%>
$("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @after_que}) %>");
<% end%>
<% end %>
<% if @exercise_question.question_type == 1%>
$("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_question}) %>");
<% elsif @exercise_question.question_type == 2%>
$("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_question}) %>");
<% elsif @exercise_question.question_type == 3%>
$("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_question}) %>");
<% elsif @exercise_question.question_type == 4%>
$("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @exercise_question}) %>");
<% end%>

View File

@ -19,7 +19,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','css/syllabus', 'css/moduel','css/contest'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','css/syllabus', 'css/moduel','css/contest','css/font-awesome'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
<!-- page specific tags -->
<%= yield :header_tags -%>
@ -170,6 +170,9 @@
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="ajax-notice" style="display: none; text-align: center; bottom: 200px; left: 50%; margin-left: -70px; background: #a1a1a1; width: 140px; height: 80px; position: absolute; z-index: 999999;">
<p id="ajax_notice_p" style="text-align: center; color: #fff; font-size: 18px; padding-top: 26px;">分数已保存</p>
</div>
<div id="ajax-modal" style="display:none;"></div>
<div id="nh_tx_dialog_html" class="white_content" style="display:none;">
<%=render :partial => 'layouts/upload_avatar', :locals => {:source => @course} %>

View File

@ -1908,7 +1908,11 @@ zh:
excel_a_penalty: 缺评扣分
excel_l_penalty: 迟交扣分
excel_f_score: 成绩
excel_objective_score: 客观成绩
excel_subjective_score: 主观成绩
excel_commit_time: 提交时间
excel_answer_time: 答题时间
excel_no_answer: 未答
excel_homework_score: 作业积分
excel_class: "班级:"
excel_member_with_out_class: "未加入班级的学生"

View File

@ -291,15 +291,20 @@ RedmineApp::Application.routes.draw do
get 'show_student_result'
post 'create_exercise_question'
post 'commit_answer'
post 'commit_exercise'
get 'commit_exercise'
post 'update_question_num'
post 'send_to_course'
get 'get_student_uncomplete_question'
post 'edit_question_score'
end
collection do #生成路径为 /exercise/方法名
delete 'delete_exercise_question'
get 'delete_exercise_question'
post 'update_exercise_question'
get 'other_exercise'
post 'import_other_exercise'
get 'search_exercises'
get 'search_courses'
end
end

View File

@ -0,0 +1,10 @@
class AddColumnToExercise < ActiveRecord::Migration
def change
add_column :exercise_users, :objective_score, :integer, :default => -1
add_column :exercise_users, :subjective_score, :integer, :default => -1
ExerciseUser.all.each do |eu|
eu.update_column('objective_score', eu.score)
end
end
end

View File

@ -2,6 +2,36 @@
namespace :exercise_publish do
desc "publish exercise and end exercise"
def calculate_student_score(exercise, user)
score = 0
score1 = 0
score2 = 0
score3 = 0
exercise_qustions = exercise.exercise_questions
exercise_qustions.each do |question|
answer = get_user_answer(question, user)
standard_answer = get_user_standard_answer(question, user)
unless answer.empty?
# 问答题有多个答案
if question.question_type == 3 && !standard_answer.empty?
if standard_answer.include?(answer.first.answer_text)
score1 = score1+ question.question_score unless question.question_score.nil?
end
elsif question.question_type == 1 && !standard_answer.nil?
if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id
score2 = score2 + question.question_score unless question.question_score.nil?
end
elsif question.question_type == 2 && !standard_answer.nil?
arr = get_mulscore(question, user)
if arr.to_i == standard_answer.exercise_choice_id
score3 = score3 + question.question_score unless question.question_score.nil?
end
end
end
end
score = score1 + score2 + score3
end
task :publish => :environment do
Rails.logger.info("log--------------------------------exercise_publish start")
puts "--------------------------------exercise_publish start"
@ -24,16 +54,14 @@ namespace :exercise_publish do
course = exercise.course
exercise.update_column('exercise_status', 3)
course.student.each do |student|
if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,exercise.id).blank?
ExerciseUser.create(:user_id => student.student_id, :exercise_id => exercise.id, :start_at => exercise.end_time, :status => true,:score=>0)
else
ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,exercise.id).first.update_column('commit_status', 1)
end
=begin
s_score = calculate_student_score(exercise, student.student)
exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, exercise.id).first
exercise_user.update_attributes(:score => s_score)
=end
if exercise_user
exercise_user = ExerciseUser.create(:user_id => student.student_id, :exercise_id => exercise.id, :start_at => exercise.end_time, :status => true,:score=>0)
else
exercise_user.update_column('commit_status', 1)
end
s_score = calculate_student_score(exercise, student.student)
exercise_user.update_attributes(:objective_score => s_score, :score => (s_score + (exercise_user.subjective_score > 0 ? exercise_user.subjective_score : 0)))
end
end
end

View File

@ -1773,6 +1773,15 @@ function notice_box(str){
pop_box_new(htmlvalue, 300, 140);
}
// 长提示框:只有一个确定按钮,点击关闭弹框
function long_notice_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:380px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">' + str + '</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 164px;">确定</a></div></div>';
pop_box_new(htmlvalue, 380, 140);
}
//提示框:只有一个确定按钮,点击跳转
function notice_box_redirect(url, str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="'+ url +'" class="muban_icons_close fr"></a></div>'+

View File

@ -453,4 +453,11 @@ a:hover.btn-blue{background: #2788d0; color: #fff;}
.sy_popup_con02{ margin:30px auto 0; font-size:14px; text-align:center; width:360px;}
.sy_popup_con02 ul li p{ margin-bottom:15px; text-align:center; font-size:14px; color:#616161;}
.sy_popup_con02 a{ margin:0 auto;}
#sy_popup_box{ width:460px; background:#fff; padding-bottom:30px; border-radius:5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
#sy_popup_box{ width:460px; background:#fff; padding-bottom:30px; border-radius:5px; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);}
a.btn_blue_64_width{ width: 64px; display:inline-block; color: #fff; background: #3b94d6; text-align: center; font-size: 12px; height: 30px; line-height: 30px;border-radius:3px; }
a:hover.btn_blue_64_width{ background: #2788d0; color: #fff;}
.btn_grey_64_width{ width: 64px; display:inline-block; color: #656565; background: #d9d9d9; text-align: center; font-size: 12px; height: 30px; line-height: 30px;border-radius:3px; }
a:hover.btn_grey_64_width{ background: #717171; color: #fff;}
a.btn_green_64_width{ width: 64px; display:inline-block; color: #fff; background: #28be6c; text-align: center; font-size: 12px; height: 30px; line-height: 30px;border-radius:3px; }
a:hover.btn_green_64_width{ background: #14ad5a; color: #fff;}

View File

@ -545,4 +545,7 @@ a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px;
/* 新版测验 */
a.question_choice_white{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a.question_choice_blue{ background: #3b94d6; color: #fff; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
.question_choice_dash{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px dashed #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
.question_choice_dash{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px dashed #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
.question_answer_span{ background: #fff; color: #000000; padding: 6px 10px; border: 1px solid #c8cbce; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
.bg_blue{ background: #3b94d6;}
.score_input{ width: 40px; border: 1px solid #d8d3d3;}

View File

@ -23,6 +23,7 @@
.courseSend {width:390px; height:15px; line-height:15px; margin-bottom:10px;display:block;white-space:nowrap;}
.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;}
.sendCourseName {font-size:12px; color:#5f6060;display:inline-block}
.chooseCourseName {font-size: 12px; color: #5f6060; max-width: 320px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#3b94d6; margin-right:25px; float:left;cursor: pointer;}
.courseSendSubmit:hover {background-color:#297fb8;}
.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}
@ -33,7 +34,7 @@ input.sendSourceText:hover {background-color:#297fb8;}
/*input.sendSourceText:hover {font-size:14px; color:#ffffff;}*/
.resourcesSendTo {float:left; height:20px; margin-top:15px;}
.resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;}
.courseReferContainer {float:left; max-height:120px;margin-right:16px;margin-bottom:10px; overflow:auto; overflow-x:hidden;}
.courseReferContainer {float:left; max-height:120px;margin-right:16px;margin-bottom:10px; overflow:auto; overflow-x:hidden;}
/*上传资源弹窗*/
.resourceUploadPopup {width:400px; height:auto; border:3px solid #3b94d6; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:fixed; top:50%; left:50%; margin-left:-200px; z-index:1000;}
.uploadText {font-size:16px; color:#3b94d6; line-height:16px; padding-top:15px; width:140px; display:inline-block;}

View File

@ -108,6 +108,7 @@ a:hover.ur_icon_de{ background:url(images/icons.png) -20px -338px no-repeat;}
a:hover.ur_icon_edit{ background:url(images/icons.png) -21px -272px no-repeat;}
.ur_icon_add{ background:url(images/icons.png) 0px -310px no-repeat; width:16px; height:27px; display:block;float:right; margin-right:10px;}
a:hover.ur_icon_add{background:url(images/icons.png) -20px -310px no-repeat;}
.up_and_down{float: right; margin-top: 5px; margin-right: 10px;}
/***弹框***/
.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}