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

Conflicts:
	app/helpers/exercise_helper.rb

解决冲突
This commit is contained in:
huang 2015-11-18 14:03:17 +08:00
commit 7f5fa7fb6f
16 changed files with 133 additions and 45 deletions

View File

@ -5,6 +5,7 @@ class ExerciseController < ApplicationController
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
include ExerciseHelper
include ExerciseHelper
def index
remove_invalid_exercise(@course)
@is_teacher = User.current.allowed_to?(:as_teacher,@course)

View File

@ -8,7 +8,7 @@ module ExerciseHelper
#判断用户是否已经提交了问卷
def has_commit_exercise?(exercise_id, user_id)
pu = PollUser.find_by_poll_id_and_user_id(exercise_id, user_id)
pu = ExerciseUser.find_by_excercise_id_and_user_id(exercise_id, user_id)
if pu.nil?
false
else
@ -16,4 +16,13 @@ module ExerciseHelper
end
end
def convert_to_char(str)
result = ""
if str.count >= 1
for i in 0 .. str.count do i
result += (str[i].to_i + 64).chr
end
end
end
end

View File

View File

View File

@ -7,14 +7,14 @@
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选)</label>-->
<%# end %>
<div class="calendar_div fl mr10">
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= exercise.publish_time%>" >
<input type="text" name="exercise[publish_time]" id="exercise_publish_time" placeholder="发布时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if exercise.publish_time %>" >
<%= calendar_for('exercise_publish_time')%>
</div>
<%# if edit_mode %>
<!--<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>-->
<%# end %>
<div class="calendar_div fl">
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= exercise.end_time%>" >
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>" >
<%= calendar_for('exercise_end_time')%>
</div>
<div class="fl ml10 f14 fontGrey2"><span class="mr5">考试时长:</span><input name="exercise[time]" id="exercise_time" type="text" class="examTime mr5" value="<%=exercise.time %>" />分钟</div>

View File

View File

@ -1,22 +1,21 @@
<% exercise.exercise_questions.each do |poll_question|%>
<div id="poll_questions_<%= poll_question.id%>">
<!--<div id="show_poll_questions_<%= poll_question.id %>">
<%# if poll_question.question_type == 1%>
<%#= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 2%>
<%#= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 3%>
<%#= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
<%# end%>
</div>-->
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
<% if poll_question.question_type == 1%>
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 2%>
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
<% exercise.exercise_questions.each do |exercise_question|%>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<% if exercise_question.question_type == 1%>
<%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %>
<% elsif exercise_question.question_type == 2%>
<%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %>
<% elsif exercise_question.question_type == 3%>
<%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %>
<% end%>
</div>
<div id="edit_poll_questions_<%= exercise_question.id %>" style="display: none;">
<% if exercise_question.question_type == 1%>
<%= render :partial => 'edit_MC', :locals => {:exercise_question => exercise_question} %>
<% elsif exercise_question.question_type == 2%>
<%= render :partial => 'edit_MCQ', :locals => {:exercise_question => exercise_question} %>
<% elsif exercise_question.question_type == 3%>
<%= render :partial => 'edit_single', :locals => {:exercise_question => exercise_question} %>
<% end%>
</div>
</div>

View File

@ -231,7 +231,7 @@
//添加标题时确定按钮
function add_poll_question(doc)
{
var title = $.trim($("#question_title").val());
var title = $.trim($("#poll_questions_title").val());
if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();}
}
//修改标题时确定按钮
@ -340,7 +340,7 @@
<div class="ur_buttons"> <a class="ur_button_submit" onclick="poll_submit();"> 提交 </a>
<div class="polls_cha">
<input name="" value="" type="checkbox">
<input name="show_result" value="" type="checkbox">
<label for="">允许学生查看测验结果</label>
</div>
</div>

View File

@ -9,10 +9,15 @@
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="1" type="hidden">
<input name="question_title" id="question_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
<input name="question_title" id="poll_questions_title" class="questionTitle" placeholder="请输入单选题题目" type="text">
</div>
<div class="ur_editor_content">
<ul>
<li class="ur_item">
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input maxlength="200" type='text' name='question_answer[0]' placeholder='新建选项'>

View File

