从题库选用作业时增加提示:“您选中的题是“我收到的作业”,不能选用”
This commit is contained in:
parent
bae775ec34
commit
cecf917764
|
@ -739,7 +739,7 @@ class UsersController < ApplicationController
|
|||
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
||||
courses = @user.courses.where("is_delete = 1")
|
||||
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids}").order("#{@order} #{@b_sort}")
|
||||
@type = params[:type]
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
|
@ -894,6 +894,19 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#检查改作业是否可以选用
|
||||
def check_homework
|
||||
homework = HomeworkCommon.find_by_id params[:homework]
|
||||
student_ids = homework.course.student.empty? ? [] : homework.course.student.map{|student| student.student_id}.join(',')
|
||||
resultObj = {status: 2}
|
||||
if student_ids.include?(User.current.id.to_s)
|
||||
resultObj[:status] = 1
|
||||
else
|
||||
resultObj[:status] = 0
|
||||
end
|
||||
render :json => resultObj
|
||||
end
|
||||
|
||||
#导入作业,确定按钮
|
||||
def user_select_homework
|
||||
homework = HomeworkCommon.find_by_id params[:checkMenu]
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
<%= render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks}%>
|
||||
</div>
|
||||
<% end %>
|
||||
<div><span id="choose_courses_notice" class="c_red"></span></div>
|
||||
<div class="courseSendSubmit mr15">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#select_homework_form').submit();hideModal()">选用</a>
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="choose_homework_submit();">选用</a>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="hideModal()">取消</a>
|
||||
|
@ -44,6 +45,26 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function choose_homework_submit() {
|
||||
var checkboxs = $("input[name='checkMenu']:checked");
|
||||
if(checkboxs.length == 0) {
|
||||
$("#choose_courses_notice").html("请先选择作业");
|
||||
} else{
|
||||
$.post(
|
||||
'<%=check_homework_users_path() %>',
|
||||
{homework: checkboxs.val()},
|
||||
function(data){
|
||||
if(data.status == 1) {
|
||||
$("#choose_courses_notice").html("您选中的题是“我收到的作业”,不能选用");
|
||||
} else if(data.status == 0) {
|
||||
$("#choose_courses_notice").html("");
|
||||
$('#select_homework_form').submit();
|
||||
hideModal();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
$("#public_homeworks_choose").click(function(){
|
||||
$(this).addClass("resource-tab-active");
|
||||
$("#user_homeworks_choose").removeClass("resource-tab-active");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<% if @is_import.to_i == 1 %>
|
||||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>");
|
||||
$("#choose_courses_notice").html("");
|
||||
<% else %>
|
||||
var htmlvalue = "<%= escape_javascript(render :partial => 'users/homework_repository_detail') %>";
|
||||
pop_box_new(htmlvalue,820,50,50);
|
||||
|
|
|
@ -3,6 +3,7 @@ $("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'us
|
|||
$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
|
||||
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
|
||||
$("#choose_courses_notice").html("");
|
||||
<% else %>
|
||||
$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>''})%>');
|
||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>');
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
$("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks})%>');
|
||||
$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
|
||||
$("#choose_courses_notice").html("");
|
||||
<% else %>
|
||||
$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>@search})%>');
|
||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>');
|
||||
|
|
|
@ -565,6 +565,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'user_messages_unviewed'
|
||||
post "user_commit_homework"
|
||||
post 'user_select_homework'
|
||||
post 'check_homework'
|
||||
get 'all_journals'
|
||||
get 'expand_courses'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue