parent
1ae8c7d234
commit
a006e2e462
|
@ -1,5 +1,6 @@
|
|||
class StudentWorkController < ApplicationController
|
||||
layout "base_courses"
|
||||
include StudentWorkHelper
|
||||
before_filter :find_homework, :only => [:new, :index, :create]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score]
|
||||
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score]
|
||||
|
@ -72,9 +73,30 @@ class StudentWorkController < ApplicationController
|
|||
|
||||
#评分
|
||||
def add_score
|
||||
score = student_work_score @work,User.current
|
||||
if score
|
||||
if params[:new_form] && params[:new_form][:user_message]
|
||||
score.score = params[:score]
|
||||
score.comment = params[:new_form][:user_message]
|
||||
end
|
||||
else
|
||||
if params[:new_form] && params[:new_form][:user_message]
|
||||
score = StudentWorksScore.new
|
||||
score.score = params[:score]
|
||||
score.comment = params[:new_form][:user_message]
|
||||
score.user_id = User.current.id
|
||||
score.student_work_id = @work.id
|
||||
score.reviewer_role = 1
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
score.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(score)
|
||||
|
||||
if score.save
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: utf-8
|
||||
module StudentWorkHelper
|
||||
def user_projects_option
|
||||
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
|
@ -18,4 +19,9 @@ module StudentWorkHelper
|
|||
end
|
||||
type
|
||||
end
|
||||
|
||||
#获取指定用户对某一作业的评分结果
|
||||
def student_work_score work,user
|
||||
StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id)) do |f|%>
|
||||
<li >
|
||||
<span class="tit_fb"> 评价:</span>
|
||||
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<span class="tit_fb mt2"> 评分:</span>
|
||||
<input type="number" name="score" id="score_<%= work.id%>" value="50" min="0" max="100" size="4" data-units="dollars" />
|
||||
<span class=" ml5">分</span>
|
||||
<div class="cl"></div></li>
|
||||
<li >
|
||||
<span class="tit_fb"> 批阅结果:</span>
|
||||
<div>
|
||||
<%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work} %>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="blue_n_btn fr" onclick="$(this).parent().parent().submit();">提交</a>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end%>
|
|
@ -32,26 +32,9 @@
|
|||
</li>
|
||||
<div class="cl"></div>
|
||||
|
||||
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id)) do |f|%>
|
||||
<li >
|
||||
<span class="tit_fb"> 评价:</span>
|
||||
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li >
|
||||
<span class="tit_fb mt2"> 评分:</span>
|
||||
<input type="number" name="score" id="score_<%= work.id%>" value="50" min="0" max="100" size="4" data-units="dollars" />
|
||||
<span class=" ml5">分</span>
|
||||
<div class="cl"></div></li>
|
||||
<li >
|
||||
<span class="tit_fb"> 批阅结果:</span>
|
||||
<div>
|
||||
<%= render :partial => 'student_work/student_work_attachment_form', :locals => {:id => work.id} %>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="blue_n_btn fr" onclick="$(this).parent().parent().submit();">提交</a>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end%>
|
||||
<div id="add_student_score">
|
||||
<%= render :partial => 'add_score',:locals => {:work => work}%>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
<div class="ping_box">
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<div class="fl">
|
||||
<span id="attachments_fields<%= id%>" xmlns="http://www.w3.org/1999/html"></span>
|
||||
<span id="attachments_fields<%= work.id%>" xmlns="http://www.w3.org/1999/html"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
|
||||
<%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => "_file#{id}",
|
||||
:id => "_file#{work.id}",
|
||||
:class => 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => "addInputFiles_board(this, '#{id}');",
|
||||
:onchange => "addInputFiles_board(this, '#{work.id}');",
|
||||
:style => 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
|
@ -19,9 +19,9 @@
|
|||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:delete_all_files => l(:text_are_you_sure_all),
|
||||
:containerid => "#{id}"
|
||||
:containerid => "#{work.id}"
|
||||
} %>
|
||||
<span id="upload_file_count<%= id%>">
|
||||
<span id="upload_file_count<%= work.id%>">
|
||||
<%= l(:label_no_file_uploaded) %>
|
||||
</span>
|
||||
(<%= l(:label_max_size) %>:
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
$("#add_student_score").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
alert("评分成功");
|
Loading…
Reference in New Issue