diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index bed3d9061..296c744b6 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -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]
diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb
index e469c471c..15a684a62 100644
--- a/app/views/exercise/_exercise.html.erb
+++ b/app/views/exercise/_exercise.html.erb
@@ -15,7 +15,7 @@
<% if exercise.exercise_status == 1%>
统计结果
<% else %>
- <%= link_to l(:label_statistical_results), statistics_result_exercise_path(exercise.id), :class => "pollsbtn fl ml10"%>
+ <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%>
<% end%>
<% if exercise.exercise_status == 1 %>
diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb
new file mode 100644
index 000000000..b133baa04
--- /dev/null
+++ b/app/views/exercise/_student_exercise.html.erb
@@ -0,0 +1,46 @@
+
+
+ 测验
+
+ (<%= @exercise_count%>人已交)
+
+ <% if !@is_teacher && @exercise_users_list.empty?%>
+ 您尚未提交
+ <% elsif !@is_teacher && !@exercise_users_list.empty?%>
+ 您已提交
+ <% end %>
+
+ <%if @is_teacher || @exercise.exercise_status == 3%>
+
+ <%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %>
+ <% end%>
+
[ 显示测验信息 ]
+
+
+
+
+ <%= render :partial => "evaluation_un_title"%>
+
+
+
+<% @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%>
+
+
+ <% 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 %>
+
+
+<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb
new file mode 100644
index 000000000..8653836ca
--- /dev/null
+++ b/app/views/exercise/student_exercise_list.html.erb
@@ -0,0 +1,138 @@
+
+
+
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 3f1ca2ba0..f1073381f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb
new file mode 100644
index 000000000..90aec321f
--- /dev/null
+++ b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb
@@ -0,0 +1,6 @@
+class AddPublishTimeEndTimeToExercise < ActiveRecord::Migration
+ def change
+ add_column :exercises, :publish_time, :timestamp
+ add_column :exercises, :end_time, :timestamp
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 272db1944..3feb43adb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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|