1.修改作业提交流程,

2.增加修改作业、删除作业方法
3.修改作业页面显示
This commit is contained in:
sw 2014-05-29 20:02:02 +08:00
parent 86cb496f3f
commit 96504d6806
9 changed files with 126 additions and 53 deletions

View File

@ -18,7 +18,7 @@ class HomeworkAttachController < ApplicationController
end
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]
bid_id = params[:bid_id]
sta = 0
@ -46,7 +46,7 @@ class HomeworkAttachController < ApplicationController
format.json { render json: @homework.errors, status: :unprocessable_entity }
end
end
end
#end
end
def new
@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController
def update
@homework = HomeworkAttach.find(params[:id])
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.json { head :no_content }
else
@ -77,12 +77,12 @@ class HomeworkAttachController < ApplicationController
end
def destroy
@homework = HomeworkAttach.find(params([:id]))
@homework.destroy
respond_to do |format|
format.html {render @homework}
format.json {render json: @homework}
end
#@homework = HomeworkAttach.find(params([:id]))
#@homework.destroy
#respond_to do |format|
# format.html {render @homework}
# format.json {render json: @homework}
#end
end
#显示作业信息

View File

@ -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

View File

@ -25,7 +25,8 @@
</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) %>
<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>
<% end %>

View File

@ -32,17 +32,28 @@
<td>
<table width="580px" border="0">
<tr>
<td style="width: 300px">
<td style="width: 300px;">
&nbsp;&nbsp;<strong>作业&nbsp;&nbsp; :</strong>&nbsp;
<% if homework.name == nil || homework.name == "" %>
<% attachments = homework.attachments.map %>
<% for attachment in attachments %>
<% if attachments.count > 1 %>
<% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %>
<% else %>
<% homework_filename = attachment.filename %>
<% end %>
<!--
<% if attachments.count > 1 && attachment != attachments.first %>
<br/>
<% for item in 1..7 %>
&nbsp;
<% end %>
<% end %>
<%= link_to_attachment attachment , :download => true -%>
-->
<% end %>
<strong><%= homework_filename %></strong>
<% else %>
<strong><%= homework.name %></strong>
<% end %>
</td>
<td style="vertical-align: top">
@ -76,12 +87,21 @@
</td>
</tr>
<tr>
<td colspan="2" valign="top">&nbsp;
<td valign="top">&nbsp;
<% if is_cur_course_user? @bid %>
<strong><%= l(:label_bidding_user_studentcode) %>&nbsp; &nbsp;<%= homework.user.user_extensions.student_id%></strong>
<% end %>
</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>
<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) %>
@ -93,6 +113,7 @@
<% end %>
</td>
</tr>
-->
</table>
</td>
</tr>

View File

@ -8,4 +8,6 @@
:controller => 'attachments', :action => 'show',
:id => attachment, :filename => attachment.filename %>
<% end %>
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
<% end -%>

View File

@ -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>

View File

@ -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>
<div class="box tabular">
<div class="box">
<%= form_for('new_form', :remote => true, :method => :post,
:url => {:controller => 'homework_attach',
:action => 'create',
:user_id => User.current.id,
:bid_id => @bid
}) do |f|%>
<p>
<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>
<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>
<fieldset>
<p style="padding-left: 60px">
<fieldset style="text-align: left;">
<legend>
<%= l(:label_attachment_plural) %>
</legend>
<p id="put-bid-form-partial">
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<%= render :partial => 'attachments/form' %>
</p>
</fieldset>
<span style="padding-left: 60px">
<%= submit_tag t(:label_new), :sta => 0, :class => "enterprise"%>
<%= submit_tag t(:label_memo_create), :sta => 1, :class => "enterprise"%>
</p>
<p style="padding-left: 60px;padding-top: 10px;">
<span >
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
</span>
</p>
<% end %>

View File

@ -25,7 +25,6 @@
发布人员:<%= link_to @homework.user, user_path(@homework.user)%>
</td>
<td>发布时间:<%=format_time @homework.created_at %></td>
</tr>
<tr>
<td style="padding-left: 40px">
@ -58,15 +57,19 @@
<tr>
<td colspan="2" valign="top"><div style="font-size: 15px;"><strong>作业描述:</strong></div></td>
</tr>
<% @homework.attachments.map do |attachment| %>
<% if attachment.description != nil && attachment.description != "" %>
<tr>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all">
<div style="padding-top: 5px"> <%= attachment.description %></div>
<div style="padding-top: 5px">
<% if @homework.description != nil && @homework.description != "" %>
<%= @homework.description %>
<% else %>
<div style="font-size: 15px;color: #15BCCC;vertical-align:middle;padding-top: 10px;padding-left: 10px ">
<strong>该作业无任何描述!</strong>
</div>
<% end %>
</div>
</td>
</tr>
<% end %>
<% end %>
</table>
</td>
</tr>

View File

@ -11,7 +11,7 @@
#
# 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|
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", ["created_on"], :name => "index_attachments_on_created_on"
create_table "attachmentstypes", :id => false, :force => true do |t|
t.integer "id", :null => false
t.integer "typeId"
create_table "attachmentstypes", :force => true do |t|
t.integer "typeId", :null => false
t.string "typeName", :limit => 50
end
add_index "attachmentstypes", ["id"], :name => "id"
create_table "auth_sources", :force => true do |t|
t.string "type", :limit => 30, :default => "", :null => false
t.string "name", :limit => 60, :default => "", :null => false
@ -488,6 +485,7 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
t.boolean "is_readed"
t.integer "m_reply_count"
t.integer "m_reply_id"
t.integer "is_comprehensive_evaluation"
end
create_table "member_roles", :force => true do |t|