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

97 lines
5.7 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>
<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}" %>
<% 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>
<% 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>
<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>
<% 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%>
<% 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%>