三天两头反复改 不如自挂东南枝

This commit is contained in:
yanxd 2014-02-22 09:44:14 +08:00
parent d4fb5665df
commit cf2689917b
13 changed files with 429 additions and 21 deletions

View File

@ -180,13 +180,13 @@ class UsersController < ApplicationController
membership.collect { |e| membership.collect { |e|
@memberships.push(e) if(e.project.project_type == 1) @memberships.push(e) if(e.project.project_type == 1)
} }
## 判断课程是否过期 [需封装]
@memberships_doing = [] @memberships_doing = []
@memberships_done = [] @memberships_done = []
now_time = Time.now now_time = Time.now.year
@memberships.map { |e| @memberships.map { |e|
end_time = e.project.course_extra.get_endup_time end_time = e.project.course_extra.get_time.year
if end_time > now_time if end_time >= now_time
@memberships_doing.push e @memberships_doing.push e
else else
@memberships_done.push e @memberships_done.push e

View File

@ -73,5 +73,8 @@ class WelcomeController < ApplicationController
render :layout => false, :content_type => 'text/plain' render :layout => false, :content_type => 'text/plain'
end end
def course
end
end end

View File

@ -21,12 +21,12 @@ module WelcomeHelper
include CoursesHelper include CoursesHelper
def find_all_hot_project def find_all_hot_project limit=15
sort_project_by_hot sort_project_by_hot limit
end end
def find_all_hot_course def find_all_hot_course limit=15
sort_course_by_hot sort_course_by_hot limit
end end
def find_all_hot_bid def find_all_hot_bid
@ -141,12 +141,12 @@ module WelcomeHelper
private private
def sort_project_by_hot def sort_project_by_hot limit=15
sort_project_by_hot_rails 0, 'grade DESC' sort_project_by_hot_rails 0, 'grade DESC', limit
end end
def sort_course_by_hot def sort_course_by_hot limit=15
sort_project_by_hot_rails 1, 'course_ac_para DESC' sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
end end
def sort_bid_by_hot def sort_bid_by_hot

View File

@ -28,4 +28,15 @@ class Course < ActiveRecord::Base
end end
end end
def get_time
begin
time = Date.new(self.time).to_time
rescue Exception => e
time = Time.parse("3000-01-01")
Rails.logger.error "[Error] course time error. ===> #{e}"
ensure
return time
end
end
end end

View File

@ -1,6 +1,6 @@
<% <%
request.headers['REQUEST_URI'] = "" if request.headers['REQUEST_URI'].nil? request.headers['REQUEST_URI'] = "" if request.headers['REQUEST_URI'].nil?
if (request.headers['REQUEST_URI'].match(/course/)) if (request.headers['REQUEST_URI'].match(/project\/course/))
@nav_dispaly_course_label = 1 @nav_dispaly_course_label = 1
elsif (request.headers['REQUEST_URI'].match(/projects/)) elsif (request.headers['REQUEST_URI'].match(/projects/))
@nav_dispaly_project_label = 1 @nav_dispaly_project_label = 1
@ -12,6 +12,10 @@
@nav_dispaly_bid_label = 1 @nav_dispaly_bid_label = 1
elsif (request.headers['REQUEST_URI'].match(/forums/)) elsif (request.headers['REQUEST_URI'].match(/forums/))
@nav_dispaly_forum_label = 1 @nav_dispaly_forum_label = 1
elsif (request.headers['REQUEST_URI'].match(/[^projects]\/course$/))
@nav_dispaly_course_label = 1
@nav_dispaly_project_label = 1
@nav_dispaly_contest_label = 1
else else
@nav_dispaly_course_label = 1 @nav_dispaly_course_label = 1
@nav_dispaly_project_label = 1 @nav_dispaly_project_label = 1

View File

@ -138,15 +138,15 @@
<tr> <tr>
<td valign="top" style="padding-left: 8px; width:60px"><%= l(:label_main_teacher) %> :</td><td class="font_lighter_sidebar"><%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher)) %></td> <td valign="top" style="padding-left: 8px; width:60px"><%= l(:label_main_teacher) %> :</td><td class="font_lighter_sidebar"><%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher)) %></td>
</tr> </tr>
<!--
<tr> <tr class="hidden">
<td valign="top" style="padding-left: 8px;"><%= l(:label_setup_time) %> :</td><td class="font_lighter_sidebar"><%= @course.setup_time %></td> <td valign="top" style="padding-left: 8px;"><%= l(:label_setup_time) %> :</td><td class="font_lighter_sidebar"><%= @course.setup_time %></td>
</tr> </tr>
<tr> <tr class="hidden">
<td valign="top" style="padding-left: 8px;"><%= l(:label_endup_time) %> :</td><td class="font_lighter_sidebar"><%= @course.endup_time %></td> <td valign="top" style="padding-left: 8px;"><%= l(:label_endup_time) %> :</td><td class="font_lighter_sidebar"><%= @course.endup_time %></td>
</tr> </tr>
-->
<tr> <tr>
<td valign="top" style="padding-left: 8px;"><%= l(:label_class_period) %> :</td><td class="font_lighter_sidebar"><%= @course.class_period %>&nbsp;<%= l(:label_class_hour)%></td> <td valign="top" style="padding-left: 8px;"><%= l(:label_class_period) %> :</td><td class="font_lighter_sidebar"><%= @course.class_period %>&nbsp;<%= l(:label_class_hour)%></td>
</tr> </tr>

