socialforge/app/views/exercise/_exercise.html.erb

112 lines
6.8 KiB
Plaintext

<%# 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 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 %>
<span class="exercise_status_pub fl mt3"></span>
<% else %>
<span class="exercise_status_end fl mt3"></span>
<% end%>
</div>
</div>
<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>
<li><a href="javascript:void(0)" onclick="send_exercise_to_course();" 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>
<div class="mt10">
<span class="c_grey fl mr15">测试时长:<%= exercise.time.nil? || exercise.time == -1 ? '不限' : exercise.time.to_s + "分钟" %></span>
<span class="c_grey fl mr15">截止时间:<%= exercise.end_time.nil? ? '未设置' : format_time(exercise.end_time) %></span>
<span class="c_grey fl mr15">发布时间:<%= exercise.publish_time.nil? ? '未设置' : format_time(exercise.publish_time) %></span>
<% 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>
<% else%>
<% if exercise.exercise_status != 1%>
<% eu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise.id, User.current.id, true).first %>
<div>
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :title => "#{exercise_name}", :class => "polls_title polls_title_st fl c_dblue "%>
<% if exercise.exercise_status == 3 %>
<span class="exercise_status_end fl"></span>
<% end%>
<% if eu && exercise.end_time >= eu.created_at %>
<span class="exercise_status_com fl ml5"></span>
<% else %>
<span class="exercise_status_nocom fl ml5"></span>
<% end %>
</div>
<div class="cl"></div>
<div class="mt10">
<span class="c_grey fl mr15">测试时长:<%= exercise.time.nil? || exercise.time == -1 ? '不限' : exercise.time.to_s + "分钟" %></span>
<span class="c_grey fl mr15">截止时间:<%= exercise.end_time.nil? ? '未设置' : format_time(exercise.end_time) %></span>
<span class="c_grey fl mr15">发布时间:<%= exercise.publish_time.nil? ? '未设置' : format_time(exercise.publish_time) %></span>
<% exercise_end = exercise.end_time > Time.now
if exercise.time == -1 || exercise.time.nil?
can_edit_excercise = exercise_end
else
can_edit_excercise = !has_commit_exercise?(exercise.id,User.current.id)&& exercise_end
end%>
<% if can_edit_excercise && eu %>
<a href="<%=exercise_path(exercise.id) %>" class="pollsbtn btn_pu fr mr10 ml5">继续答题</a>
<% elsif can_edit_excercise %>
<a href="<%=exercise_path(exercise.id) %>" class="pollsbtn btn_pu fr mr10 ml5">开始答题</a>
<% else %>
<a href="<%=exercise_path(exercise.id) %>" class="pollsbtn btn_pu fr mr10 ml5">查看答题</a>
<% end %>
<% if exercise.show_result == 1 %>
<% if exercise.end_time <= Time.now %>
<%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%>
<% else %>
<div class="pollsbtn fr mr10 pollsbtn_grey" title="截止时间还未到,暂不可查看统计结果">统计结果</div>
<%end%>
<% end %>
<div class="clear"></div>
</div>
<% end%>
<% end%>
<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>