parent
86cb496f3f
commit
96504d6806
|
@ -18,7 +18,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
|
#if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)
|
||||||
user_id = params[:user_id]
|
user_id = params[:user_id]
|
||||||
bid_id = params[:bid_id]
|
bid_id = params[:bid_id]
|
||||||
sta = 0
|
sta = 0
|
||||||
|
@ -46,7 +46,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
format.json { render json: @homework.errors, status: :unprocessable_entity }
|
format.json { render json: @homework.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
@homework = HomeworkAttach.find(params[:id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @post.update_attributes(params[:homework])
|
if @homework.update_attributes(params[:homework])
|
||||||
format.html { redirect_to @homework, notice: 'Homework was successfully updated.' }
|
format.html { redirect_to @homework, notice: 'Homework was successfully updated.' }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
|
@ -77,12 +77,12 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@homework = HomeworkAttach.find(params([:id]))
|
#@homework = HomeworkAttach.find(params([:id]))
|
||||||
@homework.destroy
|
#@homework.destroy
|
||||||
respond_to do |format|
|
#respond_to do |format|
|
||||||
format.html {render @homework}
|
# format.html {render @homework}
|
||||||
format.json {render json: @homework}
|
# format.json {render json: @homework}
|
||||||
end
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
#显示作业信息
|
#显示作业信息
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
module HomeworkAttachHelper
|
||||||
|
def attach_delete(project)
|
||||||
|
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -25,7 +25,8 @@
|
||||||
</div>
|
</div>
|
||||||
<% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %>
|
<% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %>
|
||||||
<div class='icon icon-add'>
|
<div class='icon icon-add'>
|
||||||
<%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %>
|
<!-- <%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> -->
|
||||||
|
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -32,17 +32,28 @@
|
||||||
<td>
|
<td>
|
||||||
<table width="580px" border="0">
|
<table width="580px" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 300px">
|
<td style="width: 300px;">
|
||||||
<strong>作业 :</strong>
|
<strong>作业 :</strong>
|
||||||
<% attachments = homework.attachments.map %>
|
<% if homework.name == nil || homework.name == "" %>
|
||||||
<% for attachment in attachments %>
|
<% attachments = homework.attachments.map %>
|
||||||
<% if attachments.count > 1 && attachment != attachments.first %>
|
<% for attachment in attachments %>
|
||||||
<br/>
|
<% if attachments.count > 1 %>
|
||||||
<% for item in 1..7 %>
|
<% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %>
|
||||||
|
<% else %>
|
||||||
|
<% homework_filename = attachment.filename %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<!--
|
||||||
|
<% if attachments.count > 1 && attachment != attachments.first %>
|
||||||
|
<br/>
|
||||||
|
<% for item in 1..7 %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
-->
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to_attachment attachment , :download => true -%>
|
<strong><%= homework_filename %></strong>
|
||||||
|
<% else %>
|
||||||
|
<strong><%= homework.name %></strong>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td style="vertical-align: top">
|
<td style="vertical-align: top">
|
||||||
|
@ -76,12 +87,21 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top">
|
<td valign="top">
|
||||||
<% if is_cur_course_user? @bid %>
|
<% if is_cur_course_user? @bid %>
|
||||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.user_extensions.student_id%></strong>
|
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.user_extensions.student_id%></strong>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
|
||||||
|
<%= link_to l(:button_edit), edit_homework_attach_path(homework) %>
|
||||||
|
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => homework},
|
||||||
|
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<!--
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" width="580px" >
|
<td colspan="2" width="580px" >
|
||||||
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
|
<% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %>
|
||||||
|
@ -93,6 +113,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
-->
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -8,4 +8,6 @@
|
||||||
:controller => 'attachments', :action => 'show',
|
:controller => 'attachments', :action => 'show',
|
||||||
:id => attachment, :filename => attachment.filename %>
|
:id => attachment, :filename => attachment.filename %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
|
||||||
|
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
||||||
|
<div class="box">
|
||||||
|
<%= @homework.attachments.count %>
|
||||||
|
<%= form_for(@homework) do |f|%>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong>标 题:</strong>
|
||||||
|
<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;"%>
|
||||||
|
</p>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
|
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p style="padding-left: 60px">
|
||||||
|
<fieldset style="text-align: left;">
|
||||||
|
<p style="padding-left: 60px">
|
||||||
|
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
|
||||||
|
<%= render :partial => 'attachments/links',
|
||||||
|
:locals => {:attachments => @homework.attachments, :options => options} %>
|
||||||
|
</p>
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_attachment_plural) %>
|
||||||
|
</legend>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<%= render :partial => 'attachments/form' %>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</p>
|
||||||
|
<p style="padding-left: 60px;padding-top: 10px;">
|
||||||
|
<span >
|
||||||
|
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -1,32 +1,34 @@
|
||||||
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
||||||
<div class="box tabular">
|
<div class="box">
|
||||||
<%= form_for('new_form', :remote => true, :method => :post,
|
<%= form_for('new_form', :remote => true, :method => :post,
|
||||||
:url => {:controller => 'homework_attach',
|
:url => {:controller => 'homework_attach',
|
||||||
:action => 'create',
|
:action => 'create',
|
||||||
:user_id => User.current.id,
|
:user_id => User.current.id,
|
||||||
:bid_id => @bid
|
:bid_id => @bid
|
||||||
}) do |f|%>
|
}) do |f|%>
|
||||||
<p>
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong>标题:</strong>
|
<strong>标 题:</strong>
|
||||||
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong style="vertical-align: top">描述:</strong>
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
<span style="margin-left:-10px;padding-right: 20px;">
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<fieldset>
|
<p style="padding-left: 60px">
|
||||||
<legend>
|
<fieldset style="text-align: left;">
|
||||||
<%= l(:label_attachment_plural) %>
|
<legend>
|
||||||
</legend>
|
<%= l(:label_attachment_plural) %>
|
||||||
<p id="put-bid-form-partial">
|
</legend>
|
||||||
<%= render :partial => 'attachments/form' %>
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
</p>
|
<%= render :partial => 'attachments/form' %>
|
||||||
</fieldset>
|
</p>
|
||||||
<span style="padding-left: 60px">
|
</fieldset>
|
||||||
<%= submit_tag t(:label_new), :sta => 0, :class => "enterprise"%>
|
</p>
|
||||||
<%= submit_tag t(:label_memo_create), :sta => 1, :class => "enterprise"%>
|
<p style="padding-left: 60px;padding-top: 10px;">
|
||||||
|
<span >
|
||||||
|
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
|
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
|
||||||
</td>
|
</td>
|
||||||
<td>发布时间:<%=format_time @homework.created_at %></td>
|
<td>发布时间:<%=format_time @homework.created_at %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 40px">
|
<td style="padding-left: 40px">
|
||||||
|
@ -58,15 +57,19 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top"><div style="font-size: 15px;"><strong>作业描述:</strong></div></td>
|
<td colspan="2" valign="top"><div style="font-size: 15px;"><strong>作业描述:</strong></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% @homework.attachments.map do |attachment| %>
|
<tr>
|
||||||
<% if attachment.description != nil && attachment.description != "" %>
|
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
|
||||||
<tr>
|
<div style="padding-top: 5px">
|
||||||
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
|
<% if @homework.description != nil && @homework.description != "" %>
|
||||||
<div style="padding-top: 5px"> <%= attachment.description %></div>
|
<%= @homework.description %>
|
||||||
</td>
|
<% else %>
|
||||||
</tr>
|
<div style="font-size: 15px;color: #15BCCC;vertical-align:middle;padding-top: 10px;padding-left: 10px ">
|
||||||
<% end %>
|
<strong>该作业无任何描述!</strong>
|
||||||
<% end %>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140522025721) do
|
ActiveRecord::Schema.define(:version => 20140527060344) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -57,14 +57,11 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type"
|
||||||
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on"
|
||||||
|
|
||||||
create_table "attachmentstypes", :id => false, :force => true do |t|
|
create_table "attachmentstypes", :force => true do |t|
|
||||||
t.integer "id", :null => false
|
t.integer "typeId", :null => false
|
||||||
t.integer "typeId"
|
|
||||||
t.string "typeName", :limit => 50
|
t.string "typeName", :limit => 50
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "attachmentstypes", ["id"], :name => "id"
|
|
||||||
|
|
||||||
create_table "auth_sources", :force => true do |t|
|
create_table "auth_sources", :force => true do |t|
|
||||||
t.string "type", :limit => 30, :default => "", :null => false
|
t.string "type", :limit => 30, :default => "", :null => false
|
||||||
t.string "name", :limit => 60, :default => "", :null => false
|
t.string "name", :limit => 60, :default => "", :null => false
|
||||||
|
@ -482,12 +479,13 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
t.text "notes"
|
t.text "notes"
|
||||||
t.integer "status"
|
t.integer "status"
|
||||||
t.integer "reply_id"
|
t.integer "reply_id"
|
||||||
t.datetime "created_on", :null => false
|
t.datetime "created_on", :null => false
|
||||||
t.datetime "updated_on", :null => false
|
t.datetime "updated_on", :null => false
|
||||||
t.string "m_parent_id"
|
t.string "m_parent_id"
|
||||||
t.boolean "is_readed"
|
t.boolean "is_readed"
|
||||||
t.integer "m_reply_count"
|
t.integer "m_reply_count"
|
||||||
t.integer "m_reply_id"
|
t.integer "m_reply_id"
|
||||||
|
t.integer "is_comprehensive_evaluation"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "member_roles", :force => true do |t|
|
create_table "member_roles", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue