diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 9cc940bdd..281f6216d 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -8,6 +8,30 @@ class SoftapplicationsController < ApplicationController def index @softapplications = Softapplication.all + #new added fenyefunction + @limit = 5 + @softapplication_count = @softapplications.count + @softapplication_pages = Paginator.new @softapplication_count, @limit, params['page'] + @offset ||= @softapplication_pages.offset + #@softapplications = @softapplications[@offset,@limit] + #new added end + + #new added sort + if params[:softapplication_sort_type].present? + case params[:softapplication_sort_type] + when '0' + @softapplications = @softapplications[@offset, @limit] + @s_state = 0 + when '1' + @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit] + @s_state = 1 + end + else + @softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit] + @s_state = 1 + end + #new added end + respond_to do |format| format.html # index.html.erb format.json { render json: @softapplications } @@ -16,8 +40,25 @@ class SoftapplicationsController < ApplicationController # GET /softapplications/1 # GET /softapplications/1.json + + def percent_of(num, percent) + num.to_f / percent.to_f * 100.0 + end + def show @softapplication = Softapplication.find(params[:id]) + # 打分统计 + stars_reates = @softapplication. + rates(:quality) + stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count + stars_status = stars_reates.select("stars, count(*) as scount"). + group("stars") + + @stars_status_map = Hash.new(0.0) + stars_status.each do |star_status| + @stars_status_map["star#{star_status.stars.to_i}".to_sym] = + percent_of(star_status.scount, stars_reates_count).to_s + "%" + end @jours = @softapplication.journals_for_messages.order('created_on DESC') @image_results = [] @softapplication.attachments.each do |f| diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 710b73194..c662c44f7 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -39,17 +39,18 @@ class WelcomeController < ApplicationController @courseCount = Project.course_entities.count @teacherCount = User.teacher.count @studentCount = User.student.count - @logoLink = logolink(params[:school_id]) + @logoLink = logolink() end - def logolink(id) + def logolink() + id = params[:school_id] logo_link = "" if id.nil? and User.current.user_extensions.school.nil? logo_link = '/images/transparent.png' else - if id.to_i == 0 + if id == "0" logo_link = '/images/transparent.png' else if id.nil? diff --git a/app/helpers/softapplications_helper.rb b/app/helpers/softapplications_helper.rb index e3cb6410d..fe78e9875 100644 --- a/app/helpers/softapplications_helper.rb +++ b/app/helpers/softapplications_helper.rb @@ -1,2 +1,18 @@ module SoftapplicationsHelper + def sort_softapplication(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'})) + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'}, :class=>"selected"), :class=>"selected") + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '1'}, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'softapplications', action: 'index' ,:softapplication_sort_type => '0'})) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end end + + diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 5b455a01b..43ee05db8 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -54,57 +54,111 @@ module UserScoreHelper watcher_count = Watcher.where("watchable_type = 'principal' AND watchable_id = ?", user.id).count end + + + def calculate_skill_count(user) - praise_count = 0 - tread_count = 0 + praise_count_l0 = 0 + praise_count_l1 = 0 + praise_count_l2 = 0 + tread_count_l0 = 0 + tread_count_l1 = 0 + tread_count_l2 = 0 issues = Issue.where('author_id = ?', user.id) issues.each do |i| - ptcs = PraiseTreadCache.where('object_id = ?', i.id) - ptcs.each do |p| - praise_count = praise_count + p.praise_num - tread_count = tread_count + p.tread_num + pts = PraiseTread.where('praise_tread_object_id = ?', i.id) + pts.each do |p| + templevel = calculate_level(User.find(p.user_id)) + + if templevel.to_i == 0 + if p.praise_or_tread == 1 + praise_count_l0 = praise_count_l0 + 1 + else + tread_count_l0 = tread_count_l0 + 1 + end + end + if templevel.to_i == 1 + if p.praise_or_tread == 1 + praise_count_l1 = praise_count_l1 + 1 + else + tread_count_l1 = tread_count_l1 + 1 + end + end + if templevel.to_i == 2 + if p.praise_or_tread == 1 + praise_count_l2 = praise_count_l2 + 1 + else + tread_count_l2 + tread_count_l2 + 1 + end + end end end + + + bids = Bid.where('author_id = ?', user.id) bids.each do |b| - ptcs = PraiseTreadCache.where('object_id = ?', b.id) + ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id) ptcs.each do |p| - praise_count = praise_count + p.praise_num - tread_count = tread_count + p.tread_num + templevel = calculate_level(User.find(p.user_id)) + + if templevel.to_i == 0 + if p.praise_or_tread == 1 + praise_count_l0 = praise_count_l0 + 1 + else + tread_count_l0 = tread_count_l0 + 1 + end + end + if templevel.to_i == 1 + if p.praise_or_tread == 1 + praise_count_l1 = praise_count_l1 + 1 + else + tread_count_l1 = tread_count_l1 + 1 + end + end + if templevel.to_i == 2 + if p.praise_or_tread == 1 + praise_count_l2 = praise_count_l2 + 1 + else + tread_count_l2 + tread_count_l2 + 1 + end + end end end contests = Contest.where('author_id = ?', user.id) contests.each do |c| - ptcs = PraiseTreadCache.where('object_id = ?', c.id) + ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id) ptcs.each do |p| - praise_count = praise_count + p.praise_num - tread_count = tread_count + p.tread_num + templevel = calculate_level(User.find(p.user_id)) + + if templevel.to_i == 0 + if p.praise_or_tread == 1 + praise_count_l0 = praise_count_l0 + 1 + else + tread_count_l0 = tread_count_l0 + 1 + end + end + if templevel.to_i == 1 + if p.praise_or_tread == 1 + praise_count_l1 = praise_count_l1 + 1 + else + tread_count_l1 = tread_count_l1 + 1 + end + end + if templevel.to_i == 2 + if p.praise_or_tread == 1 + praise_count_l2 = praise_count_l2 + 1 + else + tread_count_l2 + tread_count_l2 + 1 + end + end end end - level = calculate_level(user) - - skill_score = 0 - - if level == 0 - skill_score = praise_count - 0.5 * tread_count - end - if level == 1 - skill_score = 2 * praise_count - 1.5 * tread_count - end - if level == 2 - skill_socre = 3 * praise_count - 2.5 * tread_count - end - if level == 3 - skill_socre = 4 * praise_count - 3.5 * tread_count - end - if level == 4 - skill_socre = 5 * praise_count - 4.5 * tread_count - end # case level # when 0 skill_score = praise_count - 0.5 * tread_count @@ -114,12 +168,19 @@ module UserScoreHelper # when 4 skill_socre = 5 * praise_count - 4.5 * tread_count # end - + skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f + - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count - skill_score = skill_score - 0.5 * tread_user_count - + skill_score = skill_score.to_f - tread_user_count.to_f + + + + + + + return skill_score @@ -135,7 +196,7 @@ module UserScoreHelper issues.each do |i| ptcs = PraiseTreadCache.where('object_id = ?', i.id) ptcs.each do |p| - if p.praise_num > max_praise_num + if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end end @@ -145,7 +206,7 @@ module UserScoreHelper bids.each do |b| ptcs = PraiseTreadCache.where('object_id = ?', b.id) ptcs.each do |p| - if p.praise_num > max_praise_num + if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end end @@ -155,7 +216,7 @@ module UserScoreHelper contests.each do |c| ptcs = PraiseTreadCache.where('object_id = ?', c.id) ptcs.each do |p| - if p.praise_num > max_praise_num + if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end end diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb index eb179718a..9b99b675c 100644 --- a/app/views/contests/_list_softapplications.html.erb +++ b/app/views/contests/_list_softapplications.html.erb @@ -14,7 +14,7 @@ 简介: - <%= c_softapplication.softapplication.description %> + <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 98befd091..7552b9941 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,4 +1,132 @@ + + <%=(@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区 @@ -88,9 +216,7 @@
<% @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> -
<%#需要交由浏览器异步刷新,或者一次连表查询,n+1 查询问题搞不定%> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%> -
+ <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"}%>
diff --git a/app/views/layouts/_base_softapplication_index_top_content.html.erb b/app/views/layouts/_base_softapplication_index_top_content.html.erb new file mode 100644 index 000000000..0a41036f1 --- /dev/null +++ b/app/views/layouts/_base_softapplication_index_top_content.html.erb @@ -0,0 +1,22 @@ +
+ + + + + + + + + + + +
创新竞赛社区<%= l(:label_user_location) %> : + +
<%=link_to request.host()+"/softapplications", :controller=>'softapplications', :action=>'index' %><%=link_to l(:field_homepage), home_path %> > + <%=link_to l(:label_contest_softapplication), :controller=>'softapplications', :action=>'index' %> +
+
\ No newline at end of file diff --git a/app/views/softapplications/index.html.erb b/app/views/softapplications/index.html.erb index 16a206508..950e822a3 100644 --- a/app/views/softapplications/index.html.erb +++ b/app/views/softapplications/index.html.erb @@ -1,4 +1,4 @@ -

