导入作业增加引用次数
This commit is contained in:
parent
a613b58b46
commit
c942c843b9
|
@ -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
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
<% if homework.homework_type == 2 && homework.homework_detail_programing %>
|
||||
编程语言:<%=homework.language_name %><br/>
|
||||
<% end %>
|
||||
贡献者:<%=homework.user.show_name %><br />
|
||||
贡献者:<%=homework.user.show_name %>
|
||||
<% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %>
|
||||
,<%=homework.user.user_extensions.occupation%>
|
||||
<% end %>
|
||||
<br />
|
||||
描述如下:
|
||||
</div>
|
||||
<div class="subjectContent" id="homework_description">
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
分组
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="subjectCount fl"><%= homework.quotes %></li>
|
||||
<li class="subjectPublisher fl"><%= homework.user.show_name %></li>
|
||||
<li class="fl subjectDate"><%=format_date homework.publish_time %></li>
|
||||
</ul>
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
<div>
|
||||
<ul class="subjectBanner mt10">
|
||||
<li class="subjectName fl hidden"><span style="padding-left:15px;">作业名称</span></li>
|
||||
<li class="subjectType fl">作业类型</li>
|
||||
<li class="subjectType fl">类型</li>
|
||||
<li class="subjectCount fl">引用数</li>
|
||||
<li class="subjectPublisher fl">贡献者</li>
|
||||
<li class="fl subjectDate">发布时间</li>
|
||||
</ul>
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
<div class=" mt10">
|
||||
<%= 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 %>
|
||||
<input type="hidden" name="quotes" id="ref_homework_id" value=""/>
|
||||
<% end %>
|
||||
<% if edit_mode %>
|
||||
<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>
|
||||
<% end %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddQuotesToHomework < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :homework_commons, :quotes, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -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"
|
||||
|
|
|
@ -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;}
|
||||
|
|
|
@ -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;}
|
||||
|
|
Loading…
Reference in New Issue