diff --git a/ReadMe.txt b/ReadMe.txt index 129b99216..32ac107e3 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,4 +1,4 @@ -patch: +patch: 用户姓名的部分,根据issues#655。 为了修改方便 alias: @@ -65,4 +65,8 @@ bundle exec rake db:migrate:up VERSION=20140410021724 2 启动rails 3 运行migrate 3 打开admin配置插件(http://127.0.0.1:3000/settings/plugin/redmine_ckeditor) -4 点击“查询”(就是确定的功能) \ No newline at end of file +4 点击“查询”(就是确定的功能) +=============================================================================== +0719:若遇到首页定制报错问题请尝试如下操作 +1.运行 bundle exec rake db:migrate:down version=20140719080032 +2.运行 bundle exec rake db:migrate:up version=20140719080032 \ No newline at end of file diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 033b6405c..e971970bc 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -357,26 +357,44 @@ module CoursesHelper #获取作业的互评得分 def student_score_for_homework homework - member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - if member.nil? - return "0.00" + #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + #student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + members = searchStudent(homework.bid.courses.first) + user_ids = [] + members.each do |user| + user_ids << user.user_id end - student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars") student_stars_count = 0 student_stars.each do |star| student_stars_count = student_stars_count + star.stars end return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) + + + end #获取作业的教师评分 + #多个教师只获取一份教师评分 def teacher_score_for_homework homework - member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - if member.nil? - return "0.00" + members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + teacher_ids = [] + members.each do |user| + teacher_ids << user.user_id + end + teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars") + teacher_stars_count = 0 + teacher_stars.each do |star| + teacher_stars_count = teacher_stars_count + star.stars end - teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first - return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) + return format("%.2f",teacher_stars_count) end #获取指定项目的得分 diff --git a/app/models/course.rb b/app/models/course.rb index 04b0535bd..1c2828adc 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -34,7 +34,7 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files - validates_presence_of :password, :term,:name + validates_presence_of :password, :term,:name ,:class_period validates_format_of :class_period, :with =>/^\d*$/ #validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index a8f1f4356..8b241030a 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -117,9 +117,9 @@ 互评得分:  - <% student_homework_score = student_score_for_homework(homework) %> - ;"> - <% score = student_homework_score == "0.00"? "N/A" : student_homework_score %> + <%# student_homework_score = student_score_for_homework(homework) %> + ;"> + <% score = homework.s_score.nil? ? "N/A" : format("%.2f",homework.s_score) %> <%= score %>    <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> @@ -136,7 +136,8 @@ 终评得分:  - <% totle_homework_score = score_for_homework(homework) %> + <%# totle_homework_score = score_for_homework(homework) %> + <% totle_homework_score = format("%.2f",(homework.t_score.nil? ? 0.00 : homework.t_score) * (@bid.proportion * 1.0 / 100) + (homework.s_score.nil? ? 0.00 : homework.s_score) * (1 - @bid.proportion * 1.0 / 100)) %> ;"> <% score = totle_homework_score == "0.00"? "N/A" : totle_homework_score %> <%= score %> diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index c46de9be4..ba353c47c 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -146,7 +146,7 @@ <%= l(:label_work_deposit_project) %>: <%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %> - <%= link_to l(:label_create_new_projects), new_project_path(course: 0, project_type: 0), :target => '_blank' %> + <%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %>

diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 0586262e9..24eefd4cb 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -1,3 +1,7 @@ +<% @nav_dispaly_course_all_label = 1 + @nav_dispaly_forum_label = 1 + @nav_dispaly_course_label = nil + @nav_dispaly_store_all_label = 1 %> <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %> diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 57d8a60cb..c9fecc6a9 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -38,7 +38,10 @@ <% end -%>
    - <%= l(:field_description)%>: <%= issue.short_description %> +
    + <%= textilizable issue, :description, :attachments => issue.attachments %> +
    +
    diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index ef26df0bd..fa20bdff6 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -149,7 +149,7 @@
    -
    +
    <%= textilizable @project.description %>
    diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index c4b2bdc9e..5d479bced 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,3 +1,5 @@ +<% @nav_dispaly_project_label = 1 + @nav_dispaly_forum_label = 1 %> <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %> diff --git a/db/migrate/20140719080032_repair_first_page.rb b/db/migrate/20140719080032_repair_first_page.rb new file mode 100644 index 000000000..a1faf7f90 --- /dev/null +++ b/db/migrate/20140719080032_repair_first_page.rb @@ -0,0 +1,59 @@ +# -*coding:utf-8 -*- +class RepairFirstPage < ActiveRecord::Migration + def change + pro_fps = FirstPage.where("page_type = 'project'") + if pro_fps.nil? || pro_fps.first.nil? + fp = FirstPage.new + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.title = "Trustie在线项目托管平台" + fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" + fp.page_type = "project" + fp.sort_type = 1 + fp.save + else + fp = pro_fps.first + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.title = "Trustie在线项目托管平台" + fp.description = "面向中国大学生与软件从业者,提供社交化的项目管理、代码托管、资源共享、合作交流。" + fp.page_type = "project" + fp.sort_type = 1 + fp.save + end + course_fps = FirstPage.where("page_type = 'course'") + if course_fps.nil? || course_fps.first.nil? + fp = FirstPage.new + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.title = "Trustie在线课程实践平台" + fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" + fp.page_type = "course" + fp.sort_type = 1 + fp.save + else + fp = course_fps.first + fp.web_title = "Trustie - 为大学生技术创新筑巢" + fp.title = "Trustie在线课程实践平台" + fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。" + fp.page_type = "course" + fp.sort_type = 1 + fp.save + end + contest_fps = FirstPage.where("page_type = 'contest'") + if contest_fps.nil? || contest_fps.first.nil? + fp1 = FirstPage.new + fp1.web_title = "Trustie - 为大学生技术创新筑巢" + fp1.title = "Trustie在线竞赛实战平台" + fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" + fp1.page_type = "contest" + fp1.sort_type = 1 + fp1.save + else + fp1 = contest_fps.first + fp1.web_title = "Trustie - 为大学生技术创新筑巢" + fp1.title = "Trustie在线竞赛实战平台" + fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。" + fp1.page_type = "contest" + fp1.sort_type = 1 + fp1.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 87e6be3f3..690ec2681 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140719030941) do +ActiveRecord::Schema.define(:version => 20140719080032) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -809,18 +809,18 @@ ActiveRecord::Schema.define(:version => 20140719030941) do create_table "relative_memos", :force => true do |t| t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false + t.string "subject", :null => false + t.text "content", :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 t.string "url" t.string "username" t.string "userhomeurl" @@ -844,19 +844,6 @@ ActiveRecord::Schema.define(:version => 20140719030941) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1