diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2a825e303..f1b8ba528 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -180,13 +180,13 @@ class UsersController < ApplicationController membership.collect { |e| @memberships.push(e) if(e.project.project_type == 1) } - + ## 判断课程是否过期 [需封装] @memberships_doing = [] @memberships_done = [] - now_time = Time.now + now_time = Time.now.year @memberships.map { |e| - end_time = e.project.course_extra.get_endup_time - if end_time > now_time + end_time = e.project.course_extra.get_time.year + if end_time >= now_time @memberships_doing.push e else @memberships_done.push e diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6d3574309..5b4e8caff 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -73,5 +73,8 @@ class WelcomeController < ApplicationController render :layout => false, :content_type => 'text/plain' end + def course + + end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 154c2a98b..b85b3276b 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -21,12 +21,12 @@ module WelcomeHelper include CoursesHelper - def find_all_hot_project - sort_project_by_hot + def find_all_hot_project limit=15 + sort_project_by_hot limit end - def find_all_hot_course - sort_course_by_hot + def find_all_hot_course limit=15 + sort_course_by_hot limit end def find_all_hot_bid @@ -141,12 +141,12 @@ module WelcomeHelper private - def sort_project_by_hot - sort_project_by_hot_rails 0, 'grade DESC' + def sort_project_by_hot limit=15 + sort_project_by_hot_rails 0, 'grade DESC', limit end - def sort_course_by_hot - sort_project_by_hot_rails 1, 'course_ac_para DESC' + def sort_course_by_hot limit=15 + sort_project_by_hot_rails 1, 'course_ac_para DESC', limit end def sort_bid_by_hot diff --git a/app/models/course.rb b/app/models/course.rb index 9fff8713a..5873c4f48 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -28,4 +28,15 @@ class Course < ActiveRecord::Base 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 diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index a6b00aee0..f38c40fd8 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -1,6 +1,6 @@ <% 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 elsif (request.headers['REQUEST_URI'].match(/projects/)) @nav_dispaly_project_label = 1 @@ -12,6 +12,10 @@ @nav_dispaly_bid_label = 1 elsif (request.headers['REQUEST_URI'].match(/forums/)) @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 @nav_dispaly_course_label = 1 @nav_dispaly_project_label = 1 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index d339d12a8..8eacd707d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -138,15 +138,15 @@ <%= l(:label_main_teacher) %> :<%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher)) %> - + <%= l(:label_class_period) %> :<%= @course.class_period %> <%= l(:label_class_hour)%> diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 472465ce9..6f029428b 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -22,10 +22,12 @@

- <%=l(:label_course_done)%>(<%=@memberships_done.count%>) + <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", '#', :onclick => '$("#courses_history_block").slideToggle(400);' if User.current.logged? %>

-
+ + + <% end %>
diff --git a/app/views/users/_my_joinedcourse.html.erb b/app/views/users/_my_joinedcourse.html.erb index 24b4557c0..decc45efa 100644 --- a/app/views/users/_my_joinedcourse.html.erb +++ b/app/views/users/_my_joinedcourse.html.erb @@ -22,11 +22,13 @@

- <%=l(:label_course_done)%>(<%=@memberships_done.count%>) + <%= link_to l(:label_course_done)+"("+@memberships_done.count.to_s+")", '#', :onclick => '$("#courses_history_block").slideToggle(400); ' if User.current.logged? %>

-
+ + + <% end %>
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb new file mode 100644 index 000000000..9ef5b660f --- /dev/null +++ b/app/views/welcome/course.html.erb @@ -0,0 +1,255 @@ + + + + +
+ +
+
+ <%= l(:label_welcome_trustie) %> , <%= l(:label_welcome_trustie_description) %> +
+ +
+
+
+ +
+ + +<%= stylesheet_link_tag 'welcome' %> +
+

热门课程

+ <%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %> +
+ +
+
+ +
+

我的课程

+ <%= (link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}) if User.current.login? %> +
+ +
+
+

当前网站状态

+ + + + + + + + + + + + + + + +
课程总量: 15教师数量: 6
用户总量: 810学生数量: 233
资源总量: 0810 
+
+ <%= link_to "意见反馈" , '#', {:class => 'orangeButton', :style => "color: #EEEEEE" }%> +
+
+
+
+
+

热门项目

+ <%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0}, :target => "_blank" %> +
+ +
+
+ + +
+

热门竞赛

+ <%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1}, :target => "_blank" %> +
+ +
+
+ + + + +
+
+ + +






+
+ + + diff --git a/config/routes.rb b/config/routes.rb index 1d71474fe..882544a55 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + match 'course', :to => 'welcome#course', :via => :get resources :stores do collection do match 'search', via: [:get, :post] diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 6c4ca09ea..bc032ebc8 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -34,6 +34,15 @@ -webkit-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; @@ -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 { -moz-box-shadow:inset 0px 1px 0px 0px #ffffff; -webkit-box-shadow:inset 0px 1px 0px 0px #ffffff; diff --git a/public/stylesheets/welcome.css b/public/stylesheets/welcome.css index 4cc58beb6..040e47a9d 100644 --- a/public/stylesheets/welcome.css +++ b/public/stylesheets/welcome.css @@ -374,3 +374,20 @@ a.attachments_list_color { .forum-topic li{ 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; +} \ No newline at end of file diff --git a/test/unit/course_test.rb b/test/unit/course_test.rb new file mode 100644 index 000000000..ada3a4bc3 --- /dev/null +++ b/test/unit/course_test.rb @@ -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