From 12b6525cc6f01998ac99d19afff101509beeed9b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Jul 2014 10:29:37 +0800 Subject: [PATCH 1/7] t --- app/helpers/courses_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index b1ec023c8..daf15c1b7 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -332,7 +332,7 @@ module CoursesHelper return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) end - #获取指定作业的得分 + #获取指定项目的得分 def project_score project issue_count = project.issues.count issue_journal_count = project.issue_changes.count From 4470f0dd7337518da45561f6a8dbe1a3f81ad98c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Jul 2014 11:53:55 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=95=99=E5=B8=88=E8=AF=84=E5=88=86?= =?UTF-8?q?=E6=89=80=E5=8D=A0=E6=AF=94=E4=BE=8B=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 7 ++++--- app/controllers/courses_controller.rb | 1 + app/helpers/courses_helper.rb | 15 ++++++++++++++- app/views/courses/_homework_form.html.erb | 2 ++ config/locales/zh.yml | 1 + .../20140701031909_add_proportion_to_bid.rb | 5 +++++ db/schema.rb | 11 ++++++----- 7 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20140701031909_add_proportion_to_bid.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 5f20d2cef..76872d783 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -498,10 +498,10 @@ class BidsController < ApplicationController #增加作业按评分排序, #@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") @homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.courses.first.teacher.id}) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.courses.first.teacher.id}) AS s_score + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY - (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * 0.6 END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * 0.4 END) DESC,created_at ASC") + (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC") if params[:student_id].present? @temp = [] @homework_list.each do |pro| @@ -788,6 +788,7 @@ class BidsController < ApplicationController @bid.name = params[:bid][:name] @bid.description = params[:bid][:description] @bid.is_evaluation = params[:bid][:is_evaluation] + @bid.proportion = params[:bid][:proportion] @bid.reward_type = 3 # @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7cd46b65a..20bda61e0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -490,6 +490,7 @@ class CoursesController < ApplicationController # 新建作业 def new_homework @homework = Bid.new + @homework.proportion @homework.safe_attributes = params[:bid] if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) render :layout => 'base_courses' diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index daf15c1b7..aa09c5e98 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -83,6 +83,19 @@ module CoursesHelper type << option2 end + def proportion_option + type = [] + i = 0 + while i <= 100 + option = [] + option << i.to_s + "%" + option << i + type << option + i = i + 10 + end + type + end + alias teacherCountOrigin teacherCount def teacherCount project @@ -308,7 +321,7 @@ module CoursesHelper #最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6 def score_for_homework homework if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil - return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4)) + return format("%.2f",(homework.bid.proportion * 1.0 / 100) * (teacher_score_for_homework(homework).to_f) + (1 - homework.bid.proportion * 1.0 / 100) * (student_score_for_homework(homework).to_f)) else return teacher_score_for_homework homework end diff --git a/app/views/courses/_homework_form.html.erb b/app/views/courses/_homework_form.html.erb index 6e49fcdea..41c059603 100644 --- a/app/views/courses/_homework_form.html.erb +++ b/app/views/courses/_homework_form.html.erb @@ -34,6 +34,8 @@

<%= f.select :is_evaluation, is_evaluation_option %>

+

<%= f.select :proportion, proportion_option %> +

<%= hidden_field_tag 'course_id', @course.id %>

<%= l(:label_attachment_plural) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index eacd5ac41..c505f115a 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1573,6 +1573,7 @@ zh: field_budget: 奖励 field_deadline: 截止日期 field_is_evaluation: 是否启动互评 + field_proportion: 教师评分比例 label_tags_selected: 已选标签 label_tags_related: 相关标签 button_project_tags_add: 增加 diff --git a/db/migrate/20140701031909_add_proportion_to_bid.rb b/db/migrate/20140701031909_add_proportion_to_bid.rb new file mode 100644 index 000000000..261073cb4 --- /dev/null +++ b/db/migrate/20140701031909_add_proportion_to_bid.rb @@ -0,0 +1,5 @@ +class AddProportionToBid < ActiveRecord::Migration + def change + add_column :bids, :proportion, :integer, default: 60 + end +end diff --git a/db/schema.rb b/db/schema.rb index cc3d68cba..e8ce039c2 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 => 20140626012511) do +ActiveRecord::Schema.define(:version => 20140701031909) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -94,18 +94,19 @@ ActiveRecord::Schema.define(:version => 20140626012511) do create_table "bids", :force => true do |t| t.string "name" - t.string "budget", :null => false + t.string "budget", :null => false t.integer "author_id" t.date "deadline" t.string "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false t.integer "commit" t.integer "reward_type" t.integer "homework_type" t.integer "parent_id" t.string "password" t.integer "is_evaluation" + t.integer "proportion", :default => 60 end create_table "boards", :force => true do |t| @@ -793,7 +794,7 @@ ActiveRecord::Schema.define(:version => 20140626012511) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id" + t.integer "osp_id", :null => false t.integer "parent_id" t.string "subject", :null => false t.text "content", :null => false From 063460f1198c974a3b0838e800cfc7becb7e6a70 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 1 Jul 2014 17:49:12 +0800 Subject: [PATCH 3/7] tt --- app/views/projects/_form.html.erb | 58 ++++++++++++++++--------------- config/routes.rb | 2 +- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index fa2e8da11..ec0bf7fbf 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -5,7 +5,9 @@ <% end %>

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %>

-

<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>

+

+ <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> +

<%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %> <% unless @project.identifier_frozen? %> <%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %> @@ -24,44 +26,44 @@ <%= call_hook(:view_projects_form, :project => @project, :form => f) %> - +<%# end %> +<%# end %> --> <% unless @project.identifier_frozen? %> diff --git a/config/routes.rb b/config/routes.rb index ad493bce8..c584ba3cf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -698,7 +698,7 @@ RedmineApp::Application.routes.draw do get 'welcome/search', to: 'welcome#search' get 'school/index', to: 'school#index' get 'course/:school_id', to: 'welcome#course' - get 'course/:school_id', to: 'welcome#course' + #get 'course/:school_id', to: 'welcome#course' post 'school/get_options/:province', :to => 'school#get_options' get 'school/get_options/:province', :to => 'school#get_options' From 740f6a19ecfce8e15d1cd8d5218a0d6f62275dd8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 3 Jul 2014 15:50:36 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=94=AF=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/project.rb b/app/models/project.rb index 492ca86b7..f38ad0dd0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -113,6 +113,7 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier + validates_uniqueness_of :name validates_associated :repository, :wiki # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255 From b42d742c0626ae11e2f8ffd9bf4a7f90abf559ca Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 3 Jul 2014 17:25:51 +0800 Subject: [PATCH 5/7] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=88=91=E7=9A=84?= =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E9=93=BE=E6=8E=A5=202.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BD=93=E6=88=91=E7=9A=84=E5=AD=A6=E6=A0=A1=E6=9C=AA=E5=BC=80?= =?UTF-8?q?=E8=AE=BE=E8=AF=BE=E7=A8=8B=E6=97=B6=E6=8A=A5=E5=87=BA=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/school/index.html.erb | 3 ++- app/views/welcome/course.html.erb | 12 ++++++------ config/routes.rb | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index 755bd3151..fa5d846ec 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -69,8 +69,9 @@

+ 全部学校      - 我的学校 + <%= link_to '我的学校',scholl_course_list_path(User.current.user_extensions.school) %>