发布作业功能
This commit is contained in:
parent
af2434809b
commit
049e27f15f
|
@ -45,7 +45,7 @@ class UsersController < ApplicationController
|
|||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,
|
||||
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
|
||||
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages,:edit_brief_introduction]
|
||||
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages,:edit_brief_introduction,:user_new_homework]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
|
@ -314,6 +314,38 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def user_new_homework
|
||||
if params[:homework_common]
|
||||
homework = HomeworkCommon.new
|
||||
homework.name = params[:homework_common][:name]
|
||||
homework.description = params[:homework_common][:description]
|
||||
homework.end_time = params[:homework_common][:end_time]
|
||||
homework.publish_time = Time.now
|
||||
homework.homework_type = 1
|
||||
homework.late_penalty = 0
|
||||
homework.user_id = User.current.id
|
||||
homework.course_id = params[:course_id]
|
||||
|
||||
homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
#匿评作业相关属性
|
||||
homework_detail_manual = HomeworkDetailManual.new
|
||||
homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
|
||||
homework_detail_manual.comment_status = 1
|
||||
homework_detail_manual.evaluation_start = Time.now
|
||||
homework_detail_manual.evaluation_end = Time.now
|
||||
homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||
homework_detail_manual.absence_penalty = 0
|
||||
homework.homework_detail_manual = homework_detail_manual
|
||||
|
||||
if homework.save
|
||||
homework_detail_manual.save if homework_detail_manual
|
||||
redirect_to user_homeworks_user_path(User.current.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
include CoursesHelper
|
||||
def user_courses
|
||||
|
|
|
@ -537,4 +537,16 @@ module UsersHelper
|
|||
end
|
||||
end
|
||||
|
||||
#获取指定用户作为老师的课程
|
||||
def get_as_teacher_courses user
|
||||
type = []
|
||||
user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
|
||||
option = []
|
||||
option << course.name
|
||||
option << course.id
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="fl">
|
||||
<div class="mt10">
|
||||
<span id="attachments_fields" class="attachments_fields">
|
||||
<% if defined?(container) && container && container.saved_attachments %>
|
||||
<% container.attachments.each_with_index do |attachment, i| %>
|
||||
|
@ -10,8 +10,8 @@
|
|||
<%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% container.saved_attachments.each_with_index do |attachment, i| %>
|
||||
<% end %>
|
||||
<% container.saved_attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
|
||||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
|
||||
|
@ -20,46 +20,34 @@
|
|||
<%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% project = project %>
|
||||
<span class="add_attachment" style="font-weight:normal;">
|
||||
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => '_file',
|
||||
:class => ie8? ? '' : 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => 'addInputFiles(this);',
|
||||
:style => ie8? ? '' : 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js',:project =>project),
|
||||
:description_placeholder => l(:label_optional_description),
|
||||
:field_is_public => l(:field_is_public),
|
||||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:delete_all_files => l(:text_are_you_sure_all)
|
||||
} %>
|
||||
<span id="upload_file_count">
|
||||
<%= l(:label_no_file_uploaded)%>
|
||||
</span>
|
||||
(<%= l(:label_max_size) %>:
|
||||
<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => '_file',
|
||||
:class => ie8? ? '' : 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => 'addInputFiles(this);',
|
||||
:style => ie8? ? '' : 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js',:project =>nil),
|
||||
:description_placeholder => l(:label_optional_description),
|
||||
:field_is_public => l(:field_is_public),
|
||||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:delete_all_files => l(:text_are_you_sure_all)
|
||||
} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
||||
<div class="mt5 fl">
|
||||
<a href="javascript:void(0);" class="AnnexBtn fl mt3" onclick="$('#_file').click();">上传附件</a>
|
||||
<!--<a href="javascript:void(0);" class="FilesBtn fl mr15 mt3">资源库</a>-->
|
||||
</div>
|
||||
|
||||
|
||||
<textarea class="InputBox fl W120 " placeholder="截止日期"></textarea>
|
||||
<a href="javascript:void(0);" class="fl mr10">
|
||||
<img src="../images/Calendar.png" width="16" height="15" class="calendarContainer calendar1" />
|
||||
</a>
|
||||
<a href="javascript:void(0);" class="fl mr10">
|
||||
<img src="../images/Calendar_hover.png" width="16" height="15" class="calendarContainer calendar1Active" />
|
||||
</a>
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
|
@ -2,22 +2,16 @@
|
|||
<div class="HomeWorkCon">
|
||||
<div class="mt15">
|
||||
<input type="text" name="homework_common[name]" id="homework_name" class="InputBox W700" maxlength="255" onkeyup="regex_homework_name();" placeholder="请输入作业标题" value="<%= homework.name%>" >
|
||||
<p id="homework_name_span" class="c_red mt5"></p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class=" mt10">
|
||||
<a href="javascript:void(0);" class="BlueCirBtn fl mr10">导入作业</a>
|
||||
<div class="calendar_div fl">
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time%>" >
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" placeholder="截止日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.end_time || (Time.now + 3600 * 24).strftime('%Y-%m-%d')%>" >
|
||||
<%= calendar_for('homework_end_time')%>
|
||||
</div>
|
||||
<!--<div class="fl DateBorder mr10">-->
|
||||
<!--<a href="javascript:void(0);" class="pic_date "></a>-->
|
||||
<!--</div>-->
|
||||
<!--<textarea class="InputBox fl W120 " placeholder="发布日期"></textarea>-->
|
||||
<!--<div class="fl DateBorder" >-->
|
||||
<!--<a href="javascript:void(0);" class="pic_date "></a>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
|
@ -32,27 +26,17 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<div class="mt10">
|
||||
<input type="text" class="InputBox W700 SearchIcon" placeholder="发送到课程" />
|
||||
<!--<input type="text" class="InputBox W700 SearchIcon" placeholder="发送到课程" />-->
|
||||
<%= select_tag :course_id,options_for_select(get_as_teacher_courses(User.current),homework.course_id), {:class => "InputBox W700 SearchIcon"} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt10">
|
||||
<%= render :partial => 'attachments/new_form', :locals => {:container => homework} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<%= render :partial => 'users/user_homework_attachment', :locals => { :container => homework } %>
|
||||
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="AnnexBtn fl mt3">上传附件</a>
|
||||
<a href="javascript:void(0);" class="FilesBtn fl mr15 mt3">资源库</a>
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr">发送</a>
|
||||
<div class="mt5 fr">
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick=" submit_homework('new_homework_common');">发送</a>
|
||||
<span class="fr mr10 mt3">或</span>
|
||||
<a href="javascript:void(0);" class=" fr mr10 mt3">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<!--<div class="mt10">-->
|
||||
<!--<a href="javascript:void(0);" class=" fl DropBtn">高级功能</a>-->
|
||||
<!--<div class="DropLine" ></div>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</div>-->
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -20,7 +20,7 @@
|
|||
<div class="NewsBannerName">发布作业</div>
|
||||
</div>
|
||||
<% homework = HomeworkCommon.new %>
|
||||
<%= labelled_form_for homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
|
||||
<%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
|
||||
<%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %>
|
||||
<% end%>
|
||||
</div><!----HomeWork end-->
|
||||
|
|
|
@ -307,6 +307,7 @@ RedmineApp::Application.routes.draw do
|
|||
resources :users do
|
||||
collection do
|
||||
match "tag_saveEx" , :via => [:get, :post]
|
||||
post "user_new_homework"
|
||||
end
|
||||
member do
|
||||
match 'user_projects_index', :to => 'users#user_projects_index', :via => :get
|
||||
|
@ -325,7 +326,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get
|
||||
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
|
||||
match 'watch_projects', :to => 'users#watch_projects', :via => :get
|
||||
|
||||
#
|
||||
# added by bai
|
||||
match 'show_score', :to => 'users#show_score', :via => :get
|
||||
match 'topic_score_index', :to => 'users#topic_score_index', :via => [:get, :post]
|
||||
|
|
|
@ -54,19 +54,34 @@ function show_more_project(url){
|
|||
}
|
||||
);
|
||||
}
|
||||
//
|
||||
//$(function(){
|
||||
// $(".newsType").mouseover(function(){
|
||||
// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"});
|
||||
// });
|
||||
// $(".newsType").mouseout(function(){
|
||||
// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"});
|
||||
// });
|
||||
// $(".resourcesSelected").mouseover(function(){
|
||||
// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"});
|
||||
// });
|
||||
// $(".resourcesSelected").mouseout(function(){
|
||||
// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"});
|
||||
// });
|
||||
//});
|
||||
//个人动态 end
|
||||
|
||||
//老师提交 新建/修改 作业
|
||||
function submit_homework(id)
|
||||
{
|
||||
if(!regex_homework_name())
|
||||
{
|
||||
$("#homework_name").focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
homework_description_editor.sync();
|
||||
$("#"+id).submit();
|
||||
}
|
||||
}
|
||||
|
||||
//验证新建作业的名字
|
||||
function regex_homework_name()
|
||||
{
|
||||
var name = $.trim($("#homework_name").val());
|
||||
|
||||
if(name=="")
|
||||
{
|
||||
$("#homework_name_span").text("名称不能为空");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homework_name_span").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -857,6 +857,23 @@ img.ui-datepicker-trigger {
|
|||
.calendar_input{border-left:none !important;border-bottom: none!important; border-top: none!important; border-right: 1px solid #d9d9d9;}
|
||||
.calendar_div{border: 1px solid #d9d9d9;}
|
||||
|
||||
#attachments_fields input.filename {
|
||||
border: 0;
|
||||
height: 1.8em;
|
||||
max-width: 670px;
|
||||
color: #7f7f7f;
|
||||
background-color: inherit;
|
||||
background: url(../images/pic_file.png) 0 3px no-repeat;
|
||||
padding-left: 18px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.description{display: none !important;}
|
||||
.ispublic-label{display: none !important;}
|
||||
.is_public_checkbox{display: none !important;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue