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

This commit is contained in:
z9hang 2015-03-20 11:49:35 +08:00
commit 587a739c76
7 changed files with 108 additions and 86 deletions

View File

@ -758,22 +758,26 @@ class CoursesController < ApplicationController
def homework
if @course.is_public != 0 || User.current.member_of_course?(@course) || User.current.admin?
@offset, @limit = api_offset_and_limit({:limit => 10})
@bids = @course.homeworks.order('deadline DESC')
@bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.reverse_offset
unless @offset == 0
@bids = @bids.offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
if limit == 0
limit = 10
end
@bids = @bids.offset(@offset).limit(limit).all.reverse
end
bids = @course.homeworks.order('created_on DESC')
bids = bids.like(params[:name]) if params[:name].present?
@bids = paginateHelper bids,10
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
#
# @offset, @limit = api_offset_and_limit({:limit => 10})
#
# @bid_count = @bids.count
# @bid_pages = Paginator.new @bid_count, @limit, params['page']
#
# @offset ||= @bid_pages.reverse_offset
# unless @offset == 0
# @bids = @bids.offset(@offset).limit(@limit).all.reverse
# else
# limit = @bid_count % @limit
# if limit == 0
# limit = 10
# end
# @bids = @bids.offset(@offset).limit(limit).all.reverse
# end
render :layout => 'base_courses'
else
render_403

View File

@ -1,63 +1,36 @@
<style type="text/css">
#attachments_fields input.description {
width: auto;
}
</style>
<%= javascript_include_tag 'attachments' %>
<!-- fq -->
<div class="content-title-top">
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%>
<%= link_to(l(:label_course_homework_new), {:controller => 'courses', :action => 'new_homework'}, :class => 'icon icon-add') %>
<% else %>
<span class="font_lighter">
<%= l(:label_coursejoin_tip) %>
</span>
<div class="project_r_h">
<h2 class="project_h2">课程作业</h2>
</div>
<div class="talk_top">
<p class="fl">
共有<span><%= @obj_count%></span>个作业
</p>
<%= link_to( l(:label_course_homework_new), new_homework_course_path(@course), :class => 'problem_new_btn fl c_dorange') if @is_teacher %>
<div class="cl"></div>
</div>
<% @bids.each do |bid|%>
<div class="problem_main">
<%= link_to(image_tag(url_to_avatar(bid.author), :width => "42", :height => "42"), user_path(bid.author), :class => "problem_pic fl") %>
<div class="problem_txt fl mt5">
<%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author),:class => 'problem_name fl') %>
<span class="fl"> <%= l(:label_user_create_project_homework) %></span>
<%= link_to(bid.name, course_for_bid_path(bid), :class => 'problem_tit fl fb c_dblue') %>
<div class="cl mb5"></div>
<p class="fl ">已提交的作业 (<%= link_to bid.homeworks.count, course_for_bid_path(bid.id), :class => 'c_red'%> )</p>
<a href="#" class="fr mr10 work_edit">关闭匿评</a><a href="courses_hworkedit.html" class="fr mr10 work_edit">编辑</a>
<div class="cl"></div>
<p id="news_description" class="news_description mt5">项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题项目问题个数显示问题<br /> 创建时间 2014-11-26 10:19</p>
<div class="news_foot" onclick="show_more_msg02();">展开更多信息 <span class="g-arr-down"><img src="images/jiantou.jpg" width="12" height="6" /></span></div>
</div>
<div class="cl"></div>
</div>
<% end%>
</div>
<div id="bid-show">
<%= render :partial => 'bids/bid_homework_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %>
</div>
<div id="OpenWindow">
<div id="signup-ct">
<div id="OpenWindow-header">
<h1> 课程: <%= @course.name%> </h1>
<p id='bid-desc'> 上传作业 </p>
<a href="javascript:void(0);" class="modal_close"></a>
</div>
<div id="OpenWindow-content">
</div>
</div>
</div>
<script type="text/javascript">
$("a[rel*=leanModal]").leanModal({
top:100,
closeButton: ".modal_close"
});
function showSubH(/* ... */){
var id, name, numargs = arguments.length;
id = arguments[0];
name = arguments[1];
$("#OpenWindow").find("#bid-desc").html('作业名: '+name);
post_url = '/bids/' + id + '/homework_ajax_modal.js'
function deal_post (data, textStatus, xhr) {
if(textStatus == 'success'){
eval(data);
}
if(textStatus != 'success'){
$('#OpenWindow-content').html('<span class=\"font_color_orange\" > ' + textStatus + ' <\/span>\n');
}
}
function deal_error (argument) {
$('#OpenWindow-content').html('<strong>Network Error</strong><span class=\"font_color_orange\" > <br/>http_status:' + argument.status + '<br/>statusText:' + argument.statusText + ' <\/span>\n');
}
$.post(post_url,{}, deal_post).error(deal_error);
}
</script>
<% html_title(l(:label_homework)) -%>
<ul class="wlist" >
<li><a href="#">下一页</a></li>
<li><a href="#">...</a></li>
<li><a href="#">2</a></li>
<li class="wlist_select" ><a href="#">1</a></li>
<li><a href="#">上一页</a></li>
</ul>
<div class="cl"></div>

