Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
cxt 2015-08-25 19:24:37 +08:00
commit e4c9f05c7b
16 changed files with 178 additions and 91 deletions

View File

@ -113,7 +113,8 @@ class CoursesController < ApplicationController
courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
@courses = paginateHelper courses,10
end
@name = params[:name]
@type = 'courses'
respond_to do |format|
format.html {
render :layout => 'course_base'

View File

@ -157,7 +157,7 @@ class MyController < ApplicationController
File.delete(diskfile1) if File.exist?(diskfile1)
end
render :layout=>'base_users_new'
render :layout=>'new_base_user'
end
# Destroys user's account

View File

@ -93,7 +93,8 @@ class ProjectsController < ApplicationController
@project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
@project_pages = Paginator.new @project_count, @limit, params['page']
@name = params[:name]
@type = 'projects'
respond_to do |format|
format.html {
render :layout => 'base'

View File

@ -305,10 +305,11 @@ class UsersController < ApplicationController
#用户作业列表
def user_homeworks
@page = params[:page] ? params[:page].to_i + 1 : 0
user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc")
@homework_commons = paginateHelper homework_commons,10
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10)
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}
end
end
@ -453,6 +454,8 @@ class UsersController < ApplicationController
end
@users = scope.offset(@offset).limit(limit).all.reverse
end
@name = params[:name]
@type = 'users'
respond_to do |format|
format.html {
@groups = Group.all.sort

View File

@ -16,7 +16,7 @@
$(document).ready(function(){
$(".homepageSearchIcon").click(function(){
var val=$('input:radio[name="navSearchType"]:checked').val();
var val=$('input:radio[name="search_type"]:checked').val();
if(val==null){
$("#navSearchAlert").css({display:"block"});
}

View File

@ -17,24 +17,40 @@
</li>
</ul>
</div>
<script>
<% type = type%>
$(document).ready(function (){
if('<%= type %>' != null && '<%= type %>' == 'courses' ){
$('input:radio[value="courses"]').attr('checked','checked');
}
if('<%= type %>' != null && '<%= type %>' == 'projects' ){
$('input:radio[value="projects"]').attr('checked','checked');
}
if('<%= type %>' != null && '<%= type %>' == 'users' ){
$('input:radio[value="users"]').attr('checked','checked');
}
});
</script>
<div class="fl" id="navHomepageSearch">
<form class="navHomepageSearchBox">
<input type="text" name="navHomepageSearch" class="navHomepageSearchInput" />
<a href="javascript:void(0);" class="homepageSearchIcon"></a>
</form>
<!--<form class="navHomepageSearchBox">-->
<% name = name%>
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" class="navHomepageSearchInput" />
<input type="hidden" name="search_type" id="type" value=""/>
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#type').val($('input[type=radio]:checked').val());$(this).parent().submit();"></a>
<% end %>
<div class="navSearchTypeBox" id="navHomepageSearchType">
<div class="fl mr15 mt5">
<input type="radio" value="课程" name="navSearchType" checked/>
<div class="fl mr15 mt8">
<input type="radio" value="courses" name="search_type" checked/>
课程
</div>
<div class="fl mr15 mt5">
<input type="radio" value="项目" name="navSearchType" />
<div class="fl mr15 mt8">
<input type="radio" value="projects" name="search_type" />
项目
</div>
<div class="fl mr15 mt5">
<input type="radio" value="用户" name="navSearchType" />
<div class="fl mr15 mt8">
<input type="radio" value="users" name="search_type" />
用户
</div>
<div id="navSearchAlert" class="fr mr10">
@ -48,7 +64,9 @@
<li class="homepageProfileMenuIcon">
<%= link_to "<div class='mt5 mb8'>#{image_tag(url_to_avatar(User.current),:width =>"40",:height => "40",:alt=>"头像", :id => "nh_user_logo")}</div>".html_safe,user_activities_path(User.current.id)%>
<ul class="topnav_login_list">
<li><a href="javascript:void(0);" class="menuGrey">修改资料</a> </li>
<li>
<%= link_to "修改资料", my_account_path, :class => "menuGrey"%>
</li>
<!--<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>-->
<li>
<%= link_to "退出",signout_path,:class => "menuGrey",:method => "post"%>

View File

@ -9,29 +9,55 @@
</li>
</ul>
</div>
<script>
function search(doc){
//alert(1)
// val = $('input:radio[name="search_type"]:checked').val();
// alert(2)
// $("#search_type").val(val);
// alert(3)
$(doc).parent().submit();
}
<% type = type%>
$(document).ready(function (){
if('<%= type %>' != null && '<%= type %>' == 'courses' ){
$('input:radio[value="courses"]').attr('checked','checked');
}
if('<%= type %>' != null && '<%= type %>' == 'projects' ){
$('input:radio[value="projects"]').attr('checked','checked');
}
if('<%= type %>' != null && '<%= type %>' == 'users' ){
$('input:radio[value="users"]').attr('checked','checked');
}
});
</script>
<div class="fl" id="navHomepageSearch">
<form class="navHomepageSearchBox">
<input type="text" name="navHomepageSearch" class="navHomepageSearchInput"/>
<a href="javascript:void(0);" class="homepageSearchIcon"></a>
</form>
<!--<form class="navHomepageSearchBox">-->
<% name = name%>
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" class="navHomepageSearchInput"/>
<input type="hidden" name="search_type" id="type" value=""/>
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#type').val($('input[type=radio]:checked').val());$(this).parent().submit();"></a>
<% end %>
<div class="navSearchTypeBox" id="navHomepageSearchType">
<div class="fl mr15 mt5">
<input type="radio" value="课程" name="navSearchType" checked/>
<div class="fl mr15 mt8">
<input type="radio" value="courses" name="search_type" checked/>
课程
</div>
<div class="fl mr15 mt5">
<input type="radio" value="项目" name="navSearchType" />
<div class="fl mr15 mt8">
<input type="radio" value="projects" name="search_type" />
项目
</div>
<div class="fl mr15 mt5">
<input type="radio" value="用户" name="navSearchType" />
<div class="fl mr15 mt8">
<input type="radio" value="users" name="search_type" />
用户
</div>
<div id="navSearchAlert" class="fr mr10">
<span class="c_red">请选择搜索类型</span>
</div>
</div>
</div>
<div id="loginInButton" class="fr ml20">
<a href="<%= signin_path(:login=>true) %>" class="c_white db">登录</a>
@ -48,4 +74,5 @@
}).mouseout(function(){
$("#navHomepageSearchType").hide();
});
</script>

View File

@ -1,6 +1,6 @@
<% courses.each do |course|%>
<li class="homepageLeftMenuCoursesLine">
<%= link_to (course_endTime_timeout?(course) ? "[已关闭]&nbsp;#{course.name}" : "#{course.name}").html_safe, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden", :title => course.name%>
<%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", :title => course.name%>
</li>
<% end %>

View File

@ -24,9 +24,9 @@
<div class="cl"></div>
<div class="navContainer mb10">
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' %>
<%= render :partial => 'layouts/logined_header',:locals=>{:name=>@name,:type=>@type} %>
<% else%>
<%= render :partial => 'layouts/unlogin_header' %>
<%= render :partial => 'layouts/unlogin_header',:locals=>{:name=>@name,:type=>@type} %>
<% end%>
</div>
<div class="cl"></div>

View File

@ -21,19 +21,29 @@
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<%= stylesheet_link_tag 'base','header', :media => 'all'%>
</head>
<body class="<%=h body_css_classes %>">
<div class="cl"></div>
<div class="navContainer mb10">
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' ,:locals=>{:name=>@name,:type=>@type}%>
<% else%>
<%= render :partial => 'layouts/unlogin_header' ,:locals=>{:name=>@name,:type=>@type}%>
<% end%>
</div>
<div class="cl"></div>
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%=render :partial => 'layouts/base_header'%>
<%#=render :partial => 'layouts/base_header'%>
<div id="main" class="nosidebar">
<div id="content_">
<%= render_flash_messages %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
<%=render :partial => 'layouts/base_footer'%>
<!--<div style="clear:both;"></div>-->
<!--<%#=render :partial => 'layouts/base_footer'%>-->
</div>
</div>
@ -45,6 +55,10 @@
</div>
</div>
<div class="cl"></div>
<%= render :partial => 'layouts/footer' %>
<div class="cl"></div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_user', 'user_leftside', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_user', 'user_leftside','users', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user"%>

View File

@ -22,9 +22,9 @@
<div class="cl"></div>
<div class="navContainer mb10">
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' %>
<%= render :partial => 'layouts/logined_header',:locals=>{:name=>@name,:type=>@type} %>
<% else%>
<%= render :partial => 'layouts/unlogin_header' %>
<%= render :partial => 'layouts/unlogin_header',:locals=>{:name=>@name,:type=>@type} %>
<% end%>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,55 @@
<% homework_commons.each do |homework_common|%>
<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
<div class="HomeWork mb10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo">
<%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%>
TO
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
</div>
<div class="homepagePostTitle">
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
</div>
<div class="homepagePostSubmitContainer">
<div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %>
</div>
<div class="homepagePostDeadline">
<%= l(:label_end_time)%><%= homework_common.end_time%>
</div>
</div>
<div class="homepagePostIntro upload_img break_word">
<%= homework_common.description.html_safe %>
</div>
<div class="mt10">
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
<div class="cl"></div>
</div>
<% if is_teacher%>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%>
</li>
<li>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
</div>
<div class="cl"></div>
</div>
</div><!----HomeWork end-->
<% end%>
<input type="hidden" value="<%= page%>" id="user_show_more_homework" />

View File

@ -1,3 +1,18 @@
<script type="text/javascript">
var scrollHandler = function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
$.get(
'<%= user_homeworks_user_path(User.current.id)%>',
{ page : $("#user_show_more_homework").val()},
function (data) {
}
);
}
};
$(window).scroll(scrollHandler);
</script>
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
<!-- 老师身份才可以发布作业 -->
<div class="HomeWork mb10">
@ -42,56 +57,4 @@
</div><!----HomeWork end-->
<% end%>
<% @homework_commons.each do |homework_common|%>
<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
<div class="HomeWork mb10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo">
<%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%>
TO
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
</div>
<div class="homepagePostTitle">
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
</div>
<div class="homepagePostSubmitContainer">
<div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %>
</div>
<div class="homepagePostDeadline">
<%= l(:label_end_time)%><%= homework_common.end_time%>
</div>
</div>
<div class="homepagePostIntro upload_img break_word">
<%= homework_common.description.html_safe %>
</div>
<div class="mt10">
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
<div class="cl"></div>
</div>
<% if is_teacher%>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%>
</li>
<li>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
</div>
<div class="cl"></div>
</div>
</div><!----HomeWork end-->
<% end%>
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %>

View File

@ -0,0 +1,4 @@
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>");
<% if @homework_commons.count < 10%>
$(window).off("scroll", scrollHandler);
<% end%>

View File

@ -813,6 +813,7 @@ a:hover.icon_remove{background:url(images/icons.png) -20px -338px no-repeat;}
/*20150820提交作业 LB*/
.HomeWorkBox{ background:#f6f6f6; padding:10px; margin:10px 0;}
.c_grey{ color:#888888;}
.c_dark_grey{color:#a9a9a9 !important;}
.HomeWorkP{ width:690px; font-size:14px;}
.H150{ height:150px;}
.ProResult{width:748px; background-color:#fff; border:1px solid #dddddd;border-bottom:none; }