Merge branch 'develop' into 'develop'

本周上线



See merge request !177
This commit is contained in:
陈晓婷 2017-03-24 19:02:12 +08:00
commit b6bf0aafb1
8 changed files with 71 additions and 27 deletions

View File

@ -8,15 +8,25 @@ class Exercise < ActiveRecord::Base
has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
after_create :acts_as_course_message
after_save :acts_as_course_message
def acts_as_course_message
if self.course
if self.exercise_status == 2 #未发布
if self.exercise_status == 2 && self.course_messages.where(:status => 2).blank? #已发布
self.delay.send_exercise_message_delay
#self.course.members.each do |m|
self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2)
#self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2)
#end
# else
# self.course_messages.destroy_all 这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的
else
#self.course_messages.destroy_all #这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的
end
end
end
#测验通知delay
def send_exercise_message_delay
self.course.members.each do |m|
if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false ,:status=>2)
end
end
end

View File

@ -153,7 +153,7 @@
<%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => exercise, :current_score => current_score} %>
</div>
<div class="ur_buttons" style="width: 297px;">
<div class="ur_buttons" style="width: 298px;">
<%= 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 %>

View File

@ -45,7 +45,7 @@
<% if @homework.homework_type == 1 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。</p>
<% elsif @homework.homework_type == 2 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和测试集。</p>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。</p>
<% elsif @homework.homework_type == 3 %>
<p class="c_red mb5">已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和分组设置(可扩大分组范围)。</p>
<% end %>

View File

@ -107,7 +107,7 @@
<em></em>
<font></font>
现共有
<span class="c_red">&nbsp;<%= student_work.student_works_scores.where("reviewer_role = 3 and appeal_status != 3").group_by(&:user_id).count%>&nbsp;</span>
<span class="c_red">&nbsp;<%= student_work.student_works_scores.where(:reviewer_role => 3).group_by(&:user_id).count%>&nbsp;</span>
名学生进行了匿评,平均分为
<span class="c_red">&nbsp;<%= format("%.1f",student_work.student_score)%>&nbsp;</span>分。
</div>

View File

@ -68,11 +68,34 @@
<%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "hw_btn_green fr mt5",:method => "post"%>
<% end %>
<% if User.current == course.teacher || User.current.admin? %>
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 0, 1);" class="btn_grey_big fr mt5 mr5" style="width: 56px;">归档</a>
<div class="pr">
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 0, 1);" onmouseover="$('#archive_notice_<%=course.id %>').show();" onmouseout="$('#archive_notice_<%=course.id %>').hide();"
class="btn_grey_big fr mt5 mr5" style="width: 56px;">归档</a>
<div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px; right: -275px;">
<em></em>
<span></span>
<p class="mt5 mb5 break_word">
此班级的信息将不再显示<br/>
您和您的学生将不能在此班级中继续互动<br/>
但您可以点击“归档管理”重新恢复
</p>
</div>
</div>
<% end %>
<% else %>
<% if User.current == course.teacher || User.current.admin? %>
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 1, 1);" class="btn_grey_big fr mt5" style="width: 56px;">恢复</a>
<div class="pr">
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, 1, 1);" onmouseover="$('#archive_notice_<%=course.id %>').show();" onmouseout="$('#archive_notice_<%=course.id %>').hide();"
class="btn_grey_big fr mt5" style="width: 56px;">恢复</a>
<div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px; right: -275px; top: -10px;">
<em style="top: 21px;"></em>
<span style="top: 21px;"></span>
<p class="mt5 mb5 break_word">
此班级的信息将恢复显示<br/>
您和您的学生将可以重新在此班级中互动
</p>
</div>
</div>
<% end %>
<% end %>
<div class="cl"></div>

View File

@ -26,9 +26,9 @@
<div class="pr">
<a href="javascript:void(0)" onclick="archive_course(<%=course.id %>, <%=course.is_delete %>, 0);" onmouseover="$('#archive_notice_<%=course.id %>').show();" onmouseout="$('#archive_notice_<%=course.id %>').hide();"
class="btn_grey_big fr mt5 mr15" style="width: 56px;"><%= course.is_delete == 0 ? '归档' : '恢复' %></a>
<div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px;">
<em></em>
<span></span>
<div class="archive_course_notice fontGrey2 none" id="archive_notice_<%=course.id %>" style="width: 230px; top: -10px;">
<em style="top: 21px;"></em>
<span style="top: 21px;"></span>
<p class="mt5 mb5 break_word">
<% if course.is_delete == 0 %>
此班级的信息将不再显示<br/>

