学生测验列表

This commit is contained in:
cxt 2015-11-17 09:33:40 +08:00
parent 10ac8eaa35
commit 5400b907e6
7 changed files with 213 additions and 3 deletions

View File

@ -1,7 +1,7 @@
class ExerciseController < ApplicationController
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
def index
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
if @is_teacher
@ -44,6 +44,23 @@ class ExerciseController < ApplicationController
end
def student_exercise_list
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@exercise = Exercise.find params[:id]
@all_exercises = @course.exercises.order("created_at desc")
@exercise_count = @exercise.exercise_users.where('score is not NULL').count
if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S"))
@exercise_users_list = @exercise.exercise_users.where('score is not NULL')
elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S")
@exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id)
else
@exercise_users_list = []
end
respond_to do |format|
format.html
end
end
private
def find_course
@course = Course.find params[:course_id]

View File

@ -15,7 +15,7 @@
<% if exercise.exercise_status == 1%>
<li class="pollsbtn fl ml10 pollsbtn_grey">统计结果</li>
<% else %>
<li><%= link_to l(:label_statistical_results), statistics_result_exercise_path(exercise.id), :class => "pollsbtn fl ml10"%></li>
<li><%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%></li>
<% end%>
<% if exercise.exercise_status == 1 %>

View File

@ -0,0 +1,46 @@
<div class="fl" style="padding-bottom:10px; width:720px;">
<span class="c_dark f14 fb fl mr30">
测验
<font class="f12 c_red">
(<%= @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">
<input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%#= student_work_index_path(:homework => @homework.id)%>',event);"/>
<a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%#= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a>
</div>
<%#= 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" style="display: none">[ 显示测验信息 ]</a> </span>
</div>
<div class="cl"></div>
<div class="fl">
<%= render :partial => "evaluation_un_title"%>
</div>
<div class="cl"></div>
<% @stundet_works.each do |student_work|%>
<% if @is_evaluation%>
<%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%>
<% else%>
<%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%>
<% end%>
<div class="cl"></div>
<div id="about_hwork_<%= student_work.id%>">
<% if student_work.user == User.current && !@is_evaluation %>
<% if @homework.homework_type == 2%>
<%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %>
<% else %>
<%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %>
<% end %>
<% end %>
</div>
<div class="cl"></div>
<% end%>

View File

@ -0,0 +1,138 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
$("#Container").css("width","1000px");
});
// 匿评弹框提示
<%# if @is_evaluation && !@stundet_works.empty?%>
// $(function(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
// showModal('ajax-modal', '500px');
// $('#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().css("top","").css("left","");
// $('#ajax-modal').parent().addClass("anonymos");
// });
<%# end%>
//设置评分规则
function set_score_rule(){
$('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>');
showModal('ajax-modal', '350px');
$('#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().css("top","25%").css("left","35%").css("position","fixed");
}
$(function(){
$("#homework_info_hidden").click(function(){
$("#homeworkInformation").hide();
$("#homework_info_hidden").hide();
$("#homework_info_show").show();
});
$("#homework_info_show").click(function(){
$("#homework_info_show").hide();
$("#homeworkInformation").show();
$("#homework_info_hidden").show();
});
if($("#homework_description").height() > 54) {
$("#homeworkDetailShow").show();
}
$("#homeworkDetailShow").click(function(){
$("#homeworkDetail").toggleClass("max_h54");
$("#homeworkDetailShow").hide();
$("#homeworkDetailHide").show();
});
$("#homeworkDetailHide").click(function(){
$("#homeworkDetail").toggleClass("max_h54");
$("#homeworkDetailHide").hide();
$("#homeworkDetailShow").show();
});
});
</script>
<div class="homepageRight mt0 ml10">
<div class="resources" id="homework_page_right">
<div class="hworkListBanner">
<div id="menu_r" class="fl">
<ul class="menu_r">
<li>
<a href="javascript:void(0);" class="parent">
<% @all_exercises.each_with_index do |exercise,index |%>
<% if exercise.id == @exercise.id %>
<%="测验 #{@all_exercises.count - index}" %>
<% end %>
<% end%>
</a>
<ul>
<% @all_exercises.each_with_index do |exercise,index |%>
<li class="pr10">
<%= link_to "作业#{@all_exercises.count - index}#{exercise.exercise_name}",''%>
<%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
</li>
<% end%>
</ul>
</li>
<!---level1 end--->
</ul>
<!---menu_r end--->
</div>
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
<div class="cl"></div>
</div>
<div class="homeworkInfo" id="homeworkInformation">
<div class="">
<div class="homepagePostTitle fl hidden m_w460" title="<%= @exercise.exercise_name %>"><%= @exercise.exercise_name %></div>
<% if @exercise.exercise_status == 1 %>
<span class="grey_homework_btn_cir ml5">未发布</span>
<% elsif @exercise.exercise_status == 2 %>
<span class="green_homework_btn_cir ml5">已发布</span>
<% elsif @exercise.exercise_status == 3 %>
<span class="grey_homework_btn_cir ml5">已截止</span>
<% end%>
<span class="fr c_grey"> <a href="javascript:void(0);" class="linkGrey2" id="homework_info_hidden">[ 隐藏测验信息 ]</a> </span>
<div class="cl"></div>
<div class="fontGrey2 db mb5">发布者:<%= @exercise.user.show_name %></div>
<div class="homeworkDetail upload_img break_word list_style max_h54" id="homeworkDetail">
<div id="homework_description"><%= @exercise.exercise_description.html_safe %></div>
</div>
<div id="homeworkDetailShow" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="homeworkDetailHide" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="mt5">
<div class="fontGrey2 db fl">截止时间:<%= format_time @exercise.end_time %></div>
<% if @exercise.exercise_status == 1 %>
<div class="fontGrey2 db fl ml10">发布时间:<%= format_time @exercise.publish_time %></div>
<% end %>
<% end_time = @exercise.end_time.to_time.to_i %>
<% if end_time > Time.now.to_i %>
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
<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>
<% end %>
<div class="cl"></div>
</div>
</div>
</div>
<div class="hworkListContainer">
<div class="ctt2">
<div class="dis" id="homework_student_work_list">
<%= render :partial => "exercise/student_exercise"%>
</div>
</div>
</div>
<div class="cl"></div>
</div>
</div>
<div class="cl"></div>

View File

@ -150,6 +150,7 @@ RedmineApp::Application.routes.draw do
resources :exercise do
member do #生成路径为 /exercise/:id/方法名
get 'statistics_result'
get 'student_exercise_list'
get 'export_exercise'
end

View File

@ -0,0 +1,6 @@
class AddPublishTimeEndTimeToExercise < ActiveRecord::Migration
def change
add_column :exercises, :publish_time, :timestamp
add_column :exercises, :end_time, :timestamp
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151113025751) do
ActiveRecord::Schema.define(:version => 20151116065904) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -624,6 +624,8 @@ ActiveRecord::Schema.define(:version => 20151113025751) do
t.integer "time"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "publish_time"
t.datetime "end_time"
end
create_table "first_pages", :force => true do |t|