@ -7,33 +7,48 @@
<div class="ur_editor_content">
<ul>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="新建选项" type="text">
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="新建选项" type="text">
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
<input maxlength="200" type='text' name='question_answer[0]' placeholder='新建选项'>
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
</li>
<div class="cl"></div>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="新建选项" type="text">
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
<input maxlength="200" type='text' name='question_answer[1]' placeholder='新建选项'>
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
</li>
<div class="cl"></div>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="新建选项" type="text">
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a> <a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a> </li>
<input maxlength="200" type='text' name='question_answer[2]' placeholder='新建选项'>
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
</li>
<div class="cl"></div>
<li class="ur_item">
<label>选项<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input maxlength="200" type='text' name='question_answer[3]' placeholder='新建选项'>
<a class="icon_add" title="向下插入选项" onclick="add_single_answer($(this));"></a>
<a class="icon_remove" title="删除" onclick="remove_single_answer($(this))"></a>
</li>
<div class="cl"></div>
<li class="ur_item">
<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="若标准答案为AB,C在答案输入框填
入ABC即可" type="text">
<input name="exercise_choice" placeholder="若标准答案为AB,C在答案输入框填入ABC即可" type="text">
</li>
<div class="cl"></div>
</ul>
</div>
<div class="ur_editor_footer"> <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));"> 保存 </a> <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> </div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));"> 保存 </a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
</div>
<div class="cl"></div>
</div>

View File

@ -1,11 +1,16 @@
<div class="questionContainer">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input name="question_type" value="1" type="hidden">
<input maxlength="250" class="questionTitle" name="poll_questions_title" id="poll_questions_title" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text">
<input name="question_type" value="3" type="hidden">
<input maxlength="250" class="questionTitle" name="questions_title" id="poll_questions_title" placeholder="请输入填空题的内容(注意:目前填空题暂时仅支持一个空)" type="text">
</div>
<div class="ur_editor_content">
<ul>
<li class="ur_item">
<label>分数<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="question_score" style="width:40px; text-align:center; padding-left:0px;">分
</li>
<div class="cl"></div>
<li class="ur_item">
<label>候选答案一<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input name="question_answer[0]" placeholder="请输入候选答案一" type="text">
@ -23,6 +28,9 @@
<div class="cl"></div>
</ul>
</div>
<div class="ur_editor_footer"> <a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));"> 保存 </a> <a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a> </div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit c_white" data-button="ok" onclick="add_poll_question($(this));"> 保存 </a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().remove();"> 取消 </a>
</div>
<div class="cl"></div>
</div>

View File

@ -0,0 +1,36 @@
<div>
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
<%= exercise_question.question_title %><span class="ml10">(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)</span></div>
<%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= exercise_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mc_<%=exercise_question.id%>" onclick="chooseQuestionType('mc',<%=exercise_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" >
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
<input class="ur_radio" type="radio" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" >
<%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div><!--单选题显示 end-->
<!-- 新增问题 -->
<div id="insert_new_poll_question_mc_<%=exercise_question.id%>">
</div>
<div id="div_mc_<%=exercise_question.id%>" style="width: 50px;border: 1px solid #cbcbcb; display:none;position: absolute;padding: 5px;background: white">
<ul>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%=exercise_question.id%>);insert_MC('mc',<%=exercise_question.question_number%>,<%=exercise_question.id%>);">单选</a></li>
<!--<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%#=poll_question.id%>);insert_MCQ('mc',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">多选</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mc',<%#=poll_question.id%>);insert_SINGLE('mc',<%#=poll_question.question_number%>,<%#=poll_question.id%>);">单行主观</a></li>-->
</ul>
</div>

View File

View File

@ -1,6 +1,12 @@
<div class="ur_page_head ur_editor02" ><!--头部显示 start-->
<a href="javascript:" class="ur_icon_edit" title="编辑" onclick="pollsEdit();"></a>
<div class="testStatus"><!--头部显示 start-->
<a href="javascript:" class="testEdit" title="编辑" onclick="pollsEdit();"></a>
<!-- <a class='ur_icon_add' title='导入' id="import_btn" onclick="importPoll();"></a> -->
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
<%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
<div class="fontGrey2">
<span class="mr100">发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%></span>
<span class="mr100">截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %></span>
<span>考试时长:<%= exercise.time %>分钟</span></div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>
</div><!--头部显示 end-->
<div class="cl"></div>
</div>

View File

View File

@ -1156,4 +1156,13 @@ a:hover.btn_cancel{ color:#666;}
.mr118 {margin-right:118px !important;}
.questionContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;}
.questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;}
.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; }
.testStatus{width:698px; border:1px solid #cbcbcb; padding:10px; margin-bottom:10px; background:#ffffff; position:relative; color:#767676;}
.testEdit{ background:url(images/icons.png) 0px -272px no-repeat; width:16px; height:27px; display:block;float:right; bottom:10px; right:10px; position:absolute;}
a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;}
.mr100 {margin-right:100px;}
.testDesEdit {width:670px; overflow:hidden;}
.testEditTitle{ padding:10px 0px ; float:left; width:564px; }
.questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;}
.fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;}
.mr130 {margin-right:130px;}