View File

@ -368,6 +368,7 @@
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" id="new_message_cancel_btn" class="fr mr10 mt3">取消</a>
<% end %>
<p id="modify_inputs_notice" class="mt3 fr none c_red mr10"></p>
<div class="cl"></div>
</div>
</div>

View File

@ -8,15 +8,13 @@
<% homework.homework_samples.each_with_index do |sample, index| %>
<div class="mt10" style="margin-left:57px;">
<label class="fl fontGrey2 mr10 mt5 w20" name="sample_inputs_label"><%= index+1 %>&nbsp;&nbsp;</label>
<textarea class="InputBox w547 fl mr5" placeholder="样例输入" name="sample[input][]" <%= not_allow_select ? 'disabled' : '' %>><%= sample.input %></textarea>
<% unless not_allow_select %>
<textarea class="InputBox w547 fl mr5" placeholder="样例输入" name="sample[input][]"><%= sample.input %></textarea>
<a href="javascript:void(0);" class="fl icon_add sample_icon_add" title="增加样例组"></a>
<% if index != 0 %>
<a href="javascript:void(0);" class="fl icon_remove sample_icon_remove" title="删除样例组"></a>
<% end %>
<% end %>
<div class="cl"></div>
<textarea class="InputBox w547 fl ml30 mt10" placeholder="样例输出" name="sample[output][]" <%= not_allow_select ? 'disabled' : '' %>><%= sample.output %></textarea>
<textarea class="InputBox w547 fl ml30 mt10" placeholder="样例输出" name="sample[output][]"><%= sample.output %></textarea>
<div class="cl"></div>
</div>
<% end %>
@ -40,18 +38,17 @@
<span class="f12 c_red mt5 fr">温馨提示:您可以在发布作业后,在作业"模拟答题"中进行标准代码的检测。</span>
<div class="cl"></div>
<div id="input_boxes_div">
<% if edit_mode && homework.is_program_homework? %>
<% homework.homework_tests.each_with_index do |test, index| %>
<div class="mt10" style="margin-left:57px;">
<label class="fl fontGrey2 mr10 mt5 w20" name="inputs_label"><%= index+1 %>&nbsp;&nbsp;</label>
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]" <%= not_allow_select ? 'disabled' : '' %>><%= test.input %></textarea>
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]" <%= not_allow_select ? 'disabled' : '' %>><%= test.output %></textarea>
<% unless not_allow_select %>
<textarea class="InputBox w265 fl mr10" placeholder="测试输入" name="program[input][]"><%= test.input %></textarea>
<textarea class="InputBox w265 fl mr5" placeholder="测试输出" name="program[output][]"><%= test.output %></textarea>
<a href="javascript:void(0);" class=" fl icon_add test_icon_add" title="增加测试组"></a>
<% if index != 0 %>
<a href="javascript:void(0);" class=" fl icon_remove test_icon_remove" title="删除测试组"></a>
<% end %>
<% end %>
<div class="cl"></div>
</div>
<% end %>
@ -66,6 +63,7 @@
</div>
<% end %>
</div>
</div>
</div>
<script>
@ -74,6 +72,10 @@
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
<% if not_allow_select %>
$("#input_boxes_div .InputBox").on('focus', modify_input_notice);
<% end %>
$("#programHomework").on('click', 'a.test_icon_add', function () {
var html = bt('t:test-answer-list', null);
$(this).parent('.mt10').after(html);
@ -90,6 +92,9 @@
}
}
$(inputs[inputs.length - 1]).focus();
<% if not_allow_select %>
$("#input_boxes_div .InputBox").on('focus', modify_input_notice);
<% end %>
});
$("#programHomework").on('click', 'a.test_icon_remove', function () {
$(this).parent('.mt10').remove();
@ -152,4 +157,9 @@
}
}
<% end %>
function modify_input_notice(){
$("#modify_inputs_notice").html("修改测试集后请通知学生重新提交作品");
$("#modify_inputs_notice").show();
}
</script>