View File

@ -9,9 +9,21 @@
<span class="re_tag f_l " id="tag">
<%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id, :class => 'pt5' %>
<span class="del">
<%= link_to('x', :controller => "tags", :action => "remove_tag", :remote => true, :tag_name => tag,:taggable_id => obj.id, :taggable_type => object_flag) if (CourseInfos.find_by_course_id(obj.id)).try(:user_id) == User.current.id %>
<%= link_to('x', remove_tag_path(:tag_name => tag,:taggable_id => obj.id, :taggable_type => object_flag), :remote => true, :confirm => l(:text_are_you_sure) ) if (CourseInfos.find_by_course_id(obj.id)).try(:user_id) == User.current.id %>
</span>
</span>
<% end %>
<% end %>
<% end %>
<% if User.current.logged?%>
<a href="javascript:void(0)" class="yellowBtn f_l" onclick="$('#add_tag01').slideToggle();"><%= l(:label_add_tag)%></a>
<span id="add_tag01" style="display:none; vertical-align: middle;" class="ml10 f_l">
<%= form_for "tag_for_save",:remote=>true,:url=>save_tag_path,:update => "tags_show",:complete => '$("#put-tag-form").slideUp();' do |f| %>
<%= f.text_field :name ,:id => "tags_name",:size=>"20",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length,:class =>"isTxt w90 f_l" %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<input type="button" class="submit f_l" onclick="$('#tags_name').parent().submit();" />
<% end %>
</span>
<% end%>

View File

@ -6,8 +6,10 @@ $('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_n
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false, :object_flag => @object_flag}) %>');
<% elsif @object_flag == '9'%>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/new_tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>');
<% else%>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>');
<% end %>

View File

@ -1,9 +1,23 @@
//本js使用的新的tag显示方法
<% if @obj_flag == '6'%>
<% if @obj_flag == '3'%>
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
//$('#put-tag-form-issue').hide();
$('#name-issue').val("");
<% elsif @obj_flag == '6'%>
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_list',
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
//$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide();
$("#tags_name_<%= @obj.id%>").val("");
$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
<% elsif @obj_flag == '9'%>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/new_tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#tags_name').val("");
<% else%>
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
$('#tags_name').val("");
//$('#put-tag-form').hide();
<% end %>

View File

@ -28,3 +28,20 @@ function show_more_msg()
$(document).ready(function () {
$("#RSide").css("min-height",$("#LSide").height()-30);
});
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
$("#"+divname).html("<span style='color: #acaeb1;'>作业提交还剩&nbsp;:</span>&nbsp;<span style='color: red;'>"
+day1+"&nbsp;</span><span style='color: #acaeb1;'>天</span><span style='color: red;'>&nbsp;"
+hour+"&nbsp;</span><span style='color: #acaeb1;'>时</span><span style='color: red;'>&nbsp;"
+minute+"&nbsp;</span><span style='color: #acaeb1;'>分</span><span style='color: red;'>&nbsp;"
+second+"&nbsp;</span><span style='color: #acaeb1;'>秒</span>");
}