参赛应用

+ + + + +<%=render :partial => 'layouts/base_softapplication_index_top_content'%> + +<% if @softapplications.size > 0%> + <%= sort_softapplication(@s_state)%> + +
+ <% @softapplications.each do |softapplication| %> +
+ <%= link_to softapplication.name, softapplication, :target => "_blank" %> + <%= rating_for softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %> + +
+
<%= image_tag('/images/app1.png')%>
+
<%= softapplication.description.truncate(95, omission: '...') %>
+
+ <%contest = softapplication.contests.first%> +

所属竞赛:<%= contest ? link_to(contest.name, show_softapplication_contest_path(contest) ) : '尚未加入竞赛'%>

+

所属类别:<%= softapplication.app_type_name %>

+

系统支持:<%= softapplication.android_min_version_available %>

+
+
+ 开发人员:<%= softapplication.application_developers %> + 发布时间:<%=format_time softapplication.created_at %> +
+
+
+ <% end %> +
+ +<% else %> + <%= render :partial => "layouts/no_content"%> +<% end %> + + + + +<% html_title l(:label_softapplication_list)%> \ No newline at end of file diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index 32ab3474b..7d876d6c8 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -27,7 +27,7 @@ 所属类别:<%= @softapplication.app_type_name %> <% contest = @softapplication.contests.first %> - 所属竞赛:<%= contest ? link_to(contest.name, show_contest_contest_path(contest)) : '尚未加入竞赛'%> + 所属竞赛:<%= contest ? link_to(contest.name, show_softapplication_contest_path(contest)) : '尚未加入竞赛'%> 发布人员:<%= @softapplication.user.name %> @@ -56,14 +56,40 @@
-
应用简介:
-
<%= @softapplication.description.truncate(150, omission: '...') %>
+
应用简介:
+
<%= @softapplication.description %>
+
+
+ +
+
应用得分:
+
+
+
得分比例
+
+ <% 100.step(20,-20) do |star| %> +
+
+
+
+
+
+ <%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> +
+ <% end %> +
+
+
+
最终得分
+
<%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %>
+
+
软件截图:
-
+
<% @image_results.take(4).each do |attachment| %> <%= link_to_attachment_img attachment, :class => "soft-application", :download => "true" %> <% end %> @@ -72,7 +98,18 @@
- +
软件评论:
评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %>
diff --git a/app/views/test/index.html.erb b/app/views/test/index.html.erb index 0aa1a5d95..eeef0f3da 100644 --- a/app/views/test/index.html.erb +++ b/app/views/test/index.html.erb @@ -12,14 +12,13 @@ <%= user.lastname %><%= user.firstname %> - - <%= user.changesets.count %> + <% end %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index 6c89489c6..daeca6de4 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -201,7 +201,7 @@

