导入共享题库中的作业
This commit is contained in:
parent
af7ca36c92
commit
ec41cd4318
|
@ -403,8 +403,47 @@ class UsersController < ApplicationController
|
|||
|
||||
#导入作业
|
||||
def user_import_homeworks
|
||||
@user = User.current
|
||||
@select_course = params[:select_course] ? 1 : 0
|
||||
@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
||||
#@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids}").order("created_at desc")
|
||||
@type = params[:type]
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@hw_count = @homeworks.count
|
||||
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
|
||||
@offset ||= @hw_pages.offset
|
||||
@homeworks = paginateHelper @homeworks,10
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def user_homework_type
|
||||
@user = User.current
|
||||
if(params[:type].blank? || params[:type] == "1") #公共题库
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids}").order("created_at desc")
|
||||
elsif params[:type] == "2" #我的题库
|
||||
@homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@hw_count = @homeworks.count
|
||||
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
|
||||
@offset ||= @hw_pages.offset
|
||||
@homeworks = paginateHelper @homeworks,10
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def show_homework_detail
|
||||
@homework = HomeworkCommon.find params[:homework].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -412,7 +451,21 @@ class UsersController < ApplicationController
|
|||
|
||||
#用户主页过滤作业
|
||||
def user_search_homeworks
|
||||
@user_homeworks = HomeworkCommon.where("user_id = '#{@user.id}' and lower(name) like '%#{params[:name].to_s.downcase}%'").order("created_at desc")
|
||||
search = params[:name].to_s.strip.downcase
|
||||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and (name like '%#{search}%')").order("created_at desc")
|
||||
elsif params[:type] == "2" #课程资源
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and (name like '%#{search}%')").order("created_at desc")
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
@hw_count = @homeworks.count
|
||||
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
|
||||
@offset ||= @hw_pages.offset
|
||||
@homeworks = paginateHelper @homeworks,10
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<div class="subjectInfo">题目信息</div>
|
||||
<div class="subjectWrap">
|
||||
<% if homework.nil? %>
|
||||
<span class="c_red" id="homework_notice_span">请先在左侧选择作业</span>
|
||||
<% else %>
|
||||
<div class="subjectIntro mb15">标题:<%=homework.name %><br />
|
||||
来源:<%=homework.course.name %><br />
|
||||
<% if homework.homework_type == 2 && homework.homework_detail_programing %>
|
||||
编程语言:<%=homework.language_name %><br/>
|
||||
<% end %>
|
||||
贡献者:<%=homework.user.show_name %><br />
|
||||
描述如下:
|
||||
</div>
|
||||
<div class="subjectContent" id="homework_description">
|
||||
<%=homework.description.html_safe %>
|
||||
</div>
|
||||
<% if homework.homework_type == 2 %>
|
||||
<div class="subjectContent mt10">
|
||||
测试集:<%=homework.homework_tests.count %>组
|
||||
</div>
|
||||
<% elsif homework.homework_type ==3 && homework.homework_detail_group %>
|
||||
<div class="subjectContent mt10">
|
||||
分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,29 @@
|
|||
<input type="text" name="search" placeholder="输入关键词进行搜索" class="subjectSearch fr" />
|
||||
<script type="text/javascript">
|
||||
var lastSearchCondition = '';
|
||||
var count = 0;
|
||||
function search_hws(e){
|
||||
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'users', :action => 'user_search_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>',
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(method,context,e){
|
||||
clearTimeout(method.tId);
|
||||
method.tId=setTimeout(function(){
|
||||
method.call(context,e);
|
||||
},500);
|
||||
}
|
||||
|
||||
//查询项目
|
||||
$("input[name='search']").on('input', function (e) {
|
||||
throttle(search_hws,window,e);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -1,13 +1,24 @@
|
|||
<% user_homeworks.each do |homework|%>
|
||||
<ul class="homeworkPublish">
|
||||
<li class="fl">
|
||||
<input name="checkMenu" type="radio" class="courseSendCheckbox" value="<%= homework.id%>"/>
|
||||
</li>
|
||||
<li class="sendCourseName fl hidden w450">
|
||||
<%= homework.name%>
|
||||
<% homeworks.each do |homework| %>
|
||||
<ul class="subjectRow">
|
||||
<li class="subjectName fl hidden">
|
||||
<label onclick="show_homework_detail('<%=show_homework_detail_user_path(@user,:homework=>homework.id) %>')">
|
||||
<input type="radio" name="checkMenu" class="mr5" style="vertical-align:middle;" value="<%= homework.id%>"/>
|
||||
<span><%= homework.name%></span>
|
||||
</label>
|
||||
</li>
|
||||
<li class="subjectPublisher fl"><%= homework.user.show_name %></li>
|
||||
<li class="fl subjectDate"><%=format_date homework.publish_time %></li>
|
||||
</ul>
|
||||
<div class="homeworkPublishTime">
|
||||
创建时间:<%= format_date homework.created_at%>
|
||||
</div>
|
||||
<% end%>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
function show_homework_detail(url){
|
||||
$.get(
|
||||
url,
|
||||
{
|
||||
|
||||
},
|
||||
function (data) {
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
|
@ -1,27 +1,50 @@
|
|||
<div class="coursesChoosePopup" id="coursesChoosePopup">
|
||||
<div>
|
||||
<div class="sendText">导入作业</div>
|
||||
</div>
|
||||
|
||||
<div >
|
||||
<%= form_tag user_search_homeworks_user_path(User.current.id), :multipart => true, :remote => true, :class => "coursesSearchBox" do%>
|
||||
<input type="text" name="name" placeholder="输入作业名称进行搜索" class="searchCoursesPopup" id="search_homework_name"/>
|
||||
<a href="javascript:void(0);" class="searchIconPopup" onclick="$(this).parent().submit();"></a>
|
||||
<% end%>
|
||||
</div>
|
||||
<%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %>
|
||||
<input type="hidden" name="select_course" value="<%= @select_course%>">
|
||||
<div class="homeworkListForm mb10 " id="homework_list_form_show">
|
||||
<%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%>
|
||||
</div>
|
||||
<div>
|
||||
<div class="courseSendSubmit">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#select_homework_form').submit();">确定</a>
|
||||
<div class="w985" style="padding:11px;"> <a href="javascript:void(0);" class="popupClose" onclick="hideModal()"></a>
|
||||
<div class="f16 fb fontBlue mb10">选用题库中的题目</div>
|
||||
<div class="subjectList fl mr10">
|
||||
<a href="<%= user_homework_type_user_path(@user) %>" id="public_homeworks_choose" class="subjectChoose chooseActive fl" data-remote="true">公共题库</a>
|
||||
<a href="<%= user_homework_type_user_path(@user,:type=>'2') %>" id="user_homeworks_choose" class="subjectChoose fl" data-remote="true">我的题库</a>
|
||||
<div id="homework_search_input">
|
||||
<%=render :partial=>'homework_search_input', :locals=>{:type=>@type} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<ul class="subjectBanner mt10">
|
||||
<li class="subjectName fl hidden"><span style="padding-left:15px;">作业名称</span></li>
|
||||
<li class="subjectPublisher fl">贡献者</li>
|
||||
<li class="fl subjectDate">发布时间</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %>
|
||||
<input type="hidden" name="select_course" value="<%= @select_course%>">
|
||||
<div style="height:400px; min-height:400px; max-height:400px;" id="homework_list_form_show">
|
||||
<%= render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks}%>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="hideModal('#coursesChoosePopup')">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end%>
|
||||
<% end %>
|
||||
<div class="courseSendSubmit mr15">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#select_homework_form').submit();hideModal()">选用</a>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="hideModal()">取消</a>
|
||||
</div>
|
||||
<div >
|
||||
<ul class="wlist" id="homewrok_ref_pages" style="margin-top: 5px;margin-right: 20px">
|
||||
<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="subjectDetail fl" id="homework_detail_information">
|
||||
<%=render :partial=>'homework_detail_information', :locals=>{:homework=>nil} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$("#public_homeworks_choose").click(function(){
|
||||
$(this).toggleClass("chooseActive");
|
||||
$("#user_homeworks_choose").toggleClass("chooseActive");
|
||||
});
|
||||
$("#user_homeworks_choose").click(function(){
|
||||
$(this).toggleClass("chooseActive");
|
||||
$("#public_homeworks_choose").toggleClass("chooseActive");
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="cl"></div>
|
||||
|
||||
<div class=" mt10">
|
||||
<%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业(将于2016年春上线)") unless edit_mode%>
|
||||
<%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
|
||||
<% if edit_mode %>
|
||||
<label class="fl c_grey f14" style="margin-top: 4px;">截止日期:</label>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>")
|
|
@ -0,0 +1,4 @@
|
|||
$("#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}) %>");
|
||||
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type}) %>");
|
|
@ -1,7 +1,4 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>');
|
||||
showModal('ajax-modal', '580px');
|
||||
$('#ajax-modal').css('height','300px').css("width","580px");
|
||||
showModal('ajax-modal', '1040px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
|
||||
"<a href='javascript:void(0)' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9");
|
|
@ -1 +1,3 @@
|
|||
$("#homework_list_form_show").html("<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks})%>");
|
||||
$("#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}) %>");
|
|
@ -503,7 +503,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get
|
||||
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
|
||||
get 'user_import_homeworks'
|
||||
post 'user_search_homeworks'
|
||||
get 'user_search_homeworks'
|
||||
get 'user_import_resource'
|
||||
match 'watch_projects', :to => 'users#watch_projects', :via => :get
|
||||
#
|
||||
|
@ -553,7 +553,9 @@ RedmineApp::Application.routes.draw do
|
|||
get 'user_organizations'
|
||||
get 'search_user_orgs'
|
||||
get 'search_user_org' #for send resource
|
||||
|
||||
get 'user_homework_type'
|
||||
get 'user_ref_homework_search'
|
||||
get 'show_homework_detail'
|
||||
# end
|
||||
end
|
||||
#resources :blogs
|
||||
|
|
|
@ -1432,4 +1432,25 @@ span.at a{color:#269ac9;text-decoration: none;}
|
|||
.w80{ width:80px;}
|
||||
.label03{ width:70px; text-align:right; display:block; float:left;}
|
||||
.pro_info_p{color:#0781b4 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
|
||||
.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
|
||||
.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; }
|
||||
|
||||
/*导入题库样式*/
|
||||
.popupWrap {border:3px solid #269ac9; padding:15px; background-color:#ffffff; position:relative; z-index:1000;}
|
||||
.subjectList {width:585px;}
|
||||
.subjectDetail {width:385px;}
|
||||
a.subjectChoose {padding:8px 20px; background-color:#f1f1f1; color:#888888;}
|
||||
a.chooseActive {background-color:#269ac9; color:#ffffff;}
|
||||
.subjectBanner {width:585px; height:40px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;}
|
||||
.subjectBanner li {height:40px; line-height:40px; vertical-align:middle;}
|
||||
.subjectName {width:360px; padding-left:10px;}
|
||||
.subjectPublisher {width:100px; text-align:center;}
|
||||
.subjectDate {width:115px; text-align:center;}
|
||||
.subjectRow {width:585px; height:40px; color:#7a7a7a; font-size:12px;}
|
||||
.subjectRow li {height:40px; line-height:40px; vertical-align:middle;}
|
||||
.subjectSearch {border:1px solid #dddddd; height:32px; width:250px;outline: none;}
|
||||
.subjectInfo {width:385px; background-color:#f1f1f1; border:1px solid #dddddd; height:32px; line-height:32px; vertical-align:middle; text-align:center; color:#7a7a7a;}
|
||||
.subjectWrap {border:1px solid #dddddd; border-top:none; padding:10px; width:365px; height:460px; overflow-y:auto;}
|
||||
.subjectIntro {color:#585858; line-height:18px; font-size:12px;}
|
||||
.subjectContent {color:#888888; line-height:18px; font-size:12px;}
|
||||
.popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;}
|
||||
.subjectContent p,.subjectContent div,.subjectContent em, .subjectContent span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important; color:#888888 !important; font-size:12px !important;}
|
||||
|
|
|
@ -1017,3 +1017,24 @@ a:hover.userCancel{border:1px solid #888888; }
|
|||
.resourceCopy {padding:0px; margin:0px; width:12px; height:12px; display:inline-block;}
|
||||
|
||||
.relatePWrap{max-height: 210px;overflow:hidden;}
|
||||
|
||||
/*导入题库样式*/
|
||||
.popupWrap {border:3px solid #269ac9; padding:15px; background-color:#ffffff; position:relative; z-index:1000;}
|
||||
.subjectList {width:585px;}
|
||||
.subjectDetail {width:385px;}
|
||||
a.subjectChoose {padding:8px 20px; background-color:#f1f1f1; color:#888888;}
|
||||
a.chooseActive {background-color:#269ac9; color:#ffffff;}
|
||||
.subjectBanner {width:585px; height:40px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;}
|
||||
.subjectBanner li {height:40px; line-height:40px; vertical-align:middle;}
|
||||
.subjectName {width:360px; padding-left:10px;}
|
||||
.subjectPublisher {width:100px; text-align:center;}
|
||||
.subjectDate {width:115px; text-align:center;}
|
||||
.subjectRow {width:585px; height:40px; color:#7a7a7a; font-size:12px;}
|
||||
.subjectRow li {height:40px; line-height:40px; vertical-align:middle;}
|
||||
.subjectSearch {border:1px solid #dddddd; height:32px; width:250px;outline: none;}
|
||||
.subjectInfo {width:385px; background-color:#f1f1f1; border:1px solid #dddddd; height:32px; line-height:32px; vertical-align:middle; text-align:center; color:#7a7a7a;}
|
||||
.subjectWrap {border:1px solid #dddddd; border-top:none; padding:10px; width:365px; height:460px; overflow-y:auto;}
|
||||
.subjectIntro {color:#585858; line-height:18px; font-size:12px;}
|
||||
.subjectContent {color:#888888; line-height:18px; font-size:12px;}
|
||||
.popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;}
|
||||
.subjectContent p,.subjectContent div,.subjectContent em, .subjectContent span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important; color:#888888 !important; font-size:12px !important;}
|
||||
|
|
Loading…
Reference in New Issue