diff --git a/Gemfile b/Gemfile index f462133c3..91e72a745 100644 --- a/Gemfile +++ b/Gemfile @@ -16,8 +16,6 @@ gem "coderay", "~> 1.0.6" gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' -gem 'spreadsheet' -gem 'ruby-ole' group :development do gem 'better_errors', path: 'lib/better_errors' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 771928e40..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,287 +0,0 @@ -PATH - remote: lib/better_errors - specs: - better_errors (1.1.0) - coderay (>= 1.0.0) - erubis (>= 2.6.6) - -PATH - remote: lib/rack-mini-profiler - specs: - rack-mini-profiler (0.9.1) - rack (>= 1.1.3) - -PATH - remote: lib/seems_rateable - specs: - seems_rateable (1.0.13) - jquery-rails - rails - -GEM - remote: http://ruby.taobao.org/ - remote: https://rubygems.org/ - specs: - actionmailer (3.2.13) - actionpack (= 3.2.13) - mail (~> 2.5.3) - actionpack (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) - erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) - activerecord (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - activesupport (3.2.13) - i18n (= 0.6.1) - multi_json (~> 1.0) - acts-as-taggable-on (2.4.1) - rails (>= 3, < 5) - arel (3.0.3) - builder (3.0.0) - capybara (2.4.1) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - celluloid (0.15.2) - timers (~> 1.1.0) - childprocess (0.5.3) - ffi (~> 1.0, >= 1.0.11) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.4) - climate_control (>= 0.0.3, < 1.0) - coderay (1.0.9) - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.3.0) - coffee-script-source - execjs - coffee-script-source (1.7.1) - erubis (2.7.0) - execjs (2.2.1) - factory_girl (4.4.0) - activesupport (>= 3.0.0) - fastercsv (1.5.5) - ffi (1.9.3) - ffi (1.9.3-x86-mingw32) - formatador (0.2.5) - guard (2.6.1) - formatador (>= 0.2.4) - listen (~> 2.7) - lumberjack (~> 1.0) - pry (>= 0.9.12) - thor (>= 0.18.1) - guard-rails (0.5.3) - guard (~> 2.0) - guard-spork (1.5.1) - childprocess (>= 0.2.3) - guard (>= 1.1) - spork (>= 0.8.4) - guard-test (1.0.0) - guard (>= 1.8) - test-unit (~> 2.2) - hike (1.2.3) - htmlentities (4.3.2) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.0.3) - railties (>= 3.1.0, < 5.0) - thor (~> 0.14) - json (1.8.1) - kaminari (0.16.1) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - libv8 (3.16.14.3) - listen (2.7.9) - celluloid (>= 0.15.2) - rb-fsevent (>= 0.9.3) - rb-inotify (>= 0.9) - lumberjack (1.0.9) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - metaclass (0.0.4) - method_source (0.8.2) - mime-types (1.25.1) - mini_portile (0.6.0) - mocha (1.1.0) - metaclass (~> 0.0.1) - multi_json (1.10.1) - mysql2 (0.3.11) - mysql2 (0.3.11-x86-mingw32) - net-ldap (0.3.1) - nokogiri (1.6.3) - mini_portile (= 0.6.0) - nokogiri (1.6.3-x86-mingw32) - mini_portile (= 0.6.0) - paperclip (3.5.4) - activemodel (>= 3.0.0) - activesupport (>= 3.0.0) - cocaine (~> 0.5.3) - mime-types - polyglot (0.3.5) - pry (0.9.12.6) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - pry (0.9.12.6-x86-mingw32) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - win32console (~> 1.3) - pry-nav (0.2.3) - pry (~> 0.9.10) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-openid (1.4.2) - rack (>= 1.1.0) - ruby-openid (>= 2.1.8) - rack-raw-upload (1.1.1) - multi_json - rack-ssl (1.3.4) - rack - rack-test (0.6.2) - rack (>= 1.0) - rails (3.2.13) - actionmailer (= 3.2.13) - actionpack (= 3.2.13) - activerecord (= 3.2.13) - activeresource (= 3.2.13) - activesupport (= 3.2.13) - bundler (~> 1.0) - railties (= 3.2.13) - railties (3.2.13) - actionpack (= 3.2.13) - activesupport (= 3.2.13) - rack-ssl (~> 1.3.2) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.3.2) - rb-fsevent (0.9.4) - rb-inotify (0.9.5) - ffi (>= 0.5.0) - rdoc (3.12.2) - json (~> 1.4) - ref (1.0.5) - rich (1.4.6) - jquery-rails - kaminari - mime-types - paperclip - rack-raw-upload - rails (>= 3.2.0) - sass-rails - rmagick (2.13.2) - ruby-ole (1.2.11.7) - ruby-openid (2.1.8) - rubyzip (1.1.6) - sass (3.3.10) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - selenium-webdriver (2.42.0) - childprocess (>= 0.5.0) - multi_json (~> 1.0) - rubyzip (~> 1.0) - websocket (~> 1.0.4) - shoulda (3.5.0) - shoulda-context (~> 1.0, >= 1.0.1) - shoulda-matchers (>= 1.4.1, < 3.0) - shoulda-context (1.2.1) - shoulda-matchers (2.6.1) - activesupport (>= 3.0.0) - slop (3.5.0) - spork (0.9.2) - spork-testunit (0.0.8) - spork (>= 0.6.0) - spreadsheet (1.0.0) - ruby-ole (>= 1.0) - sprockets (2.2.2) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - test-unit (2.5.5) - therubyracer (0.12.1) - libv8 (~> 3.16.14.0) - ref - thor (0.19.1) - tilt (1.4.1) - timers (1.1.0) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.40) - uglifier (2.5.1) - execjs (>= 0.3.0) - json (>= 1.8.0) - websocket (1.0.7) - win32console (1.3.2-x86-mingw32) - xpath (2.0.0) - nokogiri (~> 1.3) - -PLATFORMS - ruby - x86-mingw32 - -DEPENDENCIES - activerecord-jdbc-adapter (= 1.2.5) - activerecord-jdbcmysql-adapter - acts-as-taggable-on (= 2.4.1) - better_errors! - builder (= 3.0.0) - capybara (~> 2.4.1) - coderay (~> 1.0.6) - coffee-rails (~> 3.2.1) - factory_girl (~> 4.4.0) - fastercsv (~> 1.5.0) - guard-rails (~> 0.5.3) - guard-spork (~> 1.5.1) - guard-test (~> 1.0.0) - htmlentities - i18n (~> 0.6.0) - jquery-rails (~> 2.0.2) - kaminari - mocha (~> 1.1.0) - mysql2 (= 0.3.11) - net-ldap (~> 0.3.1) - nokogiri (~> 1.6.3) - paperclip (~> 3.5.4) - pry - pry-nav - rack-mini-profiler! - rack-openid - rails (= 3.2.13) - rich (= 1.4.6) - rmagick (>= 2.0.0) - ruby-ole - ruby-openid (~> 2.1.4) - sass-rails (~> 3.2.3) - seems_rateable! - selenium-webdriver (~> 2.42.0) - shoulda (~> 3.5.0) - spork-testunit (~> 0.0.8) - spreadsheet - therubyracer - uglifier (>= 1.0.3) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 73f78b587..afaf02881 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -318,7 +318,7 @@ class CoursesController < ApplicationController else page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) - @results = student_homework_score(0,page_from, 10,"") + @results = student_homework_score(0,page_from, 10,"desc") @results = paginateHelper_for_members @results, 10 end @@ -909,11 +909,47 @@ class CoursesController < ApplicationController def student_homework_score(groupid,start_from, nums, score_sort_by) #teachers = find_course_teachers(@course) start_from = start_from * nums + sql_select = "" + if groupid == 0 + if nums == 0 + sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches + WHERE members.course_id = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id + +UNION +SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND +students_for_courses.course_id = 122 and members.user_id = students_for_courses.student_id AND +members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 ) +) +GROUP BY members.user_id ORDER BY score #{score_sort_by}" + else + sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches + WHERE members.course_id = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id + +UNION +SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND +students_for_courses.course_id = 122 and members.user_id = students_for_courses.student_id AND +members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 ) +) +GROUP BY members.user_id ORDER BY score #{score_sort_by} limit #{start_from}, #{nums}" + + end + else + sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches + WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id + and members.course_group_id = #{groupid} + GROUP BY members.user_id +UNION +SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} +and members.course_group_id = #{groupid} AND +students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND +members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = 122 ) +) +GROUP BY members.user_id ORDER BY score #{score_sort_by}" + end sql = ActiveRecord::Base.connection() - - homework_scores = Member.find_by_sql("call member_score(#{@course.id},#{groupid},#{start_from},#{nums}, '#{score_sort_by}')") - + homework_scores = Member.find_by_sql(sql_select) sql.close() + homework_scores end #获取课程的老师列表 diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index fc07bb202..83c26b713 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -435,6 +435,7 @@ class HomeworkAttachController < ApplicationController @is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value] @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 @homework = HomeworkAttach.find(params[:homework_id]) + homework = @homework is_teacher = @is_teacher ? 1 : 0 #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) if @m_score @@ -445,7 +446,23 @@ class HomeworkAttachController < ApplicationController else @homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save! end - end + if homework.is_teacher_score == 0 + if is_teacher == 1 + homework.score = @m_score + homework.is_teacher_score = 1 + else + homework.score = (homework.score.nil? ? 0 : homework.score + @m_score) / homework.rates(:quality).count + + end + else + if is_teacher == 1 + homework.score = @m_score + homework.is_teacher_score = 1 + end + end + homework.save! + end + #保存评论 @is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言 if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言 diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index e08697e9d..3e446f16e 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -74,7 +74,7 @@ <% end %> <% if @subPage_title == l(:label_student_list) %> - <%= link_to format("%0.2f",member.score.to_s), { + <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), { :action => 'show_member_score', :member_id => member.id, :remote => true}, diff --git a/app/views/layouts/_base_ad.html.erb b/app/views/layouts/_base_ad.html.erb index fcb560239..807f9afde 100644 --- a/app/views/layouts/_base_ad.html.erb +++ b/app/views/layouts/_base_ad.html.erb @@ -1,64 +1,64 @@ - - - - -浮动倒计时公告 - - - - -
-
- - 00: - 00: - 00 -
-
- - - - - - + + + + +浮动倒计时公告 + + + + +
+
+ + 00: + 00: + 00 +
+
+ + + + + + diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 498d4bed1..460020393 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -1,46 +1,46 @@ - - - - -<%=h html_title %> - - -<%= csrf_meta_tag %> -<%= favicon %> -<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> -<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> -<%= javascript_heads %> -<%= javascript_include_tag "jquery.leanModal.min" %> -<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> -<%= heads_for_theme %> -<%= call_hook :view_layouts_base_html_head %> - -<%= yield :header_tags -%> - - -
-
-
-<%=render :partial => 'layouts/base_header'%> -<%= render :partial => 'layouts/base_ad' %> -
-
- <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
- <%=render :partial => 'layouts/base_footer'%> -
- -
-
- - - - - -
-
-<%= call_hook :view_layouts_base_body_bottom %> - - + + + + +<%=h html_title %> + + +<%= csrf_meta_tag %> +<%= favicon %> +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> +<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> +<%= javascript_heads %> +<%= javascript_include_tag "jquery.leanModal.min" %> +<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> +<%= heads_for_theme %> +<%= call_hook :view_layouts_base_html_head %> + +<%= yield :header_tags -%> + + +
+
+
+<%=render :partial => 'layouts/base_header'%> +<%= render :partial => 'layouts/base_ad' %> +
+
+ <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+ <%=render :partial => 'layouts/base_footer'%> +
+ +
+
+ + + + + +
+
+<%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/app/views/users/search.html.erb b/app/views/users/search.html.erb index fbc9155bc..ef1db3b0c 100644 --- a/app/views/users/search.html.erb +++ b/app/views/users/search.html.erb @@ -1,94 +1,94 @@ - - -
- <%= form_tag( users_search_path, :method => :get, :id => 'search_user_form') do %> - - - - - - - - - - -
- <%= l(:label_software_user ) %> - - <%= l(:label_user_location) %> : - - - -
- <%=link_to l(:field_homepage), home_path %> > - <%= l(:label_software_user)%> -
-
-<% end %> - - -
- <% if @users.size > 0 %> - <%= render :partial => 'user_show' %> - - - <% else %> - <%= render :partial => "layouts/no_content"%> - <% end %> -
- -<% html_title(l(:label_user_plural)) -%> - + + +
+ <%= form_tag( users_search_path, :method => :get, :id => 'search_user_form') do %> + + + + + + + + + + +
+ <%= l(:label_software_user ) %> + + <%= l(:label_user_location) %> : + + + +
+ <%=link_to l(:field_homepage), home_path %> > + <%= l(:label_software_user)%> +
+
+<% end %> + + +
+ <% if @users.size > 0 %> + <%= render :partial => 'user_show' %> + + + <% else %> + <%= render :partial => "layouts/no_content"%> + <% end %> +
+ +<% html_title(l(:label_user_plural)) -%> + diff --git a/app/views/welcome/_search_project.html.erb b/app/views/welcome/_search_project.html.erb index 196213636..b86ff64f9 100644 --- a/app/views/welcome/_search_project.html.erb +++ b/app/views/welcome/_search_project.html.erb @@ -1,99 +1,99 @@ -<% - select_option = [] - (select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project - (select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course - select_option << ['用户', 'users'] -%> - - -<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> - -<% end %> +<% + select_option = [] + (select_option << ['项目', 'projects']) if project_type == Project::ProjectType_project + (select_option << ['课程', 'courses']) if project_type == Project::ProjectType_course + select_option << ['用户', 'users'] +%> + + +<%= form_tag({controller: :welcome, action: :search }, method: :get) do %> + +<% end %> diff --git a/db/migrate/20141230081209_add_column_to_homeworkattaches.rb b/db/migrate/20141230081209_add_column_to_homeworkattaches.rb new file mode 100644 index 000000000..68198dc05 --- /dev/null +++ b/db/migrate/20141230081209_add_column_to_homeworkattaches.rb @@ -0,0 +1,6 @@ +class AddColumnToHomeworkattaches < ActiveRecord::Migration + def change + add_column :homework_attaches, :score, :float, default: 0 + add_column :homework_attaches, :is_teacher_score, :integer, :default => 0 + end +end diff --git a/db/migrate/20141230081744_update_score_to_homeworkattaches.rb b/db/migrate/20141230081744_update_score_to_homeworkattaches.rb new file mode 100644 index 000000000..c8b201778 --- /dev/null +++ b/db/migrate/20141230081744_update_score_to_homeworkattaches.rb @@ -0,0 +1,18 @@ +class UpdateScoreToHomeworkattaches < ActiveRecord::Migration + def up + sql = ("UPDATE homework_attaches set is_teacher_score = 1, + score = (SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates + WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id + AND is_teacher_score = 1 GROUP BY rateable_id);") + sql_student = ("UPDATE homework_attaches set is_teacher_score = 0, + score = (SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates + WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id + AND is_teacher_score = 0 GROUP BY rateable_id) WHERE homework_attaches.score = 0 OR homework_attaches.score is NULL +") + execute(sql) + execute(sql_student) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index eb84e19e6..528ebdee6 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 => 20141230062844) do +ActiveRecord::Schema.define(:version => 20141230081744) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -483,13 +483,15 @@ ActiveRecord::Schema.define(:version => 20141230062844) do create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "reward" t.string "name" t.text "description" t.integer "state" - t.integer "project_id", :default => 0 + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 end create_table "homework_evaluations", :force => true do |t|