From c942c843b94fec9d660b60e64e87728bb7958b9d Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 28 Jan 2016 16:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E4=B8=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BC=95=E7=94=A8=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 21 ++++++++++++------- .../_homework_detail_information.html.erb | 6 +++++- .../users/_show_user_homework_form.html.erb | 1 + app/views/users/_show_user_homeworks.html.erb | 3 ++- app/views/users/_user_homework_form.html.erb | 3 +++ app/views/users/user_select_homework.js.erb | 1 + .../20160128024452_add_quotes_to_homework.rb | 5 +++++ db/schema.rb | 3 ++- public/stylesheets/new_user.css | 9 ++++---- public/stylesheets/public.css | 9 ++++---- 10 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20160128024452_add_quotes_to_homework.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9cf69504b..190784f26 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -408,7 +408,7 @@ class UsersController < ApplicationController #@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids}").order("created_at desc") + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc") @type = params[:type] @limit = 15 @is_remote = true @@ -426,9 +426,9 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") #公共题库 visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids}").order("created_at desc") + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc") elsif params[:type] == "2" #我的题库 - @homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") end @type = params[:type] @limit = 15 @@ -451,13 +451,14 @@ class UsersController < ApplicationController #用户主页过滤作业 def user_search_homeworks + @user = User.current search = params[:name].to_s.strip.downcase if(params[:type].blank? || params[:type] == "1") #全部 visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and (name like '%#{search}%')").order("created_at desc") + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'} and (name like '%#{search}%')").order("created_at desc") elsif params[:type] == "2" #课程资源 - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and (name like '%#{search}%')").order("created_at desc") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") end @type = params[:type] @limit = 15 @@ -479,6 +480,7 @@ class UsersController < ApplicationController @homework = HomeworkCommon.new @select_course = params[:select_course] || 0 if homework + @ref_homework = homework @homework.name = homework.name @homework.description = homework.description @homework.end_time = homework.end_time @@ -636,13 +638,15 @@ class UsersController < ApplicationController homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing homework_detail_group.save if homework_detail_group - + if params[:quotes] && !params[:quotes].blank? + homework = HomeworkCommon.find params[:quotes].to_i + homework.update_attribute(:quotes, homework.quotes+1) + end if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => homework.course_id) else redirect_to user_homeworks_user_path(User.current.id) end - end end else @@ -1681,7 +1685,8 @@ class UsersController < ApplicationController end attach_copied_obj.save unless Project.find(project_id).project_score.nil? - Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) + Project.find(project_id).project_score.update_attribute(:attach_num, + Project.find(project_id).project_score.attach_num + 1) end end end diff --git a/app/views/users/_homework_detail_information.html.erb b/app/views/users/_homework_detail_information.html.erb index 6887444ab..d650cd084 100644 --- a/app/views/users/_homework_detail_information.html.erb +++ b/app/views/users/_homework_detail_information.html.erb @@ -8,7 +8,11 @@ <% if homework.homework_type == 2 && homework.homework_detail_programing %> 编程语言:<%=homework.language_name %>
<% end %> - 贡献者:<%=homework.user.show_name %>
+ 贡献者:<%=homework.user.show_name %> + <% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %> + ,<%=homework.user.user_extensions.occupation%> + <% end %> +
描述如下:
diff --git a/app/views/users/_show_user_homework_form.html.erb b/app/views/users/_show_user_homework_form.html.erb index b316093c3..43d204508 100644 --- a/app/views/users/_show_user_homework_form.html.erb +++ b/app/views/users/_show_user_homework_form.html.erb @@ -16,6 +16,7 @@ 分组 <% end %> +
  • <%= homework.quotes %>
  • <%= homework.user.show_name %>
  • <%=format_date homework.publish_time %>
  • diff --git a/app/views/users/_show_user_homeworks.html.erb b/app/views/users/_show_user_homeworks.html.erb index f013705c5..9f90a633f 100644 --- a/app/views/users/_show_user_homeworks.html.erb +++ b/app/views/users/_show_user_homeworks.html.erb @@ -10,7 +10,8 @@
      -
    • 作业类型
    • +
    • 类型
    • +
    • 引用数
    • 贡献者
    • 发布时间
    diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 5781a3416..4082854da 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -34,6 +34,9 @@
    <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%> + <% unless edit_mode %> + + <% end %> <% if edit_mode %> <% end %> diff --git a/app/views/users/user_select_homework.js.erb b/app/views/users/user_select_homework.js.erb index 9b4b43b33..306374b84 100644 --- a/app/views/users/user_select_homework.js.erb +++ b/app/views/users/user_select_homework.js.erb @@ -5,6 +5,7 @@ $("#homework_end_time").val("<%= @homework.end_time%>"); <% if @select_course == "0"%> $("#course_id").val("<%= @homework.course_id%>"); <% end%> +$("#ref_homework_id").val("<%= @ref_homework.id%>"); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework,:has_program => true,:has_group => true,:show_member=>true})%>"); homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>"); <% if @homework_detail_group %> diff --git a/db/migrate/20160128024452_add_quotes_to_homework.rb b/db/migrate/20160128024452_add_quotes_to_homework.rb new file mode 100644 index 000000000..7f02062fb --- /dev/null +++ b/db/migrate/20160128024452_add_quotes_to_homework.rb @@ -0,0 +1,5 @@ +class AddQuotesToHomework < ActiveRecord::Migration + def change + add_column :homework_commons, :quotes, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 42a5ea702..4539131c1 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 => 20160126031857) do +ActiveRecord::Schema.define(:version => 20160128024452) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -783,6 +783,7 @@ ActiveRecord::Schema.define(:version => 20160126031857) do t.datetime "updated_at", :null => false t.integer "teacher_priority", :default => 1 t.integer "anonymous_comment", :default => 0 + t.integer "quotes", :default => 0 end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 3f5c21567..d31c1ee0c 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1442,10 +1442,11 @@ a.subjectChoose {padding:8px 20px; background-color:#f1f1f1; color:#888888;} a.chooseActive {background-color:#269ac9; color:#ffffff;} .subjectBanner {width:585px; height:40px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;} .subjectBanner li {height:40px; line-height:40px; vertical-align:middle;} -.subjectName {width:260px; padding-left:10px;} -.subjectType {width:100px; text-align:center;} -.subjectPublisher {width:100px; text-align:center;} -.subjectDate {width:115px; text-align:center;} +.subjectName {width:270px; padding-left:10px; padding-right:10px;} +.subjectPublisher {width:80px; text-align:center;} +.subjectDate {width:80px; text-align:center;} +.subjectType {width:70px; text-align:center;} +.subjectCount {width:65px; text-align:center;} .subjectRow {width:585px; height:30px; color:#7a7a7a; font-size:12px;} .subjectRow li {height:30px; line-height:30px; vertical-align:middle;} .subjectSearch {border:1px solid #dddddd; height:32px; width:250px;outline: none;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 2d6bad0a1..be9d51799 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1026,10 +1026,11 @@ a.subjectChoose {padding:8px 20px; background-color:#f1f1f1; color:#888888;} a.chooseActive {background-color:#269ac9; color:#ffffff;} .subjectBanner {width:585px; height:40px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;} .subjectBanner li {height:40px; line-height:40px; vertical-align:middle;} -.subjectName {width:360px; padding-left:10px;} -.subjectType {width:100px; text-align:center;} -.subjectPublisher {width:100px; text-align:center;} -.subjectDate {width:115px; text-align:center;} +.subjectName {width:270px; padding-left:10px; padding-right:10px;} +.subjectPublisher {width:80px; text-align:center;} +.subjectDate {width:80px; text-align:center;} +.subjectType {width:70px; text-align:center;} +.subjectCount {width:65px; text-align:center;} .subjectRow {width:585px; height:30px; color:#7a7a7a; font-size:12px;} .subjectRow li {height:30px; line-height:30px; vertical-align:middle;} .subjectSearch {border:1px solid #dddddd; height:32px; width:250px;outline: none;}