最新参赛应用

- + <%= link_to "更多>>", {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %>
<% if Softapplication.count > 0%>
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 8ad0cd6bf..b8b755b58 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -20,40 +20,37 @@
- <%= image_tag(@logoLink, size:'75x75') %> - -
-
- - - <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - <% else%> - <% if params[:school_id] == "0" %> - <% else %> - <% if params[:school_id].nil? %> + <%= image_tag(@logoLink, size:'75x75') %> - <%= School.find(User.current.user_extensions.school.id).name %> -
+
+
+
+ <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> + <% else%> + <% if params[:school_id] == "0" %> <% else %> - <%= School.find(params[:school_id]).name %> -
+ <% if params[:school_id].nil? %> + <%= School.find(User.current.user_extensions.school.id).name %> +
+ <% else %> + <%= School.find(params[:school_id]).name %> +
+ <% end %> <% end %> - <% end %> - <% end %> -
+ <% end %> <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= l(:label_welcome_trustie_course_description) %> <% else %> <% if params[:school_id] == "0" %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= l(:label_welcome_trustie_course_description) %> <% end %> <% end %> -
- -
+
+ +
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index f4b6fe0ce..9acb5e592 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1425,7 +1425,7 @@ zh: label_has_praisers: 赞(%{count}) label_has_watchers: 关注(%{count}) label_has_fans: 粉丝(%{count}) - label_coursefile_sharingarea: 课程资源共享区 + label_coursefile_sharingarea: 课程文件共享专区 #modify by men label_x_has_fans: zero: 粉丝(%{count}) @@ -1547,7 +1547,6 @@ zh: label_sort_by_time: 按时间排序 label_sort_by_active: 按活跃度排序 label_sort_by_influence: 按影响力排序 - label_sort_by_activity: 按动态数排序 label_bids_published: 发布于 label_bids_published_ago: 之前 label_welcome_trustie: Trustie @@ -1668,7 +1667,7 @@ zh: label_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。) label_course_view_student: 查看其他课程 label_course_student: 学生 - label_homework: 课程实践 + label_homework: 课程作业 label_course_file: 资源库 #资料共享 label_stores_index: 资源搜索 label_course_new_homework: 新建作业 @@ -1716,11 +1715,6 @@ zh: zero: 份资料 one: 份资料 other: 份资料 -#added by gcm - label_x_activity: - zero: 个动态 - one: 个动态 - other: 个动态 @@ -1765,13 +1759,13 @@ zh: label_has_been: 已经被 label_course_userd_by: 个课程引用 - - label_school_all: 中国高校 - - role_of_course: 课程角色 label_student: 学生 + #added by Wen + label_school_all: 中国高校 + + label_project_grade: 项目得分 label_user_grade: 个人得分 label_user_for_project_grade: 个人得分 @@ -1829,8 +1823,7 @@ zh: label_sumbit_empty: 搜索内容不能为空 #add by linchun (竞赛相关) - label_upload_files: 上传资源 - label_relation_files: 关联已有资源 + label_upload_files: 上传文件 label_upload_softwarepackage: 上传软件包 label_upload_cuttingphoto: 上传截图 label_contests_reward_method: 奖励方式 @@ -1869,8 +1862,20 @@ zh: label_add_contest_succeed_fail: 添加失败,该应用已参赛. label_no_ftapplication: 暂无应用 label_edit_softapplication: 修改应用 + label_contest_delete: 删除竞赛 + label_softapplication_list: 应用列表 + + label_coursefile_sharingarea: 课程资源共享区 + label_sort_by_activity: 按动态数排序 + label_homework: 课程实践 + label_x_activity: + zero: 个动态 + one: 个动态 + other: 个动态 + label_school_all: 中国高校 + label_upload_files: 上传资源 + label_relation_files: 关联已有资源 label_contest_settings: 配置竞赛 label_contest_delete: 删除竞赛 - - - + label_school_all: 学校列表 + \ No newline at end of file diff --git a/public/images/school/1578.png b/public/images/school/1578.png deleted file mode 100644 index 84340ace5..000000000 Binary files a/public/images/school/1578.png and /dev/null differ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 36a8a61ca..5425f1826 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -624,7 +624,7 @@ ul.tool li{list-style-type:none; font-family: Tahoma,"Microsoft YaHei"; font-weight: bold; font-size: 20px; - color:#FF9900; + color:#e8770d; } .font_welcome_Cdescription{ diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 306d6d113..b73123590 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -2247,130 +2247,4 @@ ul.messages-for-user-reply li { .footer_text_link{ margin: 0px 5px; } -/*gcm*/ - -#ver-zebra, .file_table_des -{ - font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; - font-size: 12px; - margin: 5px 10px; - width: 98%; - text-align: left; - border-collapse: collapse; - line-height: 20px; - font-size: 14px; -} -#ver-zebra th -{ - font-size: 14px; - font-weight: normal; - padding: 12px 15px; - border-right: 1px solid #fff; - border-left: 1px solid #fff; - color: #039; - text-align: left; -} -#ver-zebra td -{ - padding: 8px 15px; - border-right: 1px solid #fff; - border-left: 1px solid #fff; - color: #669; -} -#ver-zebra td.description { - background-color: white; - padding: 0px; - margin: 0px auto; -} -div.tags_area { - padding: 2px 10px 10px 10px; - margin: 0px; - margin-bottom: 10px; - /*border-bottom: 1px dashed #CCCCCC;*/ - overflow: hidden; - position: relative; -} -.tags_gradint { -} -.read-more{ - padding: 5px; - border-top: 4px double #ddd; - background: #fff; - color: #333; -} -.read-more a{ - padding-right: 22px; - background: url() no-repeat 100% 50%; - font-weight: bold; - text-decoration: none; -} -.read-more a:hover{ - color: #000; -} -.vzebra-odd -{ - background: #eff2ff; -} -.vzebra-even -{ - background: #e8edff; -} -#ver-zebra #vzebra-adventure, #ver-zebra #vzebra-children -{ - background: #ffffff; - border-bottom: 1px solid #c8d4fd; -} -#ver-zebra #vzebra-comedy, #ver-zebra #vzebra-action -{ - background: #ffffff; - border-bottom: 1px solid #d6dfff; -} -.filename{ - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} -div.pagination{ - margin: 10px 0px; - height: 1.5em; - text-align: left; - font-size: 13px; -} -.m5p5{ - display: inline-block; - height: auto; - color: white !important; - margin: 8px; - padding: 3px 7px; -} -.m5p5:hover { - text-decoration: none; - /*padding-bottom: 3px;*/ - /*border-bottom: 1px solid #666666;*/ - border-radius: 4px; - border: 1px solid #15bccf; - box-shadow: 3px 3px 3px #666666; -} -.relation_file_div{ - margin: 0px 25px; -} -.relation_file_div fieldset{ - margin: 0px 0px; - padding: 10px; - border-radius: 5px; - transition: all 2s linear 1s; -} -.relation_file_div input#attach_search:focus{ - border: 1px solid #1B95C6; - box-shadow: 0px 0px 4px #1B95C6; - width: 200px; -} -.relation_file_div input#attach_search{ - width: 150px; - outline: none; - border-radius: 5px; - -webkit-transition: 1s width; - -moz-transition : 1s width; - -o-transition : 1s width; - transition : 1s width; -} \ No newline at end of file +/*gcm*/ \ No newline at end of file