diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 8fa90ea46..25b5dacec 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -16,10 +16,7 @@ class ExerciseController < ApplicationController exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) end end - end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) - end_exercises.each do |exercise| - exercise.update_column('exercise_status', 3) - end + if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 return @@ -46,10 +43,7 @@ class ExerciseController < ApplicationController exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) end end - end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) - end_exercises.each do |exercise| - exercise.update_column('exercise_status', 3) - end + unless User.current.member_of_course?(@course) || User.current.admin? render_403 return diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index d20a58b75..e0aff6254 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -120,15 +120,16 @@ class SchoolController < ApplicationController condition.scan(/./).each_with_index do |char,index| if char =~ /[a-zA-Z0-9]/ pinyin << char + elsif char =~ /\'/ else chinese << char end end if(condition == '') - @school = School.page((params[:page].to_i || 1) - 1).per(100) + @school = School.reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.count else - @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").page((params[:page].to_i || 1) - 1).per(100) + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count end diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 00dfc03e3..4dcdb7749 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,20 +1,3 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false) %> - <%= javascript_include_tag "init_activity_KindEditor" %> -<% end %> - - - <% if topic %> - <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> - <% end %> - <% end %> - - <% if topics.count == 10 %> -
展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
- <% end %> -<% end%> - - - + <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %> diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb new file mode 100644 index 000000000..c324f1d69 --- /dev/null +++ b/app/views/boards/_course_show_detail.html.erb @@ -0,0 +1,70 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag "init_activity_KindEditor" %> +<% end %> + + +<% if topics%> + <% topics.each do |topic| %> + + <% if topic %> + <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + + <% if topics.count == 10 %> +
展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
+ <% end %> +<% end%> + + \ No newline at end of file diff --git a/app/views/boards/show.js.erb b/app/views/boards/show.js.erb index dd5fa4688..c088abce5 100644 --- a/app/views/boards/show.js.erb +++ b/app/views/boards/show.js.erb @@ -1 +1 @@ -$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show',:locals => {:topics => @topics, :page => @page} )%>"); \ No newline at end of file +$("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show_detail',:locals => {:topics => @topics, :page => @page} )%>"); \ No newline at end of file diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index bbbe9026d..3bcd6b83f 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -75,6 +75,9 @@
  • <% if exercise.created_at%> <%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>  + <% if @exercise.end_time <= exercise.created_at %> + [未答] + <% end %> <% end %>
  • diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 115a70e7a..fd6171f18 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -18,7 +18,7 @@ } $(function () { - init_activity_KindEditor_data(<%= issue.id%>, null, "87%"); + init_activity_KindEditor_data(<%= issue.id%>, null, "87%", "<%= issue.class.name %>"); showNormalImage('activity_description_<%= issue.id %>'); if ($("#intro_content_<%= issue.id %>").height() > 360) { $("#intro_content_show_<%= issue.id %>").show(); diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index c832c884f..4af757c77 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,9 +1,9 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false) %> + <%= import_ke(enable_at: true) %> <%= javascript_include_tag 'create_kindeditor'%> <% end %> \ No newline at end of file + +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 60b8e6728..f02105fb6 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -97,11 +97,21 @@
    -
    + +
    + 迟交扣分:<%= activity.late_penalty%>分 +
    +
    匿评开启时间:<%= activity.homework_detail_manual.evaluation_start%> 00:00
    -
    +
    +
    +
    +
    + 缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品 +
    +
    匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%> 23:59
    diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index 006743cd7..84b727cbf 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -26,7 +26,7 @@
    - <% count=course.journals_for_messages.where('m_parent_id IS NULL').count %> + <% count = fetch_user_leaveWord_reply(activity).count %>
    @@ -47,7 +47,7 @@ <% if count > 0 %>
      - <% course.journals_for_messages.where('m_parent_id IS NULL').reorder("created_on desc").each do |comment| %> + <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %> -
      -
      - <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33", :class =>"mt8"), user_path(reply.user_id), :alt => "用户头像" %> -
      -
      -
      - <% if reply.try(:user).try(:realname) == ' ' %> - <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> - <% end %> - <%= l(:label_reply_to)%> - <% if comment.try(:user).try(:realname) == ' ' %> - <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14 ml10" %> - <% else %> - <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14 ml10" %> - <% end %> - <%= format_time reply.created_on %> -
      -
      - <%= reply.notes.html_safe %>
      -
      -
      -
      -
      - <% end %> - <% end %> + <%= comment.notes.html_safe %> +
    + <% end %> <% end %>
    diff --git a/app/views/users/_user_group_attr.html.erb b/app/views/users/_user_group_attr.html.erb index 652cb723a..a815d85e7 100644 --- a/app/views/users/_user_group_attr.html.erb +++ b/app/views/users/_user_group_attr.html.erb @@ -10,7 +10,7 @@

    提醒:勾选后各小组必须在Trustie平台创建项目,教师可随时观察平台对各小组最新进展的实时统计。

    diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index d9421f5ea..5bfe1814d 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -102,11 +102,21 @@
    -
    + +
    + 迟交扣分:<%= homework_common.late_penalty%>分 +
    +
    匿评开启时间:<%= homework_common.homework_detail_manual.evaluation_start%> 00:00
    -
    +
    +
    +
    +
    + 缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品 +
    +
    匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%> 23:59
    diff --git a/db/migrate/20151218022014_batch_delete_project_journal_activities.rb b/db/migrate/20151218022014_batch_delete_project_journal_activities.rb index 95d6a39c5..6752b5b30 100644 --- a/db/migrate/20151218022014_batch_delete_project_journal_activities.rb +++ b/db/migrate/20151218022014_batch_delete_project_journal_activities.rb @@ -1,7 +1,15 @@ # encoding: utf-8 class BatchDeleteProjectJournalActivities < ActiveRecord::Migration def up - ForgeActivity.where('forge_act_type = \'Journal\'').destroy_all #需要触发回调 + #ForgeActivity.where('forge_act_type = \'Journal\'').destroy_all #需要触发回调 + count = ForgeActivity.where('forge_act_type = \'Journal\'').count / 30 + 2 + transaction do + for i in 1 ... count do i + ForgeActivity.where('forge_act_type = \'Journal\'').page(i).per(30).each do |activity| + activity.destroy + end + end + end end def down diff --git a/db/schema.rb b/db/schema.rb index 9c7702aa2..eac8a81db 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -558,23 +558,26 @@ ActiveRecord::Schema.define(:version => 20151218022014) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "editor_of_documents", :force => true do |t| @@ -923,16 +926,6 @@ ActiveRecord::Schema.define(:version => 20151218022014) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake index a27c6a6fb..13ae8c484 100644 --- a/lib/tasks/exercise_publish.rake +++ b/lib/tasks/exercise_publish.rake @@ -14,9 +14,21 @@ namespace :exercise_publish do end task :end => :environment do + include ExerciseHelper exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) exercises.each do |exercise| + course = exercise.course exercise.update_column('exercise_status', 3) + course.student.each do |student| + if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,exercise.id).empty? + ExerciseUser.create(:user_id => student.student_id, :exercise_id => exercise.id, :start_at => exercise.end_time, :status => true,:score=>0) + end +=begin + s_score = calculate_student_score(exercise, student.student) + exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, exercise.id).first + exercise_user.update_attributes(:score => s_score) +=end + end end end end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 6f8e489f8..930911e76 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -260,7 +260,7 @@ K.options = { bodyClass : 'ke-content', indentChar : '\t', cssPath : K.basePath +'plugins/code/previewcode.css', - cssData : '', + cssData : 'font{color:black;}', minWidth : 650, minHeight : 100, minChangeSize : 1, diff --git a/public/javascripts/create_kindeditor.js b/public/javascripts/create_kindeditor.js index 3f555ac88..0eac4b01e 100644 --- a/public/javascripts/create_kindeditor.js +++ b/public/javascripts/create_kindeditor.js @@ -3,6 +3,7 @@ function sd_create_editor(params){ // var minHeight; //最小高度 var paramsHeight = params.height; //设定的高度 var id = arguments[1] ? arguments[1] : undefined; + var type = arguments[2] ? arguments[2] : ''; var paramsWidth = params.width == undefined ? "100%" : params.width; var editor = params.kindutil.create(params.textarea, { @@ -74,7 +75,9 @@ function sd_create_editor(params){ edit.html("我要回复"); this.resize(null,paramsHeight);// Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ paramsHeight , paramsHeight) // params.toolbar_container.hide(); - + if(typeof enableAt === 'function'){ + enableAt(this, id, type); + } } }).loadPlugin('paste'); return editor; @@ -136,6 +139,7 @@ function sd_reset_editor_form(params){ function sd_create_editor_from_data(id){ var height = arguments[1] ? arguments[1] : undefined; var width = arguments[2] ? arguments[2] : undefined; + var type = arguments[3] ? arguments[3] : undefined; KindEditor.ready(function (K) { $("div[nhname='new_message_" + id + "']").each(function () { var params = {}; @@ -153,7 +157,7 @@ function sd_create_editor_from_data(id){ params.height = height; params.width = width; if (params.textarea.data('init') == undefined) { - params.editor = sd_create_editor(params,id); + params.editor = sd_create_editor(params,id, type); sd_create_form(params); params.cancel_btn.click(function () { sd_reset_editor_form(params);