View File

@ -22,10 +22,12 @@
<div style="clear:both;"></div> <div style="clear:both;"></div>
<p> <p>
<span><%=l(:label_course_done)%>(<%=@memberships_done.count%>)</span> <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", '#', :onclick => '$("#courses_history_block").slideToggle(400);' if User.current.logged? %>
</p> </p>
<div class="courses_history" >
<div id="courses_history_block" class="courses_history hidden" >
<%= render :partial => 'course_form', :locals => {:memberships => @memberships_done}%> <%= render :partial => 'course_form', :locals => {:memberships => @memberships_done}%>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -22,11 +22,13 @@
<div style="clear:both;"></div> <div style="clear:both;"></div>
<p> <p>
<span><%=l(:label_course_done)%>(<%=@memberships_done.count%>)</span> <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", '#', :onclick => '$("#courses_history_block").slideToggle(400); ' if User.current.logged? %>
</p> </p>
<div class="courses_history" >
<div id="courses_history_block" class="courses_history hidden" >
<%= render :partial => 'course_form', :locals => {:memberships => @memberships_done}%> <%= render :partial => 'course_form', :locals => {:memberships => @memberships_done}%>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -0,0 +1,255 @@
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
$(function(){
$("#main").find("a").attr("target", "_blank");
});
function showInfo(id, content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
</script>
<script type="text/javascript">
(function (){
window.onload = function(){
function fixedBar(id, options){
var ele = document.getElementById(id);
if(!ele) return;
if(/msie (\d+\.\d+)/i.test(navigator.userAgent)){
var pageHeight=window.innerHeight;
var d=document;
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
if(options.addclass) ele.className = options.addclass;
ele.style.position= 'absolute';
if(options.show){
ele.style.top = 0 + "px";
ele.style.display= 'block';
}
window.attachEvent('onscroll' , function (){
var ieScrollTop=window.pageYOffset || d.documentElement.scrollTop || d.body.scrollTop;
ele.style.top = 0 + "px";
if(options.autoHidden){
if(ieScrollTop==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
});
}else{
var ele = document.getElementById(id);
if(typeof pageHeight!="number"){
if(document.compatMode=="CSS1Compat"){
pageHeight=document.documentElement.clientHeight;
}else{
pageHeight=document.body.clientHeight;
}
}
if(options.show) ele.style.display= 'block';
ele.style.top = 0 +'px';
window.addEventListener('scroll',function (){
if(options.autoHidden){
if(baidu.page.getScrollTop()==0){
ele.style.display="none";
}else{
ele.style.display="block";
}
}
},false);
}
}
fixedBar('backTopBtn' , {autoHidden: true, top : 186});
fixedBar('identifier-pannel' , {autoHidden: false , top : 956 , show : true});
}
})();
</script>
<div class='top_bar'>
<div id="identifier-pannel" style="display:none">
<%= image_tag '/images/qrweixin.jpg', size: '150x150', alt: 'trustie', class: "weixin" %>
<div class="weixin-content">微信扫码</div>
</div>
<div class="main-content-bar">
<div class="welcome_left" >
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %> </span><span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_description) %></span>
</div>
<div class="search-bar">
<%= render :partial => "search_bar"%>
</div>
<div style="clear: both;"></div>
</div>
</div>
<div style="clear:both"></div>
<%= stylesheet_link_tag 'welcome' %>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门课程</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %>
<li style="background-image:none;">
<div style="float: left;">
<% if get_avatar?(project)%>
<%= image_tag(url_to_avatar(project), :class => "avatar-4") %>
<% else %>
<%= image_tag('../images/avatars/Project/course.jpg', :class => "avatar-4") %>
<% end %>
</div>
<div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout">
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}", :target => "_blank" )%>
<span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %></span>
</p>
<p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
</p>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>我的课程</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= (link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}) if User.current.login? %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist" style="height:200px;">
<%if !User.current.login?%>
<li style="background-image:none;">
请<%=link_to "登录", signin_path %>后查看
</li>
<%else%>
<% find_all_hot_course(2).map do |project| %>
<li style="background-image:none;">
<div style="float: left;">
<% if get_avatar?(project)%>
<%= image_tag(url_to_avatar(project), :class => "avatar-4") %>
<% else %>
<%= image_tag('../images/avatars/Project/course.jpg', :class => "avatar-4") %>
<% end %>
</div>
<div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout">
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}", :target => "_blank" )%>
<span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %></span>
</p>
<p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
</p>
</div>
</li>
<% end %>
<% end -%>
</ul>
</div>
<div class="web_status">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>当前网站状态</strong></h3>
<table>
<tbody>
<tr>
<td>课程总量: 15</td>
<td>教师数量: 6</td>
</tr>
<tr>
<td>用户总量: 810</td>
<td>学生数量: 233</td>
</tr>
<tr>
<td>资源总量: 0810</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div style="text-align: right; padding-right: 20px">
<%= link_to "意见反馈" , '#', {:class => 'orangeButton', :style => "color: #EEEEEE" }%>
</div>
</div>
</div>
<div class="clearfix"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_project(6).map do |project| %>
<li style="background-image:none;">
<div style="float: left;">
<%= image_tag url_to_avatar(project), :class => "avatar-4" %>
</div>
<div style="float: left; margin-left: 10px; width: 360px;">
<p class="layout">
<span style="display: inline-block; width: 250px;"><%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}", :target => "_blank" )%></span>
<%= content_tag "span", show_grade(project),
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</p>
<p class="layout-1" >
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
</p>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<li style="background-image:none;">
<p class="layout">
<span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}",
:style => "margin-left: 28px;", :target => "_blank") %></span>
</p>
<p class="layout-1" >
<%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %>
</p>
</li>
<% end %>
</ul>
</div>
</div>
<div class="clr">
</div>
<br/><br/><br/><br/><br/><br/><br/>
<div style="padding-top: 40px"></div>

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do RedmineApp::Application.routes.draw do
match 'course', :to => 'welcome#course', :via => :get
resources :stores do resources :stores do
collection do collection do
match 'search', via: [:get, :post] match 'search', via: [:get, :post]

