diff --git a/.gitignore b/.gitignore index fe3677396..1ef7e63ce 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ vendor/cache public/javascripts/wechat/node_modules/ .ruby-version .access_token +tmux*.log diff --git a/Gemfile b/Gemfile index afe85df1d..03dbb5785 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' if RUBY_PLATFORM =~ /darwin/ gem "rmagick", "= 2.15.4" ## osx must be this version - else + elsif RUBY_PLATFORM =~ /linux/ #gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel end gem 'certified' @@ -51,7 +51,7 @@ gem 'elasticsearch-rails' ### profile -#gem 'oneapm_rpm' +gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/Gemfile~ b/Gemfile~ deleted file mode 100644 index 334f15853..000000000 --- a/Gemfile~ +++ /dev/null @@ -1,114 +0,0 @@ -source 'https://ruby.taobao.org/' - -unless RUBY_PLATFORM =~ /w32/ - # unix-like only - gem 'iconv' - gem "rmagick", ">= 2.0.0" - gem 'certified' -end - -gem 'net-ssh', '2.9.1' -gem 'jenkins_api_client' -gem 'nokogiri' - -gem 'wechat',path: 'lib/wechat' -gem 'grack', path:'lib/grack' -gem 'gitlab', path: 'lib/gitlab-cli' -gem 'rest-client' -gem "mysql2", "= 0.3.18" -gem 'redis-rails' -gem 'rubyzip' -gem 'delayed_job_active_record'#, :group => :production -gem 'daemons' -gem 'grape', '~> 0.9.0' -gem 'grape-entity' -gem 'rack-cors', :require => 'rack/cors' -gem 'seems_rateable', '~> 1.0.13' -gem 'rails', '~> 3.2' -gem "jquery-rails", "~> 2.0.2" -gem "i18n", "~> 0.6.0" -gem 'coderay', '~> 1.1.0' -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' -gem 'rails_kindeditor',path:'lib/rails_kindeditor' -gem 'binding_of_caller' -gem 'chinese_pinyin' -# gem 'sunspot_rails', '~> 1.3.3' -# gem 'sunspot_solr' -# gem 'sunspot' -# gem 'progress_bar' -gem 'ansi' - -gem 'kaminari' -gem 'elasticsearch-model' -gem 'elasticsearch-rails' - - -### profile -#gem 'oneapm_rpm' - -group :development do - gem 'grape-swagger' - gem 'better_errors', '~> 1.1.0' - # gem "query_reviewer" - # gem 'rack-mini-profiler', '~> 0.9.3' - if RUBY_PLATFORM =~ /w32/ - gem 'win32console' - end -end - -group :development, :test do - unless RUBY_PLATFORM =~ /w32/ - gem 'pry-rails' - if RUBY_VERSION >= '2.0.0' - gem 'pry-byebug' - end - gem 'pry-stack_explorer' - if RUBY_PLATFORM =~ /darwin/ - gem 'puma' - end - end - - gem 'rspec-rails', '~> 3.0' - gem 'factory_girl_rails' -end - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer', :platforms => :ruby - - gem 'uglifier', '>= 1.0.3' -end - -# Optional gem for LDAP authentication -group :ldap do - gem "net-ldap", "~> 0.3.1" -end - - -# Optional gem for OpenID authentication -group :openid do - gem "ruby-openid", "~> 2.1.4", :require => "openid" - gem "rack-openid" -end - - -database_file = File.join(File.dirname(__FILE__), "config/database.yml") -if File.exist?(database_file) -else - warn("Please configure your config/database.yml first") -end - -# Load plugins' Gemfiles -Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| - puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` - instance_eval File.read(file) -end diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb index d5823d5b4..16531940f 100644 --- a/app/api/mobile/apis/resources.rb +++ b/app/api/mobile/apis/resources.rb @@ -8,23 +8,13 @@ module Mobile desc '获取所有课件' params do requires :token, type: String - requires :page, type: Integer end - post do + get do authenticate! - page = params[:page] ? params[:page] : 0 - rs = ResourcesService.new # data = current_user.course_attachments data = rs.all_course_attachments current_user - all_count = data.count - data = data.limit(10).offset(page * 10) - count = data.count - present :data, data, with: Mobile::Entities::Attachment,user: current_user - present :all_count, all_count - present :count, count - present :page, page present :status, 0 end @@ -34,24 +24,14 @@ module Mobile desc '获取所有作业' params do requires :token, type: String - requires :page, type: Integer end - post 'homeworks' do + get 'homeworks' do authenticate! - page = params[:page] ? params[:page] : 0 - rs = ResourcesService.new homeworks = rs.all_homework_commons current_user - all_count = homeworks.count - homeworks = homeworks.limit(10).offset(page * 10) - count = homeworks.count - present :data, homeworks, with: Mobile::Entities::Homework,user: current_user - present :all_count, all_count - present :count, count - present :page, page present :status, 0 end @@ -59,23 +39,13 @@ module Mobile desc '获取所有测验' params do requires :token, type: String - requires :page, type: Integer end - post 'exercises' do + get 'exercies' do authenticate! - page = params[:page] ? params[:page] : 0 - rs = ResourcesService.new exercises = rs.all_exercises current_user - all_count = exercises.count - exercises = exercises.limit(10).offset(page * 10) - count = exercises.count - present :data, exercises, with: Mobile::Entities::Exercise,user: current_user - present :all_count, all_count - present :count, count - present :page, page present :status, 0 end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index bc764d034..52e1f5fd0 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -61,7 +61,7 @@ class AdminController < ApplicationController if params[:syllabus_id] && params[:course_id] course = Course.where("id = #{params[:course_id].to_i}").first unless course.nil? - course.update_attribute('syllabus_id', params[:syllabus_id].to_i) + course.update_column('syllabus_id', params[:syllabus_id].to_i) @flag = true end end @@ -112,10 +112,10 @@ class AdminController < ApplicationController def non_syllabus_courses @name = params[:name].to_s.strip.downcase if @name && @name != "" - @courses = Course.where("syllabus_id is null").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} + @courses = Course.where("syllabus_id is null and is_delete = 0").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} @courses = @courses.sort{|x, y| y.created_at <=> x.created_at} else - @courses = Course.where("syllabus_id is null").order('created_at desc') + @courses = Course.where("syllabus_id is null and is_delete = 0").order('created_at desc') end @courses = paginateHelper @courses,30 @page = (params['page'] || 1).to_i - 1 @@ -124,11 +124,11 @@ class AdminController < ApplicationController end end - #修改课程名称 + #修改班级名称 def update_course_name @course = Course.where("id = #{params[:course_id].to_i}").first unless @course.nil? - @course.update_attribute("name", params[:name]) + @course.update_column("name", params[:name]) respond_to do |format| format.js end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 73672d11a..03ed7945a 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -114,7 +114,7 @@ class QualityAnalysisController < ApplicationController end end rescue => e - puts e + @message = e.message end respond_to do |format| if @current_build_status == "success" @@ -227,9 +227,6 @@ class QualityAnalysisController < ApplicationController end @ha.store(key,value) end - - issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read - @sonar_issues = JSON.parse(issue_date).first end rescue => e puts e diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 4c3a608de..bc1b97a2f 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -110,9 +110,9 @@ class StudentWorkController < ApplicationController #status 0:答案正确 -5program_test_ex 函数出错 -4judge代码出错 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时 resultObj[:status] = -3 CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id) - rescue + rescue => e #-4 judge代码 出错 - logger.debug "program_test_error 1" + logger.debug "program_test_error #{e}" resultObj[:status] = -4 tmpstatus = -4 CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>0,:wait_time=>0,:student_work_id=>student_work.id) @@ -197,7 +197,7 @@ class StudentWorkController < ApplicationController resultObj[:status] = 0 end student_work.save! - resultObj[:time] = student_work_test.created_at.to_s(:db) + resultObj[:time] = student_work_test.created_at.strftime(format='%Y-%m-%d %H:%M:%S') resultObj[:index] = student_work.student_work_tests.count end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3f23d94dc..83a794cd9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2023,7 +2023,7 @@ class UsersController < ApplicationController @flag = true if params[:send_id].present? rs = ResourcesService.new - @ori, @flag, @save_message = rs.send_resource_to_course(params) + @ori, @flag, @save_message = rs.send_resource_to_course(User.current, params) elsif params[:send_ids].present? send_ids = params[:send_ids].split(",") course_ids = params[:course_ids] diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb index 2a7d350e7..5940dd255 100644 --- a/app/helpers/quality_analysis_helper.rb +++ b/app/helpers/quality_analysis_helper.rb @@ -3,16 +3,16 @@ module QualityAnalysisHelper def sqale_rating_status val arr = [] - if val < 5 + if val <= 5 arr << "很好" arr << "b_green2" - elsif val. > 5 && val < 10 + elsif val. > 5 && val <= 10 arr << "较好" arr << "b_slow_yellow" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 arr << "中等" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "较差" arr << "b_slow_red" elsif val > 20 @@ -23,10 +23,10 @@ module QualityAnalysisHelper def complexity_status val arr = [] - if val < 10 + if val <= 10 arr << "良好" arr << "b_green2" - elsif val > 10 && val < 15 + elsif val > 10 && val <= 15 arr << "较高" arr << "b_yellow" elsif val > 15 @@ -37,10 +37,10 @@ module QualityAnalysisHelper def duplicated_lines_density_status val arr = [] - if val < 30 + if val <= 30 arr << "良好" arr << "b_green2" - elsif val > 30 && val < 50 + elsif val > 30 && val <= 50 arr << "较高" arr << "b_yellow" elsif val > 50 @@ -51,10 +51,10 @@ module QualityAnalysisHelper def comment_lines_density_status val arr = [] - if val < 20 + if val <= 20 arr << "较低" arr << "b_yellow" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 arr << "正常" arr << "b_green2" elsif val > 50 @@ -64,15 +64,15 @@ module QualityAnalysisHelper end def score_sqale_rating val - if val > 0 && val < 5 + if val >= 0 && val <= 5 "5" - elsif val > 5 && val < 10 + elsif val > 5 && val <= 10 "4" - elsif val > 10 && val < 20 + elsif val > 10 && val <= 20 "3" - elsif val > 20 && val < 50 + elsif val > 20 && val <= 50 "2" - elsif val > 20 + elsif val > 50 "1" end end diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 54d5ab07a..f2a35871f 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -45,7 +45,7 @@ class StudentWorkTest < ActiveRecord::Base private def get_success_count self.results.inject(0) do |sum, result| - sum += (result["status"] && result["status"].to_i == 0 ? 1 : 0) + sum += (result["status"] && result["status"].class == ::Fixnum && result["status"].to_i == 0 ? 1 : 0) end || 0 end diff --git a/app/views/admin/_courselist_detail_tr.html.erb b/app/views/admin/_courselist_detail_tr.html.erb index 07486faa3..83b7904ce 100644 --- a/app/views/admin/_courselist_detail_tr.html.erb +++ b/app/views/admin/_courselist_detail_tr.html.erb @@ -7,7 +7,7 @@
+ | 序号 | -+ | 班级 | @@ -42,6 +42,9 @@ | <%=l(:field_is_public)%> | ++ 状态 + | <%=l(:field_created_on)%> | @@ -58,9 +61,11 @@
---|---|---|---|---|---|---|---|
+ | 序号 | -+ | 班级 | @@ -42,6 +42,9 @@ | <%=l(:field_is_public)%> | ++ 状态 + | <%=l(:field_created_on)%> | @@ -58,17 +61,18 @@
---|---|---|---|---|---|---|---|
<%= course.id %> | -- <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> + <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %> | <%= course.class_period %> @@ -76,6 +80,9 @@ | <%= checked_image course.is_public? %> | ++ <%= course.is_delete == 0 ? '正常' : '归档' %> + | <%= format_date(course.created_at) %> | @@ -90,6 +97,7 @@
真实姓名:<%= User.find(ma.course_message_id).realname %>
申请课程:<%= Course.find(ma.course_id).name%>
申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>