From a467736a5ef031b17bda1ee7ec2ce005aaf8b483 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 14:52:36 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E5=A4=9A?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=94=AF=E4=B8=80=E6=80=A7=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E3=80=8B=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_group.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/models/course_group.rb b/app/models/course_group.rb index c7fc81df4..680fa6497 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -12,8 +12,7 @@ class CourseGroup < ActiveRecord::Base before_destroy :set_member_nil attr_accessible :name - validates :name, :presence => true, :length => {:maximum => 20} - validate :unique_name_and_course + validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => { :scope => :course_id} @@ -22,10 +21,5 @@ class CourseGroup < ActiveRecord::Base self.members.update_all("course_group_id = 0") end end - private - def unique_name_and_course - if CourseGroup.where("name=? and course_id=?", name, course_id).first - errors.add(:name, :groupname_repeat) - end - end + end From a0debe77bb2923e91929a3d416f4b35a481fb687 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 15:27:16 +0800 Subject: [PATCH 2/7] 111 --- db/schema.rb | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 7c9e6d556..d7a1b18bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1070,14 +1070,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do t.string "description" end - create_table "social_groups", :force => true do |t| - t.string "name" - t.text "description" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1293,36 +1285,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - create_table "voting_choices", :force => true do |t| - t.integer "poll_id", :null => false - t.string "text", :null => false - t.datetime "created_on", :null => false - t.integer "position", :default => 1 - end - - add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" - - create_table "voting_polls", :force => true do |t| - t.integer "project_id", :null => false - t.string "question", :null => false - t.datetime "created_on", :null => false - t.boolean "revote" - end - - add_index "voting_polls", ["project_id"], :name => "polls_project_id" - - create_table "voting_votes", :force => true do |t| - t.integer "user_id", :null => false - t.integer "poll_id", :null => false - t.integer "choice_id", :null => false - t.datetime "created_on", :null => false - end - - add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" - add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" - add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true - add_index "voting_votes", ["user_id"], :name => "votes_user_id" - create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false From f2a3ce0ecee59315cb3617cbb36b554490290814 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 16:05:36 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E6=A0=87=E9=A2=98=E6=98=BE=E7=A4=BA=E4=B8=BA=E2=80=9C?= =?UTF-8?q?=E4=B8=AD=E5=9B=BD=E9=AB=98=E6=A0=A1=E2=80=9D=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E9=80=82=E3=80=8Bbug=20Signed-off-by:=20alan=20<547533434@qq.c?= =?UTF-8?q?om>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_group.rb | 2 +- app/views/enterprises/index.html.erb | 2 +- config/locales/zh.yml | 3 ++- config/routes.rb | 2 +- db/schema.rb | 38 ---------------------------- 5 files changed, 5 insertions(+), 42 deletions(-) diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 680fa6497..c6aa1299d 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -21,5 +21,5 @@ class CourseGroup < ActiveRecord::Base self.members.update_all("course_group_id = 0") end end - + end diff --git a/app/views/enterprises/index.html.erb b/app/views/enterprises/index.html.erb index 9db8d99ab..6124f5c7f 100644 --- a/app/views/enterprises/index.html.erb +++ b/app/views/enterprises/index.html.erb @@ -22,4 +22,4 @@
-<% html_title(l(:label_school_all)) -%> +<% html_title(l(:label_enterprise_all)) -%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 343ad2432..524494f45 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2204,7 +2204,8 @@ zh: label_project_deposit: 项目托管 label_course_practice: 课程实践 label_forum_all: 公共贴吧 - label_school_all: 中国高校 + label_school_all: 中国高校 + :label_enterprise_all: 名企 label_contest_innovate: 创新竞赛 label_software_user: 软件创客 label_requirement_enterprise: 软件众包 diff --git a/config/routes.rb b/config/routes.rb index aad7adcb3..0692103bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -731,7 +731,7 @@ RedmineApp::Application.routes.draw do match 'delete_avatar', :to => 'avatar#delete_image',:via => :post # Endof Tao's code get 'robots.txt', :to => 'welcome#robots' - match 'welcome/course', :to => 'welcome#course' + #match 'welcome/course', :to => 'welcome#course' ##############测试留言功能 fq post 'words/new', :to => 'words#new' post 'words/create', :to => 'words#create' diff --git a/db/schema.rb b/db/schema.rb index 7c9e6d556..d7a1b18bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1070,14 +1070,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do t.string "description" end - create_table "social_groups", :force => true do |t| - t.string "name" - t.text "description" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1293,36 +1285,6 @@ ActiveRecord::Schema.define(:version => 20150128032421) do add_index "versions", ["project_id"], :name => "versions_project_id" add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - create_table "voting_choices", :force => true do |t| - t.integer "poll_id", :null => false - t.string "text", :null => false - t.datetime "created_on", :null => false - t.integer "position", :default => 1 - end - - add_index "voting_choices", ["poll_id"], :name => "choices_poll_id" - - create_table "voting_polls", :force => true do |t| - t.integer "project_id", :null => false - t.string "question", :null => false - t.datetime "created_on", :null => false - t.boolean "revote" - end - - add_index "voting_polls", ["project_id"], :name => "polls_project_id" - - create_table "voting_votes", :force => true do |t| - t.integer "user_id", :null => false - t.integer "poll_id", :null => false - t.integer "choice_id", :null => false - t.datetime "created_on", :null => false - end - - add_index "voting_votes", ["choice_id"], :name => "votes_choice_id" - add_index "voting_votes", ["poll_id"], :name => "votes_poll_id" - add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true - add_index "voting_votes", ["user_id"], :name => "votes_user_id" - create_table "watchers", :force => true do |t| t.string "watchable_type", :default => "", :null => false t.integer "watchable_id", :default => 0, :null => false From 36488560119da0dc33492442300e249abc691553 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 16:05:52 +0800 Subject: [PATCH 4/7] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2show=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=202=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E6=98=9F=E6=98=9F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/css.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/stylesheets/css.css b/public/stylesheets/css.css index d53b6ec02..ffb9da644 100644 --- a/public/stylesheets/css.css +++ b/public/stylesheets/css.css @@ -1,5 +1,6 @@ /* CSS Document */ #content{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9; background:#fff; font-style:normal;} +#popbox{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9; background:#fff; font-style:normal;} div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span,textarea{ margin:0; padding:0;} div,img,tr,td,textarea{ border:0;} table,tr,td{border:0; cellspacing:0; cellpadding:0;} @@ -79,7 +80,7 @@ a.wzan_visited{background:url(images/pic_zan.png) 0 0 no-repeat;} .ping_con h2{ font-size:14px; color:#444443; margin-bottom:10px; } .ping_con p{ color:#777777; font-size:12px; border-bottom:1px dashed #CCC; padding-bottom:5px;} .ping_con p span a{ color:#777777;} -.ping_star{ width:160px; color:#333; font-weight:bold; margin-bottom:5px;} +.ping_star{ width:165px; color:#333; font-weight:bold; margin-bottom:5px;} .ping_star span a{ float:right; width:20px; height:20px; background:url(images/star.png);background-repeat: no-repeat; margin-right:3px;} .ping_con textarea{ height:76px; border:1px solid #15bccf; margin-bottom:5px; color:#666; font-size:12px;} a.ping_sub{ float:right; height:22px; width:60px; margin-right:20px; background:#15bccf; color:#fff; text-align:center;} From 34c68a59fc5d6c386d9e8a7806f2b1e065446eef Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 30 Jan 2015 16:19:05 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=85=B3=E9=97=AD=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E8=80=81=E5=B8=88=E5=AE=B9=E8=AE=B8=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index fdf534405..644b678b8 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -22,9 +22,9 @@ <% end %> <%if @is_teacher%> - <% if poll.polls_status == 1 || poll.polls_status == 3 %> + <% if poll.polls_status == 1%>
  • 统计结果
  • - <% elsif poll.polls_status == 2%> + <% elsif poll.polls_status == 2 || poll.polls_status == 3 %>
  • <%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
  • From 6bd202e80a1c29bc4b9c69cc0290af2ef8095cdb Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 30 Jan 2015 16:58:05 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=BD=93=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=BA=E8=AF=BE=E7=A8=8B=E5=AD=A6=E7=94=9F=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=88=86=E9=85=8D=E7=BB=99=E6=94=B9=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=8C=BF=E8=AF=84=E7=9A=84=E4=BD=9C=E4=B8=9A=E9=9B=86?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/homework.rb | 5 ++++ app/controllers/homework_attach_controller.rb | 8 +----- app/helpers/homework_attach_helper.rb | 11 ++++++++ app/services/courses_service.rb | 28 +++++++++++++++---- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index ae3637106..9be9bc53e 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -35,6 +35,11 @@ module Mobile #作业状态 0:新建,1:已开启匿评,2:已关闭匿评 #只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评 homework_expose :homework_state + + expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt| + f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments) + end + end end end \ No newline at end of file diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 8e69d1d72..2c943e778 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -101,13 +101,7 @@ class HomeworkAttachController < ApplicationController #获取学生匿评列表 def get_student_batch_homework @is_student_batch_homework = true - all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = 0) AS m_score - FROM homework_attaches - INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY m_score DESC") + all_homework_list = get_student_batch_homework_list @bid,User.current @cur_page = params[:page] || 1 @cur_type = 4 @homework_list = paginateHelper all_homework_list,10 diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 4744df624..c41ba54ee 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -119,4 +119,15 @@ module HomeworkAttachHelper #end ary end + + def get_student_batch_homework_list bid,user + student_batch_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, + (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, + (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = 0) AS m_score + FROM homework_attaches + INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id + WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id} ORDER BY m_score DESC") + student_batch_homework_list + end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7e3b2a545..41b6f2c68 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -1,6 +1,7 @@ class CoursesService include ApplicationHelper include CoursesHelper + include HomeworkAttachHelper #TODO:尚未整合权限系统 #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 @@ -306,10 +307,8 @@ class CoursesService bids = course.homeworks.order('deadline DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] - if is_course_teacher(current_user,course) - bids.each do |bid| - homeworks << show_homework_info(course,bid) - end + bids.each do |bid| + homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course)) end homeworks else @@ -318,7 +317,7 @@ class CoursesService end private - def show_homework_info course,bid + def show_homework_info course,bid,current_user,is_course_teacher author = bid.author.lastname + bid.author.firstname many_times = course.homeworks.index(bid) + 1 name = bid.name @@ -327,8 +326,27 @@ class CoursesService description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = bid.comment_status + unless is_course_teacher + homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user + end #end open_anonymous_evaluation = bid.open_anonymous_evaluation + {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments} + end + + #显示作业列表的同时显示分配给当前学生匿评的作业 + def show_homework_info_with_batch course,bid + author = bid.author.lastname + bid.author.firstname + many_times = course.homeworks.index(bid) + 1 + name = bid.name + homework_count = bid.homeworks.count #已提交的作业数量 + student_questions_count = bid.commit.nil? ? 0 : bid.commit + description = bid.description + #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 + state = bid.comment_status + #end + open_anonymous_evaluation = bid.open_anonymous_evaluation {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} end From 2f168dd4d70c8749430ada789ab7f8d7a1bfbfde Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 30 Jan 2015 17:47:57 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E3=80=8B=E6=A0=B7=E5=BC=8F=20Signed?= =?UTF-8?q?-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- app/views/courses/show.html.erb | 2 +- config/application.rb | 3 ++- lib/email_verifier | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) create mode 160000 lib/email_verifier diff --git a/Gemfile b/Gemfile index afd6a667a..037c606c8 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' gem 'spreadsheet' gem 'ruby-ole' -#gem 'email_verifier' +#gem 'email_verifier', path: 'lib/email_verifier' group :development do gem 'grape-swagger' diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9f0084019..9c91908d2 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -90,7 +90,7 @@ - + <%= l :label_create_time %>: <%= format_time(@course.created_at) %> diff --git a/config/application.rb b/config/application.rb index 311bf457b..c7f2f3ea5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,7 @@ module RedmineApp # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - # verifier if email is real + #verifier if email is real # EmailVerifier.config do |config| # config.verifier_email = "lizanle521@126.com" # end @@ -74,5 +74,6 @@ module RedmineApp if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb')) end + end end diff --git a/lib/email_verifier b/lib/email_verifier new file mode 160000 index 000000000..3cabcc643 --- /dev/null +++ b/lib/email_verifier @@ -0,0 +1 @@ +Subproject commit 3cabcc643f36939939685e6f55273dfbf89da545