View File

@ -34,6 +34,15 @@
-webkit-opacity: 0.7; -webkit-opacity: 0.7;
opacity: 0.7; opacity: 0.7;
} }
.clearfix {
width: 100%;
height: 0px;
clear: both;
display: block;
}
.hidden {
display: none;
}
* { * {
font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif; font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif;
@ -42,6 +51,41 @@
/* 按钮 /* 按钮
*******************************************************************************/ *******************************************************************************/
.orangeButton {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #e87832), color-stop(1, #db6825));
background:-moz-linear-gradient(top, #e87832 5%, #db6825 100%);
background:-webkit-linear-gradient(top, #e87832 5%, #db6825 100%);
background:-o-linear-gradient(top, #e87832 5%, #db6825 100%);
background:-ms-linear-gradient(top, #e87832 5%, #db6825 100%);
background:linear-gradient(to bottom, #e87832 5%, #db6825 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e87832', endColorstr='#db6825',GradientType=0);
background-color:#e87832;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border-radius:4px;
border:1px solid #e87832;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-size:16px;
padding:4px 11px;
text-decoration:none;
text-shadow:0px 1px 0px #754529;
}
.orangeButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #db6825), color-stop(1, #e87832));
background:-moz-linear-gradient(top, #db6825 5%, #e87832 100%);
background:-webkit-linear-gradient(top, #db6825 5%, #e87832 100%);
background:-o-linear-gradient(top, #db6825 5%, #e87832 100%);
background:-ms-linear-gradient(top, #db6825 5%, #e87832 100%);
background:linear-gradient(to bottom, #db6825 5%, #e87832 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#db6825', endColorstr='#e87832',GradientType=0);
background-color:#db6825;
}
.orangeButton:active {
position:relative;
top:1px;
}
input[class~='whiteButton'], .whiteButton { input[class~='whiteButton'], .whiteButton {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff; -moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff; -webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;

View File

@ -374,3 +374,20 @@ a.attachments_list_color {
.forum-topic li{ .forum-topic li{
float: left; float: left;
} }
.web_status {
width: 446px;
}
.web_status table {
margin-top: 20px;
width: auto;
}
.web_status table, .web_status tr, .web_status td{
/*border: 1px solid blue;*/
font-size: 18px;
}
.web_status table td {
width: 160px;
height: 1.5em;
padding-left: 50px;
color:#6B6D72;
}

69
test/unit/course_test.rb Normal file
View File

@ -0,0 +1,69 @@
# Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
class CourseTest < ActiveSupport::TestCase
def setup
@course_1 = Course.new
course_now.id = 1
course_now.tea_id = 1
course_now.name = 'course1'
course_now.state = 1234
course_now.time = 2012
course_now.term = '秋季学期'
course_now.password = 1234
course_now.class_period = 40
@course_2 = Course.new
course_now.id = 2
course_now.tea_id = 1
course_now.name = 'course2'
course_now.state = 1234
course_now.time = 2013
course_now.term = '秋季学期'
course_now.password = 1234
course_now.class_period = 40
@course_3 = Course.new
course_now.id = 3
course_now.tea_id = 1
course_now.name = 'course3'
course_now.state = 1234
course_now.time = 2014
course_now.term = '秋季学期'
course_now.password = 1234
course_now.class_period = 40
@course_now = Course.new
course_now.id = 4
course_now.tea_id = 1
course_now.name = 'course4'
course_now.state = 1234
course_now.time = 2013
course_now.term = '秋季学期'
course_now.password = 1234
course_now.class_period = 40
end
test 'test course whether out of date.' do
true
end
def teardown
end
end