From 74343a49299ab500a1685fe254b3d7c4a94d92c2 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:35:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E3=80=81=E5=8F=96=E6=B6=88=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 19 ++-- app/views/exercise/_alert.html.erb | 27 ++++++ app/views/exercise/_exercise.html.erb | 4 +- .../exercise/_exercise_republish.html.erb | 0 app/views/exercise/index.html.erb | 87 +++++++++++++++++++ app/views/exercise/publish_exercise.js.erb | 10 +++ app/views/exercise/republish_exercise.js.erb | 10 +++ config/routes.rb | 2 + 8 files changed, 148 insertions(+), 11 deletions(-) create mode 100644 app/views/exercise/_alert.html.erb create mode 100644 app/views/exercise/_exercise_republish.html.erb create mode 100644 app/views/exercise/publish_exercise.js.erb create mode 100644 app/views/exercise/republish_exercise.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 18248331c..d13c02d27 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_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -261,7 +261,7 @@ class ExerciseController < ApplicationController end # 发布试卷 - def publish_excercise + def publish_exercise @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save @@ -276,16 +276,17 @@ class ExerciseController < ApplicationController end # 重新发布试卷 - def republish_excercise + # 重新发布的时候会删除所有的答题 + def republish_exercise @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_ansers.destroy_all end - # @poll.poll_users.destroy_all - # @poll.polls_status = 1 - # @poll.save - # respond_to do |format| - # format.js - # end + @exercise.exercise_users.destroy_all + @exercise.exercise_status = 1 + @exercise.save + respond_to do |format| + format.js + end end def student_exercise_list diff --git a/app/views/exercise/_alert.html.erb b/app/views/exercise/_alert.html.erb new file mode 100644 index 000000000..b3de53d1f --- /dev/null +++ b/app/views/exercise/_alert.html.erb @@ -0,0 +1,27 @@ + + + + + + + +
+
+
+

+ <%= message%> +

+ +
+
+
+
+ + + diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index 15a684a62..e44cd69c6 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -19,9 +19,9 @@ <% end%> <% if exercise.exercise_status == 1 %> -
  • 发布试卷
  • +
  • 发布试卷
  • <% elsif exercise.exercise_status == 2%> -
  • 取消发布
  • +
  • 取消发布
  • <% else%>
  • 发布试卷
  • <% end%> diff --git a/app/views/exercise/_exercise_republish.html.erb b/app/views/exercise/_exercise_republish.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index bbe4dd707..8e8940f33 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,4 +1,91 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +
    <%= render :partial => 'exercises_list'%>
    \ No newline at end of file diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb new file mode 100644 index 000000000..ac2899402 --- /dev/null +++ b/app/views/exercise/publish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','111px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb new file mode 100644 index 000000000..320cd3cf0 --- /dev/null +++ b/app/views/exercise/republish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise_content',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','80px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 516b8977f..559bf4376 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,6 +152,8 @@ RedmineApp::Application.routes.draw do get 'statistics_result' get 'student_exercise_list' get 'export_exercise' + get 'publish_exercise' + get 'republish_exercise' post 'create_exercise_question' post 'commit_answer' post 'commit_exercise' From 20a80fe6eb2b250f91885a132c3b5b3e3e81f10a Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:38:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/index.html.erb | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 8e8940f33..14db03e09 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -57,34 +57,6 @@ } } - function close_poll(poll_id) - { - $('#ajax-modal').html("
    " + - "
    " + - "
    " + - "

    问卷关闭后学生将不能继续提交问卷,
    是否确定关闭该问卷?

    " + - "
    " + - "确  定" + - "取  消" + - "
    " + - "
    " + - "
    " + - "
    " + - "
    "); - showModal('ajax-modal', '310px'); - $('#ajax-modal').css('height','120px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before("" + - ""); - $('#ajax-modal').parent().removeClass("alert_praise"); - $('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("popbox_polls"); - } - - function closeModal() - { - hideModal($("#popbox_upload")); - }
    <%= render :partial => 'exercises_list'%> From 7dc16775dcaa7902a145007a899bf02bdf7e9366 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:44:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51119124148_add_end_at_to_exercise_user.rb | 5 ++ db/schema.rb | 55 +------------------ 2 files changed, 7 insertions(+), 53 deletions(-) create mode 100644 db/migrate/20151119124148_add_end_at_to_exercise_user.rb diff --git a/db/migrate/20151119124148_add_end_at_to_exercise_user.rb b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb new file mode 100644 index 000000000..db4cc4c47 --- /dev/null +++ b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb @@ -0,0 +1,5 @@ +class AddEndAtToExerciseUser < ActiveRecord::Migration + def change + add_column :exercise_users, :end_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 07dac5706..042058c5a 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 => 20151118015638) do +ActiveRecord::Schema.define(:version => 20151119124148) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -241,58 +241,6 @@ ActiveRecord::Schema.define(:version => 20151118015638) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -614,6 +562,7 @@ ActiveRecord::Schema.define(:version => 20151118015638) do t.datetime "start_at" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.datetime "end_at" end create_table "exercises", :force => true do |t|