diff --git a/.access_token b/.access_token new file mode 100644 index 000000000..610b08d2e --- /dev/null +++ b/.access_token @@ -0,0 +1 @@ +{"access_token":"oEEf8ZKAB8Y2G0o_xnTPkPJHKKk8iHkLC-f5ptvQ2nCMj9IpC86ivLD2-p38GfOkuG-HuQp3pWZqhs3NJXUMdPLWsr5k67hPZYuqg4ozLccx0xdLswapj0mn8ovZhK1tKIKiAFAOMO","expires_in":7200,"got_token_at":1467012449} \ No newline at end of file diff --git a/.gitignore b/.gitignore index ba7890841..dbc349c80 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ vendor/cache /config/initializers/gitlab_config.rb 1234567 public/javascripts/wechat/node_modules/ +.ruby-version diff --git a/Gemfile b/Gemfile index d392c6561..bb94100a5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,19 @@ source 'https://ruby.taobao.org/' -### ����ִ��bundle config mirror.https://rubygems.org https://gems.ruby-china.org �л���ruby-chinaԴ unless RUBY_PLATFORM =~ /w32/ # unix-like only gem 'iconv' + if RUBY_PLATFORM =~ /darwin/ + gem "rmagick", "= 2.15.4" ## osx must be this version + else + gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel + end + gem 'certified' + gem 'net-ssh', '2.9.1' + gem 'jenkins_api_client' + gem 'nokogiri' end -gem 'certified' - gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' @@ -31,7 +37,6 @@ gem 'acts-as-taggable-on', '2.4.1' gem 'spreadsheet' gem 'ruby-ole' gem 'rails_kindeditor',path:'lib/rails_kindeditor' -#gem "rmagick", ">= 2.0.0" gem 'binding_of_caller' gem 'chinese_pinyin' # gem 'sunspot_rails', '~> 1.3.3' @@ -81,7 +86,7 @@ group :assets do gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby + # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index c86a36d05..c555eb633 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -18,11 +18,13 @@ module Mobile require_relative 'apis/blog_comments' require_relative 'apis/new_comment' require_relative 'apis/praise' + require_relative 'apis/resources' class API < Grape::API version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" + use ActionDispatch::Session::CookieStore use Mobile::Middleware::ErrorHandler helpers do @@ -34,6 +36,10 @@ module Mobile raise('Unauthorized. 用户认证失败.') unless current_user end + def session + env['rack.session'] + end + def current_user openid = params[:openid] if openid @@ -66,9 +72,9 @@ module Mobile mount Apis::BlogComments mount Apis::NewComment mount Apis::Praise + mount Apis::Resources - #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 49fdaff8f..661925012 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -9,7 +9,7 @@ module Mobile params do requires :page, type: Integer - requires :openid, type: String + requires :token, type: String end post do authenticate! diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 3a36a9e37..42303b63d 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -14,8 +14,9 @@ module Mobile optional :token, type: String end get do + authenticate! cs = CoursesService.new - courses = cs.course_list(params,current_user.nil? ? User.find(2):current_user) + courses = cs.user_courses_list(current_user) present :data, courses, with: Mobile::Entities::Course present :status, 0 end @@ -97,25 +98,20 @@ module Mobile desc "加入课程" params do - requires :course_password, type: String + requires :token, type: String + requires :invite_code, type: String, desc: '邀请码' end - post ":id" do + post "join" do authenticate! cs = CoursesService.new - status = cs.join_course({:object_id => params[:id],:course_password => params[:course_password]},current_user) - out = {status: status[:state]} - message = case status[:state] - when 0; "加入成功" - when 1; "密码错误" - when 2; "课程已过期 请联系课程管理员重启课程。(在配置课程处)" - when 3; "您已经加入了课程" - when 4; "您加入的课程不存在" - when 5; "您还未登录" - else; "未知错误,请稍后再试" - end - out.merge(message: message) + status = cs.join_course({role: "10", openid: params[:openid], invite_code: params[:invite_code]}, current_user) + { + status: status[:state], + messsge:CoursesService::JoinCourseError.message(status[:state]) + } end + desc "退出课程" params do requires :token, type: String @@ -201,6 +197,7 @@ module Mobile end route_param :id do get do + authenticate! cs = CoursesService.new course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user)) #course = Course.find(params[:id]) @@ -388,7 +385,16 @@ module Mobile end - + desc '获取测验列表' + params do + requires :token, type:String + end + get ':course_id/exercises' do + authenticate! + exercises = Course.find(params[:course_id]).exercises + present :data,exercises,with:Mobile::Entities::Exercise + present :status,0 + end end end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index b767bd768..4a6417cb4 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -8,7 +8,8 @@ module Mobile desc "get special issuse" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user issue = Issue.find params[:id] present :data, issue, with: Mobile::Entities::Issue,user: user present :status, 0 diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 15a571a82..5f2d01185 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -7,7 +7,8 @@ module Mobile desc "get special journal" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user jour = JournalsForMessage.find params[:id] present :data, jour, with: Mobile::Entities::Jours,user: user present :status, 0 diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index ae2f9a39c..bab82de8d 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -7,7 +7,8 @@ module Mobile desc "get special topic" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user message = Message.find params[:id] present :data, message, with: Mobile::Entities::Message,user: user present :status, 0 diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 694ec0613..5b7159301 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -11,12 +11,12 @@ module Mobile params do requires :type, type: String requires :content, type: String - requires :openid, type: String + requires :token, type: String end post ':id' do + authenticate! type = params[:type] result = 1 - current_user = UserWechat.find_by_openid(params[:openid]).user if params[:content]!="" && current_user case type when "HomeworkCommon" diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index 8bdd460cc..d42177783 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -7,7 +7,8 @@ module Mobile desc "get special news" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user news = News.find params[:id] present :data, news, with: Mobile::Entities::News,user: user present :status, 0 diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index 57dbd0729..834d1195b 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -9,12 +9,13 @@ module Mobile params do requires :type, type: String - requires :openid, type: String + requires :token, type: String end post ':id' do + authenticate! obj_id = params[:id] obj_type = params[:type] - user = UserWechat.find_by_openid(params[:openid]).user + user = current_user pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first if pts.blank? praise_or_cancel(obj_type,obj_id,user,1) diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb new file mode 100644 index 000000000..fca94a642 --- /dev/null +++ b/app/api/mobile/apis/resources.rb @@ -0,0 +1,55 @@ +#coding=utf-8 +module Mobile + module Apis + class Resources < Grape::API + + resource :resources do + + desc '获取所有课件' + params do + requires :token, type: String + end + get do + authenticate! + data = current_user.course_attachments + present :data, data, with: Mobile::Entities::Attachment + present :status, 0 + + end + + + + desc '获取所有作业' + params do + requires :token, type: String + end + get 'homeworks' do + authenticate! + + homeworks = current_user.homework_commons + + present :data, homeworks, with: Mobile::Entities::Homework + present :status, 0 + + end + + desc '获取所有测验' + params do + requires :token, type: String + end + get 'exercies' do + authenticate! + + exercises = current_user.exercises + present :data, exercises, with: Mobile::Entities::Exercise + present :status, 0 + end + + + end + + + + end + end +end \ No newline at end of file diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 6ce3cacbb..b5ee14d19 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -4,6 +4,48 @@ module Mobile class Users < Grape::API resource :users do + desc "查询是否已绑定" + params do + requires :openid, type: String, desc: 'wechat openid' + end + post 'isbind' do + openid = params[:openid] + uw = UserWechat.where(openid: openid).first + raise "还未绑定trustie帐户" unless uw + + user = uw.user + ::ApiKey.delete_all(user_id: user.id) + key = ::ApiKey.create!(user_id: user.id) + present status: 0, token: key.access_token + end + + desc "绑定微信用户" + params do + requires :login, type: String, desc: 'username' + requires :password, type: String, desc: 'password' + end + post 'wxbind' do + openid = session[:wechat_openid] + logger.debug "openid ============== #{openid}" + raise "无法获取到openid,请在微信中打开本页面" unless openid + uw = UserWechat.where(openid: openid).first + raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw + + user, last_login_on = User.try_to_login(params[:login], params[:password]) + raise "用户名或密码错误,请重新输入" unless user + #补全用户信息 + + raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat + + UserWechat.create!( + openid: openid, + user: user + ) + # ws = WechatService.new + # ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) + present status: 0, message: '您已成功绑定Trustie平台' + end + desc "注册用户" params do requires :login, type: String, desc: 'username' diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index a88d509a3..c8377aa0d 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -7,7 +7,8 @@ module Mobile desc "get one homework" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user homework = HomeworkCommon.find params[:id] present :data, homework, with: Mobile::Entities::Whomework,user: user present :status, 0 diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 50812b349..487a75c4d 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -45,6 +45,8 @@ module Mobile course_expose :tea_id course_expose :term course_expose :time + course_expose :invite_code + course_expose :qrcode course_expose :updated_at course_expose :course_student_num expose :teacher, using: Mobile::Entities::User do |c, opt| diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb new file mode 100644 index 000000000..3218264fb --- /dev/null +++ b/app/api/mobile/entities/exercise.rb @@ -0,0 +1,8 @@ +module Mobile + module Entities + class Exercise < Grape::Entity + expose :exercise_name + expose :exercise_description + end + end +end diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 8c6a839b3..2eb20f0db 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -26,6 +26,8 @@ module Mobile u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id when :realname u.nil? ? "" : get_user_realname(u) + when :name + u.nil? ? "" : u.show_name end end end @@ -57,6 +59,11 @@ module Mobile user_expose :student_num # 活跃值 user_expose :active_count + + user_expose :role_name + + user_expose :name + end end diff --git a/app/assets/javascripts/quality_analyses.js.coffee b/app/assets/javascripts/quality_analyses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/quality_analyses.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/quality_analyses.css.scss b/app/assets/stylesheets/quality_analyses.css.scss new file mode 100644 index 000000000..9404eb70f --- /dev/null +++ b/app/assets/stylesheets/quality_analyses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the QualityAnalyses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 33d988e35..8187055be 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -239,14 +239,23 @@ class AccountController < ApplicationController end def resendmail + result = {:status=>1, :email=>""} user = User.find(params[:user]) if params[:user] + result[:email] = user.mail token = Token.new(:user => user, :action => "register") if token.save - Mailer.run.register(token) - + # Mailer.run.register(token) + Mailer.register(token).deliver else yield if block_given? + result[:status] = 0 end + render :json => result + end + + def email_activation + + end private @@ -264,6 +273,7 @@ class AccountController < ApplicationController if user.nil? invalid_credentials elsif user.status == 2 + @user = user invalid_credentials_new elsif user.new_record? onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) @@ -375,8 +385,9 @@ class AccountController < ApplicationController def invalid_credentials_new logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" - flash[:error] = l(:notice_account_invalid_creditentials_new) - render signin_path(:login=>true) + # flash[:error] = l(:notice_account_invalid_creditentials_new) + # render signin_path(:login=>true) + render :action => 'email_activation' end # Register a user for email activation. diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 960bc61e6..a6b5f09cf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -612,7 +612,7 @@ class AttachmentsController < ApplicationController @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Syllabus' || @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e421b8c69..e81251f63 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -74,7 +74,7 @@ class CoursesController < ApplicationController else @state = 5 #未登录 end - @object_id = params[:object_id] + @object_id = @course.id if @course respond_to do |format| format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end @@ -715,6 +715,7 @@ class CoursesController < ApplicationController @trackers = Tracker.sorted.all @course = Course.new @course.safe_attributes = params[:course] + @syllabus = Syllabus.where("id = #{params[:syllabus_id].to_i}").first if params[:syllabus_id] # month = Time.now.month render :layout => 'new_base' else @@ -1224,7 +1225,7 @@ class CoursesController < ApplicationController def member_to_xls homeworks, course, members,groups xls_report = StringIO.new book = Spreadsheet::Workbook.new - sheet1 = book.create_worksheet :name => "student" + sheet1 = book.create_worksheet :name => "总成绩" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 #sheet1.row(0).default_format = blue #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) @@ -1268,6 +1269,121 @@ class CoursesController < ApplicationController count_row += 1 end + homeworks.each_with_index do |home, i| + sheet = book.create_worksheet :name => "第#{i+1}次作业" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程学期" + sheet[1,1] = course.time.to_s+"年"+course.term + sheet[2,0] = "课程名称" + sheet[2,1] = course.name + sheet[3,0] = "教师团队" + sheet[3,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_name}.join('、') + sheet[4,0] = "主讲教师" + sheet[4,1] = course.teacher.show_name + sheet[4,0] = "作业批次" + sheet[4,1] = "第#{i+1}次作业" + sheet[4,0] = "作业名称" + sheet[4,1] = home.name + if home.homework_type == 1 #普通作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.name + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,12] = format_time(stu.created_at) + else + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,10] = format_time(stu.created_at) + end + count_row += 1 + end + elsif home.homework_type == 2 #编程作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.name + sheet[count_row,5] = stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + sheet[count_row,8] = stu.system_score.nil? ? l(:label_without_score) : stu.system_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,9] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,10] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,11] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,12] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,13] = format_time(stu.created_at) + else + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,11] = format_time(stu.created_at) + end + count_row += 1 + end + elsif home.homework_type == 3 #分组作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = get_group_member_names stu + sheet[count_row,2] = stu.name + sheet[count_row,3] = (stu.project_id == 0 || stu.project_id.nil?) ? l(:excel_no_project) : stu.project.name + sheet[count_row,4] = strip_html stu.description + sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,8] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.absence_penalty + sheet[count_row,9] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,11] = format_time(stu.created_at) + else + sheet[count_row,7] = (home.teacher_priority == 1 && !stu.teacher_score.nil?) ? 0 : stu.late_penalty + sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,9] = format_time(stu.created_at) + end + count_row += 1 + end + end + end + =begin group0 = CourseGroup.new(); group0.id = 0; diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 0883b3799..32c605516 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -127,12 +127,14 @@ class MyController < ApplicationController end @user.safe_attributes = params[:user] + @user.lastname = params[:lastname] + @user.firstname = "" @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') #@user.login = params[:login] unless @user.user_extensions.nil? if @user.user_extensions.identity == 2 - @user.firstname = params[:enterprise_name] + # @user.firstname = params[:enterprise_name] end end @@ -144,7 +146,7 @@ class MyController < ApplicationController # end @se.school_id = params[:occupation] - @se.gender = params[:gender] + @se.gender = params[:sex] @se.location = params[:province] if params[:province] @se.location_city = params[:city] if params[:city] @se.identity = params[:identity].to_i if params[:identity] diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index b6eb54d2f..9f0fe41c8 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -131,6 +131,8 @@ class PraiseTreadController < ApplicationController @obj = Bid.find_by_id(id) when 'Contest' @obj = Contest.find_by_id(id) + when 'Syllabus' + @obj = Syllabus.find_by_id(id) else @obj = nil end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c8b272480..8664a1372 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -100,8 +100,8 @@ class ProjectsController < ApplicationController render_404 end - def course - render_404 + def courserender_404 + end # Time 2015-01-29 11:19:11 @@ -299,6 +299,8 @@ class ProjectsController < ApplicationController if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end + + logger.debug "111111111"*100 # over @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @page = params[:page] ? params[:page].to_i + 1 : 0 @@ -319,6 +321,7 @@ class ProjectsController < ApplicationController else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10); end + logger.debug "2"*100 # g = Gitlab.client unless @project.gpid.nil? || @project.project_score.changeset_num == 0 # rep_statics_commit = @project.rep_statics.order("commits_num desc") @@ -332,12 +335,20 @@ class ProjectsController < ApplicationController @a_commits_del = rep_statics_code.map {|s| s.del.to_i } @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i } g = Gitlab.client + logger.debug "3"*100 begin - g_branch = g.project(@project.gpid).default_branch.to_s - rescue - logger.error("get gitlab project failed!") + gid = @project.gpid + logger.debug "31"*100 + g_branch = g.project(gid) + logger.debug "4"*100 + g_branch = g_branch.default_branch.to_s + logger.debug "5"*100 + rescue =>e + logger.error("get gitlab project failed: " + e) end + logger.debug "6"*100 @rev = g_branch.nil? ? "master" : g_branch + logger.debug "7"*100 end # 根据对应的请求,返回对应的数据 respond_to do |format| @@ -393,7 +404,7 @@ class ProjectsController < ApplicationController unless @project.gpid.nil? g = Gitlab.client @gitlab_branches = g.branches(@project.gpid) - @branch_names = g.branches(@project.gpid).map{|b| b.name} + @branch_names = @gitlab_branches.map{|b| b.name} @gitlab_default_branch = g.project(@project.gpid).default_branch end end @@ -645,7 +656,7 @@ class ProjectsController < ApplicationController params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 - unless @project.gpid.nil? + if !@project.gpid.nil? && @project.is_public != (params[:project][:is_public] == "on" ? true : false) g = Gitlab.client params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch]) end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb new file mode 100644 index 000000000..2c55f780c --- /dev/null +++ b/app/controllers/quality_analysis_controller.rb @@ -0,0 +1,227 @@ +class QualityAnalysisController < ApplicationController + before_filter :find_project_by_project_id#, :except => [:getattachtype] + before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job] + before_filter :authorize + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index] + layout "base_projects" + include ApplicationHelper + include QualityAnalysisHelper + require 'jenkins_api_client' + require 'nokogiri' + require 'json' + require 'open-uri' + + def show + + end + + # params 说明:{identifier:版本库名} + def create + begin + user_name = User.find(params[:user_id]).try(:login) + identifier = params[:identifier] + rep_id = params[:rep_id] + + # job_name and sonar_name 前者为job名字,后者为jenkins配置名 + job_name = "#{user_name}-#{rep_id}" + sonar_name = "#{user_name}:#{rep_id}" + + # Checks if the given job exists in Jenkins. + unless @client.job.exists?(job_name) + @g = Gitlab.client + branch = params[:branch] + language = swith_language_type(params[:language]) + path = params[:path].blank? ? "./" : params[:path] + qa = QualityAnalysis.where(:project_id => @project.id, :author_login => user_name).first + version = qa.nil? ? 1 : qa.sonar_version + 1 + properties = "sonar.projectKey=#{sonar_name} + sonar.projectName=#{sonar_name} + sonar.projectVersion=#{version} + sonar.sources=#{path} + sonar.language=#{language.downcase} + sonar.sourceEncoding=utf-8" + git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" + + # 替换配置文件 + @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) + @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url + @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" + @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties + + # jenkins job创建 + jenkins_job = @client.job.create("#{job_name}", @doc.to_xml) + logger.info("Jenkins status of create ==> #{jenkins_job}") + + # 将地址作为hook值添加到gitlab + @g.add_project_hook(@project.gpid, @jenkins_address + "/project/#{job_name}") + # job创建完成后自动运行job,如果运行成功则返回‘200’ + code = @client.job.build("#{job_name}") + logger.error("build result ==> #{code}") + + # 判断调用sonar分析是否成功 + # 等待启动时间处理, 最长时间为30分钟 + for i in 0..60 do + sleep(60) + @current_build_status = @client.job.get_current_build_status("#{job_name}") + if (@current_build_status != "not_run" || @current_build_status != "running") + break + if i == 60 + @build_console_result = false + break + end + end + end + + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + logger.info("@current_build_status is ==> #{@current_build_status}") + logger.info("@console_build is ==> #{@console_build}") + + d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201' + logger.error("delete result ==> #{code}") + if qa.blank? && @current_build_status == "success" + QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier, + :sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}") + else + qa.update_attribute(:sonar_version, version) + end + end + rescue => e + puts e + end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)} + # format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)} + end + end + + # get language type + def swith_language_type language + if language == "c#" + "cs" + elsif language == "python" + "py" + elsif language == "c" + "c++" + else + language + end + end + + def edit + @g = Gitlab.client + gitlab_branches = @g.branches(@project.gpid) + @branch_names = gitlab_branches.map{|b| b.name} + @gitlab_default_branch = @g.project(@project.gpid).default_branch + end + + # 更新Jenkins job,主要包括相关配置文件参数的更新,Trustie平台数据的更新 + def update_jenkins_job + begin + rep_id = Repository.where(:project_id => @project.id).first.try(:id) + logger.error("#############################===>666") + sonar_name = @quality_analysis.sonar_name + job_name = "#{@quality_analysis.author_login}-#{rep_id}" + version = @quality_analysis.sonar_version + path = params[:path].blank? ? "./" : params[:path] + language = swith_language_type(params[:language]) + branch = params[:branch] + identifier = @quality_analysis.rep_identifier + properties = "sonar.projectKey=#{sonar_name} + sonar.projectName=#{sonar_name} + sonar.projectVersion=#{version} + sonar.sources=#{path} + sonar.language=#{language.downcase} + sonar.sourceEncoding=utf-8" + git_url = @gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ identifier + "."+"git" + + # modify config.yml + @doc = Nokogiri::XML(File.open(File.join(Rails.root, 'tmp', 'config.xml'))) + @doc.at_xpath("//hudson.plugins.git.UserRemoteConfig/url").content = git_url + @doc.at_xpath("//hudson.plugins.git.BranchSpec/name").content = "*/#{branch}" + @doc.at_xpath("//hudson.plugins.sonar.SonarRunnerBuilder/properties").content = properties # sonar-properties + + # update成功则返回 ‘200’ + jenkins_job = @client.job.update("#{job_name}", @doc.to_xml) + get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280") + logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200' + + # 数据更新到Trustie数据库 + if jenkins_job == '200' + logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}") + @quality_analysis.path = path + @quality_analysis.language = language + @quality_analysis.branch = branch + @quality_analysis.save + end + rescue Exception => e + logger.error("Update jenkins job: #{e}") + end + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + format.js + end + end + + # resource_id: login + @repository.id + def index + begin + @resource_id = params[:resource_id] + @sonar_address = Redmine::Configuration['sonar_address'] + @jenkins_address = Redmine::Configuration['jenkins_address'] + if params[:resource_id].nil? + @name_flag = true + projects_date = open(@sonar_address + "/api/projects/index").read + arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] + @quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)} + + else + if params[:current_build_status] == "failure" + job_name = params[:job_name] + @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text') + end + complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read + @complexity =JSON.parse(complexity_date).first + 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 + end + + end + + # Find project of id params[:project_id] + def find_project_by_project_id + @project = Project.find(params[:project_id]) + rescue ActiveRecord::RecordNotFound + render_404 + end + + def find_quality_analysis + begin + @quality_analysis = QualityAnalysis.find(params[:id]) + rescue + render_404 + end + end + + # Authorize the user for the requested action + def authorize(ctrl = params[:controller], action = params[:action], global = false) + unless @project.archived? && @project.gpid.nil? + true + else + render_403 :message => :notice_not_authorized_archived_project + end + end + + def connect_jenkins + @gitlab_address = Redmine::Configuration['gitlab_address'] + @jenkins_address = Redmine::Configuration['jenkins_address'] + + # connect jenkins + @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => "temp", :password => '123123') + rescue => e + logger.error("failed to connect Jenkins ==> #{e}") + end + +end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 9e785c562..d0904ddf5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -20,6 +20,8 @@ require 'SVG/Graph/BarHorizontal' require 'digest/sha1' require 'redmine/scm/adapters/abstract_adapter' require 'tempfile' +require 'json' +require 'open-uri' class ChangesetNotFound < Exception; end class InvalidRevisionParam < Exception; end @@ -30,11 +32,13 @@ class RepositoriesController < ApplicationController menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats] + before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analysis] + # 链接gitlab + before_filter :connect_gitlab, :only => [:quality_analysis] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -43,6 +47,7 @@ class RepositoriesController < ApplicationController helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH $g=Gitlab.client + require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -306,6 +311,37 @@ update end end + def quality_analysis + gitlab_branches = @g.branches(@project.gpid) + @branch_names = gitlab_branches.map{|b| b.name} + @gitlab_default_branch = @g.project(@project.gpid).default_branch + # language = params[:language] + # branch = params[:branch] + # path = params[:path] + # user_name = User.find(@project.user_id).try(:login) + # rep_name = params[:repository_id] + # host = "192.168.0.200" + # port = "1125" + # username = "git" + # password = "123123" + # server_cmd1 = "sh gitclone.sh" + " " + user_name + " " + rep_name + # # 连接到远程主机 foobar + # ssh = Net::SSH.start(host, username, :port => port, :password => password) do |ssh| + # result = ssh.exec!(server_cmd1) + # path = "/home/git/repo/" + user_name + "/" + rep_name + # # sonar 分析 + # # server_cmd2 + # # 删除clone的版本库 + # # server_cmd3 + # end + respond_to do |format| + format.js + format.html{ + render :layout => "base_projects" + } + end + end + def destroy DestroyRepositoryTask.new.destroy(User.current.id, @repository.id) @repository.hidden = true @@ -338,7 +374,7 @@ update @changesets = g.commits(@project.gpid, :ref_name => @rev) g_project = g.project(@project.gpid) # 总的提交数 - @changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count + @changesets_all_count = @project.gpid.nil? ? 0 : commit_count(@project, @rev) @g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch # 访问该页面的是会后则刷新 if @project.project_score.nil? @@ -615,6 +651,14 @@ update project.project_score.update_attribute(:commit_time, date.created_at) end + # 链接gitlab + def connect_gitlab + @g = Gitlab.client + unless @project.gpid.nil? + @g_project = @g.project(@project.gpid) + end + end + def find_repository @repository = Repository.find(params[:id]) @project = @repository.project diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index e0aff6254..44f4378fe 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -150,4 +150,55 @@ class SchoolController < ApplicationController format.js end end + + #申请高校(单位) name:名称 province:省 city:市 address:地址 remarks:备注 + def apply_add_school + + data = {result:0,name:params[:name],school_id:0} + #0 成功 1参数错误 2名称已存在 + data[:result] = 0 + + #检验参数 + if params[:name] == "" || params[:province] == "" || params[:city] == "" || params[:address] == "" + data[:result] = 1 + else + school_id = School.find_by_sql("select id from schools where name='#{params[:name]}'").first + if school_id + data[:result] = 2 + else + school = School.new + school.name = params[:name].strip + school.pinyin = Pinyin.t(params[:name].strip, splitter: '') + school.save + + #status 0未处理 1通过 2拒绝 + applyschool = ApplyAddSchools.new + applyschool.school_id = school.id + applyschool.name = school.name + applyschool.province = params[:province] + applyschool.city = params[:city] + applyschool.address = params[:address] + applyschool.remarks = params[:remarks] + applyschool.save + + data[:school_id] = school.id + end + end + render :json =>data + end + + def search_repeat_schoolname + status = 0 + name = params[:name] + + if name + school_id = School.find_by_sql("select id from schools where name='#{name}'").first + + if school_id + status = 1 + end + end + + render :json =>status + end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d478b4d63..661770206 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1096,7 +1096,7 @@ class StudentWorkController < ApplicationController all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")" end all_students = User.where("id in #{all_student_ids}") - student_work_id = @homework.student_work_projects.where("user_id=?",User.current.id).empty? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id + student_work_id = @homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id @commit_student_ids = @homework.student_work_projects.where("student_work_id != #{student_work_id}").map{|student| student.user_id} @users = searchstudent_by_name all_students,name respond_to do |format| @@ -1209,13 +1209,18 @@ class StudentWorkController < ApplicationController sheet1 = book.create_worksheet :name => "homework" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - if @homework.homework_type == 1 #匿评作业 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) + if @homework.homework_type == 1 #普通作业 + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end count_row = 1 items.each do |homework| sheet1[count_row,0]=homework.user.id - sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s + sheet1[count_row,1] = homework.user.show_name sheet1[count_row,2] = homework.user.login sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail @@ -1223,18 +1228,31 @@ class StudentWorkController < ApplicationController sheet1[count_row,6] = strip_html homework.description sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) - sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) - sheet1[count_row,11] = format_time(homework.created_at) + if @homework.anonymous_comment ==0 + sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,10] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,12] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,13] = format_time(homework.created_at) + else + sheet1[count_row,9] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,11] = format_time(homework.created_at) + end count_row += 1 end elsif @homework.homework_type == 2 #编程作业 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end count_row = 1 items.each do |homework| sheet1[count_row,0]=homework.user.id - sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s + sheet1[count_row,1] = homework.user.show_name sheet1[count_row,2] = homework.user.login sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail @@ -1243,11 +1261,48 @@ class StudentWorkController < ApplicationController sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2) - sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) - sheet1[count_row,12] = format_time(homework.created_at) + if @homework.anonymous_comment ==0 + sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,11] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,12] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,13] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,14] = format_time(homework.created_at) + else + sheet1[count_row,10] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,12] = format_time(homework.created_at) + end count_row += 1 end + elsif @homework.homework_type == 3 #分组作业 + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 1 + items.each do |homework| + sheet1[count_row,0] = get_group_member_names homework + sheet1[count_row,1] = homework.name + sheet1[count_row,2] = (homework.project_id == 0 || homework.project_id.nil?) ? l(:excel_no_project) : homework.project.name + sheet1[count_row,3] = strip_html homework.description + sheet1[count_row,4] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) + sheet1[count_row,5] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) + if @homework.anonymous_comment ==0 + sheet1[count_row,6] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,7] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.absence_penalty + sheet1[count_row,8] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,10] = format_time(homework.created_at) + else + sheet1[count_row,6] = (@homework.teacher_priority == 1 && !homework.teacher_score.nil?) ? 0 : homework.late_penalty + sheet1[count_row,7] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,8] = format_time(homework.created_at) + end + count_row += 1 + end end book.write xls_report xls_report.string diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 69982b99a..8ff88823d 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -1,15 +1,164 @@ +# encoding: utf-8 class SyllabusesController < ApplicationController + include ApplicationHelper + helper :attachments + include AttachmentsHelper + include CoursesHelper - before_filter :is_logged, :only => [:index, :show] - before_filter :find_syllabus, :only => [:show] + before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus] + before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info, :delete_syllabus, :delete_des] def index user = User.current @syllabuses = user.syllabuses end def show - @courses = @syllabus.courses + #@courses = @syllabus.courses + respond_to do |format| + format.js + format.html{render :layout => 'base_syllabus'} + format.api + end + end + + def new + @syllabus = Syllabus.new + render :layout => 'new_base' + end + + def create + if User.current.user_extensions.identity + @syllabus = Syllabus.new + @syllabus.title = params[:title] + @syllabus.eng_name = params[:eng_name] + @syllabus.user_id = User.current.id + @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content + if @syllabus && @syllabus.save + respond_to do |format| + flash[:notice] = l(:notice_successful_create) + format.html {redirect_to syllabus_path(@syllabus)} + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'syllabuses', :action => 'show', :id => @syllabus.id) } + end + else + respond_to do |format| + flash[:notice] = l(:notice_create_failed) + format.html { redirect_to new_syllabus_path } #Added by young + format.api { render_validation_errors(@syllabus) } + end + end + end + end + + def edit + respond_to do |format| + format.html{render :layout => 'base_syllabus'} + end + end + + def delete_syllabus + respond_to do |format| + format.js + end + end + + def update + @syllabus.description = params[:syllabus][:description] + @syllabus.des_status = 1 + @syllabus.save_attachments(params[:attachments]) + if @syllabus.save + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@syllabus.id,OwnerTypeHelper::SYLLABUS + end + redirect_to syllabus_path(@syllabus) + else + redirect_to syllabus_path(@syllabus) + end + end + + #删除课程大纲的描述 + def delete_des + if @syllabus + @syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content + @syllabus.des_status = 0 + @syllabus.attachments.destroy_all + if @syllabus.save + redirect_to syllabus_path(@syllabus) + end + end + end + + def destroy + if @syllabus && @syllabus.courses.empty? + @syllabus.destroy + redirect_to user_courselist_user_path(User.current.id) + end + end + + #班级列表 + def syllabus_courselist + @order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 + + #确定 sort_type + if @order.to_i == @type.to_i + @c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序 + else + @c_sort = 2 + end + + sort_name = "updated_on" + sort_type = @c_sort == 1 ? "asc" : "desc" + + @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + + #根据 作业+资源数排序 + if @order.to_i == 2 + @type = 2 + @courses.each do |course| + course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count) + if course[:infocount] < 0 + course[:infocount] = 0 + end + end + @c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]}) + @courses = sortby_time_countcommon_nosticky @courses,sort_name + else + @type = 1 + end + + #分页 + @limit = 10 + @is_remote = true + @atta_count = @courses.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + @courses = paginateHelper @courses,@limit + + respond_to do |format| + format.js + format.html{render :layout => 'base_syllabus'} + end + end + + #修改英文名称 + def edit_syllabus_eng_name + if @syllabus + @syllabus.update_column("eng_name",params[:eng_name]) + end + respond_to do |format| + format.js + end + end + #编辑属性 + def update_base_info + if @syllabus + @syllabus.update_attributes(:credit => params[:credit], :hours => params[:hours], :theory_hours => params[:theory_hours], :practice_hours => params[:practice_hours], :applicable_major => params[:applicable_major], :pre_course => params[:pre_course]) + @syllabus.update_attributes(:syllabus_type => params[:syllabus_type]) + respond_to do |format| + format.js + end + end end private diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 2c390025e..e66f88848 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -13,6 +13,7 @@ class TagsController < ApplicationController include ForumsHelper include AttachmentsHelper include ContestsHelper + include SyllabusesHelper include ActsAsTaggableOn::TagsHelper include TagsHelper include FilesHelper @@ -529,6 +530,8 @@ class TagsController < ApplicationController @obj = Course.find_by_id(@obj_id) when '10' @obj = Attachment.find_by_id(@obj_id) + when '11' + @obj = Syllabus.find_by_id(@obj_id) else @obj = nil end @@ -619,6 +622,9 @@ class TagsController < ApplicationController when '9' then @obj = Course.find_by_id(obj_id) @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) + when '11' then + @obj = Syllabus.find_by_id(obj_id) + @obj_pages, @syllabuses_results, @results_count = for_pagination(get_syllabuses_by_tag(selected_tags)) else @obj = nil end @@ -684,6 +690,8 @@ class TagsController < ApplicationController return 'Course' when '10' return 'Attachment' + when '11' + return 'Syllabus' else render_error :message => e.message return diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ca63f496c..69a38610e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -87,7 +87,10 @@ class UsersController < ApplicationController #展开所有回复 def show_all_replies - @comment = JournalsForMessage.find params[:comment].to_i + case params[:type] + when 'JournalsForMessage' + @comment = JournalsForMessage.find params[:comment].to_i + end end #二级回复 @@ -95,6 +98,7 @@ class UsersController < ApplicationController case params[:type] when 'HomeworkCommon' @reply = JournalsForMessage.find params[:reply_id] + @type = 'HomeworkCommon' if params[:user_activity_id] @user_activity_id = params[:user_activity_id] else @@ -102,6 +106,11 @@ class UsersController < ApplicationController end @is_in_course = params[:is_in_course].to_i @course_activity = params[:course_activity].to_i + when 'JournalsForMessage' + @reply = JournalsForMessage.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'JournalsForMessage' end respond_to do |format| format.js @@ -132,10 +141,10 @@ class UsersController < ApplicationController # 未读的消息存放在数组 mess = message_all.message if (message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end - break if @message_alls.length == 5 + break if @message_alls.length == 10 end end end @@ -166,7 +175,7 @@ class UsersController < ApplicationController messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") messages.each do |message_all| mess = message_all.message - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end end @@ -177,7 +186,7 @@ class UsersController < ApplicationController # 在点击或者刷新消息列表后未读的消息存放在数组 mess = message_all.message if message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed) - unless (message_all.message_type == 'CourseMessage' && mess && mess.course.is_delete == 1) + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) @message_alls << mess end end @@ -1239,6 +1248,12 @@ class UsersController < ApplicationController render :layout=>'new_base_user' end + #给某人留言 + def feedBackTo + + + end + def user_comments end @@ -1358,7 +1373,15 @@ class UsersController < ApplicationController #显示更多用户课程 def user_courses4show @page = params[:page].to_i + 1 - @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) + @type = params[:type] + if @type == 'User' + @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) + @all_count = @user.courses.visible.where("is_delete =?", 0).count + elsif @type == 'Syllabus' + @syllabus = Syllabus.where("id = #{params[:syllabus]}").first + @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) + @all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count + end end #显示更多用户项目 @@ -1489,8 +1512,8 @@ class UsersController < ApplicationController # 减少数据库交互 watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(',')) user_ids = "(" + @user.id.to_s + watched_user_ids + ")" - watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") - blog_ids = "(" + watched_user_blog_ids + ")" + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}") + blog_ids = watched_user_blog_ids.empty? ? "(-1)" : "(" + watched_user_blog_ids.map { |blog| blog.id}.join(",") + ")" @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ @@ -3167,23 +3190,26 @@ class UsersController < ApplicationController @c_sort = 2 end - sort_name = "updated_on" + sort_name = "updated_at" sort_type = @c_sort == 1 ? "asc" : "desc" - # @courses = @user.courses.visible.where("is_delete =?", 0).order("#{sort_name} #{sort_type}") - @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + @courses = @user.courses.visible.where("is_delete =?", 0) + syllabus_ids = @courses.empty? ? '(-1)' : "(" + @courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" + @syllabus = Syllabus.where("id in #{syllabus_ids} or user_id = #{User.current.id}").order("#{sort_name} #{sort_type}") #根据 作业+资源数排序 if @order.to_i == 2 @type = 2 - @courses.each do |course| - course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count) - if course[:infocount] < 0 - course[:infocount] = 0 + @syllabus.each do |syllabus| + count = 0 + courses = @courses.where("syllabus_id = #{syllabus.id}") + courses.each do |c| + count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count) end + syllabus[:infocount] = count end - @c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]}) - @courses = sortby_time_countcommon_nosticky @courses,sort_name + @c_sort == 1 ? (@syllabus = @syllabus.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@syllabus = @syllabus.sort{|x,y| y[:infocount] <=> x[:infocount]}) + @syllabus = sortby_time_countcommon_nosticky @syllabus,sort_name else @type = 1 end @@ -3191,10 +3217,10 @@ class UsersController < ApplicationController #分页 @limit = 10 @is_remote = true - @atta_count = @courses.count + @atta_count = @syllabus.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset - @courses = paginateHelper @courses,@limit + @syllabus = paginateHelper @syllabus,@limit respond_to do |format| format.js @@ -3259,9 +3285,16 @@ class UsersController < ApplicationController when 'News' obj = News.where('id = ?', params[:id].to_i).first @journals = obj.comments.reorder("created_on desc") + when 'Syllabus' + obj = Syllabus.where('id = ?', params[:id].to_i).first + @journals = obj.comments.reorder("created_on desc") when 'JournalsForMessage' obj = JournalsForMessage.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_on desc") + journals = [] + @journals = get_all_children(journals, obj) + @type = 'JournalsForMessage' + @user_activity_id = params[:div_id].to_i if params[:div_id] + @allow_delete = params[:allow_delete] when 'Issue' obj = Issue.where('id = ?', params[:id].to_i).first @journals = obj.journals.reorder("created_on desc") diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 169a33fce..4a79d6d93 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -3,10 +3,12 @@ class WechatsController < ActionController::Base wechat_responder include ApplicationHelper - + ROOT_URL = ENV["wechat_url"] || "#{Setting.protocol}://#{Setting.host_name}" + #ROOT_URL = "http://www.trustie.net" # default text responder when no other match on :text do |request, content| - request.reply.text "您的意见已收到,感谢您的反馈!" # Just echo + #邀请码 + sendBindClass(request, {invite_code: content}) end # When receive 'help', will trigger this responder @@ -35,13 +37,13 @@ class WechatsController < ActionController::Base # When subscribe user scan scene_id in public account on :scan, with: 'scene_id' do |request, ticket| - request.reply.text "Subscribe user #{request[:FromUserName]} Ticket #{ticket}" + sendBindClass(request, {ticket: ticket}) end # When no any on :scan responder can match subscribe user scaned scene_id on :event, with: 'scan' do |request| if request[:EventKey].present? - request.reply.text "event scan got EventKey #{request[:EventKey]} Ticket #{request[:Ticket]}" + sendBindClass(request, {ticket: request[:Ticket]}) end end @@ -62,6 +64,9 @@ class WechatsController < ActionController::Base request.reply.text "User: #{request[:FromUserName]} click #{key}" end + on :click, with: 'DEV' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| request.reply.text "#{request[:FromUserName]} view #{view}" @@ -128,12 +133,36 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'JOIN_CLASS' do |request, key| + uw = user_binded?(request[:FromUserName]) + unless uw + sendBind(request) + else + request.reply.text "请直接回复5位班级邀请码\n(不区分大小写):" + end + end + + + def sendBindClass(request, params) + begin + uw = user_binded?(request[:FromUserName]) + if !uw + return sendBind(request) + else + return join_class(params, uw.user, request) + end + rescue => e + logger.error e.inspect + logger.error e.backtrace.join("\n") + return request.reply.text e + end + end + def default_msg(request) uw = user_binded?(request[:FromUserName]) if uw && uw.user request.reply.text "欢迎回来, #{uw.user.show_name}" else - request.reply.text "欢迎关注Trustie创新实践社区" sendBind(request) end end @@ -145,27 +174,61 @@ class WechatsController < ActionController::Base 您还未绑定确实的用户,请先绑定,谢谢!" } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" - pic_url = "#{Setting.protocol}://#{Setting.host_name}/images/weixin_pic.jpg" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login#wechat_redirect" + pic_url = "#{ROOT_URL}/images/weixin_pic.jpg" + article.item title: "#{n[:title]}", + description: n[:content], + pic_url: pic_url, + url: url + end + end + + def join_class(params, user, request) + course = nil + course = Course.where(qrcode: params[:ticket]).first if params[:ticket] + course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code] + raise "班级不存在,请确认您的邀请码是否输入正确,谢谢!" unless course + + cs = CoursesService.new + status = cs.join_course({invite_code: course.invite_code}, user) + logger.info status + if status[:state] != 0 + raise CoursesService::JoinCourseError.message(status[:state]) + end + + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', + content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } + return request.reply.news(news) do |article, n, index| # article is return object + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect" + pic_url = "#{ROOT_URL}/images/wechat/class.jpg" article.item title: "#{n[:title]}", description: n[:content], pic_url: pic_url, url: url end + end ### controller method module Controllers - def get_open_id + def get_bind begin - code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) raise "无法获取到微信openid" unless openid - render :json => {status:0, openid: openid} + + uw = UserWechat.where(openid: openid).first + raise "还未绑定trustie帐户" unless uw + logger.debug "get_bind ============= #{uw}" + + user = uw.user + ::ApiKey.delete_all(user_id: user.id) + key = ::ApiKey.create!(user_id: user.id) + + render :json =>{status: 0, token: key.access_token} rescue Exception=>e - render :json => {status: -1, msg: e.message} + render :json => {status: -1, message: e.message} end end @@ -175,14 +238,14 @@ class WechatsController < ActionController::Base code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) - raise "无法获取到openid" unless openid - raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid) + raise "无法获取到openid,请在微信中打开本页面" unless openid + raise "此微信号已绑定用户,不能重复绑定" if user_binded?(openid) user, last_login_on = User.try_to_login(params[:username], params[:password]) - raise "用户名或密码错误,请重新输入" unless user + raise "用户名或密码错误,请重新输入" unless user #补全用户信息 - raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat + raise "此用户已经绑定过公众号,请换一个帐户试试" if user.user_wechat UserWechat.create!( openid: openid, @@ -206,19 +269,26 @@ class WechatsController < ActionController::Base def user_activities session[:wechat_code] = params[:code] if params[:code] - code = params[:code] || session[:wechat_code] - openid = get_openid_from_code(code) - @wechat_user = user_binded?(openid) - unless @wechat_user - redirect_to login_wechat_path - return + @path = '/'+(params[:state] || '') + open_id = get_openid_from_code(params[:code]) rescue + unless open_id + render 'wechats/open_wechat', layout: nil and return + end + if params[:state] == 'myclass' + @course_id = params[:id]; end + session[:wechat_openid] = open_id + if params[:code] + redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return + end render 'wechats/user_activities', layout: nil end + private def get_openid_from_code(code) + return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test' openid = session[:wechat_openid] unless openid diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 22b7f1f52..828739cc4 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -54,15 +54,16 @@ class WordsController < ApplicationController :reply_id => reply_user_id, :notes => content, :is_readed => false} - @jfm = add_reply_adapter options + @activity = params[:activity_id].nil? ? JournalsForMessage.find(parent_id) : JournalsForMessage.find(params[:activity_id].to_i) + @jfm = add_reply_adapter(@activity, options) @save_succ = true if @jfm.errors.empty? if @save_succ - update_course_activity('JournalsForMessage',parent_id) - update_user_activity('JournalsForMessage',parent_id) - update_forge_activity('JournalsForMessage',parent_id) - update_org_activity('JournalsForMessage',parent_id) - update_principal_activity('JournalsForMessage',parent_id) - (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) + update_course_activity('JournalsForMessage',@activity.id) + update_user_activity('JournalsForMessage',@activity.id) + update_forge_activity('JournalsForMessage',@activity.id) + update_org_activity('JournalsForMessage',@activity.id) + update_principal_activity('JournalsForMessage',@activity.id) + @activity.update_attribute(:updated_on,Time.now) end respond_to do |format| # format.html { @@ -76,8 +77,6 @@ class WordsController < ApplicationController format.js { #@reply_type = params[:reply_type] @user_activity_id = params[:user_activity_id] - @activity = JournalsForMessage.find(parent_id) - @is_activity = params[:is_activity] if params[:is_activity] } end @@ -92,13 +91,14 @@ class WordsController < ApplicationController elsif @journal_destroyed.jour_type == "Course" @course = Course.find @journal_destroyed.jour_id @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count + @user_activity_id = params[:user_activity_id] if params[:user_activity_id] + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] elsif @journal_destroyed.jour_type == "Principal" @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @is_user = true @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @is_activity = params[:is_activity].to_i if params[:is_activity] - @activity = @journal_destroyed.parent if @journal_destroyed.parent + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] unless @activity redirect_to feedback_path(@user) return @@ -264,6 +264,28 @@ class WordsController < ApplicationController end end + #课程大纲的回复 + def leave_syllabus_message + if User.current.logged? + @user = User.current + @syllabus = Syllabus.find(params[:id]); + if params[:comment].size>0 && User.current.logged? && @user + feedback = Syllabus.add_syllabus_jour(@user, params[:comment], params[:id]) + if (feedback.errors.empty?) + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end + redirect_to syllabus_path(@syllabus) + else + flash[:error] = feedback.errors.full_messages[0] + end + end + else + render_403 + end + end + #作业的回复 def leave_homework_message if User.current.logged? @@ -337,6 +359,27 @@ class WordsController < ApplicationController UserExtensions.introduction(user, message) redirect_to user_url(user.id) end + + #邮箱激活问题留言 留言成功给出提示框 + def leave_email_activation_message + status = 1 #成功 + me = User.find(params[:user]) + if me + #课程使者id=1 + @user = User.find(1) + if params[:text].size>0 && @user + # @user.add_jour(me, params[:text]) + #私信 + message = "【未收到激活邮件的用户反馈,用户邮箱:"+me.mail+"】
"+params[:text] + @user.journals_for_messages << JournalsForMessage.new(:user_id => me.id, :notes => message, :reply_id => 0, :status => true, :is_readed => false, :private => 1) + else + status = 0 + end + render :json => status + else + render_403 + end + end private @@ -374,28 +417,44 @@ class WordsController < ApplicationController obj end - def add_reply_adapter options + def add_reply_adapter obj, options #modify by nwb #添加对课程留言的支持 #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 - obj = obj_distinguish_url_origin || User.find_by_id(2) - if obj.kind_of? User - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Project - Project.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Course - Course.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Bid - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Contest - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? Softapplication - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? HomeworkAttach - obj.add_jour(nil, nil, obj.id, options) #new added - else - raise "create reply obj unknow type.#{obj.class}" + case obj.jour_type + when 'Principal' + obj.jour.add_jour(nil, nil, nil, options) + when 'Project' + Project.add_new_jour(nil, nil, obj.jour_id, options) + when 'Course' + Course.add_new_jour(nil, nil, obj.jour_id, options) + when 'Bid' + obj.jour.add_jour(nil, nil, nil, options) + when 'Contest' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'Softapplication' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'HomeworkAttach' + obj.jour.add_jour(nil, nil, obj.jour_id, options) end + # obj = obj_distinguish_url_origin || User.find_by_id(2) + # if obj.kind_of? User + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Project + # Project.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Course + # Course.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Bid + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Contest + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? Softapplication + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? HomeworkAttach + # obj.add_jour(nil, nil, obj.id, options) #new added + # else + # raise "create reply obj unknow type.#{obj.class}" + # end end #######end of message end diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index fb1231287..e993b120f 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -489,4 +489,26 @@ module ApiHelper self.update_attribute(:praise_num, self.praise_num.to_i - num) end + + class Errors + def self.define_error(arr) + @errors = {} + arr.each_with_index { |item, index| + if index %2 == 1 + @errors[arr[index-1]] = item + end + } + if arr.count % 2== 1 + @default_error = arr.last + else + @default_error = "未知错误" + end + + end + + def self.message(msg_id) + @errors[msg_id] || @default_error + end + end + end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 46fdb02f3..98eb100ed 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -803,22 +803,22 @@ module ApplicationHelper end # 获取Gitlab版本库提交总数 - def commit_count(project) + def commit_count(project, branch) g = Gitlab.client #add by hx - if g.commits(project.gpid , :page=>200).count > 0 + if g.commits(project.gpid, :ref_name => @rev , :page=>200).count > 0 count = 4020 - elsif g.commits(project.gpid , :page=>25).count==0 + elsif g.commits(project.gpid , :page=>25, :ref_name => branch).count==0 count = count_commits(project.gpid , 0 , 25) - elsif g.commits(project.gpid , :page=>50).count ==0 + elsif g.commits(project.gpid , :page=>50, :ref_name => branch).count ==0 count = count_commits(project.gpid , 25 , 50)+ 25 * 20 - elsif g.commits(project.gpid , :page=>75).count ==0 + elsif g.commits(project.gpid , :page=>75, :ref_name => branch).count ==0 count = count_commits(project.gpid , 50 , 75)+ 50 * 20 - elsif g.commits(project.gpid , :page=>100).count== 0 + elsif g.commits(project.gpid , :page=>100, :ref_name => branch).count== 0 count = count_commits(project.gpid , 75 , 100) + 75 * 20 - elsif g.commits(project.gpid , :page=>125).count==0 + elsif g.commits(project.gpid , :page=>125, :ref_name => branch).count==0 count = count_commits(project.gpid , 100 , 125) + 100 * 20 - elsif g.commits(project.gpid , :page=>150).count==0 + elsif g.commits(project.gpid , :page=>150, :ref_name => branch).count==0 count = count_commits(project.gpid , 125 , 150) + 125 * 20 else count = count_commits(project.gpid , 150 ,200) + 150 * 20 @@ -832,7 +832,7 @@ module ApplicationHelper if $g.commits(project_id,:page => page).count == 0 break else - count = count + $g.commits(project_id,:page => page).count + count = count + $g.commits(project_id, :ref_name => @rev, :page => page).count end end return count @@ -1079,6 +1079,8 @@ module ApplicationHelper title << @organization.name elsif @user title << @user.try(:realname) + elsif @syllabus + title << @syllabus.title else title << (User.current.id == 2 ? "未登录" : User.current.try(:realname)) end @@ -3127,6 +3129,26 @@ def get_reply_parents parents_rely, comment parents_rely end +#获取回复的所有父节点(不包括根节点) +def get_reply_parents_no_root parents_rely, comment + if !comment.parent.nil? && !comment.parent.parent.nil? + parents_rely << comment.parent + get_reply_parents_no_root parents_rely, comment.parent + end + parents_rely +end + +#获取留言的所有子节点 +def get_all_children result, jour + if jour.kind_of? JournalsForMessage + jour.children.each do |jour_child| + result << jour_child + get_all_children result, jour_child + end + end + result.sort! { |a,b| b.created_on <=> a.created_on } +end + #将有置顶属性的提到数组前面 def sort_by_sticky topics tmpTopics = [] @@ -3283,3 +3305,20 @@ def get_hw_index(hw,is_teacher) index = hw_ids.index(hw.id) return index end + +def get_group_member_names work + result = "" + unless work.nil? + work.student_work_projects.each do |member| + user = User.where(:id => member.user_id).first + unless user.nil? + if result != "" + result += "、#{user.show_name}" + else + result += user.show_name + end + end + end + end + result +end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index c10652c6f..55a4da73a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -44,9 +44,9 @@ module CoursesHelper def visible_excellent_course obj # if course.is_pu end - + # 返回x项目成员数量,即roles表中定义的所有成员 - def projectCount project + def projectCount project #searchCountByRoles project, AllPeople project.members.count end @@ -147,10 +147,10 @@ module CoursesHelper # 返回学生数量,即roles表中定义的Reporter #def studentCount project - # searchStudent(project).count - # or - # searchStudent(project).count - # end + # searchStudent(project).count + # or + # searchStudent(project).count + # end # 判断用户是否是课程的管理员 # add by nwb @@ -225,11 +225,11 @@ module CoursesHelper #end # 注意:此方法有问题,速度慢且结果不准 - # alias studentCountOrigin studentCount + # alias studentCountOrigin studentCount #def studentCount course - # count = studentCountOrigin course - #garble count - # end + # count = studentCountOrigin course + #garble count + # end #获取课程所有成员 def course_all_member course @@ -265,7 +265,7 @@ module CoursesHelper def garble count count = count.round( 1-count.to_s.size ).to_i return count.to_s if count.to_s.size.eql?(1) - count.to_s << '+' + count.to_s << '+' end # ===================================================================================== @@ -274,7 +274,7 @@ module CoursesHelper #searchPeopleByRoles(project, TeacherRoles) members = [] project.members.includes(:user).each do |m| - members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) + members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) end members end @@ -304,8 +304,8 @@ module CoursesHelper members end - - + + def searchStudent_by_name project, name #searchPeopleByRoles(project, StudentRoles) members = [] @@ -324,29 +324,29 @@ module CoursesHelper mems = [] if name != "" name = name.to_s.downcase - members.each do |m| + members.each do |m| username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) mems << m end end else - mems = members - end + mems = members + end mems end def searchgroupmember_by_name members, name, group #searchPeopleByRoles(project, StudentRoles) mems = [] if name != "" - members.each do |m| - if m.course_group_id == group.id - username = m.user[:lastname].to_s + m.user[:firstname].to_s - if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name)) - mems << m + members.each do |m| + if m.course_group_id == group.id + username = m.user[:lastname].to_s + m.user[:firstname].to_s + if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name)) + mems << m + end + end end - end - end else mems = members end @@ -458,7 +458,7 @@ module CoursesHelper content = content_tag('ul', content) content_tag('div', content, :class => "tabs") end - + def findCourseTime project str = "" begin @@ -671,6 +671,22 @@ module CoursesHelper is_current_term || is_next_term end + #课程大纲下拉框 + def syllabus_option + type = [] + option1 = [] + option1 << "请选择课程" + option1 << 0 + type << option1 + Syllabus.all.each do |syllabus| + option = [] + option << syllabus.title + option << syllabus.id + type << option + end + type + end + #获取课程动态 def get_course_activity courses, activities @course_ids=activities.keys() @@ -683,9 +699,9 @@ module CoursesHelper #file_count Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment| if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin? - activities[attachment.container_id]+=1 + activities[attachment.container_id]+=1 else - activities[attachment.container_id] + activities[attachment.container_id] end end @@ -704,8 +720,8 @@ module CoursesHelper #news News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news| if news.author.member_of_course?(@course) - activities[news.course_id]+=1 - end + activities[news.course_id]+=1 + end end #homework_count @@ -777,6 +793,15 @@ module CoursesHelper result end + def visable_course_homework course + if User.current.admin? || User.current.allowed_to?(:as_teacher,course) + homework_num = course.homework_commons.count + else + homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count + end + homework_num + end + def zh_course_role role if role == "TeachingAsistant" result = l(:label_TA) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index cb06bd688..48b5f068b 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -23,7 +23,7 @@ module OrganizationsHelper when 'activity' then return '动态' when 'course' then - return '课程' + return '班级' when 'project' then return '项目' end diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index 7119d4f60..01320660c 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -7,5 +7,6 @@ module OwnerTypeHelper BID = 6 JOURNALSFORMESSAGE = 7 HOMEWORKCOMMON = 8 - BLOGCOMMENT=9 + BLOGCOMMENT = 9 + SYLLABUS = 10 end \ No newline at end of file diff --git a/app/helpers/quality_analysis_helper.rb b/app/helpers/quality_analysis_helper.rb new file mode 100644 index 000000000..2a7d350e7 --- /dev/null +++ b/app/helpers/quality_analysis_helper.rb @@ -0,0 +1,97 @@ +# encoding: utf-8 +module QualityAnalysisHelper + + def sqale_rating_status val + arr = [] + if val < 5 + arr << "很好" + arr << "b_green2" + elsif val. > 5 && val < 10 + arr << "较好" + arr << "b_slow_yellow" + elsif val > 10 && val < 20 + arr << "中等" + arr << "b_yellow" + elsif val > 20 && val < 50 + arr << "较差" + arr << "b_slow_red" + elsif val > 20 + arr << "很差" + arr << "b_red" + end + end + + def complexity_status val + arr = [] + if val < 10 + arr << "良好" + arr << "b_green2" + elsif val > 10 && val < 15 + arr << "较高" + arr << "b_yellow" + elsif val > 15 + arr << "很高" + arr << "b_red" + end + end + + def duplicated_lines_density_status val + arr = [] + if val < 30 + arr << "良好" + arr << "b_green2" + elsif val > 30 && val < 50 + arr << "较高" + arr << "b_yellow" + elsif val > 50 + arr << "很高" + arr << "b_red" + end + end + + def comment_lines_density_status val + arr = [] + if val < 20 + arr << "较低" + arr << "b_yellow" + elsif val > 20 && val < 50 + arr << "正常" + arr << "b_green2" + elsif val > 50 + arr << "较高" + arr << "b_red" + end + end + + def score_sqale_rating val + if val > 0 && val < 5 + "5" + elsif val > 5 && val < 10 + "4" + elsif val > 10 && val < 20 + "3" + elsif val > 20 && val < 50 + "2" + elsif val > 20 + "1" + end + end + + def lines_scale val + if val.to_i < 5000 + "小型" + elsif val.to_i >5000 && val.to_i < 50000 + "中型" + else + "大型" + end + end + + #统计答题百分比,统计结果保留两位小数 + def statistics_result_percentage(e, t) + e = e.to_f + t = t.to_f + t == 0 ? 0 : format("%.2f", e*100/t) + end + +end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 3cf781f76..b525c4aed 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -41,6 +41,11 @@ module RepositoriesHelper identifiers.include?(iden) ? false :true end + def quality_analysis login, rep_id + long_rep_id = "#{login}:#{rep_id}" + QualityAnalysis.where(:sonar_name => long_rep_id).first + end + # 获取文件目录的最新动态 def get_trees_last_changes(project_id, rev, ent_name) g = Gitlab.client diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb index dac84937b..00331e0dc 100644 --- a/app/helpers/syllabuses_helper.rb +++ b/app/helpers/syllabuses_helper.rb @@ -1,2 +1,72 @@ +# encoding: utf-8 module SyllabusesHelper + def get_syllabuses_by_tag(tag_name) + Syllabus.tagged_with(tag_name).order('updated_at desc') + end + + def teacher_count syllabus + count = 0 + courses = syllabus.courses + unless courses.empty? + courses.each do |c| + count += TeacherAndAssistantCount c + end + end + count + end + + def student_count syllabus + count = 0 + courses = syllabus.courses + unless courses.empty? + courses.each do |c| + count += studentCount c + end + end + count + end + + def file_count syllabus + count = 0 + courses = syllabus.courses + unless courses.empty? + courses.each do |c| + count += visable_attachemnts_incourse(c).count + end + end + count + end + + #课程性质下拉框 + def syllabus_type + type = [] + option1 = [] + option2 = [] + option3 = [] + option4 = [] + option5 = [] + option6 = [] + + option1 << "请选择" + option1 << 1 + option2 << "公共必修课" + option2 << 2 + option3 << "学科必修课" + option3 << 3 + option4 << "专业选修课" + option4 << 4 + option5 << "实践必修课" + option5 << 5 + option6 << "实践选修课" + option6 << 6 + + type << option1 + type << option2 + type << option3 + type << option4 + type << option5 + type << option6 + + type + end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 8847f4163..54753807d 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -23,6 +23,8 @@ module TagsHelper @obj= Course.find_by_id(obj_id) when '10' @obj = Attachment.find_by_id(obj_id) + when '11' + @obj = Syllabus.find_by_id(obj_id) else raise Exception, '[TagsHelper] ===> tag type unknow.' end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 4a6dbc6b6..f312d2275 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -32,7 +32,7 @@ module UsersHelper def get_resource_type type case type when 'Course' - '课程资源' + '班级资源' when 'Project' '项目资源' when 'Issue' @@ -122,11 +122,11 @@ module UsersHelper when 'homework' '作业消息' when 'course_message' - '课程讨论' + '班级讨论' when 'course_news' - '课程通知' + '班级通知' when 'poll' - '课程问卷' + '班级问卷' when 'issue' '项目任务' when 'forge_message' diff --git a/app/models/apply_add_schools.rb b/app/models/apply_add_schools.rb new file mode 100644 index 000000000..2082c0012 --- /dev/null +++ b/app/models/apply_add_schools.rb @@ -0,0 +1,3 @@ +class ApplyAddSchools < ActiveRecord::Base + attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index aa4ef8670..88fadd644 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -24,6 +24,7 @@ class Attachment < ActiveRecord::Base belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" belongs_to :organization, foreign_key: 'container_id', conditions: "attachements.container_type = 'Organization'" + belongs_to :syllabus, foreign_key: 'container_id', conditions: "attachements.container_type = 'Syllabus'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" diff --git a/app/models/course.rb b/app/models/course.rb index e3a845b11..e4b08697b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,3 +1,5 @@ +#coding=utf-8 + require 'elasticsearch/model' class Course < ActiveRecord::Base include Redmine::SafeAttributes @@ -65,7 +67,7 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_course_files, :delete_permission => :manage_files - validates_presence_of :password, :term,:name + validates_presence_of :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 @@ -88,10 +90,12 @@ class Course < ActiveRecord::Base 'description', 'class_period', 'open_student', - 'is_delete' + 'is_delete', + 'syllabus_id' acts_as_customizable + scope :not_deleted, lambda{where(is_delete: 0)} scope :all_course scope :active, lambda { where(:status => STATUS_ACTIVE) } scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } @@ -405,6 +409,7 @@ class Course < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => self.tea_id, :course_id => self.id, :viewed => false) end + #项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题 #def name # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) @@ -422,12 +427,14 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index + return if Rails.env.development? if self.is_public == 1 and self.is_delete == 0 #公开 和 没有被删除的课程才被索引 self.__elasticsearch__.index_document end end def update_course_ealasticsearch_index + return if Rails.env.development? if self.is_public == 1 and self.is_delete == 0 #如果是初次更新成为公开或者恢复被删除的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 begin self.__elasticsearch__.update_document @@ -444,6 +451,7 @@ class Course < ActiveRecord::Base end def delete_course_ealasticsearch_index + return if Rails.env.development? begin self.__elasticsearch__.delete_document rescue => e @@ -451,6 +459,35 @@ class Course < ActiveRecord::Base end end + # 延迟生成邀请码 + def invite_code + return generate_invite_code + end + + # 生成邀请码 + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def generate_invite_code + code = read_attribute(:invite_code) + if !code || code.size <5 + code = CODES.sample(5).join + return generate_invite_code if Course.where(invite_code: code).present? + update_attribute(:invite_code, code) + end + code + end + + + def generate_qrcode + ticket = self.qrcode + if !ticket || ticket.size < 10 + response = Wechat.api.qrcode_create_scene(invite_code) + logger.debug "response = #{response}" + self.qrcode = response['ticket'] + save! && reload + ticket = qrcode + end + ticket + end end diff --git a/app/models/project.rb b/app/models/project.rb index ceec0e182..bbc639f3d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -155,7 +155,7 @@ class Project < ActiveRecord::Base #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} # 创建project之后默认创建一个board,之后的board去掉了board的概念 - after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index + after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index before_destroy :delete_all_members,:delete_project_ealasticsearch_index after_update :update_project_ealasticsearch_index def remove_references_before_destroy diff --git a/app/models/quality_analysis.rb b/app/models/quality_analysis.rb new file mode 100644 index 000000000..8b8034c65 --- /dev/null +++ b/app/models/quality_analysis.rb @@ -0,0 +1,7 @@ +class QualityAnalysis < ActiveRecord::Base + attr_accessible :author_login, :project_id, :rep_identifier, :sonar_version, :branch, :path, :rep_identifier, :language, :sonar_name + + def user_rep_name + self.author_login+":"+self.rep_identifier + end +end diff --git a/app/models/sonar_analysis.rb b/app/models/sonar_analysis.rb new file mode 100644 index 000000000..0bb2089de --- /dev/null +++ b/app/models/sonar_analysis.rb @@ -0,0 +1,3 @@ +class SonarAnalysis < ActiveRecord::Base + attr_accessible :author_login, :project_id, :rep_identifier +end diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb index 7d6319955..5e368f341 100644 --- a/app/models/syllabus.rb +++ b/app/models/syllabus.rb @@ -1,5 +1,46 @@ +# encoding: utf-8 class Syllabus < ActiveRecord::Base + include Redmine::SafeAttributes + include ApplicationHelper + acts_as_taggable + acts_as_attachable + has_many_kindeditor_assets :assets, :dependent => :destroy + belongs_to :user has_many :courses - attr_accessible :description, :title + has_many :journals_for_messages, :as => :jour, :dependent => :destroy + attr_accessible :description, :title, :eng_name, :syllabus_type, :credit, :hours, :theory_hours, :practice_hours, :applicable_major, :pre_course + safe_attributes 'title', 'description', 'eng_name', 'syllabus_type', 'credit', 'hours', 'theory_hours', 'practice_hours', 'credit', 'applicable_major', 'pre_course' + + def delete_kindeditor_assets + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::SYLLABUS + end + + def syllabus_type_str + case self.syllabus_type + when 1 + type = "公共必修课" + when 2 + type = "学科必修课" + when 3 + type = "专业选修课" + when 4 + type = "实践必修课" + when 5 + type = "实践选修课" + end + type + end + + ###添加回复 + def self.add_syllabus_jour(user, notes, id , options = {}) + syllabus = Syllabus.find(id) + if options.count == 0 + jfm = syllabus.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0) + else + jfm = syllabus.journals_for_messages.build(options) + end + jfm.save + jfm + end end diff --git a/app/models/user.rb b/app/models/user.rb index 258fe2ea5..daf1237cf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -145,6 +145,7 @@ class User < Principal has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'" + has_many :course_attachments , :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Course'" #### # added by bai has_many :join_in_contests, :dependent => :destroy @@ -248,7 +249,7 @@ class User < Principal before_save :update_hashed_password before_destroy :remove_references_before_destroy,:delete_user_ealasticsearch_index # added by fq - after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index + after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index,:add_new_jour # end # 更新邮箱用户或用户名的同事,同步更新邀请信息 after_update :update_invite_list,:update_user_ealasticsearch_index @@ -1145,6 +1146,22 @@ class User < Principal end end + #为新注册用户发送留言 + def add_new_jour + if Message.where("id=19278").any? and Message.where("id=19291").any? and Message.where("id=19292").any? + lead_message1 = Message.find(19278) + notes1 = lead_message1.content + # lead_message2 = Message.find(19292) + # notes2 = lead_message2.content + # lead_message3 = Message.find(19291) + # notes3 = lead_message3.content + # # user_id 默认为课程使者创建 + self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes1, :reply_id => 0, :status => true, :is_readed => false, :private => 0) + # self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0) + # self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0) + end + end + # 更新邮箱的同事,更新invite_lists表中的邮箱信息 def update_invite_list invite_lists = InviteList.where("user_id =?",self.id).all diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 2c8387349..f6bf59af0 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -32,6 +32,18 @@ class CoursesService course_list end + + def user_courses_list(current_user) + courses = current_user.courses.not_deleted + courses.inject([]) {|course_list, course| + course_list << {:course => course,:img_url => url_to_avatar(course), + :current_user_is_member => current_user.member_of_course?(course), + :current_user_is_teacher => is_course_teacher(current_user,course), + course_student_num: searchStudent(course).count + } + } + end + #搜索课程 def search_course params,current_user courses_all = Course.all_course @@ -68,7 +80,6 @@ class CoursesService if current_user.nil? || !(current_user.admin? || c.is_public == 1 || (c.is_public == 0 && current_user.member_of_course?(c))) raise '403' end - @teachers= searchTeacherAndAssistant(c) #@canShowCode = isCourseTeacher(User.current.id,course) && params[:role] != '1' case params[:role] when '1' @@ -87,7 +98,11 @@ class CoursesService gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender work_unit = get_user_work_unit m.user location = get_user_location m.user - users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, :work_unit => work_unit, :mail => m.user.mail, :location => location, :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, + :work_unit => work_unit, :mail => m.user.mail, :location => location, + role_name: m.roles.first.name, + name: m.user.show_name, + :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} end users end @@ -162,6 +177,9 @@ class CoursesService #显示课程 def show_course(params,current_user) course = Course.find(params[:id]) + course.generate_invite_code + course.generate_qrcode + if course.school work_unit = course.school.name else @@ -193,8 +211,9 @@ class CoursesService @course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.send(:safe_attributes=, params[:course], current_user) #@course.safe_attributes(current_user,params[:course]) - @course.password = params[:course][:password] + #@course.password = params[:course][:password] @course.tea_id = current_user.id + @course.syllabus_id = params[:syllabus_id].to_i @course.term = params[:term] @course.time = params[:time] @course.end_term = params[:end_term] @@ -252,7 +271,8 @@ class CoursesService def edit_course(params,course,current_user) course.send(:safe_attributes=, params[:course], current_user) #course.safe_attributes = params[:course] - course.password = params[:course][:password] + #course.password = params[:course][:password] + course.syllabus_id = params[:syllabus_id].to_i course.time = params[:time] course.term = params[:term] course.end_time = params[:end_time] @@ -300,23 +320,27 @@ class CoursesService @state end + class JoinCourseError < Errors + define_error [ + 0, '加入成功', + 1, '密码错误', + 2, '课程已过期 请联系课程管理员重启课程。', + 3, '您已经加入了课程', + 4, '您加入的课程不存在', + 5, '您还未登录', + 6, '申请成功,请等待审核完毕', + 7, '您已经发送过申请了,请耐心等待', + 8, '您已经是该课程的教师了', + 9, '您已经是该课程的教辅了', + 10, '您已经是该课程的管理员了', + '未知错误,请稍后再试' + ] + end #加入课程 #object_id:课程id #course_password :加入课程的密码 - #@state == 0 加入成功 - #@state == 1 密码错误 - #@state == 2 课程已过期 请联系课程管理员重启课程。(在配置课程处) - #@state == 3 您已经加入了课程 - #@state == 4 您加入的课程不存在 - #@state == 5 您还未登录 - #@state == 6 申请成功,请等待审核完毕 - #@state == 7 您已经发送过申请了,请耐心等待 - #@state == 8 您已经是该课程的教师了 - #@state == 9 您已经是该课程的教辅了 - #@state == 10 您已经是该课程的管理员了 - #@state 其他 未知错误,请稍后再试 def join_course params,current_user - course = Course.find_by_id params[:object_id] + course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] @state = 10 if course @@ -326,7 +350,7 @@ class CoursesService if current_user.member_of_course?(course) #如果已经是成员 member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] roleName = member.roles[0].name if member - if params[:course_password] == course.password + if params[:invite_code].present? #如果加入角色为学生 并且当前是学生 if params[:role] == "10" && roleName == "Student" @state = 3 @@ -341,7 +365,7 @@ class CoursesService #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" ) #如果已经发送过消息了,那么就要给个提示 - if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 @state = 7 else Mailer.run.join_course_request(course, User.current, params[:role]) @@ -352,19 +376,19 @@ class CoursesService elsif params[:role] == "10" && roleName != "Student" member.role_ids = [params[:role]] member.save - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 end else @state = 1 end else - if params[:course_password] == course.password + if params[:invite_code].present? if params[:role] == "10" || params[:role] == nil members = [] members << Member.new(:role_ids => [10], :user_id => current_user.id) course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 else #如果已经发送过消息了,那么就要给个提示 diff --git a/app/views/account/email_activation.html.erb b/app/views/account/email_activation.html.erb new file mode 100644 index 000000000..9655efcf4 --- /dev/null +++ b/app/views/account/email_activation.html.erb @@ -0,0 +1,58 @@ +
+
+ + + <%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %> + +
+
+ diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb deleted file mode 100644 index 0bebfdf5f..000000000 --- a/app/views/account/register.html.erb +++ /dev/null @@ -1,127 +0,0 @@ -<% @nav_dispaly_home_path_label = 1 - @nav_dispaly_main_course_label = 1 - @nav_dispaly_main_project_label = 1 - @nav_dispaly_main_contest_label = 1 %> -<% @nav_dispaly_forum_label = 1%> - - - - - - -

<%= l(:label_register) %> <%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %>

- -<%= labelled_form_for @user, :url => register_path do |f| %> - <%= error_messages_for 'user' %> -
- - <% if @user.auth_source_id.nil? %> -

<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %> -

-

<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> -

-

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

- <% end %> - -

- <%= f.text_field :mail,:size => 25, :required => true %> - -

-

- -

<%= "#{l(:label_mail_attention)} " %>

-

<%= "#{l(:label_mail_attention1)} " %>

-
-

- - - - -
- -

- - - - -
<%= submit_tag l(:button_submit) %>
-

-<% end %> -<% if Setting.openid? %> -

<%= f.text_field :identity_url %>

-<% end %> -<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> -

<%= custom_field_tag_with_label :user, value %>

-<% end %> - -<% password_min_length = Setting.password_min_length %> - \ No newline at end of file diff --git a/app/views/admin/course_resource_list.html.erb b/app/views/admin/course_resource_list.html.erb index 2e83a96aa..4786bbe89 100644 --- a/app/views/admin/course_resource_list.html.erb +++ b/app/views/admin/course_resource_list.html.erb @@ -39,7 +39,7 @@ <%= number_to_human_size(resource.filesize)%> - 课程资源 + 班级资源 <%= format_date(resource.created_on)%> diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index 6d921903d..1d51e951a 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -2,31 +2,31 @@ <% if defined?(container) && container && container.saved_attachments %> <% if isReply %> <% container.saved_attachments.each_with_index do |attachment, i| %> - +

<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%> <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> - <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "#{i+1}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload', :containerid => "2") %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - +

<% end %> <% else %> <% container.attachments.each_with_index do |attachment, i| %> - +

<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly=>'readonly')%> <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%> - <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "#{i+1}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload', :containerid => "2") %> <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - +

<% end %> <% end %> <% end %> diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 9617b7f76..b1cd86484 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -87,17 +87,14 @@
- <% if @article.try(:author).try(:realname) == ' ' %> - <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% else %> - <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% end %> + <%= link_to @article.author.show_name, user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<%= format_time( @article.created_on)%>
-
- <%= @article.content.html_safe%> -
+ + + + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>@article.id, :content=>@article.content} %>
<%#= link_to_attachments_course @topic, :author => false %> @@ -126,11 +123,6 @@
-
<%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> @@ -146,11 +138,7 @@
- <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to reply.author.show_name, user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
<%= reply.content.html_safe%> @@ -205,12 +193,12 @@
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index d33b75f82..46191b5d3 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -22,7 +22,7 @@
- 课程问答区 + 班级问答区
diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 3b6d55d96..cc7f2fb53 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/app/views/layouts/_syllabus_base_info.html.erb b/app/views/layouts/_syllabus_base_info.html.erb new file mode 100644 index 000000000..cf4926d82 --- /dev/null +++ b/app/views/layouts/_syllabus_base_info.html.erb @@ -0,0 +1,58 @@ +
    + <% if User.current.logged? && (User.current == syllabus.user || User.current.admin?) %> + <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :class => 'fr', :onclick => "show_edit_base_info();"%> + <% end %> +
    +
  • <%=syllabus.user.show_name %>
  • + <% unless syllabus.syllabus_type.nil? || syllabus.syllabus_type == 0 %> +
  • <%=syllabus.syllabus_type_str %>
  • + <% end %> + <% unless syllabus.credit.nil? || syllabus.credit == '' %> +
  • <%=syllabus.credit %>
  • + <% end %> + <% unless syllabus.hours.nil? || syllabus.hours == '' %> +
  • <%=syllabus.hours %>
  • + <% end %> + <% unless syllabus.theory_hours.nil? || syllabus.theory_hours == '' %> +
  • <%=syllabus.theory_hours %>
  • + <% end %> + <% unless syllabus.practice_hours.nil? || syllabus.practice_hours == '' %> +
  • <%=syllabus.practice_hours %>
  • + <% end %> + <% unless syllabus.applicable_major.nil? || syllabus.applicable_major == '' %> +
  • <%=syllabus.applicable_major %>
  • + <% end %> + <% unless syllabus.pre_course.nil? || syllabus.pre_course == '' %> +
  • <%=syllabus.pre_course %>
  • + <% end %> + + <% if syllabus.syllabus_type.nil? || syllabus.syllabus_type == '' %> +
  • + <% end %> + <% if syllabus.credit.nil? || syllabus.credit == '' %> +
  • + <% end %> + <% if syllabus.hours.nil? || syllabus.hours == '' %> +
  • + <% end %> + <% if syllabus.theory_hours.nil? || syllabus.theory_hours == '' %> +
  • + <% end %> + <% if syllabus.practice_hours.nil? || syllabus.practice_hours == '' %> +
  • + <% end %> + <% if syllabus.applicable_major.nil? || syllabus.applicable_major == '' %> +
  • + <% end %> + <% if syllabus.pre_course.nil? || syllabus.pre_course == '' %> +
  • + <% end %> +
+<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?)&&(syllabus.syllabus_type.nil? || syllabus.syllabus_type == ''||syllabus.credit.nil? || syllabus.credit == ''||syllabus.hours.nil? || syllabus.hours == ''||syllabus.theory_hours.nil? || syllabus.theory_hours == ''||syllabus.practice_hours.nil? || syllabus.practice_hours == ''||syllabus.applicable_major.nil? || syllabus.applicable_major == ''||syllabus.pre_course.nil? || syllabus.pre_course == '')%> + +<% end %> + \ No newline at end of file diff --git a/app/views/layouts/_syllabus_edit_info.html.erb b/app/views/layouts/_syllabus_edit_info.html.erb new file mode 100644 index 000000000..4c24fccb9 --- /dev/null +++ b/app/views/layouts/_syllabus_edit_info.html.erb @@ -0,0 +1,27 @@ +
    + <%= form_for('syllabus',:url => update_base_info_syllabus_path(syllabus.id),:remote => true) do |f|%> + 保存 + +
    +
  • <%=syllabus.user.show_name %>
  • +
  • + <%= select_tag :syllabus_type,options_for_select(syllabus_type,syllabus.syllabus_type), {:id=>"syllabus_type_input", :class=>"syllabus_select"} %> +
    +
  • +
  • + 学分 + 请输入正整数
    +
  • +
  • 学时 + 请输入正整数
    +
  • +
  • 学时 + 请输入正整数
    +
  • +
  • 学时 + 请输入正整数
    +
  • +
  • +
  • + <% end %> +
\ No newline at end of file diff --git a/app/views/layouts/_syllabus_eng_name.html.erb b/app/views/layouts/_syllabus_eng_name.html.erb new file mode 100644 index 000000000..6b9b6f3c7 --- /dev/null +++ b/app/views/layouts/_syllabus_eng_name.html.erb @@ -0,0 +1,8 @@ +<% if syllabus.eng_name && !syllabus.eng_name.empty? %> + <%= syllabus.eng_name %> +<% else%> + 课程英文名称 +<% end %> +<% if User.current == syllabus.user %> + <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :onclick => "show_edit_eng_name();"%> +<% end %> \ No newline at end of file diff --git a/app/views/layouts/_syllabus_info.html.erb b/app/views/layouts/_syllabus_info.html.erb new file mode 100644 index 000000000..b67cb4c4d --- /dev/null +++ b/app/views/layouts/_syllabus_info.html.erb @@ -0,0 +1,22 @@ +<% teachers_num = teacher_count @syllabus%> +<% students_num = student_count @syllabus%> +<% files_num = file_count @syllabus%> + +
+

<%=@syllabus.title %>

+
+
+
+
+
+ <%= render :partial => 'layouts/syllabus_eng_name', :locals => {:syllabus => @syllabus}%> +
+ +
+
+ 教师(<%=teachers_num %>| + 学生(<%=students_num %>| + 资源(<%=files_num %>
+
\ No newline at end of file diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 0675c8a4a..689c1268a 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -52,7 +52,7 @@ <% name = name%> <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> - " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户、资源以及帖子" onkeypress="search_in_header_I(event,$(this));"/> + " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的班级、项目、用户、资源以及帖子" onkeypress="search_in_header_I(event,$(this));"/> diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index ff18e68bd..31f06689d 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -2,7 +2,7 @@
  • <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", - :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+"("+current_time_and_term(course)+")"%> + :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> @@ -47,7 +47,13 @@ <%= link_to "+",course_boards_path(course, :flag => true, :is_new => 1), :class => 'fr fb', :title => '发布帖子',:target => '_blank' %>
  • - <% if User.current == @user %> + <% if type=='User' && !course.syllabus.nil? %> + + <% end %> + <% if User.current == user %> <% end %> -<% if courses.size == 5%> +<% if all_count > (page.to_i+1) * 5%>
  • - +
  • <% end%> + + + + + +<% is_current_user = User.current.logged?%> + +
    +
    +
    +
    +
    + <%=render :partial => 'layouts/syllabus_info' %> +
    + <% update_visiti_count @syllabus %> + +
    + <%= render :partial => 'layouts/syllabus_base_info', :locals => {:syllabus => @syllabus} %> +
    + +
    +
    + <%=link_to '班级', {:controller => "syllabuses", :action => "syllabus_courselist", :id => @syllabus.id}, :class => 'homepageMenuText' %> + <% if is_current_user%> + <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> +
    +
      +
    • +
        +
      • + <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "menuGrey", :target => '_blank'%> +
      • +
      • + <%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%> +
      • +
      +
    • +
    +
    + <% else%> + <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入班级"%> + <% end%> + <% end%> +
    + <% courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> + <% all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count%> +
    +
    +
      + <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => User.current,:all_count => all_count,:type =>'Syllabus',:page => 0} %> +
    +
    + <% if !courses.empty? %> +
    + +
    + <% end %> +
    +
    + +
    +

    标签:

    +
    + <%= render :partial => 'tags/syllabus_tag', :locals => {:obj => @syllabus,:object_flag => "11"}%> +
    +
    +
    +
    访问计数 <%=@syllabus.visits %> (自2016年7月)
    + +
    +
    + <%= yield %> +
    +
    + <%= render :partial => 'layouts/new_feedback' %> +
    +
    +<%= render :partial => 'layouts/footer' %> +
    + + + + + + diff --git a/app/views/layouts/base_tags.html.erb b/app/views/layouts/base_tags.html.erb index 08ebb02d7..cfbf6cec9 100644 --- a/app/views/layouts/base_tags.html.erb +++ b/app/views/layouts/base_tags.html.erb @@ -12,7 +12,7 @@ <%= csrf_meta_tag %> <%= favicon %> -<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application','prettify', :media => 'all' %> +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application','prettify','public', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_include_tag 'prettify' %> <%= javascript_heads %> diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index 6a16940fc..92a99b3b6 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -203,7 +203,7 @@ <% end %> <% end %> <% if (get_join_course_count(@user) != 0) %> -
  • 加入课程 :
  • +
  • 加入班级 :
  • <% end %> <% if @user.user_extensions.identity == 1 %>
  • 参加匿评 :
  • diff --git a/app/views/layouts/new_base.html.erb b/app/views/layouts/new_base.html.erb index e7695f0e7..4922882b9 100644 --- a/app/views/layouts/new_base.html.erb +++ b/app/views/layouts/new_base.html.erb @@ -13,7 +13,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> - <%= stylesheet_link_tag 'public', 'leftside', 'courses','header','prettify', 'org'%> + <%= stylesheet_link_tag 'public', 'leftside', 'courses','header','prettify', 'org', 'syllabus'%> <%= javascript_include_tag "course","header",'prettify' %> <%= yield :header_tags -%> diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 8455d5693..776de074b 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users',:media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users','syllabus',:media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%> @@ -198,18 +198,21 @@
    • - <%= link_to "新建课程", new_course_path(:host=> Setting.host_course), :class => "menuGrey"%> + <%= link_to "新建课程", new_syllabus_path(:host=> Setting.host_course), :class => "menuGrey"%> +
    • +
    • + <%= link_to "新建班级", new_course_path(:host=> Setting.host_course), :class => "menuGrey"%>
    • - <%= link_to "加入课程",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%> + <%= link_to "加入班级",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%>
  • <% else%> - <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入课程"%> + <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入班级"%> <% end%> <% end%>
    @@ -227,10 +230,11 @@ end %> <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> + <% all_count = @user.courses.visible.where("is_delete =?", 0).count%>
      - <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %> + <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user,:all_count => all_count,:type =>'User',:page => 0} %>
    <% if !courses.empty? %> diff --git a/app/views/mailer/register.html.erb b/app/views/mailer/register.html.erb index 282deca90..5b4e8262b 100644 --- a/app/views/mailer/register.html.erb +++ b/app/views/mailer/register.html.erb @@ -1,2 +1,6 @@

    <%= l(:mail_body_register) %>
    <%= link_to h(@url), @url %>

    +

    如果点击链接无效请复制该链接到浏览器中打开

    +
    +

    感谢您的使用!

    +

    Trustie团队

    diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 9b3e82447..69e36ca34 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -81,11 +81,6 @@
    回复(<%=@reply_count %>)
    - - - - -
    <% @replies.each_with_index do |reply,i| %> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 746881bdc..560925070 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -71,11 +71,7 @@
    - <% if @topic.try(:author).try(:realname) == ' ' %> - <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% else %> - <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% end %> + <%= link_to @topic.author.show_name, user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
    <%= format_time( @topic.created_on)%>
    @@ -114,11 +110,7 @@
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to reply.author.show_name, user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
    <%= reply.content.html_safe%> diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb index 145afcfd7..e5455bc85 100644 --- a/app/views/messages/_org_subfield_show.html.erb +++ b/app/views/messages/_org_subfield_show.html.erb @@ -103,11 +103,7 @@
    - <% if @topic.try(:author).try(:realname) == ' ' %> - <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% else %> - <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% end %> + <%= link_to @topic.author.show_name, user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
    <%= format_time( @topic.created_on)%>
    @@ -127,11 +123,6 @@
    回复(<%=@reply_count %>)
    -
    <% @replies.each_with_index do |reply,i| %> @@ -147,11 +138,7 @@
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to reply.author.show_name, user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
    <%= reply.content.html_safe%> diff --git a/app/views/my/_apply_add_school.html.erb b/app/views/my/_apply_add_school.html.erb new file mode 100644 index 000000000..1449fa1f1 --- /dev/null +++ b/app/views/my/_apply_add_school.html.erb @@ -0,0 +1,337 @@ +

    添加新的高校(单位)

    +
    +
      +
    • + + + +
    • +
    • + + 例如:国防科学技术大学 + 国防科大计算机1班 +
    • +
    • + + + + +
    • +
    • + + +
    • +
    • +
      +
    • +
    + + diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 9cca5da5c..589541c39 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -15,14 +15,13 @@ <%= error_messages_for 'user',@user.user_extensions %> <% end %>
      -
    • 登录名 : *
    • -
    • 邮箱 : *
    • -
    • 身份 : *
    • -
    • 姓(Last Name) : *
    • -
    • 名(First Name) : *
    • +
    • *  登录名 : 
    • +
    • *  邮箱 : 
    • +
    • *  职业 : 
    • +
    • *  姓名 : 
    • 组织名 : *
    • -
    • 性别 : 
    • -
    • 工作单位 : 
    • +
    • *  性别 : 
    • +
    • *  单位名称 : 
    • 地区 : 
    • 邮件通知 : 
    • @@ -65,34 +64,50 @@ -
    • <%= f.text_field :lastname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %> -
    • <%= f.text_field :firstname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %> -
    • <%= text_field_tag :enterprise_name,@user.firstname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %> +
    • <%= text_field_tag :lastname,@user.lastname+@user.firstname,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210" %> +
    • - + <% if User.current.user_extensions && User.current.user_extensions.gender && User.current.user_extensions.gender == 1 %> + + <% else %> + + <% end %> +
    • <% if User.current.user_extensions.nil? %> - - - - + + +

      + + +

      + <% elsif User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %> - - - - + + +

      + + +

      + <% elsif User.current.user_extensions.school.nil? %> - - - - + + +

      + + +

      + <% else %> - - - - + + +

      + + +

      + <% end %>
    • @@ -140,13 +155,13 @@
    • <%= select_tag( 'user[mail_notification]', options_for_select( user_mail_notification_options(@user), @user.mail_notification) ) %> - +
    • <%= f.select :language, :Chinese => :zh, :English => :en %>
    • - 确认 + 确定
    • @@ -429,6 +444,7 @@ $("*[nh_required='1']",$(this)).attr("required",true); $(this).show() }); + $("#identity_hint").hide(); } function init_identity_and_title(pField, identity, cField, title, language) { for (var i = 0; i < pField.options.length; i++) { @@ -533,6 +549,14 @@ $("input[name='occupation']").val(data); $("#search_school_result_list").hide(); $("#hint").hide(); + $("#errortip").hide(); + + } + + function apply_add_school(){ + var htmlvalue = "<%= escape_javascript( render :partial => 'my/apply_add_school' )%>"; + pop_up_box(htmlvalue,580,20,48); + } function add_school(name){ $.ajax({ @@ -619,16 +643,19 @@ $("#search_school_result_list").show(); if($(e.target).val().trim() != '') { str = e.target.value.length > 8 ? e.target.value.substr(0, 6)+"..." : e.target.value; - $("#hint").html('找到了' + count + '个包含"' + str + '"的高校'); + $("#hint").html('找到了' + count + '个包含"' + str + '"的高校(单位)'); $("#hint").show(); + $("#errortip").hide(); }else{ $("#hint").hide(); + $("#errortip").hide(); } }else{ $("#search_school_result_list").html(''); str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; - $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); + $("#hint").html('您输入的名称尚不存在,申请添加'); $("#hint").show(); + $("#errortip").show(); } } }); @@ -638,6 +665,7 @@ { $("#search_school_result_list").hide(); $("#hint").hide(); + $("#errortip").hide(); } }); $("input[name='province']").on('focus', function (e) { @@ -665,16 +693,19 @@ $("#search_school_result_list").show(); if($(e.target).val().trim() != '') { str = e.target.value.length > 8 ? e.target.value.substr(0, 6)+"..." : e.target.value; - $("#hint").html('找到了' + count + '个包含"' + str + '"的高校'); + $("#hint").html('找到了' + count + '个包含"' + str + '"的高校(单位)'); $("#hint").show(); + $("#errortip").hide(); }else{ $("#hint").hide(); + $("#errortip").hide(); } }else{ $("#search_school_result_list").html(''); str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; - $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); + $("#hint").html('您输入的名称尚不存在,申请添加'); $("#hint").show(); + $("#errortip").show(); } } }); @@ -702,19 +733,41 @@ <% if( !@act.nil? && @act == 'password') %> $("#users_tb_2").click(); <% end %> - $('#my_account_form_link').click(function(e){ + + $('#my_account_form_link').on("click",(function(e){ + //$('#my_account_form_link').click(function(e){ if($("#userIdentity").val() == -1 ) { $("#identity_hint").html('请选择身份').show(); e.stopImmediatePropagation(); return; } if( $("input[name='province']").val().trim() != '' && $("input[name='occupation']").val().trim() == ''){ //学校名字和id不对的话 - $("#hint").html('学校必须是从下拉列表中选择的,不能手动修改').show(); + $("#hint").html('单位名称必须是从下拉列表中选择的,不能手动修改').show(); + e.stopImmediatePropagation(); + return; + } + + //姓名不能为空 + if( $("#lastname").val() == '' ){ + $("#lastname").focus(); + e.stopImmediatePropagation(); + return; + } + + if( $("input[name='province']").val().trim() == '' ){ //学校名字必须填写 + $("#hint").html('高校(单位)名称不能为空').show(); e.stopImmediatePropagation(); return; } + + if($("#no").is(":visible") == true && $("#no").val() == ""){ + $("#no").focus(); + e.stopImmediatePropagation(); + return; + } + $('#my_account_form_btn').click(); - }); + })); $('#my_password_form_link').click(function(){ $('#my_password_form_btn').click(); }); diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 245ee4104..94d0d9d23 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -21,7 +21,7 @@
      - 课程通知 + 班级通知
      <% if @course && User.current.allowed_to?(:manage_news, @course) %> diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index b15dce2c6..9ca522e97 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -24,12 +24,12 @@
      -
      请选择关联到组织的课程
      -
      您的私有课程不能被关联到组织
      +
      请选择关联到组织的班级
      +
      您的私有班级不能被关联到组织
      <%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> - +
      关联 diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb index 97bc0e353..86a9a8199 100644 --- a/app/views/organizations/_org_course_create.html.erb +++ b/app/views/organizations/_org_course_create.html.erb @@ -12,7 +12,7 @@ <%= link_to activity.try(:teacher).try(:realname), user_url_in_org(activity.tea_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.name.to_s+" | 课程", course_url_in_org(activity.id), :class => "newsBlue ml15" %> + <%= link_to activity.name.to_s+" | 班级", course_url_in_org(activity.id), :class => "newsBlue ml15" %>
      <%= link_to activity.name, course_url_in_org(activity.id), :class => "postGrey" %> diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index e33787a09..8d8f591c4 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -12,7 +12,7 @@ <% else %> <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_url_in_org(activity.course.id), :class => "newsBlue ml15"%> + <%= link_to activity.course.name.to_s+" | 班级作业", homework_common_index_url_in_org(activity.course.id), :class => "newsBlue ml15"%>
      \ No newline at end of file +
      + + \ No newline at end of file diff --git a/app/views/organizations/_org_custom_left2.html.erb b/app/views/organizations/_org_custom_left2.html.erb index 2c389766f..feedf2a44 100644 --- a/app/views/organizations/_org_custom_left2.html.erb +++ b/app/views/organizations/_org_custom_left2.html.erb @@ -2,7 +2,7 @@ <% if is_default_field?(field) %> <% case field.name %> <% when 'course' %> -

      课程动态

      +

      班级动态

      <% if @course_acts.blank? %>

      该模块暂时没有相关内容

      <% else %> diff --git a/app/views/organizations/_org_custom_left3.html.erb b/app/views/organizations/_org_custom_left3.html.erb index fb2b83dd2..ff412d869 100644 --- a/app/views/organizations/_org_custom_left3.html.erb +++ b/app/views/organizations/_org_custom_left3.html.erb @@ -71,7 +71,7 @@ <% end %> <% end %>
      - <% unless acts[1..4].nil? %> + <% unless acts[1..4].blank? %> <% acts[1..4].each do |activity| %> <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' %> <% document = activity.org_act %> @@ -110,10 +110,10 @@ <% end %> <% end %>
    - <% unless acts[5..16].nil? %> + <% unless acts[5..16].blank? %>
      - <% acts[6..16].each do |activity| %> + <% acts[5..16].each do |activity| %> <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' %> <% document = activity.org_act %>
    • <%= link_to "#{document.title}".html_safe, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), class: 'por_hidden_w270 link-black', :target => "_blank" %>
    • diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index ddc504640..9d043fbb5 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -63,9 +63,9 @@ <% when 'course' %>
      - 课程 + 班级 <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联班级"%> <% end %>
      diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb index 245651daf..19a6f0eaa 100644 --- a/app/views/organizations/_org_subfield_message.html.erb +++ b/app/views/organizations/_org_subfield_message.html.erb @@ -6,11 +6,7 @@
      - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% end %> + <%= link_to activity.author.show_name, user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> TO <%= link_to activity.board.org_subfield.name.to_s+" | 帖子栏目讨论区",organization_path(activity.board.org_subfield.organization, :org_subfield_id => activity.board.org_subfield.id), :class => "newsBlue ml15 mr5"%>
      @@ -80,17 +76,7 @@ <% count=activity.children.count%> <% end %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% activity= activity.parent_id.nil? ? activity : activity.parent %> <% comments = activity.children.reorder("created_on desc").limit(3) %> diff --git a/app/views/organizations/_org_subfield_news.html.erb b/app/views/organizations/_org_subfield_news.html.erb index 22f88e91b..d6e27daf1 100644 --- a/app/views/organizations/_org_subfield_news.html.erb +++ b/app/views/organizations/_org_subfield_news.html.erb @@ -6,11 +6,8 @@
      - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.org_subfield.name.to_s+" | 帖子栏目通知", organization_path(activity.org_subfield.organization, :org_subfield_id => activity.org_subfield.id), :class => "newsBlue ml15" %>
      <% count=activity.comments.count %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#= format_date(activity.updated_on) %>
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index cfbbcb5e6..06950258e 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -71,21 +71,8 @@ <% count = document.children.count() %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>document, :user_activity_id=>document.id,:type=>"activity"}%> - -
      - <% if count > 3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => document, :user_activity_id => document.id} %> +
      <%= render :partial => 'users/all_replies', :locals => {:comments => comments_for_doc}%>
      diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 2c7d36fb5..6961fcbac 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -55,6 +55,12 @@ <%= link_to "+"+l(:project_gitlab_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %> <% end %>
      + + <% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %> + + <% end %> <% end %> diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb index c823f5ed0..1708d0a33 100644 --- a/app/views/projects/_new_join.html.erb +++ b/app/views/projects/_new_join.html.erb @@ -30,8 +30,8 @@ :remote => true, :method => :post, :id => 'new_join_course') do %> - - <%= text_field_tag 'course_password', nil, :style=>'width:300px;'%> + + <%= text_field_tag 'invite_code', nil, :style=>'width:300px;'%>
      - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>
      <% count=activity.comments.count %>
      - + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index bced1e936..d0f46611e 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -48,7 +48,7 @@ var last_name = $.trim($('#last_name').val()); if(last_name.length > 30) { - $("#valid_email").text("用户姓氏过长,最长为30个字符"); + $("#valid_email").text("用户姓名过长,最长为30个字符"); return false; } else diff --git a/app/views/quality_analysis/_console_output.html.erb b/app/views/quality_analysis/_console_output.html.erb new file mode 100644 index 000000000..45115b9fe --- /dev/null +++ b/app/views/quality_analysis/_console_output.html.erb @@ -0,0 +1,8 @@ +<%= javascript_include_tag 'highcharts','highcharts-more' %> +
      +

      质量分析

      +
      +

      + <%= h @console_build.to_json.html_safe %> +

      + diff --git a/app/views/quality_analysis/_edit.html.erb b/app/views/quality_analysis/_edit.html.erb new file mode 100644 index 000000000..f508ee5de --- /dev/null +++ b/app/views/quality_analysis/_edit.html.erb @@ -0,0 +1,23 @@ +
      代码质量分析
      +
      + <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'update_jenkins_job', :project_id => @project.id), :id => 'quality_analyses_edit_form') do %> +
      +
      + +
      +
      +
      + <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @quality_analysis.branch), :value => 77, :id => 'branch', :class => "analysis-option-box" %> +
      +
      +
      +
      + <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"], "#{@quality_analysis.language}"), :id => 'branch', :class => "analysis-option-box" %> +
      +
      + + +
      +
      + <% end %> +
      diff --git a/app/views/quality_analysis/_hightchars.html.erb b/app/views/quality_analysis/_hightchars.html.erb new file mode 100644 index 000000000..9e6cdf5aa --- /dev/null +++ b/app/views/quality_analysis/_hightchars.html.erb @@ -0,0 +1,483 @@ + \ No newline at end of file diff --git a/app/views/quality_analysis/_result_list.html.erb b/app/views/quality_analysis/_result_list.html.erb new file mode 100644 index 000000000..51d91c04f --- /dev/null +++ b/app/views/quality_analysis/_result_list.html.erb @@ -0,0 +1,30 @@ + +
      +

      分析结果

      +
      +
        +
      • 名称
      • +
      • 分支
      • +
      • 语言
      • +
      • 路径
      • +
      • 编辑
      • + +
        +
      +<% if @quality_analyses.count >0 %> + <% @quality_analyses.each do |qa| %> +
        +
      • <%=link_to "#{qa.author_login}:#{qa.rep_identifier}", project_quality_analysis_path(:resource_id => qa.sonar_name, :branch => (qa.branch.nil? ? "master" : qa.branch)), :class => "analysis-result-name fl fontBlue2" %>
      • +
      • <%= qa.branch %>
      • +
      • <%= qa.language %>
      • +
      • <%= qa.path %>
      • +
      • <%=link_to "编辑", edit_project_quality_analysi_path(qa, :project_id => @project.id), :remote => true %>
      • +
        +
      + <% end %> +<% end %> + + diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb new file mode 100644 index 000000000..1a7869fd0 --- /dev/null +++ b/app/views/quality_analysis/_show.html.erb @@ -0,0 +1,133 @@ +<%= javascript_include_tag 'highcharts','highcharts-more' %> +
      +

      质量分析

      +
      +
      当前分支:<%= params[:branch] %>
      +
      +
      项目代码质量分析报告
      +
      概要信息
      +<% if @complexity["msr"].count > 3 %> + <%= render :partial => "hightchars" %> +
      +
      +
      +

      +

      质量等级

      +

      <%= @complexity["msr"][9].nil? ? "A" : @complexity["msr"][9]["frmt_val"] %> + borderRadius"><%= @complexity["msr"][9].blank? ? "很好" : sqale_rating_status(@complexity["msr"][9]["val"].to_i)[0] %>

      +
      +
      +

      +

      复杂度

      +

      <%= @complexity["msr"][6].nil? ? 0 : @complexity["msr"][6]["val"] %> + borderRadius"><%= @complexity["msr"][6].nil? ? 0 : complexity_status(@complexity["msr"][6]["val"].to_i)[0] %>

      +
      +
      +
      +
      +

      +

      代码重复度

      +

      <%= @complexity["msr"][7].nil? ? 0 : @complexity["msr"][7]["frmt_val"] %> + borderRadius"><%= @complexity["msr"][7].nil? ? 0 : duplicated_lines_density_status(@complexity["msr"][7]["val"].to_i)[0] %>

      +
      +
      +

      +

      注释率

      +

      <%= @complexity["msr"][5].nil? ? 0 : @complexity["msr"][5]["frmt_val"] %> + borderRadius"><%= @complexity["msr"][5].nil? ? 0 : comment_lines_density_status(@complexity["msr"][5]["val"].to_i)[0] %>

      +
      +
      +
      +<% end %> + +
      质量等级<%=@complexity["msr"][9].nil? ? 0 : score_sqale_rating(@complexity["msr"][9]["val"].to_i) %>/5分 + 可定性评价为:质量<%=@complexity["msr"][9].nil? ? "很好" : sqale_rating_status(@complexity["msr"][9]["val"])[0] %>
      + +
      代码规模可定性评价为:<%=@complexity["msr"][0].nil? ? 0 : lines_scale(@complexity["msr"][0]["frmt_val"].to_i) %>
      +
      +
      +

      代码行数

      +

      <%= @complexity["msr"][0].nil? ? 0 : @complexity["msr"][0]["frmt_val"] %>

      +
      +
      +

      文件

      +

      <%= @complexity["msr"][2].nil? ? 0 : @complexity["msr"][2]["frmt_val"] %>

      +
      +
      +

      目录

      +

      <%= @complexity["msr"][3].nil? ? 0 : @complexity["msr"][3]["frmt_val"] %>

      +
      +
      +

      +

      <%= @complexity["msr"][1].nil? ? 0 : @complexity["msr"][1]["frmt_val"] %>

      +
      +
      +

      方法

      +

      <%=@complexity["msr"][4].nil? ? 0 : @complexity["msr"][4]["frmt_val"] %>

      +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/views/quality_analysis/create.html.erb b/app/views/quality_analysis/create.html.erb new file mode 100644 index 000000000..e7c81f662 --- /dev/null +++ b/app/views/quality_analysis/create.html.erb @@ -0,0 +1,9 @@ +<% if @current_build_status == "success" %> + <%= render :partial => "show", :locals => {:branch => params[:branch]} %> +<% else %> + <% if @build_console_result %> + 运行结果超时 + <% else %> + <%= render :partial => "console_output" %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/quality_analysis/create.js.erb b/app/views/quality_analysis/create.js.erb new file mode 100644 index 000000000..abe8c4a6e --- /dev/null +++ b/app/views/quality_analysis/create.js.erb @@ -0,0 +1,11 @@ +$("#ajax-indicator").hide(); +<% if @current_build_status == "success" %> + <%= escape_javascript( render :partial => 'quality_analysis/show', :locals => {:branch => branch}) %> +<% elsif @current_build_status == "failure" %> + <%=h @console_build.html_safe %> +<% elsif @current_build_status == "not_run" %> + alert('任务启动失败'); +<% else %> + alert('你已经创建类一个同名job'); +<% end %> + diff --git a/app/views/quality_analysis/edit.js.erb b/app/views/quality_analysis/edit.js.erb new file mode 100644 index 000000000..4277ae28e --- /dev/null +++ b/app/views/quality_analysis/edit.js.erb @@ -0,0 +1,8 @@ +$('#ajax-modal').html('<%= escape_javascript( render :partial => 'quality_analysis/edit', :locals => {}) %>'); +showModal('ajax-modal', '615px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","20%").css("left","32%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); + + diff --git a/app/views/quality_analysis/index.html.erb b/app/views/quality_analysis/index.html.erb new file mode 100644 index 000000000..19b5c5eea --- /dev/null +++ b/app/views/quality_analysis/index.html.erb @@ -0,0 +1,14 @@ +<% if @name_flag %> + <%= render :partial => "result_list" %> +<% else %> + <% if params[:current_build_status].nil? || params[:current_build_status] == "success" %> + <%= render :partial => "show", :locals => {:branch => params[:branch]} %> + <% else %> + <% if params[:build_console_result] %> + 运行结果超时 + <% else %> + <%= render :partial => "console_output" %> + <% end %> + <% end %> +<% end %> + diff --git a/app/views/quality_analysis/show.html.erb b/app/views/quality_analysis/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/repositories/_quality_analysis.html.erb b/app/views/repositories/_quality_analysis.html.erb new file mode 100644 index 000000000..0053849a3 --- /dev/null +++ b/app/views/repositories/_quality_analysis.html.erb @@ -0,0 +1,23 @@ +
      代码质量分析
      +
      + <%= form_tag( url_for(:controller => 'quality_analysis', :action => 'create', :project_id => @project.id, :user_id => User.current.id, :identifier => @repository.identifier, :rep_id => @repository.id), :id => 'quality_analyses_form') do %> +
      +
      + +
      +
      +
      + <%= select_tag :branch, options_for_select(["#{@gitlab_default_branch}"]+ @branch_names, @rev), :id => 'branch', :class => "analysis-option-box" %> +
      +
      +
      +
      + <%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %> +
      +
      + + +
      +
      + <% end %> +
      diff --git a/app/views/repositories/quality_analyses.html.erb b/app/views/repositories/quality_analyses.html.erb new file mode 100644 index 000000000..69dae2629 --- /dev/null +++ b/app/views/repositories/quality_analyses.html.erb @@ -0,0 +1,76 @@ +<%= javascript_include_tag 'highcharts','highcharts-more' %> +
      +

      <%= l(:label_quality_analyses) %>

      +
      + +
      + <%#= render :partial => 'navigation' %> +
      +
      + +
      +
      +
      +
      + + + +

      <%= link_to l(:button_back), :action => 'show', :id => @project %>

      +<% html_title(l(:label_repository), l(:label_statistics)) -%> \ No newline at end of file diff --git a/app/views/repositories/quality_analysis.js.erb b/app/views/repositories/quality_analysis.js.erb new file mode 100644 index 000000000..bafe28cdf --- /dev/null +++ b/app/views/repositories/quality_analysis.js.erb @@ -0,0 +1,8 @@ +$('#ajax-modal').html('<%= escape_javascript( render :partial => 'repositories/quality_analysis', :locals => {}) %>'); +showModal('ajax-modal', '615px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","20%").css("left","32%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); + + diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 43be57760..8164a103f 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -1,8 +1,18 @@ <%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>

      <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

      - ZIP下载 - + <% unless @entries.nil? %> + ZIP下载 + <%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%# if User.current.member_of?(@project) %> + <% if quality_analysis(User.current.try(:login), @repository.id).nil? && is_project_manager?(User.current.id, @project.id) && @project.is_public? %> + <%= link_to "质量分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch ), :remote => true, :class => "btn_zipdown fr" %> + <% end %> + <%# end %> + <%# else %> + <%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %> + <%# end %> + <% end %>
      <% if @entries.nil? %> @@ -45,7 +55,7 @@
      <%= @changesets_latest_coimmit.message %>
      <% else %> - +
      提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
      <%= @changesets_latest_coimmit.message %>
      @@ -57,7 +67,6 @@ <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交 -
      <% end %> diff --git a/app/views/student_work/_evaluation_title.html.erb b/app/views/student_work/_evaluation_title.html.erb index 6a89b51b1..9875a4cc6 100644 --- a/app/views/student_work/_evaluation_title.html.erb +++ b/app/views/student_work/_evaluation_title.html.erb @@ -1,13 +1,9 @@ - - <% if @homework.homework_type != 3 %> - + diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb index c4a6a3e9b..1b3683506 100644 --- a/app/views/student_work/_evaluation_un_title.html.erb +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -1,7 +1,3 @@ - -
      序号  作品名称作品名称 姓名
      diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 4ca5a8f2d..c4df9e715 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -4,6 +4,7 @@
    • 上交时间: <%=format_time work.created_at %> + 收起
    • <% if work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 5d9df57c1..6bdc3753e 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -118,12 +118,14 @@ remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %> <% end%> -
    • - <%= link_to("导出缺评情况", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> -
    • -
    • - <%= link_to("导出匿评情况", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> -
    • + <% if @homework.anonymous_comment == 0 %> +
    • + <%= link_to("导出缺评情况", absence_penalty_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> +
    • +
    • + <%= link_to("导出匿评情况", evaluation_list_student_work_index_path(:homework => @homework.id, :format => 'xls'),:class=>'hworkExport resourcesGrey')%> +
    • + <% end %>
    • 评分设置
    • diff --git a/app/views/student_work/index.js.erb b/app/views/student_work/index.js.erb index da2428316..16aac9945 100644 --- a/app/views/student_work/index.js.erb +++ b/app/views/student_work/index.js.erb @@ -1,4 +1,2 @@ $("#homework_student_work_list").html("<%= escape_javascript(render :partial => 'student_work/student_work_list') %>"); $("#export_student_work").replaceWith("<%= escape_javascript( link_to "导出作业成绩", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :group => @group, :name => @name, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => 'export_student_work') %>"); -/* -$("th").each(function(){$(this).css("width",$(this).width()-1);});*/ diff --git a/app/views/student_work/search_course_students.js.erb b/app/views/student_work/search_course_students.js.erb index 2ac4eeaab..65179317f 100644 --- a/app/views/student_work/search_course_students.js.erb +++ b/app/views/student_work/search_course_students.js.erb @@ -8,19 +8,19 @@ $("#all_students_list").empty(); $("#all_students_list").append(link); var str = $("#group_member_ids").val(); - /*var str = ""; + var choose_str = ""; var lists = $("#choose_students_list li"); if(lists.length > 0) { for(var i=0; i - if (str.indexOf(<%=user.id.to_s %>) < 0) { + if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) { $("#student_<%=user.id %>").one("click",function choose_student() { var li = "
    • diff --git a/app/views/syllabuses/_delete_syllabus.html.erb b/app/views/syllabuses/_delete_syllabus.html.erb new file mode 100644 index 000000000..fbc0a0995 --- /dev/null +++ b/app/views/syllabuses/_delete_syllabus.html.erb @@ -0,0 +1,17 @@ +
      +
      + <% if @syllabus.courses.empty? %> + 确认删除该课程吗? + <% else %> + 该课程下已经存在班级,不能删除。 + <% end %> +
      +
      +
      + <% if @syllabus.courses.empty? %> + <%=link_to '确认', syllabus_path(@syllabus), :class => 'Blue-btn fl', :method => 'delete'%> + 关闭 + <% else %> + 关闭 + <% end %> +
      \ No newline at end of file diff --git a/app/views/syllabuses/_syllabus_course_list.html.erb b/app/views/syllabuses/_syllabus_course_list.html.erb new file mode 100644 index 000000000..2667a2baa --- /dev/null +++ b/app/views/syllabuses/_syllabus_course_list.html.erb @@ -0,0 +1,72 @@ +
      +

      班级列表

      +
      +
      + 排序: + <%= link_to "时间", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 1 %> + <%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> + <%= link_to "人气", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 2 %> + <%= link_to "", {:controller => 'syllabuses', :action => 'syllabus_courselist', :id =>@syllabus, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> +
      +

      创建老师:<%=@syllabus.user.show_name %> 创建时间:<%=format_date @syllabus.created_at %>

      +
      +
      + +
      + <% if @courses.any? %> + <% @courses.each do |course|%> +
        +
      • + + <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "list-title fl #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", + :style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+"("+current_time_and_term(course)+")"%> + <% teacher = User.where("id=?",course.tea_id).first%> + + <%='主讲老师:'+(teacher.try(:realname) != " " ? teacher.lastname + teacher.firstname : teacher.try(:login)) %> + +
      • +
        +
      • + + 更新:<%= format_time(course.updated_on) %> + + 学期:  <%= current_time_and_term course %> + + <% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %> + <% homework_num = course.homework_commons.count %> + <% else %> + <% homework_num = course.homework_commons.where("publish_time <= '#{Date.today}'").count %> + <% end %> +

        <%= homework_num %>作业| <%= visable_attachemnts_incourse(course).count %>资源

        +
      • +
        +
      + <% end %> +
      +
        + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
      +
      +
      + <% else %> +

      <%= l(:label_no_data) %>

      + <% end %> +
      +
      + + \ No newline at end of file diff --git a/app/views/syllabuses/delete_syllabus.js.erb b/app/views/syllabuses/delete_syllabus.js.erb new file mode 100644 index 000000000..e764aa80b --- /dev/null +++ b/app/views/syllabuses/delete_syllabus.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%=escape_javascript(render :partial => 'delete_syllabus') %>"; +pop_up_box(htmlvalue,500,30,50); \ No newline at end of file diff --git a/app/views/syllabuses/edit.html.erb b/app/views/syllabuses/edit.html.erb new file mode 100644 index 000000000..a23bf9cb8 --- /dev/null +++ b/app/views/syllabuses/edit.html.erb @@ -0,0 +1,47 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> +<% end %> +
      +

      课程信息

      +
      +
      +

      <%=@syllabus.title %>课程大纲

      +
      + <%= labelled_form_for @syllabus, :url =>syllabus_path(@syllabus), + :html => {:nhname=>'form',:multipart => true, :id => 'syllabus-form'} do |f| %> +
      +
      + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :description, :editor_id => 'syllabus_description_editor', + :owner_id => @syllabus.nil? ? 0: @syllabus.id, + :owner_type => OwnerTypeHelper::SYLLABUS, + :width => '100%', + :height => 300, + :minHeight=>300, + :class => 'talk_text fl', + :input_html => { :id => 'syllabus_content', + :class => 'talk_text fl', + :maxlength => 5000 } + %> +
      +

      +
      + +
      +
      + <%= render :partial => 'attachments/form_course', :locals => {:container => @syllabus, :isReply => false} %> +
      +
      + +
      + 发送 + + 取消 +
      +
      + <% end %> + +
      +
      \ No newline at end of file diff --git a/app/views/syllabuses/edit_syllabus_eng_name.js.erb b/app/views/syllabuses/edit_syllabus_eng_name.js.erb new file mode 100644 index 000000000..8a4c1efa8 --- /dev/null +++ b/app/views/syllabuses/edit_syllabus_eng_name.js.erb @@ -0,0 +1,3 @@ +$("#syllabus_eng_name_show").html("<%= escape_javascript render :partial => 'layouts/syllabus_eng_name', :locals => {:syllabus => @syllabus} %>"); +$("#syllabus_eng_name_show").show(); +$("#syllabus_eng_name_edit").hide(); \ No newline at end of file diff --git a/app/views/syllabuses/new.html.erb b/app/views/syllabuses/new.html.erb new file mode 100644 index 000000000..6f38d5f07 --- /dev/null +++ b/app/views/syllabuses/new.html.erb @@ -0,0 +1,27 @@ +
      +

      新建课程

      +
      +
      +
        + <%= labelled_form_for @syllabus do |f| %> +
      • + + + +
      • +
        +
      • + + + +
      • +
        +
      • + 提交 + <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%> +
        +
      • + <% end%> +
      +
      +
      \ No newline at end of file diff --git a/app/views/syllabuses/show.html.erb b/app/views/syllabuses/show.html.erb new file mode 100644 index 000000000..e3e6436b4 --- /dev/null +++ b/app/views/syllabuses/show.html.erb @@ -0,0 +1,91 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> +<% end %> + +
      +

      课程信息

      +
      +<% if @syllabus.des_status == 1 && @syllabus.courses.empty? %> +
      + <% if User.current == @syllabus.user %> +

      您建立的课程还未创建班级,请 + <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%> +

      + <% elsif User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> +

      本课程下还未创建班级,请 + <%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "syllabusbox_a_blue", :target => '_blank'%> +

      + <% else %> +

      本课程下还未创建班级,敬请期待。 +

      + <% end %> +
      +<% end %> +
      + <% if @syllabus.des_status == 0%> + <% if User.current == @syllabus.user %> +

      您建立的课程尚未填写课程大纲,请完善您的<%=link_to '课程大纲', edit_syllabus_path(@syllabus), :class => 'syllabusbox_a_blue' %>!

      + <% else %> +

      <%=@syllabus.user.show_name %>老师尚未完成课程大纲的编写,敬请期待。

      + <% end %> + <% else %> +
      + <%=@syllabus.description.html_safe %> +
      + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @syllabus} %> +
      +
      + <% if User.current.logged? && User.current == @syllabus.user%> +
      +
        +
      • +
          +
        • <%=link_to '编辑', edit_syllabus_path(@syllabus), :class => 'postOptionLink'%>
        • +
        • <%=link_to '删除', delete_des_syllabus_path(@syllabus), :class => 'postOptionLink', :confirm => l(:text_are_you_sure)%>
        • +
        +
      • +
      +
      +
      + <% end %> +
      更新时间:<%=format_time @syllabus.updated_at %>
      +
      +<% end %> + + <% count=@syllabus.journals_for_messages.count %> +
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => @syllabus, :user_activity_id => @syllabus.id} %> + + <% comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3) %> + <% if count > 0 %> +
      + <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> +
      + <% end %> +
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
      +
      + <% if User.current.logged? %> +
      + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_syllabus_message', :id => @syllabus.id},:method => "post") do |f|%> +
      + + +
      +

      + <% end%> +
      + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
      +
      +
      +
      +
      +
      +
      diff --git a/app/views/syllabuses/syllabus_courselist.html.erb b/app/views/syllabuses/syllabus_courselist.html.erb new file mode 100644 index 000000000..0b0713738 --- /dev/null +++ b/app/views/syllabuses/syllabus_courselist.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'syllabus_course_list'%> \ No newline at end of file diff --git a/app/views/syllabuses/syllabus_courselist.js.erb b/app/views/syllabuses/syllabus_courselist.js.erb new file mode 100644 index 000000000..5433ea2c1 --- /dev/null +++ b/app/views/syllabuses/syllabus_courselist.js.erb @@ -0,0 +1 @@ +$("#course-list").replaceWith('<%= escape_javascript( render :partial => 'syllabus_course_list') %>'); \ No newline at end of file diff --git a/app/views/syllabuses/update_base_info.js.erb b/app/views/syllabuses/update_base_info.js.erb new file mode 100644 index 000000000..5fceec213 --- /dev/null +++ b/app/views/syllabuses/update_base_info.js.erb @@ -0,0 +1,2 @@ +$("#syllabus_base_info").html("<%=escape_javascript(render :partial => 'layouts/syllabus_edit_info', :locals => {:syllabus => @syllabus}) %>"); +$("#syllabus_base_info").html("<%=escape_javascript(render :partial => 'layouts/syllabus_base_info', :locals => {:syllabus => @syllabus}) %>"); diff --git a/app/views/tags/_syllabus_tag.html.erb b/app/views/tags/_syllabus_tag.html.erb new file mode 100644 index 000000000..4d6fc6b87 --- /dev/null +++ b/app/views/tags/_syllabus_tag.html.erb @@ -0,0 +1,5 @@ +
      +
      + <%= render :partial => "tags/tag_syllabus_new_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %> +
      +
      \ No newline at end of file diff --git a/app/views/tags/_tag_syllabus_new_name.html.erb b/app/views/tags/_tag_syllabus_new_name.html.erb new file mode 100644 index 000000000..093e372ac --- /dev/null +++ b/app/views/tags/_tag_syllabus_new_name.html.erb @@ -0,0 +1,28 @@ +<% @tags = obj.reload.tag_list %> +<% if non_list_all && @tags.size > 0 %> + +<% else %> + + <% if @tags.size > 0 %> + <% @tags.each do |tag| %> + + <%= link_to tag, :controller => "tags", :action => "index", :q => tag, :object_flag => object_flag, :obj_id => obj.id, :class => 'pt5' %> + + <%= link_to('x', remove_tag_path(:tag_name => tag,:taggable_id => obj.id, :taggable_type => object_flag), :remote => true, :confirm => l(:text_are_you_sure) ) if obj.user == User.current %> + + + <% end %> + <% end %> +<% end %> + +<% if User.current.logged?%> + <%= l(:label_add_tag)%> + +<% end%> \ No newline at end of file diff --git a/app/views/tags/remove_tag.js.erb b/app/views/tags/remove_tag.js.erb index 4c4409c1c..b53aef949 100644 --- a/app/views/tags/remove_tag.js.erb +++ b/app/views/tags/remove_tag.js.erb @@ -19,6 +19,9 @@ $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_project $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty(); $("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/course_attachment_tag_name', :locals => {:obj => @obj,:non_list_all => false, :object_flag => @object_flag}) %>'); +<% elsif @object_flag == '11'%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_syllabus_new_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>'); <% else%> $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @object_flag}) %>'); diff --git a/app/views/tags/tag_save.js.erb b/app/views/tags/tag_save.js.erb index e4f12b558..10b1393d8 100644 --- a/app/views/tags/tag_save.js.erb +++ b/app/views/tags/tag_save.js.erb @@ -38,6 +38,10 @@ $('#tags_name2').val(""); $('#tags_name').val(""); <% elsif @obj_flag == '10'%> //$("#put-tag-form-<%#=@obj.class%>-<%#=@obj.id%>").hide(); +<% elsif @obj_flag == '11'%> +$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_syllabus_new_name', + :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); +$('#tags_name4').val(""); <% else%> $('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name', :locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>'); diff --git a/app/views/test/courselist.html.erb b/app/views/test/courselist.html.erb index 3f9f22489..b5222b664 100644 --- a/app/views/test/courselist.html.erb +++ b/app/views/test/courselist.html.erb @@ -4,7 +4,7 @@
    • - + @@ -45,7 +45,7 @@ <% elsif User.current.member_of_course? item %> 提交作品 <% elsif User.current.logged?%> - <%= link_to "加入课程",try_join_path(:object_id => item.id), :class => "blue_n_btn fr mt20", :remote => "true",:id => "try_join_course_link"%> + <%= link_to "加入班级",try_join_path(:object_id => item.id), :class => "blue_n_btn fr mt20", :remote => "true",:id => "try_join_course_link"%> <% end %>
      \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 8de9b3dce..cf8e782e6 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -7,12 +7,9 @@
      - <% if activity.try(:user).try(:realname) == ' ' %> - <%= link_to activity.try(:user), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> + <%= link_to activity.user.show_name, user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + TO + <%= link_to activity.course.name.to_s+" | 班级作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%>
      - <% if activity.try(:user).try(:realname) == ' ' %> - <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %> + TO <% course=Course.find(activity.jour_id) %> - <%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %> + <%= link_to course.name.to_s+" | 班级留言", course_feedback_path(course), :class => "newsBlue ml15" %>
      @@ -49,33 +45,35 @@ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
      - +
      + <% end %>
      @@ -87,22 +85,7 @@ <% count=activity.children.count%> <% end %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#=format_date(activity.updated_on)%>
      - <%if count > 3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% activity= activity.parent ? activity.parent : activity%> <% comments = activity.children.reorder("created_on desc").limit(3) %> diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index fff0348ca..18f16b068 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -6,12 +6,9 @@
      - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %> + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO + <%= link_to activity.course.name.to_s+" | 班级通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
      <% count=activity.comments.count %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#= format_date(activity.updated_on) %>
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %> @@ -90,7 +74,7 @@ <% end %>
      -
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
      <% if User.current.logged? %>
      diff --git a/app/views/users/_homework_replies.html.erb b/app/views/users/_homework_replies.html.erb index 7f4dc379b..285d464b1 100644 --- a/app/views/users/_homework_replies.html.erb +++ b/app/views/users/_homework_replies.html.erb @@ -12,11 +12,7 @@
      - <% if comment.try(:user).try(:realname) == ' ' %> - <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to comment.user.show_name, user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <%= time_from_now(comment.created_on) %>
      <% unless comment.m_parent_id.nil? %> @@ -37,7 +33,7 @@
      - <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment),:remote=>true %> + <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %>
      <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %>
      @@ -45,7 +41,8 @@
      <% end %>
      - <%= comment.notes.html_safe %>
      + <%= comment.notes.html_safe %> +
      diff --git a/app/views/users/_journal_comment_reply.html.erb b/app/views/users/_journal_comment_reply.html.erb new file mode 100644 index 000000000..9906abeb5 --- /dev/null +++ b/app/views/users/_journal_comment_reply.html.erb @@ -0,0 +1,8 @@ +
      + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> +
      + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> +
      + <% end %> + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => comment} %> +
      \ No newline at end of file diff --git a/app/views/users/_journal_replies.html.erb b/app/views/users/_journal_replies.html.erb new file mode 100644 index 000000000..7fc708ebb --- /dev/null +++ b/app/views/users/_journal_replies.html.erb @@ -0,0 +1,85 @@ +
        + <% comments.each do |comment| %> + +
      • +
        + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
        +
        +
        + <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> + <%= time_from_now(comment.created_on) %> +
        + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents_no_root parents_rely, comment %> + <% length = parents_rely.length %> +
        + <% if length <= 3 %> + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> + <% else %> +
        +
        +
        + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => parents_rely[length - 1]} %> +
        + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> +
        +
        + + + <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %> +
        + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> +
        + <% end %> +
        + <% end %> + <% if !comment.content_detail.blank? || comment.class == Journal %> +
        + <% if comment.class == Journal %> + <% if comment.details.any? %> + <% details_to_strings(comment.details).each do |string| %> +

        <%= string %>

        + <% end %> + <% end %> +

        <%= comment.notes.html_safe %>

        + <% else %> + <%= comment.content_detail.html_safe %> + <% end %> +
        +
        +
        + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if allow_delete %> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
        +
        +
        +

        + <% end %> +
        +
        +
      • + <% end %> +
      \ No newline at end of file diff --git a/app/views/users/_journal_reply_banner.html.erb b/app/views/users/_journal_reply_banner.html.erb new file mode 100644 index 000000000..c231f473d --- /dev/null +++ b/app/views/users/_journal_reply_banner.html.erb @@ -0,0 +1,18 @@ +
      +
      + 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
      +
      <%#= format_date(activity.updated_on) %>
      + <%if count>3 %> + + <% end %> +
      \ No newline at end of file diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index d8714400d..ccf0e456e 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -13,29 +13,31 @@ <% end %> TO <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
      -
      -
        -
      • -
          -
        • - <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %> -
        • -
        • - <% if !defined?(project_id) && !defined?(user_id) %> - <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% elsif defined?(project_id) %> - <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% elsif defined?(user_id) %> - <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> - <% end %> -
        • -
        • - <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> + <% if User.current.logged? %> +
          +
            +
          • +
              +
            • + <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %> +
            • +
            • + <% if !defined?(project_id) && !defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(project_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% end %> +
            • +
            • + <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> +
            • +
          -
        • -
        -
      +
      + <% end %>
      <% case activity.tracker_id %> <% when 1%> diff --git a/app/views/users/_project_issue_reply.html.erb b/app/views/users/_project_issue_reply.html.erb index d1f7363a7..3dac8026a 100644 --- a/app/views/users/_project_issue_reply.html.erb +++ b/app/views/users/_project_issue_reply.html.erb @@ -1,21 +1,6 @@ <% count = activity.journals.count %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#= format_date(activity.updated_on) %>
      - <% if count > 3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.journals.includes(:user, :details).reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index daee1a71c..1abc36a31 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -6,11 +6,7 @@
      - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> TO <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> @@ -49,33 +45,35 @@
      <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
      - +
      + <% end %>
      @@ -86,18 +84,7 @@ <% count=activity.children.count%> <% end %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#=format_date(activity.updated_on)%>
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% activity= activity.parent_id.nil? ? activity : activity.parent %> <% comments = activity.children.reorder("created_on desc").limit(3) %> diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index 34c124b5e..cdceb490d 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -6,11 +6,8 @@
      - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.project.name.to_s+" | 新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>
      <% count=activity.comments.count %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#= format_date(activity.updated_on) %>
      - <%if count>3 %> - - <% end %> -
      - + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %>
      diff --git a/app/views/users/_reply_banner.html.erb b/app/views/users/_reply_banner.html.erb new file mode 100644 index 000000000..25175542f --- /dev/null +++ b/app/views/users/_reply_banner.html.erb @@ -0,0 +1,18 @@ +
      +
      + 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
      +
      <%#= format_date(activity.updated_on) %>
      + <%if count>3 %> + + <% end %> +
      \ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index a7034ffc7..621b56fbd 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -2,23 +2,38 @@ <% if User.current.logged? %>
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
      -
      - <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> - > - > - > - -
      - - -
      -

      - <% end%> +
      + <% if @type == 'HomeworkCommon' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> + > + > + > + +
      + + +
      +

      + <% end%> + <% elsif @type == 'JournalsForMessage' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => reply.user.id %> + <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => reply.id %> + <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> + <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> +
      + + +
      + <% end%> + <% end %> +
      +
      <% else %> <%= render :partial => "users/show_unlogged_reply" %> <% end %> -
      -
      \ No newline at end of file diff --git a/app/views/users/_selector_for_messages.html.erb b/app/views/users/_selector_for_messages.html.erb index 66f9ec7a3..3727e4a1d 100644 --- a/app/views/users/_selector_for_messages.html.erb +++ b/app/views/users/_selector_for_messages.html.erb @@ -7,9 +7,9 @@
      • 课程消息
      • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "homepagePostTypeAssignment postTypeGrey" %>
      • -
      • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "homepagePostTypeForum postTypeGrey" %>
      • -
      • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "homepagePostTypeNotice postTypeGrey" %>
      • -
      • <%= link_to "课程问卷", user_message_path(User.current, :type => 'poll'), :class => "homepagePostTypeQuiz postTypeGrey" %>
      • +
      • <%= link_to "班级讨论",user_message_path(User.current, :type => 'course_message'), :class => "homepagePostTypeForum postTypeGrey" %>
      • +
      • <%= link_to "班级通知",user_message_path(User.current, :type => 'course_news'), :class => "homepagePostTypeNotice postTypeGrey" %>
      • +
      • <%= link_to "班级问卷", user_message_path(User.current, :type => 'poll'), :class => "homepagePostTypeQuiz postTypeGrey" %>
      diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 3b327c080..5d06a7001 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -86,7 +86,7 @@ <% case user_activity.act_type.to_s %> <% when 'JournalsForMessage' %> <% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %> - <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_activity=>1} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% when 'Blog'%> diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index f0761ff78..77510c858 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -6,11 +6,8 @@
      - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
      @@ -46,22 +43,7 @@
      <% count=activity.children.count %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      <%#= format_date(activity.updated_on) %>
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.children.reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index b84adf5fe..4fb79ee2d 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -50,7 +50,7 @@
      • <%= link_to(l(:label_bid_respond_delete), - {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity}, + {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id, :activity_id => activity.id}, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "postOptionLink", :title => l(:button_delete)) %>
      • @@ -62,29 +62,17 @@
      - <% count=fetch_user_leaveWord_reply(activity).count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %> + <% allow_delete = (activity.user == User.current || User.current.admin?) %>
      -
      -
      回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
      -
      - <%if count>3 %> - - <% end %> -
      + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
      - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
      <% end %> @@ -99,7 +87,6 @@ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %> <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
      diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb index 6211aac7d..517d66038 100644 --- a/app/views/users/_user_jours_list.html.erb +++ b/app/views/users/_user_jours_list.html.erb @@ -11,7 +11,7 @@ sd_create_editor_from_data(<%= jour.id%>, null, "100%", "<%=jour.class.to_s%>"); }); - <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id,:is_activity=>0} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id} %> <%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %> <% end %> <%end%> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 0c18dbcc3..fc66711d3 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -43,7 +43,7 @@
      @@ -479,7 +479,7 @@ <%= User.current.allowed_to?(:as_teacher,ma.course_message.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:

        -
      • 课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
      • +
      • 班级名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
      • 作业标题:<%= ma.course_message.homework_common.name %>
      • 提交截止:<%= ma.course_message.homework_common.end_time %> 23:59
      • 提交时间:<%= format_time(ma.course_message.created_at) %>
      • @@ -541,29 +541,29 @@
      • 系统提示 - ">您成功创建了课程: + ">您成功创建了班级:
      • - <%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message), + <%= link_to "班级名称:" + ma.course_message.name, course_path(ma.course_message), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
      • <%= time_tag(ma.created_at).html_safe %>
      • @@ -580,13 +580,13 @@
      • 系统提示 "> - 课程申请进度反馈: + 班级申请进度反馈:
      • <%= link_to ma.status == 1 ? - '您申请成为课程"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'申请已通过' + '您申请成为班级"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'申请已通过' : - '您申请成为课程"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'的申请被拒绝', course_path(Course.find(ma.course_id)), + '您申请成为班级"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'的申请被拒绝', course_path(Course.find(ma.course_id)), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -595,10 +595,10 @@
      • @@ -614,7 +614,7 @@
      • <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - ">将您加入了课程: + ">将您加入了班级:
      • <%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -625,14 +625,14 @@ @@ -648,7 +648,7 @@
      • 系统提示 - ">您增加了新的课程成员: + ">您增加了新的班级成员:
      • <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -658,15 +658,15 @@
      • @@ -682,7 +682,7 @@
      • <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - ">将您移出了课程: + ">将您移出了班级:
      • <%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -692,8 +692,8 @@
      • @@ -715,7 +715,7 @@
      • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user), :target => '_blank' %>
      • <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>">发布了课程测验 :
      • + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>">发布了班级测验 :
      • <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %> @@ -725,10 +725,10 @@ diff --git a/app/views/wechats/open_wechat.html.erb b/app/views/wechats/open_wechat.html.erb new file mode 100644 index 000000000..4584e81b5 --- /dev/null +++ b/app/views/wechats/open_wechat.html.erb @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 3d61d8fcf..1e3957ea9 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -2,17 +2,23 @@ - 我的动态 + Trustie平台 + @@ -20,8 +26,31 @@
        - - + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index a714f53d2..4f434757f 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -33,7 +33,7 @@
        • <%= item.try(:highlight).try(:name) ? item.highlight.name[0].html_safe : item.name %> -
          <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>课程
          +
          <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>班级
        • <%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %>
        • diff --git a/app/views/welcome/_search_course_results.html.erb b/app/views/welcome/_search_course_results.html.erb index e51452ada..322a47de5 100644 --- a/app/views/welcome/_search_course_results.html.erb +++ b/app/views/welcome/_search_course_results.html.erb @@ -2,16 +2,16 @@ <% courses.each do |course|%>
          • - <%= link_to image_tag(url_to_avatar(Course.find(course.id)), :width => "75", :height => "75",:class=>'searchCourseImage'), course_path(course.id), :alt => "课程图片" %> + <%= link_to image_tag(url_to_avatar(Course.find(course.id)), :width => "75", :height => "75",:class=>'searchCourseImage'), course_path(course.id), :alt => "班级图片" %>
            • <%= course.try(:highlight).try(:name) ? course.highlight.name[0].html_safe : course.name %> -
              <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>课程
              +
              <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>班级
            • -
            • <%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该课程描述') %>
            • +
            • <%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %>
            • 教师:<%= User.find(course.tea_id).realname %> 授课时间:<%= course.time.to_s + course.term%> diff --git a/app/views/welcome/search.html.erb b/app/views/welcome/search.html.erb index ca26ba8c3..15491c1c0 100644 --- a/app/views/welcome/search.html.erb +++ b/app/views/welcome/search.html.erb @@ -79,7 +79,7 @@
              • 全部(<%= @total_count%>)
              • 用户(<%= @users_count%>)
              • -
              • 课程(<%=@course_count%>)
              • +
              • 班级(<%=@course_count%>)
              • 资源(<%= @attach_count%>)
              • 项目(<%= @project_count%>)
              • 帖子(<%= @memo_count%>)
              • diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index ded05887f..9f3b0164e 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -1,8 +1,8 @@ <% if @save_succ %> <% if @user_activity_id %> - <% if @is_activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - <% else %> + <% if @activity.jour_type == 'Principal' %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% elsif @activity.jour_type == 'Course' %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); <% end %> //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index a2d606e76..c527474cd 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -3,8 +3,7 @@ <% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon'].include? @journal_destroyed.jour_type)%> <% if @is_user%> <% if @activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); <% else %> $("#user_activity_<%= @user_activity_id%>").hide(); @@ -20,7 +19,12 @@ <% if @bid && @jours_count %> $('#jours_count').html("<%= @jours_count %>"); <% elsif @course && @jours_count%> - $('#course_jour_count').html("(<%= @jours_count %>)"); + <% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); + <% else %> + $('#course_jour_count').html("(<%= @jours_count %>)"); + <% end %> <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 70236d9ba..49d5f4d03 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -188,7 +188,7 @@ zh: text_are_you_sure: 您确定要删除吗? #js 提示 - text_are_you_sure_out: 你确定要退出该课程吗? + text_are_you_sure_out: 你确定要退出该班级吗? text_are_you_sure_out_group: 你确定要退出该分班吗? text_are_you_sure_all: 您确定要删除所有文件吗 diff --git a/config/locales/courses/en.yml b/config/locales/courses/en.yml index 20d9d112c..cc8ac2c0d 100644 --- a/config/locales/courses/en.yml +++ b/config/locales/courses/en.yml @@ -13,7 +13,7 @@ en: label_homework: Task - label_course_news: 课程通知 + label_course_news: 班级通知 label_main_teacher: 主讲教师 label_course_term: 开始学期 diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index c3d4b0d58..1aa1ea666 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -10,14 +10,14 @@ zh: # # 课程公共标签 # - label_course_join_student: 加入课程 - label_course_exit_student: 退出课程 + label_course_join_student: 加入班级 + label_course_exit_student: 退出班级 label_course_new: 新建课程 label_course_name: 课程名称 label_homework: 作业 - label_course_news: 课程通知 - label_course_mail_news_reply: 课程通知回复 + label_course_news: 班级通知 + label_course_mail_news_reply: 班级通知回复 label_main_teacher: 主讲教师 label_course_term: 开始学期 label_isuue_mail_status: 更新了issue状态! @@ -27,7 +27,7 @@ zh: # 资源库 (课程、项目按类型分) label_course_file: 资源库 label_upload_files: 上传资源 - label_apply_join_course: 申请加入课程 + label_apply_join_course: 申请加入班级 label_apply_for_homework: 申请引用作业 # # 课程托管平台主页 diff --git a/config/locales/en.yml b/config/locales/en.yml index 033f12ad2..98d02cdb6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -602,6 +602,7 @@ en: label_time_tracking: Time tracking label_change_plural: Changes label_statistics: Statistics + label_quality_analyses: Quality Analyses label_commits_per_month: Commits per month label_commits_per_author: Commits per author label_diff: diff diff --git a/config/locales/my/zh.yml b/config/locales/my/zh.yml index 25a949df4..85ba156ef 100644 --- a/config/locales/my/zh.yml +++ b/config/locales/my/zh.yml @@ -28,7 +28,7 @@ zh: label_account_identity_choose: --请选择身份-- label_account_identity_teacher: 教师 label_account_identity_student: 学生 - label_account_identity_developer: 开发者 + label_account_identity_developer: 从业者 label_account_identity_enterprise: 组织 label_account_identity_studentID: 请输入学号 @@ -37,7 +37,7 @@ zh: field_firstname: 名字或组织名 firstname_empty: 名字不能为空 field_firstname_eg: '(例:张三丰,请填写[三丰])' - field_lastname: 姓氏 + field_lastname: 姓名 lastname_empty: 姓氏不能为空 enterprise_empty: 企业名不能为空 field_lastname_eg: '(例:张三丰,请填写[张])' diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 94be8af6d..6a040782d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -329,7 +329,7 @@ zh: permission_manage_subtasks: 管理子任务 permission_view_journals_for_messages: 查看留言 permission_view_courses: 查看课程 - permission_new_course: 新建课程 + permission_new_course: 新建班级 permission_configure_course: 配置课程 permission_close_course: 关闭/重开 permission_new_assignment: 新建任务 @@ -354,12 +354,12 @@ zh: permission_as_student: 作为学生 permission_paret_in_homework: 加入作业 permission_view_homework_attaches: 查看作品附件 - permission_view_course_journals_for_messages: 查看课程留言 - view_course_journals_for_messages: 课程留言 + permission_view_course_journals_for_messages: 查看班级留言 + view_course_journals_for_messages: 班级留言 label_send_course_journals_for_messages: 发布了留言 label_send_course_messages: 发布了讨论 permission_select_course_modules: 选择课程模块 - permission_view_course_files: 查看课程资源 + permission_view_course_files: 查看班级资源 permission_add_course: 新建课程 permission_edit_course: 编辑课程 permission_select_contest_modules: 选择竞赛模块 @@ -485,7 +485,7 @@ zh: label_new_course: 课程列表 label_course_all: 课程列表 label_excellent_courses_list: 精品课程列表 - label_course_resource_list: 课程资源列表 + label_course_resource_list: 班级资源列表 label_project_resource_list: 項目资源列表 label_teacher_all: 所有教师 label_requirement_enterprise_list: 众包列表 @@ -732,6 +732,7 @@ zh: label_time_tracking: 时间跟踪 label_change_plural: 变更 label_statistics: 统计 + label_quality_analyses: 质量分析 label_commits_per_month: 每月提交次数 label_commits_per_author: 每用户提交次数 @@ -1264,7 +1265,9 @@ zh: label_delete_confirm: 确认删除? label_tags_bid: 需求名称 - label_tags_course_name: 课程名称 + label_tags_syllabus_name: 课程名称 + label_tags_course_name: 班级名称 + label_tags_course_eng_name: 英文名称 label_tags_bid_description: 需求描述 label_tags_issue_description: 问题描述 label_tags_all_objects: 所有 @@ -1535,7 +1538,7 @@ zh: label_my_brief_introduction: 今天的心情如何?留下你的脚印吧~ label_time: 年度 - label_main_term: 课程学期 + label_main_term: 班级学期 label_teacher_work_unit: 教师单位 label_course_time: 课程年度 label_i_new_activity: 有了新活动在 @@ -1664,7 +1667,7 @@ zh: #add by men label_account_identity_teacher: 教师 label_account_identity_student: 学生 - label_account_identity_developer: 开发者 + label_account_identity_developer: 从业者 label_account_identity_enterprise: 组织 label_teaching_course: 我执教的课程 @@ -1691,7 +1694,7 @@ zh: label_new_join_group: 加入当前分班 label_new_course_password: 课程密码 label_new_course_school: 开课学校 - label_new_course_description: 课程描述 + label_new_course_description: 班级描述 label_homework_description: 作业描述 label_new_join_order: 请输入课程密码 label_task_submit_form_accessory: 作业最终以附件形式提交 @@ -1716,7 +1719,7 @@ zh: label_assign_homework: 中布置了作业 label_noawards: 未评奖 - label_course_modify_settings: 配置课程 + label_course_modify_settings: 配置班级 label_homework_prompt: 贴心小提示: label_homework_prompt_content: 亲,在这里我们的作业将以项目的形式提交,如果小伙伴们还没有创建项目,请先创建一个项目。项目创建成功后,就可以 label_create_homework: 布置了作业: @@ -1731,13 +1734,13 @@ zh: label_search_by_student_id: 按学号过滤 label_institution_name: 单位名称 label_duration_time: 授课时间 - label_course_brief_introduction: 课程简介 + label_course_brief_introduction: 班级简介 field_teacher_name: 教 师 label_newbie_faq: '新手指引 & 问答' label_hot_project: '热门项目' label_borad_project: 项目讨论区 - label_borad_course: 课程问答区 + label_borad_course: 班级问答区 label_borad_org_subfield: 资源栏目讨论区 view_borad_course: 课程讨论 label_memo_create_succ: 发布成功 @@ -1847,7 +1850,7 @@ zh: label_contest_notification: 竞赛通知 label_company_name: 组织名 - label_coursefile_sharingarea: 课程资源共享区 + label_coursefile_sharingarea: 班级资源共享区 label_x_activity: @@ -1864,12 +1867,18 @@ zh: excel_nickname: 登录名 excel_student_id: 学号 excel_mail: 电子邮箱 + excel_rank: 排名 excel_homework_name: 作品名 excel_homework_des: 作品描述 + excel_homework_project: 关联项目 + excel_no_project: 无关联项目 + excel_group_member: 组员 excel_t_score: 教师评分 excel_ta_score: 教辅评分 excel_n_score: 匿名评分 excel_s_score: 系统评分 + excel_a_penalty: 缺评扣分 + excel_l_penalty: 迟交扣分 excel_f_score: 成绩 excel_commit_time: 提交时间 excel_homework_score: 作业积分 @@ -1910,7 +1919,7 @@ zh: label_attendingcontestwork_adaptive_system: 系统支持 label_attendingcontestwork_download: 作品下载 label_course_attendingcontestwork_download: 课件下载 - label_course_mail_files: 课程资源 + label_course_mail_files: 班级资源 label_attendingcontestwork_developers: 开发人员 label_attendingcontestwork_average_scores: 平均评分 label_attendingcontestwork_release_time: 发布时间 @@ -1930,7 +1939,7 @@ zh: label_notification: 通知公告 label_course_ad_description: 课程模块正在优化中,使用过程中如有问题请您与我们联系,感谢大家的支持! label_course_adcolick: 请点击: - label_coursejoin_tip: 提示:加入课程才有权限查看或提交作业,“加入”按钮见课程图标右侧! + label_coursejoin_tip: 提示:加入班级才有权限查看或提交作业,“加入”按钮见班级图标右侧! # ajax异步验证 modal_valid_passing: 可以使用 @@ -2038,7 +2047,7 @@ zh: label_recently_updated_homework: 最近更新了作业 label_recently_updated_message: 最近更新了留言 label_recently_updated_courseware: 最近更新了课件 - label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧! + label_no_courses: 您没有参与任何班级,请搜索班级、加入班级,或者创建班级吧! label_commit_failed: 提交失败 label_recently: 最近被 label_creat: 创建 @@ -2115,7 +2124,7 @@ zh: # 课程推荐 label_homework_commont: 作业 - label_homework_recommendation: 课程推荐 + label_homework_recommendation: 班级推荐 #资源 label_resource_name: 资源名称 diff --git a/config/menu.yml b/config/menu.yml index c2579d8e6..213130240 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,30 +2,26 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf694495398c7d470&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=http://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - name: "我的课程" sub_button: - - type: "view" + type: "click" name: "课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf694495398c7d470&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + key: "DEV" - - type: "view" + type: "click" name: "资源" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf694495398c7d470&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + key: "DEV" - name: "更多" sub_button: - - type: "view" + type: "click" name: "加入班级" - url: "https://www.trustie.net/" - - - type: "view" - name: "点名" - url: "https://www.trustie.net/organizations/1/downloads" + key: "JOIN_CLASS" - type: "click" name: "反馈" diff --git a/config/routes.rb b/config/routes.rb index 189c2671d..bc9abeb35 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -213,7 +213,8 @@ RedmineApp::Application.routes.draw do resources :school, :except => [:show] do collection do - + get 'apply_add_school' + get 'search_repeat_schoolname' end member do @@ -485,15 +486,18 @@ RedmineApp::Application.routes.draw do match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] match 'agreement',:to => 'account#agreement',:as => 'agreement',:via=>[:get] match 'about_us',:to=>'account#about_us',:as=>'about_us',:via=>[:get] - match 'account/register', :via => [:get, :post], :as => 'register' + match 'account/register',:to=>'account#register', :via => [:get, :post], :as => 'register' match 'account/lost_password', :via => [:get, :post], :as => 'lost_password' match 'account/activate', :via => :get match 'account/valid_ajax', :via => :get match 'account/email_valid', :to => 'account#email_valid', :via => :get - match 'account/resendmail', :to => 'account#resendmail', :via=> :get + match 'account/resendmail', :to => 'account#resendmail', :via=> :get, :as => 'resendmail' match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] + #激活邮箱反馈问题 + match 'users/:id/leave_email_activation_message', :to => 'words#leave_email_activation_message', :via => :post, :as => "leave_email_activation_message" + # boards match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message' match 'boards/:id/join_to_org_subfields', :to => 'boards#join_to_org_subfields' @@ -786,6 +790,15 @@ RedmineApp::Application.routes.draw do end end + resources :quality_analysis, :only => [:index, :create, :edit, :update] do + collection do + end + member do + match 'update_jenkins_job' + match 'edit' + match 'create' + end + end # resources :files, :only => [:index, :new, :create] do # member do # match "quote_resource_show_project",:via => [:get] @@ -906,6 +919,7 @@ RedmineApp::Application.routes.draw do # repositories routes get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats', :as => "stats_repository_project" + get 'projects/:id/repository/:repository_id/quality_analysis', :to => 'repositories#quality_analysis', :as => "quality_analysis" get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', :to => 'repositories#changes' @@ -924,6 +938,8 @@ RedmineApp::Application.routes.draw do } get 'projects/:id/repository/statistics', :to => 'repositories#stats' + get 'projects/:id/repository/quality_analysis', :to => 'repositories#quality_analysis' + get 'projects/:id/repository/graph', :to => 'repositories#graph' get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes' @@ -1063,6 +1079,22 @@ RedmineApp::Application.routes.draw do match 'courses/search' match '/contests/search', :via => [:get, :post] + + #课程大纲路由设置 + resources :syllabuses do + member do + match 'syllabus_courselist', :to => 'syllabuses#syllabus_courselist', :via => :get, :as => 'syllabus_courselist' + get 'edit_syllabus_eng_name' + post 'update_base_info' + get 'delete_syllabus' + get 'delete_des' + end + + collection do + + end + end + # add by nwb # 课程路由设置 resources :courses do @@ -1181,6 +1213,7 @@ RedmineApp::Application.routes.draw do match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' match 'project/:id/share', :to => 'projects#share', :as => 'share_show' #share post 'words/:id/leave_user_message', :to => 'words#leave_user_message', :as => "leave_user_message" + post 'words/:id/leave_syllabus_message', :to => 'words#leave_syllabus_message', :as => "leave_syllabus_message" post 'words/:id/leave_homework_message', :to => 'words#leave_homework_message', :as => "leave_homework_message" post 'words/:id/reply_to_homework', :to => 'words#reply_to_homework', :as => "reply_to_homework" @@ -1254,7 +1287,7 @@ RedmineApp::Application.routes.draw do get :login get :user_activities post :bind - post :get_open_id + post :get_bind end end diff --git a/config/wechat.yml b/config/wechat.yml index cf5be1f2b..9bc33029e 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -12,10 +12,10 @@ default: &default secret: "beb4d3bc4b32b3557811680835357841" token: "123456" - access_token: "1234567" + access_token: ".access_token" encrypt_mode: false # if true must fill encoding_aes_key encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" - jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + jsapi_ticket: "tmp/wechat_jsapi_ticket" #template binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc" @@ -30,4 +30,4 @@ development: <<: *default test: - <<: *default \ No newline at end of file + <<: *default diff --git a/db/migrate/20160614072229_add_invite_code_to_course.rb b/db/migrate/20160614072229_add_invite_code_to_course.rb new file mode 100644 index 000000000..8f7bb8da1 --- /dev/null +++ b/db/migrate/20160614072229_add_invite_code_to_course.rb @@ -0,0 +1,5 @@ +class AddInviteCodeToCourse < ActiveRecord::Migration + def change + add_column :courses, :invite_code, :string + end +end diff --git a/db/migrate/20160622033322_create_quality_analyses.rb b/db/migrate/20160622033322_create_quality_analyses.rb new file mode 100644 index 000000000..6316d5764 --- /dev/null +++ b/db/migrate/20160622033322_create_quality_analyses.rb @@ -0,0 +1,11 @@ +class CreateQualityAnalyses < ActiveRecord::Migration + def change + create_table :quality_analyses do |t| + t.integer :project_id + t.string :author_login + t.string :rep_identifier + + t.timestamps + end + end +end diff --git a/db/migrate/20160622074138_add_jk_version_to_quality_analysis.rb b/db/migrate/20160622074138_add_jk_version_to_quality_analysis.rb new file mode 100644 index 000000000..838d6d896 --- /dev/null +++ b/db/migrate/20160622074138_add_jk_version_to_quality_analysis.rb @@ -0,0 +1,5 @@ +class AddJkVersionToQualityAnalysis < ActiveRecord::Migration + def change + add_column :quality_analyses, :sonar_version, :integer, :default => false + end +end diff --git a/db/migrate/20160624032138_add_index_to_invite_code.rb b/db/migrate/20160624032138_add_index_to_invite_code.rb new file mode 100644 index 000000000..420951874 --- /dev/null +++ b/db/migrate/20160624032138_add_index_to_invite_code.rb @@ -0,0 +1,6 @@ +class AddIndexToInviteCode < ActiveRecord::Migration + def change + add_column :courses, :qrcode, :string + add_index :courses, :invite_code, unique: true + end +end diff --git a/db/migrate/20160624054614_add_column_to_quality_analyses.rb b/db/migrate/20160624054614_add_column_to_quality_analyses.rb new file mode 100644 index 000000000..ed3e6b137 --- /dev/null +++ b/db/migrate/20160624054614_add_column_to_quality_analyses.rb @@ -0,0 +1,6 @@ +class AddColumnToQualityAnalyses < ActiveRecord::Migration + def change + add_column :quality_analyses, :path, :string + add_column :quality_analyses, :branch, :string + end +end diff --git a/db/migrate/20160624055127_add_languae_to_quality_analyses.rb b/db/migrate/20160624055127_add_languae_to_quality_analyses.rb new file mode 100644 index 000000000..de531b1db --- /dev/null +++ b/db/migrate/20160624055127_add_languae_to_quality_analyses.rb @@ -0,0 +1,5 @@ +class AddLanguaeToQualityAnalyses < ActiveRecord::Migration + def change + add_column :quality_analyses, :language, :string + end +end diff --git a/db/migrate/20160627074232_add_column_to_syllabus.rb b/db/migrate/20160627074232_add_column_to_syllabus.rb new file mode 100644 index 000000000..f907f7a31 --- /dev/null +++ b/db/migrate/20160627074232_add_column_to_syllabus.rb @@ -0,0 +1,12 @@ +class AddColumnToSyllabus < ActiveRecord::Migration + def change + add_column :syllabuses, :eng_name, :string + add_column :syllabuses, :type, :integer + add_column :syllabuses, :credit, :integer + add_column :syllabuses, :hours, :integer + add_column :syllabuses, :theory_hours, :integer + add_column :syllabuses, :practice_hours, :integer + add_column :syllabuses, :applicable_major, :string + add_column :syllabuses, :pre_course, :string + end +end diff --git a/db/migrate/20160627090316_add_sonar_name_to_quality_analyses.rb b/db/migrate/20160627090316_add_sonar_name_to_quality_analyses.rb new file mode 100644 index 000000000..c69b5c909 --- /dev/null +++ b/db/migrate/20160627090316_add_sonar_name_to_quality_analyses.rb @@ -0,0 +1,5 @@ +class AddSonarNameToQualityAnalyses < ActiveRecord::Migration + def change + add_column :quality_analyses, :sonar_name, :string + end +end diff --git a/db/migrate/20160629030320_add_school_type_to_schools.rb b/db/migrate/20160629030320_add_school_type_to_schools.rb new file mode 100644 index 000000000..ad23ae555 --- /dev/null +++ b/db/migrate/20160629030320_add_school_type_to_schools.rb @@ -0,0 +1,5 @@ +class AddSchoolTypeToSchools < ActiveRecord::Migration + def change + add_column :schools, :school_type, :integer, :default => false + end +end diff --git a/db/migrate/20160629081520_create_apply_add_schools.rb b/db/migrate/20160629081520_create_apply_add_schools.rb new file mode 100644 index 000000000..3d47f55a1 --- /dev/null +++ b/db/migrate/20160629081520_create_apply_add_schools.rb @@ -0,0 +1,15 @@ +class CreateApplyAddSchools < ActiveRecord::Migration + def change + create_table :apply_add_schools do |t| + t.string :name + t.string :province + t.string :city + t.string :address + t.string :remarks + t.integer :school_id + t.integer :status, :default => false + + t.timestamps + end + end +end diff --git a/db/migrate/20160629084146_add_visits_to_syllabus.rb b/db/migrate/20160629084146_add_visits_to_syllabus.rb new file mode 100644 index 000000000..7dc997e00 --- /dev/null +++ b/db/migrate/20160629084146_add_visits_to_syllabus.rb @@ -0,0 +1,5 @@ +class AddVisitsToSyllabus < ActiveRecord::Migration + def change + add_column :syllabuses, :visits, :integer, :default => 0 + end +end diff --git a/db/migrate/20160629094716_add_des_status_to_syllabus.rb b/db/migrate/20160629094716_add_des_status_to_syllabus.rb new file mode 100644 index 000000000..aa91bdd3c --- /dev/null +++ b/db/migrate/20160629094716_add_des_status_to_syllabus.rb @@ -0,0 +1,5 @@ +class AddDesStatusToSyllabus < ActiveRecord::Migration + def change + add_column :syllabuses, :des_status, :integer, :default => 0 + end +end diff --git a/db/migrate/20160630112733_rename_syllabus_column.rb b/db/migrate/20160630112733_rename_syllabus_column.rb new file mode 100644 index 000000000..a461672dd --- /dev/null +++ b/db/migrate/20160630112733_rename_syllabus_column.rb @@ -0,0 +1,8 @@ +class RenameSyllabusColumn < ActiveRecord::Migration + def up + rename_column :syllabuses, :type, :syllabus_type + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 95ffceef1..3258f89c1 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 => 20160612043259) do +ActiveRecord::Schema.define(:version => 20160627090316) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -550,8 +550,14 @@ ActiveRecord::Schema.define(:version => 20160612043259) do t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 + t.integer "syllabus_id" + t.string "invite_code" + t.string "qrcode" end + add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true + add_index "courses", ["syllabus_id"], :name => "index_courses_on_syllabus_id" + create_table "custom_fields", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -1516,6 +1522,19 @@ ActiveRecord::Schema.define(:version => 20160612043259) do add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + create_table "quality_analyses", :force => true do |t| + t.integer "project_id" + t.string "author_login" + t.string "rep_identifier" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sonar_version", :default => 0 + t.string "path" + t.string "branch" + t.string "language" + t.string "sonar_name" + end + create_table "queries", :force => true do |t| t.integer "project_id" t.string "name", :default => "", :null => false @@ -1826,6 +1845,16 @@ ActiveRecord::Schema.define(:version => 20160612043259) do t.datetime "updated_at", :null => false end + create_table "syllabuses", :force => true do |t| + t.string "title" + t.text "description" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id" + create_table "system_messages", :force => true do |t| t.integer "user_id" t.string "content" diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 0354ed467..c78fd430e 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -300,8 +300,8 @@ K.options = { '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.background', '.border','.border-color', '.text-overflow','.overflow','.white-space' ], - a : ['id', 'class', 'href', 'target', 'name'], - embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'], + a : ['id', 'class', 'href', 'target', 'name','data-method','data-remote','rel'], + embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'], img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'], 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [ 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background', diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 69ea8f1fa..f042daba7 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -20,23 +20,25 @@
                -
                +
                迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
                缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
      - 普通作业 - 编程作业 - 分组作业 - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + 普通作业 + 编程作业 + 分组作业 + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -58,14 +60,16 @@
      - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -87,14 +91,16 @@
      - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -127,21 +133,23 @@
      -
      +
      状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
      指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
      - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -164,14 +172,16 @@
      - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -208,13 +218,15 @@
      - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -237,13 +249,15 @@
      - {{act.latest_update}} - 回复 - {{act.reply_count}} -
      -
      {{act.praise_count}}
      -
      {{act.praise_count}}
      -
      +
      + {{act.latest_update}} + 回复 + {{act.reply_count}} +
      +
      {{act.praise_count}}
      +
      {{act.praise_count}}
      +
      +
      @@ -254,6 +268,7 @@
      更多
      + diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 5059c41ab..a3977ec5c 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -2,7 +2,7 @@ - 我的动态 + 仅供本地调试使用 @@ -10,6 +10,7 @@ + @@ -17,8 +18,38 @@
      + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 509e0171a..762bd090e 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -39,7 +39,7 @@ - +
      diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html new file mode 100644 index 000000000..dc575dc64 --- /dev/null +++ b/public/assets/wechat/class.html @@ -0,0 +1,55 @@ +
      +
      +
      {{course.name}}邀请码
      +
      + + +
      + +
      +
      +
      +
      + +
      +
      +
      +
      + +
      +
      + +
      +
      {{r.filename}}发送
      +

      暂无课件,
      + 请登录Trustie网站,在PC浏览器中上传课件。

      +
      +
      +
      授课老师
      + +
      + {{teacher.name}}{{teacher.role_name|identify}} +
      +
      我的同学
      +
      + {{student.name}} +
      +
      + +
      +
      {{r.homework_name}}发送
      +

      暂无作业,
      + 请登录Trustie网站,在PC浏览器中上传作业。

      + +
      + +
      +
      {{r.exercise_name}}发送
      +

      暂无小测验,
      + 请登录Trustie网站,在PC浏览器中上传小测验。

      +
      + + + + +
      diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html new file mode 100644 index 000000000..8ec8bcaa5 --- /dev/null +++ b/public/assets/wechat/class_list.html @@ -0,0 +1,21 @@ +
      +
      +
      课程列表
      +
      未命名课程
      +
        +
      • + + + > + {{course.course_student_num}}人 +
      • +
      + + + + +
      \ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 2e7ed3151..4b578366d 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -13,9 +13,9 @@ - +
      序号 <%= item.teacher.show_name %> 课程作业:班级作业: <%= item.homework_commons.count %>
      来   源:{{discussion.course_project_name}}  |  课程问答区{{discussion.course_project_name}}  |  班级问答区
      -
      +
      {{discussion.created_on}}
      @@ -46,7 +46,7 @@
      - +
      diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index cca135681..f30105d40 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -12,9 +12,9 @@ 来   源: - {{news.course_name}}  |  课程通知 + {{news.course_name}}  |  班级通知 -
      +
      {{news.created_on}}
      @@ -45,7 +45,7 @@
      - +
      diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 0fc39c735..387b69867 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -18,13 +18,13 @@ 类   别: - 普通作业 - 编程作业 - 分组作业 + 普通作业 + 编程作业 + 分组作业 -
      +
      迟交扣分:{{homework.late_penalty}}分
      缺评扣分:{{homework.absence_penalty}}分/作品
      匿评开启时间:{{homework.evaluation_start}}
      @@ -59,7 +59,7 @@
      - +
      diff --git a/public/assets/wechat/invite_code.html b/public/assets/wechat/invite_code.html new file mode 100644 index 000000000..1aa0c8830 --- /dev/null +++ b/public/assets/wechat/invite_code.html @@ -0,0 +1,16 @@ +
      +
      +
      + +
      +
      邀请码:{{course.invite_code}}
      +
      +
      + +
      \ No newline at end of file diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html deleted file mode 100644 index 558496ef0..000000000 --- a/public/assets/wechat/issue.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - react js - - - - - - - - - - - -
      - - - - - - - - - - \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 1d7f9a536..4fc085b7e 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -14,7 +14,7 @@ 来   源: {{issue.project_name}}  |  项目问题 -
      +
      状   态:{{issue.issue_status}}
      优先级:{{issue.issue_priority}}
      指派给:{{issue.issue_assigned_to}}
      @@ -49,7 +49,7 @@
    - +
    diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index dc6b1409f..9fd09de2c 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -37,7 +37,7 @@
    - +
    diff --git a/public/assets/wechat/login.html b/public/assets/wechat/login.html new file mode 100644 index 000000000..309db29de --- /dev/null +++ b/public/assets/wechat/login.html @@ -0,0 +1,25 @@ +
    +
    + +
    +
    绑定注册
    + + + + + +
    +
    + + \ No newline at end of file diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html new file mode 100644 index 000000000..9d3bf0fda --- /dev/null +++ b/public/assets/wechat/myresource.html @@ -0,0 +1,26 @@ +
    +
    我的资源
    +
    + {{menu}} +
    +
    +
    + +
    +
    +
    +
    {{r.filename}}发送
    +

    暂无课件,
    + 请登录Trustie网站,在PC浏览器中上传课件。

    +
    +
    +
    {{r.homework_name}}发送
    +

    暂无作业,
    + 请登录Trustie网站,在PC浏览器中创建作业。

    +
    +
    +
    {{r.exercise_name}}发送
    +

    暂无测验,
    + 请登录Trustie网站,在PC浏览器中创建测验。

    +
    +
    diff --git a/public/assets/wechat/new_class.html b/public/assets/wechat/new_class.html new file mode 100644 index 000000000..2bb5d2aac --- /dev/null +++ b/public/assets/wechat/new_class.html @@ -0,0 +1,7 @@ +
    +
    新建课程
    +
    课程
    +
    班级
    + + 完成 +
    diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 4831e1521..8be12c403 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -14,7 +14,7 @@ 来   源: {{discussion.course_project_name}}  |  项目讨论区 -
    +
    {{discussion.created_on}}
    @@ -45,7 +45,7 @@
    - +
    diff --git a/public/assets/wechat/reg.html b/public/assets/wechat/reg.html new file mode 100644 index 000000000..9184fd0ed --- /dev/null +++ b/public/assets/wechat/reg.html @@ -0,0 +1,43 @@ +
    +
    +
    注册登录
    + + + + + + + + + +
    +
    + + \ No newline at end of file diff --git a/public/assets/wechat/templates/alert.html b/public/assets/wechat/templates/alert.html new file mode 100644 index 000000000..b59a1b87f --- /dev/null +++ b/public/assets/wechat/templates/alert.html @@ -0,0 +1,12 @@ + +
    +
    +
    +
    {{title}}
    +
    {{message}}
    +
    + 确定 +
    +
    +
    + \ No newline at end of file diff --git a/public/images/code-analysis-icon.png b/public/images/code-analysis-icon.png new file mode 100644 index 000000000..18869da0e Binary files /dev/null and b/public/images/code-analysis-icon.png differ diff --git a/public/images/icons_ziliao.png b/public/images/icons_ziliao.png new file mode 100644 index 000000000..dc72e7361 Binary files /dev/null and b/public/images/icons_ziliao.png differ diff --git a/public/images/syllabus.jpg b/public/images/syllabus.jpg new file mode 100644 index 000000000..3daef5a01 Binary files /dev/null and b/public/images/syllabus.jpg differ diff --git a/public/images/syllabus/icons_syllabus.png b/public/images/syllabus/icons_syllabus.png new file mode 100644 index 000000000..7f6c4987c Binary files /dev/null and b/public/images/syllabus/icons_syllabus.png differ diff --git a/public/images/wechat/QR-code.jpg b/public/images/wechat/QR-code.jpg new file mode 100644 index 000000000..ba2a9e6a3 Binary files /dev/null and b/public/images/wechat/QR-code.jpg differ diff --git a/public/images/wechat/arrow.png b/public/images/wechat/arrow.png new file mode 100644 index 000000000..f9f9b18c5 Binary files /dev/null and b/public/images/wechat/arrow.png differ diff --git a/public/images/wechat/checked.png b/public/images/wechat/checked.png new file mode 100644 index 000000000..77986d62e Binary files /dev/null and b/public/images/wechat/checked.png differ diff --git a/public/images/wechat/class.jpg b/public/images/wechat/class.jpg new file mode 100644 index 000000000..e3eebb977 Binary files /dev/null and b/public/images/wechat/class.jpg differ diff --git a/public/images/wechat/dot.png b/public/images/wechat/dot.png new file mode 100644 index 000000000..bf1c0104e Binary files /dev/null and b/public/images/wechat/dot.png differ diff --git a/public/images/wechat/female.jpg b/public/images/wechat/female.jpg new file mode 100644 index 000000000..219865572 Binary files /dev/null and b/public/images/wechat/female.jpg differ diff --git a/public/images/wechat/female.png b/public/images/wechat/female.png new file mode 100644 index 000000000..a13733ffc Binary files /dev/null and b/public/images/wechat/female.png differ diff --git a/public/images/wechat/male.jpg b/public/images/wechat/male.jpg new file mode 100644 index 000000000..46d58f26e Binary files /dev/null and b/public/images/wechat/male.jpg differ diff --git a/public/images/wechat/male.png b/public/images/wechat/male.png new file mode 100644 index 000000000..9f1214a4c Binary files /dev/null and b/public/images/wechat/male.png differ diff --git a/public/images/wechat/minus.png b/public/images/wechat/minus.png new file mode 100644 index 000000000..32d82ea84 Binary files /dev/null and b/public/images/wechat/minus.png differ diff --git a/public/images/wechat/plus.png b/public/images/wechat/plus.png new file mode 100644 index 000000000..e5d83d212 Binary files /dev/null and b/public/images/wechat/plus.png differ diff --git a/public/images/wechat/post-avatar.jpg b/public/images/wechat/post-avatar.jpg new file mode 100644 index 000000000..bd2597dd2 Binary files /dev/null and b/public/images/wechat/post-avatar.jpg differ diff --git a/public/images/wechat/search.png b/public/images/wechat/search.png new file mode 100644 index 000000000..a04c1496c Binary files /dev/null and b/public/images/wechat/search.png differ diff --git a/public/images/wechat/setting.png b/public/images/wechat/setting.png new file mode 100644 index 000000000..3c1159fc9 Binary files /dev/null and b/public/images/wechat/setting.png differ diff --git a/public/images/wechat/tr-like.png b/public/images/wechat/tr-like.png new file mode 100644 index 000000000..9d9d38dc3 Binary files /dev/null and b/public/images/wechat/tr-like.png differ diff --git a/public/images/wechat/tr-reply.png b/public/images/wechat/tr-reply.png new file mode 100644 index 000000000..aef9cffcf Binary files /dev/null and b/public/images/wechat/tr-reply.png differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index f5edb5ef4..016526512 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1290,7 +1290,24 @@ function clear_data(k,mdu){ } } -function expand_reply(container, btnid, id, type, div_id) { +function expand_reply(container,btnid){ + var target = $(container).children(); + var btn = $(btnid); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.html('收起回复'); + target.show(); + }else{ + btn.data('init',0); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } +} + +function expand_all_reply(container, btnid, id, type, div_id) { var target = $(container); var btn = $(btnid); if (btn.data('init') == '0') { @@ -1323,6 +1340,40 @@ function expand_reply(container, btnid, id, type, div_id) { } } +function expand_journal_reply(container, btnid, id, type, div_id, allow_delete) { + var target = $(container); + var btn = $(btnid); + if (btn.data('init') == '0') { + btn.data('init', 1); + $.get( + '/users/all_journals', + { + type: type, + id: id, + div_id: div_id, + allow_delete: allow_delete + }, + function(data) { + + } + ); + btn.html('收起回复'); + //target.show(); + } else if(btn.data('init') == '1') { + btn.data('init', 3); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } + else { + btn.data('init', 1); + btn.html('收起回复'); + target.show(); + } +} + function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) { var target = $(container); var btn = $(btnid); @@ -1504,6 +1555,25 @@ function edit_file_description(url,id){ } ); } + +//展开课程大纲列表中的班级 +function expand_course_list(id, target, btnid, count) { + var target = $(target); + var btn = $(btnid); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.html('点击收起'); + target.show(); + }else{ + btn.data('init',0); + btn.html('共'+count+ '个课程,点击全部展开'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + btn.parent().show(); + } +} //删除组织成员 function ifDeleteOrgMember(id,name){ var htmlvalue = "
    您确定要删除"+name+"吗?

    确定取消
    " + diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 6fbf9f8c4..8215f3aa1 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -182,10 +182,26 @@ function regex_course_password(str) return false; } } +//验证课程大纲 +function regex_syllabus_option(str) { + if(document.getElementById(str + "_syllabus_id")) { + var obj = document.getElementById(str + "_syllabus_id"); + var syllabus = obj.options[obj.selectedIndex]; + if(parseInt(syllabus.value) == 0) { + $("#"+str+"_syllabus_notice").show(); + return false; + } else{ + $("#"+str+"_syllabus_notice").hide(); + return true; + } + } else { + return true; + } +} //提交新建课程 function submit_new_course() { - if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')&®ex_course_password('new')) + if(regex_syllabus_option('new')&®ex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')) { $("#new_course").submit(); } @@ -193,11 +209,35 @@ function submit_new_course() function submit_edit_course(id) { - if(regex_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')&®ex_course_password('edit')) + if(regex_syllabus_option('edit')&®ex_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')) { $("#edit_course_"+id).submit(); } } + +//新建课程大纲 +function submit_new_syllabus() +{ + if(regex_syllabus_name()) + { + $("#new_syllabus").submit(); + } +} + +function regex_syllabus_name() { + var name = $.trim($("#new_syllabus_name").val()); + if(name.length < 2) + { + $("#new_syllabus_name_notice").show(); + return false; + } + else + { + $("#new_syllabus_name_notice").hide(); + return true; + } +} + //课程讨论区 function regexTopicSubject() { var name = $("#message_subject").val(); diff --git a/public/javascripts/resizeable_table.js b/public/javascripts/resizeable_table.js index a43078dee..e5b57844a 100644 --- a/public/javascripts/resizeable_table.js +++ b/public/javascripts/resizeable_table.js @@ -1,7 +1,7 @@ /** * Created by ttang on 2016/5/24. */ - /*$(document).ready(function(){ + /* $(document).ready(function(){ $("th").each(function(){ $(this).css("width",$(this).width()-1); }); @@ -38,7 +38,7 @@ if (mousedown == true){ var width = (tdWidth + (evt.screenX - screenXStart)) - p1 + "px";//计算后的新的宽度 var width2 = (tdWidth2 - (evt.screenX - screenXStart)) - p2 + "px"; - if (parseInt(width)<0 || parseInt(width2)<0 || tdWidth > totalWidth || tdWidth2 > totalWidth){ + if (parseInt(width)<5 || parseInt(width2)<5 || tdWidth > totalWidth || tdWidth2 > totalWidth){ tartgetTd = null; resizeable = false; mousedown = false; diff --git a/public/javascripts/syllabus.js b/public/javascripts/syllabus.js new file mode 100644 index 000000000..1b2a18a41 --- /dev/null +++ b/public/javascripts/syllabus.js @@ -0,0 +1,100 @@ +//显示更多的班级 +function show_more_course(url){ + $.get( + url, + { page: $("#course_page_num").val() }, + function (data) { + } + ); +} + +function regex_sylla_description() { + syllabus_description_editor.sync(); + var name = syllabus_description_editor.html(); + if (name.length == 0) { + $("#description_notice_span").text("描述不能为空"); + $("#description_notice_span").css('color', '#ff0000'); + $("#description_notice_span").focus(); + return false; + } + else { + $("#description_notice_span").text("填写正确"); + $("#description_notice_span").css('color', '#008000'); + return true; + } +} + +function submit_syllabus() { + if (regex_sylla_description()) { + $("#syllabus-form").submit(); + } +} + +//编辑英文名称 +function show_edit_eng_name() { + $("#syllabus_eng_name_show").hide(); + $("#syllabus_eng_name_edit").show(); + $("#syllabus_eng_name_edit").focus(); +} + +//编辑英文名称之后提交 +function edit_syllabus_eng_name(url){ + $.get( + url, + { eng_name: $("#syllabus_eng_name_edit").val() }, + function (data) { + + } + ); +} + +//展开所有属性 +function toggle_all_syllabus_attr(){ + var btn = $("#show_all_syllabus_attr"); + var target = $("#all_syllabus_attr li"); + var none = $("#all_syllabus_attr li.none_attr"); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.removeClass('homepageLeftMenuMoreIcon'); + btn.addClass('homepageLeftMenuHideIcon'); + target.show(); + }else{ + btn.data('init',0); + btn.addClass('homepageLeftMenuMoreIcon'); + btn.removeClass('homepageLeftMenuHideIcon'); + none.hide(); + } +} + +function update_syllabus_info(){ + if(regex_syllabus_credit('credit') && regex_syllabus_credit('hours') && regex_syllabus_credit('theory_hours') && regex_syllabus_credit('practice_hours')) { + $("#submit_edit_info").parent().submit(); + } +} + +function regex_syllabus_credit(str){ + var num = $.trim($("#syllabus_"+str+"_input").val()); + var regex = /^\d*$/; + if(num.length > 0) + { + if (regex.test(num)) { + if(parseInt(num) > 0) + { + $("#syllabus_"+str+"_notice").hide(); + return true; + } else + { + $("#syllabus_"+str+"_notice").show(); + $("#syllabus_"+str+"_input").focus(); + return false; + } + } else { + $("#syllabus_"+str+"_notice").show(); + $("#syllabus_"+str+"_input").focus(); + return false; + } + } else { + return true; + } + +} \ No newline at end of file diff --git a/public/javascripts/wechat/CommentBox.jsx b/public/javascripts/wechat/CommentBox.jsx deleted file mode 100644 index 7f30b38b1..000000000 --- a/public/javascripts/wechat/CommentBox.jsx +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Created by guange on 16/3/19. - */ - - - - -var CommentBox = React.createClass({ - - loadFromServer: function(){ - $.ajax({ - url: this.props.url, - dataType: 'json', - success: function(data){ - this.setState({data: data}); - }.bind(this), - error: function(xhr,status,err){ - console.error(this.props.url, status, err.toString()); - }.bind(this) - }); - }, - onCommentSubmit: function(comment){ - console.log(comment); - }, - getInitialState: function(){ - return {data: []}; - }, - componentDidMount: function(){ - this.loadFromServer(); - setInterval(this.loadFromServer, 2000); - }, - render: function(){ - return( -
    - - -
    - ); - } -}); - -var CommentList = React.createClass({ - render: function(){ - - var commentNodes = this.props.data.map(function(comment){ - return ( - - {comment.text} - - ) - }); - - return ( -
    - {commentNodes} -
    - ); - } -}); - -var CommentForm = React.createClass({ - handleSubmit: function(e){ - e.preventDefault(); - - var author = this.refs.author.value.trim(); - var text = this.refs.text.value.trim(); - if(!text || !author){ - return; - } - - this.props.onCommentSubmit({author: author, text: text}); - - this.refs.author.value = ''; - this.refs.text.value = ''; - return; - }, - render: function(){ - return ( -
    - - - -
    - ); - } -}); - - -var Comment = React.createClass({ - - rawMarkup: function() { - var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); - return { __html: rawMarkup }; - }, - - render: function(){ - return ( -
    -

    - {this.props.author} -

    - -
    - ) - } -}) - -React.render(, document.getElementById("example")); \ No newline at end of file diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index ca9682db2..00d6bf3bc 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,546 +1,29 @@ var app = angular.module('wechat', ['ngRoute']); -var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true -if(debug===true){ - //apiUrl = 'http://localhost:3000/api/v1/'; - apiUrl = 'http://www.trustie.net/api/v1/'; -} - - -app.factory('auth', function($http,$routeParams, $q){ - var _openid = ''; - - if(typeof g_openid !== 'undefined'){ - _openid = g_openid; - } - - if(debug===true){ - _openid = "orgVLv8TlS6e7FDiI6xdTGHRaaRo"; //guange的帐号 - } - - var getOpenId = function() { - var deferred = $q.defer(); - if (typeof _openid !== 'undefined' && _openid.length > 0){ - deferred.resolve(_openid); - } else { - var code = $routeParams.code; - $http({ - url: '/wechat/get_open_id', - data: {code: code}, - method: 'POST' - }).then(function successCallback(response) { - _openid = response.data.openid; - deferred.resolve(_openid); - }, function errorCallback(response) { - deferred.reject(response); - }); - } - return deferred.promise; - }; - var openid = function(){ - return _openid; - }; - return {getOpenId: getOpenId, openid: openid}; -}); - - -app.factory('rms', function(){ - var _saveStorage = {}; - var save = function(key, value){ - _saveStorage[key] = value; - }; - - var get = function(key){ - return _saveStorage[key]; - }; - - return {save: save, get: get}; +app.constant('config', { + rootPath: '/assets/wechat/', + rootUrl: '/', + apiUrl: '/api/v1/' }); -app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){ - $scope.replaceUrl = function(url){ - return url; - }; - - console.log("ActivityController load"); - - $scope.page = rms.get('page') || 0; - $scope.activities = rms.get("activities") || []; - $scope.has_more = rms.get("has_more"); - - $scope.loadActData = function(page){ - - $scope.page = page; - $http({ - method: 'POST', - url: apiUrl+ "activities", - data: {openid: auth.openid(), page: page} - }).then(function successCallback(response) { - if(response.data.page >0) { - $scope.activities = $scope.activities.concat(response.data.data); - } else { - $scope.activities = response.data.data; - } - - rms.save("activities", $scope.activities); - $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; - rms.save('has_more', $scope.has_more); - rms.save('page', response.data.page); - console.log(response.data); - - }, function errorCallback(response) { - }); - }; - - if($scope.activities.length<=0){ - auth.getOpenId().then( - function successCallback(response){ - $scope.loadActData(0); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - } else { - $timeout(function(){ - window.scrollTo(0, rms.get("yoffset")); - }); +app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){ + if(g_redirect_path && g_redirect_path.length>1){ + $location.path(g_redirect_path); + g_redirect_path = null; } - //跳到详情页 - $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset", window.document.body.scrollTop); - $location.path('/'+type+'/'+act_id); - } - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; + $rootScope.$on('$routeChangeError', function(event, next, current){ - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.factory('common', function($http, auth, $routeParams){ - var addCommonReply = function(id, type, data, cb){ - - if(!data.comment || data.comment.length<=0){ - return; - } - - var temp = data.comment.replace(/\n/g,'
    '); - - var userInfo = { - type: type, - content: temp, - openid: auth.openid() - }; - //回复按钮禁用 - data.disabled = true; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+id, - data: userInfo - }).then(function successCallback(response) { - //alert("提交成功"); - //数据提交完成,回复按钮启用 - data.disabled = false; - if(typeof cb === 'function'){ - cb(); + if(next && next.templateUrl){ + if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){ + $location.path("/login"); } - }, function errorCallback(response) { - }); - }; - - var loadCommonData = function(id, type){ - return $http({ - method: 'GET', - url: apiUrl+ type + "/" + id+"?openid="+auth.openid() - }) - }; - - var addCommonPraise = function(act){ - act.praise_count += 1; - act.has_praise = true; - - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{openid:auth.openid(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - - }; - - var decreaseCommonPraise = function(act){ - act.praise_count -= 1; - act.has_praise = false; - - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{openid:auth.openid(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - }; - - return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; -}); - -app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'issues').then(function successCallback(response) { - console.log(response.data); - $scope.issue = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); } - ); - - $scope.addIssueReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'Issue', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - - }; + }); - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'whomeworks').then(function successCallback(response) { - console.log(response.data); - $scope.homework = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addHomeworkReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'newss').then(function successCallback(response) { - console.log(response.data); - $scope.news = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addNoticeReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'News', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'messages').then(function successCallback(response) { - console.log(response.data); - $scope.discussion = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addDiscussionReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'Message', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) { - console.log(response.data); - $scope.message = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addJournalReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - console.log(act); - common.decreaseCommonPraise(act); - }; -}); - -app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'blog_comments').then(function successCallback(response) { - console.log(response.data); - $scope.blog = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addBlogReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'BlogComment', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - console.log(act); - common.decreaseCommonPraise(act); - }; -}); - -app.filter('safeHtml', function ($sce) { - return function (input) { - return $sce.trustAsHtml(input); - } -}); - -//app.directive('textAutoHeight', function($timeout){ -// return { -// restrict: 'A', -// scope: {}, -// link: function(scope, element, attr){ -// scope.text = '点击展开'; -// $timeout(function(){ -// var e = element.parent().children().eq(5); -// var height = e[0].scrollHeight; -// if(height>90){ -// element.css('display', 'block'); -// element.on('click', function(){ -// if(element.text() == "点击展开"){ -// e.css("height", height+'px'); -// element.text("点击隐藏"); -// } else { -// e.css("height", '90px'); -// element.text("点击展开"); -// } -// -// }); -// } -// }, false); -// -// } -// } -//}); - -app.directive('inputAuto',function(){ - return{ - restrict: 'A', - scope: {}, - link: function(scope, element){ - var copyContainer = element.parent().children().eq(0); - var sendButton = element.parent().next(); - element.on('input',function(){ - console.log(sendButton); - copyContainer.html(element[0].value); - var textHeight = copyContainer[0].scrollHeight; - element.css('height', textHeight + 'px'); - }); - sendButton.on('click',function(){ - element.css('height','28px'); - }); - } - } -}); - -app.directive('loadingSpinner', ['$http', function ($http) { - return { - restrict: 'A', - replace: true, - template: '
    加载中...
    ', - }; -}]); - -app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) { - var rootPath = '/assets/wechat/' - //$locationProvider.html5Mode(true); - $routeProvider - .when('/activites', { - templateUrl: rootPath + 'activities.html', - controller: 'ActivityController' - }) - .when('/issues/:id', { - templateUrl: rootPath + 'issue_detail.html', - controller: 'IssueController' - }) - .when('/project_discussion/:id', { - templateUrl: rootPath + 'project_discussion.html', - controller: 'DiscussionController' - }) - .when('/homework/:id', { - templateUrl: rootPath + 'homework_detail.html', - controller: 'HomeworkController' - }) - .when('/course_notice/:id', { - templateUrl: rootPath + 'course_notice.html', - controller: 'CourseNoticeController' - }) - .when('/course_discussion/:id', { - templateUrl: rootPath + 'course_discussion.html', - controller: 'DiscussionController' - }) - .when('/journal_for_message/:id', { - templateUrl: rootPath + 'jour_message_detail.html', - controller: 'JournalsController' - }) - .when('/blog_comment/:id', { - templateUrl: rootPath + 'blog_detail.html', - controller: 'BlogController' - }) - .otherwise({ - redirectTo: '/activites' - }); - - //监听异步请求,实现加载中显隐标记 - $httpProvider.interceptors.push(function ($q, $rootScope) { - if ($rootScope.activeCalls == undefined) { - $rootScope.activeCalls = 0; - } - - return { - request: function (config) { - $rootScope.activeCalls += 1; - return config; - }, - requestError: function (rejection) { - $rootScope.activeCalls -= 1; - return rejection; - }, - response: function (response) { - $rootScope.activeCalls -= 1; - return response; - }, - responseError: function (rejection) { - $rootScope.activeCalls -= 1; - return rejection; - } - }; - }); -}]); + $rootScope.$on('$routeChangeStart', function(event, next, current){ + }); +} +]); \ No newline at end of file diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js deleted file mode 100644 index f9c2917fc..000000000 --- a/public/javascripts/wechat/auth.js +++ /dev/null @@ -1,36 +0,0 @@ -$(function(){ - //获取url中的参数 - function getUrlParam(name) { - var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 - var r = window.location.search.substr(1).match(reg); //匹配目标参数 - if (r != null) return unescape(r[2]); return null; //返回参数值 - } - - - var debug = false; - - var g_openid = ""; - if(debug){ - g_openid = "填写要调试的openid即可"; - } - - window.getOpenId = function(cb){ - if (g_openid.length>0){ - cb(g_openid); - } - var code = getUrlParam("code"); - $.ajax({ - url: '/wechat/get_open_id', - data: {code: code}, - type: 'post', - dataType: 'json', - success: function(data){ - g_openid = data.openid; - cb(g_openid); - }, - error: function(xhr,err){ - alert("认证失败: "+err); - } - }); - } -}); \ No newline at end of file diff --git a/public/javascripts/wechat/blog_detail.js b/public/javascripts/wechat/blog_detail.js deleted file mode 100644 index 44121f83c..000000000 --- a/public/javascripts/wechat/blog_detail.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:blog-detail',{blog: data}); - $('#blog-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - $('post-interactive-praise').click(function(){ - praiseClick(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'blog_comments/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js new file mode 100644 index 000000000..1fea6f08a --- /dev/null +++ b/public/javascripts/wechat/build/app.min.js @@ -0,0 +1,22 @@ +var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); +app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,e,n){this.message=e,this.title=t,this.visible=!0,this.cb=n},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,e,n,o,a){var i=function(){var a=n.defer(),i=c();if(i&&i.length>10)a.resolve(i);else{window.g_code||e.code||o.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?a.reject(t.data.message):(o.save("token",t.data.token),a.resolve(t.data.token))})["catch"](function(t){a.reject(t)})}return a.promise},c=function(){return o.get("token")};return{get_bind:i,token:c}}]),app.factory("session",function(){return{save:function(t,e){sessionStorage.setItem(t,e)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},e=function(e,n){t[e]=n},n=function(e){return t[e]};return{save:e,get:n}}),app.factory("common",["$http","auth","$routeParams",function(t,e,n){var o=function(n,o,a,i){if(a.comment&&!(a.comment.length<=0)){var c=a.comment.replace(/\n/g,"
    "),s={type:o,content:c,token:e.token()};a.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+n,data:s}).then(function(t){a.disabled=!1,"function"==typeof i&&i()},function(t){})}},a=function(n,o){return t({method:"GET",url:apiUrl+o+"/"+n+"?token="+e.token()})},i=function(n){n.praise_count+=1,n.has_praise=!0,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},c=function(n){n.praise_count-=1,n.has_praise=!1,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},s=function(t){t.scope.formData={comment:""};var e=function(e){a(e,t.type).then(function(e){t.loadCallback(e.data)},function(t){})};e(t.id),t.scope.addReply=function(n){console.log(n.comment),o(t.id,t.replyType,n,function(){t.scope.formData={comment:""},e(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=i,t.scope.decreasePraise=c};return{init:s,addCommonReply:o,loadCommonData:a,addCommonPraise:i,decreaseCommonPraise:c}}]); +app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}}); +app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,t,e,o,i,c,n,r,s){e.replaceUrl=function(a){return a},e.alertService=s.create(),console.log("ActivityController load"),e.page=n.get("page")||0,e.activities=n.get("activities")||[],e.has_more=n.get("has_more"),e.loadActData=function(a){e.page=a,o({method:"POST",url:apiUrl+"activities",data:{token:c.token(),page:a}}).then(function(a){a.data.page>0?e.activities=e.activities.concat(a.data.data):e.activities=a.data.data,n.save("activities",e.activities),e.has_more=a.data.count+10*a.data.page
    加载中...
    '}}]); +app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,r,t){var l=t.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},s=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",s("activities.html","ActivityController")).when("/issues/:id",s("issue_detail.html","IssueController")).when("/project_discussion/:id",s("project_discussion.html","DiscussionController")).when("/homework/:id",s("homework_detail.html","HomeworkController")).when("/course_notice/:id",s("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",s("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",s("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",s("blog_detail.html","BlogController")).when("/class",s("class.html","ClassController")).when("/new_class",s("new_class.html","NewClassController")).when("/class_list",s("class_list.html","ClassListController")).when("/myresource",s("myresource.html","MyResourceController")).when("/invite_code",s("invite_code.html","InviteCodeController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/activity.js b/public/javascripts/wechat/controllers/activity.js new file mode 100644 index 000000000..73bd09f26 --- /dev/null +++ b/public/javascripts/wechat/controllers/activity.js @@ -0,0 +1,62 @@ + +app.controller('ActivityController', + ['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common','alertService', + function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common, alertService){ + $scope.replaceUrl = function(url){ + return url; + }; + + $scope.alertService = alertService.create(); + console.log("ActivityController load"); + + $scope.page = rms.get('page') || 0; + $scope.activities = rms.get("activities") || []; + $scope.has_more = rms.get("has_more"); + + $scope.loadActData = function(page){ + + $scope.page = page; + $http({ + method: 'POST', + url: apiUrl+ "activities", + data: {token: auth.token(), page: page} + }).then(function successCallback(response) { + if(response.data.page >0) { + $scope.activities = $scope.activities.concat(response.data.data); + } else { + $scope.activities = response.data.data; + } + + rms.save("activities", $scope.activities); + $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; + rms.save('has_more', $scope.has_more); + rms.save('page', response.data.page); + + console.log(response.data); + + }, function errorCallback(response) { + }); + }; + + if($scope.activities.length<=0){ + $scope.loadActData(0); + } else { + $timeout(function(){ + window.scrollTo(0, rms.get("yoffset")); + }); + } + + //跳到详情页 + $scope.goDetail = function(type, act_id,id){ + rms.save("yoffset", window.document.body.scrollTop); + $location.path('/'+type+'/'+act_id); + } + + $scope.addPraise = function(act){ + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + common.decreaseCommonPraise(act); + }; +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js new file mode 100644 index 000000000..4c2403944 --- /dev/null +++ b/public/javascripts/wechat/controllers/blog.js @@ -0,0 +1,16 @@ +app.controller('BlogController', + ['$scope', '$http', '$routeParams', 'auth', 'common', + function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'blog_comments', + replyType: 'BlogComment', + loadCallback: function(data){ + $scope.blog = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js new file mode 100644 index 000000000..c2281be88 --- /dev/null +++ b/public/javascripts/wechat/controllers/class.js @@ -0,0 +1,128 @@ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ + + var vm = $scope; + var courseid = $routeParams.id; + + + + var getUsers = function(){ + if(vm.teachers.length<=0){ + $http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then( + function(response) { + console.log(response.data); + vm.teachers = response.data.data; + } + ) + } + + if(vm.students.length<=0){ + $http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then( + function(response) { + console.log(response.data); + vm.students = response.data.data; + } + ) + } + } + + var getResources = function(){ + if(vm.resources.length<=0){ + $http.post(config.apiUrl + "courses/"+courseid+"/attachments", + {token: auth.token(), name: ''} + ).then(function(response){ + vm.resources = response.data.data; + }); + } + } + + var getHomeworks = function(){ + if(vm.homeworks.length <=0){ + $http.get(config.apiUrl + "courses/homeworks/"+courseid+"?token="+auth.token()).then(function(response){ + vm.homeworks = response.data.data; + console.log(response.data); + }); + } + } + + var getExercises = function(){ + if(vm.exercises.length <=0){ + $http.get(config.apiUrl + "courses/"+courseid+"/exercises?token="+auth.token()).then(function(response){ + vm.exercises = response.data.data; + console.log(response.data); + }); + } + } + + + vm.isTeacher = false; + vm.currentTab = 1; + vm.tab = function(index){ + vm.currentTab = index; + vm.searchText = ''; + + vm.showClassMate = false; + vm.showResources = false; + vm.showHomework = false; + vm.showTestcase = false; + + if(vm.isTeacher){ + if(index == 1){ //课件 + getResources(); + vm.showResources = true; + } else if(index==2){ //作业 + getHomeworks(); + vm.showHomework = true; + } else if(index==3){ //小测验 + getExercises(); + vm.showTestcase = true; + } else if(index==4){ //学生管理 + getUsers(); + vm.showClassMate = true; + } + + } else { + if(index == 2){ + getUsers(); + vm.showClassMate = true; + } else if(index==1){ + getResources(); + vm.showResources = true; + } + } + } + + + + + vm.course = {}; + vm.students = []; + vm.teachers = []; + vm.resources = []; + vm.homeworks = []; + vm.exercises = []; + + vm.invite = function(){ + $location.path("/invite_code").search({id: courseid}); + }; + + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response) { + console.log(response.data); + vm.course = response.data.data; + resetMenu(vm.course.current_user_is_teacher); + vm.tab(1); + } + ); + + + var resetMenu = function(is_teacher){ + vm.isTeacher = is_teacher; + if(is_teacher){ + vm.menus = ["课件", "作业", "小测验", "学生管理"]; + } else { + vm.menus = ['课堂资源', "我的同学"]; + } + + } + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js new file mode 100644 index 000000000..4484ff834 --- /dev/null +++ b/public/javascripts/wechat/controllers/class_list.js @@ -0,0 +1,30 @@ +/** + * Created by guange on 16/6/27. + */ + + +app.controller('ClassListController', ['$scope','config','auth','$http','$location', function($scope, config, auth, $http, $location){ + var vm = $scope; + vm.courses = []; + + $http.get(config.apiUrl + "courses?token="+ auth.token() + "&per_page_count=10&page=1").then( + function(response){ + console.log(response.data); + vm.courses = response.data.data; + } + ); + + vm.goClass = function(course_id){ + console.log(course_id); + $location.path("/class").search({id: course_id}); + } + + vm.newClass = function(){ + $location.path("/new_class"); + } + + vm.goResource =function(){ + $location.path("/myresource"); + } + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/course_notice.js b/public/javascripts/wechat/controllers/course_notice.js new file mode 100644 index 000000000..77d2e6ab0 --- /dev/null +++ b/public/javascripts/wechat/controllers/course_notice.js @@ -0,0 +1,16 @@ +app.controller('CourseNoticeController', ['$scope', '$http', '$routeParams', 'auth', 'common', + function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'newss', + replyType: 'News', + loadCallback: function(data){ + $scope.news = data.data; + }, + replyCallback: function(){ + } + }); + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/discussion.js b/public/javascripts/wechat/controllers/discussion.js new file mode 100644 index 000000000..7e0811a0d --- /dev/null +++ b/public/javascripts/wechat/controllers/discussion.js @@ -0,0 +1,14 @@ + +app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'messages', + replyType: 'Message', + loadCallback: function(data){ + $scope.discussion = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/homework.js b/public/javascripts/wechat/controllers/homework.js new file mode 100644 index 000000000..58f70db5a --- /dev/null +++ b/public/javascripts/wechat/controllers/homework.js @@ -0,0 +1,16 @@ + +app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'whomeworks', + replyType: 'HomeworkCommon', + loadCallback: function(data){ + console.log(data); + $scope.homework = data.data; + }, + replyCallback: function(){ + } + }); + +}]); diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js new file mode 100644 index 000000000..1b92f592c --- /dev/null +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -0,0 +1,34 @@ +/** + * Created by guange on 16/6/22. + */ + + +app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){ + var vm = $scope; + + vm.course = {}; + var courseid = $routeParams.id; + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response){ + console.log(response.data); + vm.course = response.data.data; + } + ); + + vm.share = function(){ + window.WeixinJSBridge.invoke('sendAppMessage',{ + 'appid': 'wxf694495398c7d470', // 公众号appID + 'type': 'link', // 非必填,music,vido或link,默认为link。 + 'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用 + 'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址 + 'img_height':370, // 缩略图高度 + 'img_width':550, // 缩略图宽度 + 'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址 + 'desc':'desc', // 描述 + 'title':'title' // 标题 + },function(res){ + //alert(res.err_msg); + }); + } + +}]); diff --git a/public/javascripts/wechat/controllers/issue.js b/public/javascripts/wechat/controllers/issue.js new file mode 100644 index 000000000..ae0cc4450 --- /dev/null +++ b/public/javascripts/wechat/controllers/issue.js @@ -0,0 +1,15 @@ +app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'issues', + replyType: 'Issue', + loadCallback: function(data){ + console.log(data); + $scope.issue = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/journals.js b/public/javascripts/wechat/controllers/journals.js new file mode 100644 index 000000000..76b4f8cf6 --- /dev/null +++ b/public/javascripts/wechat/controllers/journals.js @@ -0,0 +1,13 @@ +app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'journal_for_messages', + replyType: 'JournalsForMessage', + loadCallback: function(data){ + $scope.message = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/login.js b/public/javascripts/wechat/controllers/login.js new file mode 100644 index 000000000..1dbf804ed --- /dev/null +++ b/public/javascripts/wechat/controllers/login.js @@ -0,0 +1,53 @@ +app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams', 'alertService', 'config','auth','session', + function ($scope, $http, $location, $routeParams, alertService, config, auth,session) { + if(auth.get_bind().then(function(){ + $location.path("/activities"); + })); + + if($routeParams.code){ + session.save('code', $routeParams.code); + } + + var vm = $scope; + vm.loginFailed = false; + vm.alertService = alertService.create(); + vm.findPwdDialog = alertService.create(); + + vm.login = function (frm, user) { + frm.$setSubmitted(); + console.log(user); + + if (!frm.$valid) { + console.log(frm.$error); + return; + } + + console.log(apiUrl + "auth"); + + $http.post( + config.apiUrl + "users/wxbind", + {login: user.login, password: user.password} + ).then( + function(response) { + console.log(response.data); + vm.loginFailed = (response.data.status != 0); + if (!$scope.loginFailed) { //绑定成功 + vm.alertService.showMessage('提示', response.data.message, function(){ + $location.path("/activities"); + }); + } else { + vm.alertService.showMessage('出错了', response.data.message); + } + } + ).catch(function(e){ + vm.alertService.showMessage('出错了', e); + }); + }; + + vm.showBox = function () { + vm.findPwdDialog.showMessage("提示", "请访问www.trustie.net获取密码,谢谢!"); + } + vm.goReg = function () { + $location.path('/reg'); + } + }]); diff --git a/public/javascripts/wechat/controllers/myresource.js b/public/javascripts/wechat/controllers/myresource.js new file mode 100644 index 000000000..87b2a4d82 --- /dev/null +++ b/public/javascripts/wechat/controllers/myresource.js @@ -0,0 +1,30 @@ +app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){ + var vm = $scope; + vm.menus = ['课件', '作业', '测验']; + + vm.resources = []; + vm.homeworks = []; + vm.exercise = []; + + vm.tab = function(index){ + vm.currentTab = index; + if(index==1){ + $http.get(config.apiUrl + "resources?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.resources = response.data.data; + }); + } else if(index==2){ + $http.get(config.apiUrl + "resources/homeworks?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.homeworks = response.data.data; + }); + } else if(index==3){ + $http.get(config.apiUrl + "resources/exercies?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.exercise = response.data.data; + }); + } + } + + vm.tab(1); +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/new_class.js b/public/javascripts/wechat/controllers/new_class.js new file mode 100644 index 000000000..488db31c6 --- /dev/null +++ b/public/javascripts/wechat/controllers/new_class.js @@ -0,0 +1,12 @@ + + +app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){ + var vm = $scope; + + vm.resources = []; + vm.homeworks = []; + vm.exercises = []; + + + +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/reg.js b/public/javascripts/wechat/controllers/reg.js new file mode 100644 index 000000000..dfa010ad7 --- /dev/null +++ b/public/javascripts/wechat/controllers/reg.js @@ -0,0 +1,42 @@ +app.controller('RegController', ['$scope', '$http', '$location', 'alertService', + function ($scope, $http, $location, alertService) { + + var vm = $scope; + vm.errDialog = alertService.create(); + + vm.goLogin = function () { + $location.path("/login"); + } + + vm.isagreed = true; + vm.agreed = function (_isagreed) { + vm.isagreed = !_isagreed; + }; + + vm.reg = function (frm, user) { + + frm.$setSubmitted(); + + console.log(frm); + if (!frm.$valid) { + console.log(frm.$error); + return; + } + + console.log(user); + + $http.post( + apiUrl + "users", + {login: user.username, password: user.password, mail: user.email} + ).then(function (response) { + if (response.data.status != 0) { + vm.errDialog.showMessage('出错了',response.data.message); + } else { + vm.errDialog.showMessage("提示","注册且绑定微信成功"); + } + }, function (response) { + vm.errDialo.showMessage('出错了',response.data); + }); + } + + }]); \ No newline at end of file diff --git a/public/javascripts/wechat/course_discussion.js b/public/javascripts/wechat/course_discussion.js deleted file mode 100644 index e01b6b451..000000000 --- a/public/javascripts/wechat/course_discussion.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:c-message-detail-reply',{reply: data}); - $('#all_course_message_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:course-discussion',{discussion: data}); - $('#c-discussion-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "Type" : "Message", - "Content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - alert("6"); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - /*//点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - }*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/course_notice.js b/public/javascripts/wechat/course_notice.js deleted file mode 100644 index 546aac385..000000000 --- a/public/javascripts/wechat/course_notice.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:news-detail-reply',{reply: data}); - $('#all_news_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:course-notice',{course: data}); - $('#c-notice-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'newss/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "type" : "News", - "content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/alert.js b/public/javascripts/wechat/directives/alert.js new file mode 100644 index 000000000..f53ecdb5a --- /dev/null +++ b/public/javascripts/wechat/directives/alert.js @@ -0,0 +1,19 @@ +app.directive('myAlert', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/alert.html', + scope: { + title: "=", + message: "=", + visible: "=", + cb: "=" + }, + link: function(scope){ + scope.dismiss = function(){ + scope.visible = false; + if(typeof scope.cb === 'function'){ + scope.cb(); + } + }; + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/form_validate.js b/public/javascripts/wechat/directives/form_validate.js new file mode 100644 index 000000000..553560c56 --- /dev/null +++ b/public/javascripts/wechat/directives/form_validate.js @@ -0,0 +1,10 @@ +app.directive('pwdconfirm', function(){ + return { + require: 'ngModel', + link: function(scope, elm, attrs, ctrl){ + ctrl.$validators.pwdconfirm = function(modelValue, viewValue) { + return scope.user && scope.user.password == viewValue; + } + } + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/input_auto.js b/public/javascripts/wechat/directives/input_auto.js new file mode 100644 index 000000000..bcb44141e --- /dev/null +++ b/public/javascripts/wechat/directives/input_auto.js @@ -0,0 +1,19 @@ +app.directive('inputAuto',function(){ + return{ + restrict: 'A', + scope: {}, + link: function(scope, element){ + var copyContainer = element.parent().children().eq(0); + var sendButton = element.parent().next(); + element.on('input',function(){ + console.log(sendButton); + copyContainer.html(element[0].value); + var textHeight = copyContainer[0].scrollHeight; + element.css('height', textHeight + 'px'); + }); + sendButton.on('click',function(){ + element.css('height','28px'); + }); + } + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/loading_spinner.js b/public/javascripts/wechat/directives/loading_spinner.js new file mode 100644 index 000000000..780056828 --- /dev/null +++ b/public/javascripts/wechat/directives/loading_spinner.js @@ -0,0 +1,7 @@ +app.directive('loadingSpinner', ['$http', function ($http) { + return { + restrict: 'A', + replace: true, + template: '
    加载中...
    ', + }; +}]); diff --git a/public/javascripts/wechat/gulpfile.js b/public/javascripts/wechat/gulpfile.js index 439b6ae5d..ea0649376 100644 --- a/public/javascripts/wechat/gulpfile.js +++ b/public/javascripts/wechat/gulpfile.js @@ -8,3 +8,10 @@ gulp.task('minify', function () { .pipe(concat('angular.all.min.js')) .pipe(gulp.dest('build')) }); + +gulp.task("default", function(){ + gulp.src(['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js']) + .pipe(uglify()) + .pipe(concat('app.min.js')) + .pipe(gulp.dest('build')) +}); diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js deleted file mode 100644 index 166ed20bf..000000000 --- a/public/javascripts/wechat/homework_detail.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Created by root on 3/31/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail-reply',{reply: data}); - $('#all_homework_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail',{homework: data}); - $('#homework-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'whomeworks/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - /*//将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - getOpenId(function(openid) { - //获取并传送回复用户数据 - var userInfo = { - "type": "HomeworkCommon", - "content": postInput, - openid: openid - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }) - }); - } - - }; - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - };*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js deleted file mode 100644 index 2b2766d29..000000000 --- a/public/javascripts/wechat/issue_detail.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -/** - * Created by root on 3/31/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:issue-detail-reply',{issue_reply: data}); - $('#all_issue_reply').prepend(html); - }; - - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:issue-detail',{issues: data}); - $('#issue-container').prepend(html); - $('.post-reply-submit').click(function(){ - IssueReplyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'issues/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var IssueUrl = window.location.search; - var IssueID = IssueUrl.split("=")[1]; - - loadDataFromServer(IssueID); - - //点击回复按钮,插入回复内容 - var IssueReplyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - getOpenId(function(openid) { - //获取并传送回复用户数据 - var userInfo = { - "type": "Issue", - "content": postInput, - openid: openid, - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }) - }); - } - - }; - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - };*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/message_detail.js b/public/javascripts/wechat/message_detail.js deleted file mode 100644 index 279da05d9..000000000 --- a/public/javascripts/wechat/message_detail.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:message-detail',{message: data}); - $('#message-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - $('post-interactive-praise').click(function(){ - praiseClick(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'journal_for_messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js new file mode 100644 index 000000000..6acf25c59 --- /dev/null +++ b/public/javascripts/wechat/others/factory.js @@ -0,0 +1,182 @@ +app.factory('alertService', function(){ + function Alert(){ + this.title = null; + this.message = null; + this.visible = null; + this.cb = null; + } + + Alert.prototype.showMessage = function(title, msg, cb){ + this.message = msg; + this.title = title; + this.visible = true; + this.cb = cb; + } + + Alert.prototype.dismiss = function(){ + this.message = null; + this.title = null; + this.visible = false; + if(this.cb) {this.cb();} + } + + return { + create: function(){ + return new Alert(); + } + } +}); + + +app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){ + //是否已经绑定 + var isBind = function(){ + var defer = $q.defer(); + + var token = getToken(); + if(token && token.length>10){ + defer.resolve(token); + } else { + var code = window.g_code || $routeParams.code || session.get("code"); + $http.post( + '/wechat/get_bind', + {} ///不用传code了,都由服务器来处理 + ).then(function(response){ + if(response.data.status!=0){ + defer.reject(response.data.message); + }else { + session.save("token", response.data.token); + defer.resolve(response.data.token); + } + }).catch(function(e){ + defer.reject(e); + }); + } + + return defer.promise; + } + + var getToken = function(){ + return session.get("token"); + } + return {get_bind: isBind, token: getToken}; +}]); + +app.factory("session", function(){ + return { + save: function(key,value){ + sessionStorage.setItem(key,value); + }, + get: function(key){ + return sessionStorage.getItem(key); + } + } +}); + +app.factory('rms', function(){ + var _saveStorage = {}; + var save = function(key, value){ + _saveStorage[key] = value; + }; + + var get = function(key){ + return _saveStorage[key]; + }; + + return {save: save, get: get}; +}); + +app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){ + var addCommonReply = function(id, type, data, cb){ + + if(!data.comment || data.comment.length<=0){ + return; + } + + var temp = data.comment.replace(/\n/g,'
    '); + + var userInfo = { + type: type, + content: temp, + token: auth.token() + }; + //回复按钮禁用 + data.disabled = true; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+id, + data: userInfo + }).then(function successCallback(response) { + //alert("提交成功"); + //数据提交完成,回复按钮启用 + data.disabled = false; + if(typeof cb === 'function'){ + cb(); + } + }, function errorCallback(response) { + }); + }; + + var loadCommonData = function(id, type){ + return $http({ + method: 'GET', + url: apiUrl+ type + "/" + id+"?token="+auth.token() + }) + }; + + var addCommonPraise = function(act){ + act.praise_count += 1; + act.has_praise = true; + + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + + }; + + var decreaseCommonPraise = function(act){ + act.praise_count -= 1; + act.has_praise = false; + + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + }; + + var init = function(args){ + args.scope.formData = {comment: ''}; + var loadData = function(id){ + loadCommonData(id, args.type).then(function successCallback(response) { + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + + loadData(args.id); + args.scope.addReply = function(data){ + console.log(data.comment); + addCommonReply(args.id, args.replyType, data, function(){ + args.scope.formData = {comment: ''}; + loadData(args.id); + if(typeof args.replyCallback === 'function'){ + args.replyCallback(); + } + }); + }; + args.scope.addPraise = addCommonPraise; + args.scope.decreasePraise = decreaseCommonPraise; + } + + return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/others/filter.js b/public/javascripts/wechat/others/filter.js new file mode 100644 index 000000000..96007958d --- /dev/null +++ b/public/javascripts/wechat/others/filter.js @@ -0,0 +1,14 @@ +app.filter('safeHtml', ['$sce',function ($sce) { + return function (input) { + return $sce.trustAsHtml(input); + } +}]); + +app.filter('identify', function () { + return function(input){ + if (input == 'TeachingAsistant'){ + return '教辅' + } + return ''; + } +}) \ No newline at end of file diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js new file mode 100644 index 000000000..80efa71e9 --- /dev/null +++ b/public/javascripts/wechat/others/routes.js @@ -0,0 +1,67 @@ +app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', function ($routeProvider, $httpProvider, $locationProvider, config) { + var rootPath = config.rootPath; + var resolve = { + delay: ['auth',function(auth){ + return auth.get_bind(); + }] + }; + var makeRoute = function(path, ctrl){ + return { + templateUrl: rootPath + path, + controller: ctrl, + resolve: resolve + } + } + //$locationProvider.html5Mode(true); + $routeProvider + .when('/login', { + templateUrl: rootPath + 'login.html', + controller: 'LoginController' + }) + .when('/reg', { + templateUrl: rootPath + 'reg.html', + controller: 'RegController' + }) + .when('/activites', makeRoute('activities.html', 'ActivityController')) + .when('/issues/:id', makeRoute('issue_detail.html', 'IssueController')) + .when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController')) + .when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController')) + .when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController')) + .when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController')) + .when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController')) + .when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController')) + .when('/class', makeRoute('class.html', 'ClassController')) + .when('/new_class', makeRoute('new_class.html', 'NewClassController')) + .when('/class_list', makeRoute('class_list.html', 'ClassListController')) + .when('/myresource', makeRoute('myresource.html', 'MyResourceController')) + .when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController')) + .otherwise({ + redirectTo: '/activites' + }); + + //监听异步请求,实现加载中显隐标记 + $httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) { + if ($rootScope.activeCalls == undefined) { + $rootScope.activeCalls = 0; + } + + return { + request: function (config) { + $rootScope.activeCalls += 1; + return config; + }, + requestError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + }, + response: function (response) { + $rootScope.activeCalls -= 1; + return response; + }, + responseError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + } + }; + }]); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/project_discussion.js b/public/javascripts/wechat/project_discussion.js deleted file mode 100644 index 94cdcea10..000000000 --- a/public/javascripts/wechat/project_discussion.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail-reply',{reply: data}); - $('#all_homework_reply').prepend(html); - }; - - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:project-discussion',{discussion: data}); - $('#p-discussion-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - /*//将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "type" : "Message", - "content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - }*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js deleted file mode 100644 index 36529e0b8..000000000 --- a/public/javascripts/wechat/wechat_dev.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Created by root on 3/25/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - var apiUrl = '/api/v1/'; - var loadDataFromServer = function(id, page){ - getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'activities', - data: {openid: openid, page: page}, - type: 'POST', - dataType: 'json', - success: function(data){ - setTemplate(data.data, data.all_count, data.count, data.page); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - }) - - }; - var setTemplate = function(data, all_count, count, page){ - console.log(data); - var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page}); - if (page == 0) { - $('#container').prepend(html); - } else { - $("#more_activities").remove(); - $('#container').append(html); - } - descToggle(); - }; - //内容全部显示与部分隐藏 - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - loadDataFromServer(8686, 0); -}); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index ed99217b8..178e9bb5d 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -109,7 +109,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re /*20160520作品列表table*/ .hwork-table-wrap {width:720px; border-collapse:collapse; vertical-align:middle; table-layout:fixed;} -.hwork-table-wrap th {font-size:14px; color:#2d2d2d; border-bottom:1px solid #e1e1e1;} +.hwork-table-wrap th {font-size:14px; color:#2d2d2d; border-bottom:1px solid #e1e1e1; text-align:center;} /*作业信息*/ .mt-2 {margin-top:-2px;} @@ -1270,7 +1270,7 @@ a:hover.blueCir{ background:#3598db; color:#fff;} .relatePImage {display:block; margin:0 auto;} /*上传资源弹窗*/ -.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:fixed; top:50%; left:50%; margin-left:-200px; z-index:1000;} .uploadDialogText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:140px; display:inline-block; font-weight: bold;} .uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative} .uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#269ac9; border-radius:3px; float:left; margin-right:12px;} @@ -1426,4 +1426,6 @@ a.pages-big{ width:50px;} .H60 {height:60px !important;} .W420 {width:420px;} .W300 {width:300px !important;} -.W600{ width:600px;} \ No newline at end of file +.W600{ width:600px;} + +.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;} diff --git a/public/stylesheets/header.css b/public/stylesheets/header.css index 767d76cb2..5700d0b00 100644 --- a/public/stylesheets/header.css +++ b/public/stylesheets/header.css @@ -117,3 +117,179 @@ a.f_grey:hover {color:#000000 !important;} #loginInButton {height:54px; padding-left:10px; padding-right:10px; text-align:center; line-height:54px; vertical-align:middle; color:#ffffff; font-size:16px;} #loginSignButton:hover {background-color:#297fb8;} #loginInButton:hover {background-color:#297fb8;} + +/* 邮箱验证 */ +.email_verify body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;} +.mt30{ margin-top:30px;} +.ml30{ margin-left:30px;} +.new_content{ + width:1000px; + margin:10px auto; + padding:30px 0; + background-color:#fff; +} +.email_verify{ + width:720px; + margin:0px auto; +} +.email_verify_prompt{ + border:2px solid #dd0000; + background:#ffe3e3 url(../images/icons_prompt.png) 25px 10px no-repeat;; + height:35px; + line-height:35px; + padding-left:45px; + color:#8b0000; + font-size:14px; +} +.email_verify_btn{ + border-style:none; + height:35px; + padding:0 15px; + line-height:35px; + color:#fff; + background:#3a95d7; + text-align:center; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + border-radius:5px; + font-size:14px; +} +.email_verify_btn:hover{ + background:#017bd3; +} +.email_sub_btn{ + border-style:none; + height:30px; + padding:0 25px; + line-height:30px; + color:#fff; + background:#3a95d7; + text-align:center; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + border-radius:5px; + font-size:14px; +} +.email_sub_btn:hover{ + background:#017bd3; +} +.email_prompt_p{ + font-size:14px; + color:#000; + margin-bottom:10px; +} +.email_prompt_txt{ width:480px;} +.email_prompt_txt li{ + margin-left:15px; + list-style-type: disc; + color:#777; + line-height:1.9; + font-size:14px; +} +.email_prompt_mes{ + border:1px solid #ccc; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + border-radius:5px; + width:468px; + height:60px; + background:#fff; + padding:5px; + margin-bottom: 5px; +} +.email_tanbox{ + border:2px solid #3a95d7; + background:#fff; + width:480px; + +} +.email_tancon{ + width:420px; + margin:0 auto; + text-align:center; + padding:20px 30px; + background:#fff; +} +.email_tan_title{ + font-size:18px; + color:#3a95d7; + font-weight:normal; + margin-bottom:5px; +} +.email_tan_p{ + font-size:14px; + color:#4c4c4c; + +} +.email_verify_p{ + font-size:14px; + color:#3a95d7; +} + +/***** Ajax indicator ******/ +/*-------resendmail---------*/ +#ajax-indicator { + position: absolute; /* fixed not supported by IE */ + background-color:#eee; + border: 1px solid #bbb; + top:35%; + left:40%; + width:20%; + font-weight:bold; + text-align:center; + padding:0.6em; + z-index:100000; + opacity: 0.5; +} + +html>body #ajax-indicator { position: fixed; } + +#ajax-indicator span { + background-position: 0% 40%; + background-repeat: no-repeat; + background-image: url(../images/loading.gif); + padding-left: 26px; + vertical-align: bottom; +} + +div.modal { + border-radius: 5px; + background: #fff; + z-index: 50; + padding: 4px; +} +.ui-widget-content { + border: 1px solid #ddd; + color: #333; +} +.ui-widget { + font-family: Verdana, sans-serif; + font-size: 1.1em; +} +.ui-dialog .ui-dialog-content { + position: relative; + border: 0; + padding: .5em 1em; + background: none; + overflow: auto; + zoom: 1; +} +.ui-widget-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} +.ui-widget-overlay { + background: #666 url(http://forge.trustie.net/stylesheets/jquery/images/xui-bg_diagonals-thick_20_666666_40x40.png.pagespeed.ic.9mfuw_R0z1.png) 50% 50% repeat; + opacity: .5; + filter: Alpha(Opacity=50); +} +.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.Blue-btn{ background:#3598db; color:#fff;} +/***** end Ajax indicator ******/ \ No newline at end of file diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index ee3ddf6df..b931dff6b 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1621,8 +1621,9 @@ ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} /*消息弹框*/ .shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} .shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} +.shadowbox_news_p{ height:40px; line-height:40px; font-size:12px; color:#333;} .shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } -.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_list{ max-height:400px; overflow:hidden;} .shadowbox_news_list a{ color:#999;} .shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} .shadowbox_news_list li:hover{ background-color:#eee;} @@ -1801,4 +1802,99 @@ input.new_loggin_input{ .H60 {height:60px !important;} .W420 {width:420px;} .W300 {width:300px !important;} -.W600{ width:600px;} \ No newline at end of file +.W600{ width:600px;} + +/* 个人资料修改弹框 */ +.winbox{ + background-color: #fff; + padding: 20px; + width:480px; + -webkit-border-radius:5px; + -moz-border-radius:5px; + -o-border-radius:5px; + border-radius:5px; + border:none; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%,-50%); +} +.winbox_h2{ + font-size: 14px; + font-weight: normal; + color: #333; + border-bottom: 1px solid #ccc; + height: 28px; +} +.winbox_edit_new{ + /*width: 425px;*/ + margin: 28px 0; +} +.winbox_edit_new li{ + height: 45px; + line-height: 30px; + font-size: 14px; +} +.winbox_edit_new label{ + width: 80px; + text-align: right; + display: block; +} +.winbox_input{ + width: 330px; + height: 28px; + border: 1px solid #ccc; + padding: 0 5px; + color: #888; +} +.winbox_select{ + height: 28px; + border: 1px solid #ccc; + color: #888; +} +.winbox_textarea{ + width: 330px; + height: 50px; + border: 1px solid #ccc; + padding: 5px; + color: #888; +} +.winbox_btn_blue{ + padding: 5px 25px; + color: #fff; + text-align: center; + background-color: #3b94d6; + border: none; +} +.winbox_btn_blue:hover{ + background-color: #2e83c2; +} +.icons_warning{ + display: block; + width:20px; + height:20px; + background:url(../images/icons_ziliao.png) 0 2px no-repeat; +} +.icons_right{ + display: block; + width:20px; + height:20px; + background:url(../images/icons_ziliao.png) 0 -25px no-repeat; +} +.icons_error{ + display: block; + width:20px; + height:20px; + background:url(../images/icons_ziliao.png) 0 -52px no-repeat; +} +a.winbox_btn_close{ + color: #3b94d6; + font-size: 18px; + font-weight: bold; +} +.winbox_p{ + font-size: 14px; + text-align: center; + + +} \ No newline at end of file diff --git a/public/stylesheets/org_custom.css b/public/stylesheets/org_custom.css index 95df98738..5ff340272 100644 --- a/public/stylesheets/org_custom.css +++ b/public/stylesheets/org_custom.css @@ -25,31 +25,31 @@ a.por_edit_index{ position:absolute; font-size:14px; right:5px; top:15px;} .por_h2_index{ font-size:18px; font-weight:normal; color:#3b94d6; width:100%; border-bottom:1px solid #e8e5e5; height:40px; line-height:40px;} a.por_more_index{ font-size:12px; color:#999; } .por_hotbar_left li{ width:365px; padding:12px 5px 12px 0; border-bottom:1px dashed #e8e5e5;} -a.por_hot_title{ font-size:16px; display:block; font-weight:bold; width:365px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.por_hot_txt{ color:#666; line-height:20px;max-height:60px;overflow:hidden;text-overflow:ellipsis;} +a.por_hot_title{ font-size:16px; display:block; width:365px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} +.por_hot_txt{ color:#637379; line-height:20px;max-height:60px;overflow:hidden;text-overflow:ellipsis;} .por_time{ color:#999;} a.por_hot_name{color:#3b94d6;} .por_hotbar_right{ padding:5px 0 5px 10px; margin-top:15px; width:300px; } .por_hotbar_right img{ width:300px; height:246px;} -.por_hot_title_r{ font-size:16px; display:block; font-weight:bold; width:300px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.por_hot_title_r{ font-size:16px; display:block; width:300px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} .por_hot_txt_r{color:#666; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} .por_course{ } .por_course_bar{ width:328px; margin:0 7px; padding:20px 0 0px;} -a.por_course_title{font-size:14px; margin-bottom:10px; display:block; font-weight:bold; width:328px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_course_title{font-size:16px; margin-bottom:10px; display:block; width:328px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color: #02253f;} .por_course_bar img{ width:140px; height:100px; } -.por_course_txt { width:180px; margin-left:5px;color:#666; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} +.por_course_txt { width:180px; margin-left:5px;color:#637379; line-height:20px;max-height:80px;overflow:hidden;text-overflow:ellipsis;} .por_course_time{color:#3b94d6; margin-left:5px;} .por_post{ padding-bottom:5px;} -.por_post_left{ width:394px; margin-top:15px;} +.por_post_left{ width:385px; margin-top:15px; margin-right: 9px;} .por_post_leftbar img{ width:377px; height:163px;} .por_post_leftbar { border-bottom:1px dashed #e8e5e5; padding-bottom:5px; margin-bottom:10px;} -a.por_post_title{font-size:18px; display:block; width:377px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -.por_post_txt{color:#666; line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; } +a.por_post_title{font-size:18px; display:block; width:377px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} +.por_post_txt{color:#637379; line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-bottom: 5px;} .post_icons_grey{ width:4px; height:4px; margin:10px 5px 0 0; background-color:#b3b3b3; display:block; line-height:20px;} .por_post_list li{ height:35px;} .por_post_list li a{ font-size:14px; } -a.por_hidden_w390{ display:block; width:390px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} -a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_hidden_w390{ display:block; width:390px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} +a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_post_right{ width:280px; border-left:1px solid #e8e5e5; margin-top:15px; padding-left:10px;} .por_news_list li{ padding:15px 0; border-bottom:1px dashed #e8e5e5;} .por_users_img{ width:40px; height:40px; -webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} @@ -57,11 +57,11 @@ a.por_hidden_w270{ display:block; width:280px; overflow:hidden; white-space: now .por_news_p{ line-height:20px;max-height:40px;min-width:240px;overflow:hidden;text-overflow:ellipsis; } a.por_zan{ background:url(../images/org_custom/icons_por.png) 0 -41px no-repeat; height:15px; width:20px; display:block; padding-left:15px; line-height:20px; color:#999;} a.por_zan:hover{background:url(../images/org_custom/icons_por.png) -34px -42px no-repeat; color:#3b94d6; } -.por_hidden_w205{ font-size:14px; display:block; width:205px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.por_hidden_w205{ font-size:14px; display:block; width:205px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_projects{ padding-bottom:10px; margin-top:10px;} .por_projects ul li{ padding:5px 0;} .por_projects ul{ margin-top:5px;} -.por_project_p{ line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-top:5px; margin-left:10px; color:#666; } +.por_project_p{ line-height:20px;max-height:40px;overflow:hidden;text-overflow:ellipsis; margin-top:5px; margin-left:10px; color:#637379; margin-bottom: 5px;} .por_project_li{border-bottom:1px dashed #ccc; padding-bottom:10px; margin-bottom:5px;} .por_time a{ color:#3b94d6;} .por_teachers{ margin-top:20px; } @@ -78,7 +78,7 @@ a.por_more_teacher{ font-size:12px; } .por_teachers_li{ margin-top:10px;} .por_teachers_li li{ padding:10px 0;} .por_teachers_img{ width:60px; height:60px; -webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} -a.por_teachers_name{ display:block; width:75px; font-size:18px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +a.por_teachers_name{ display:block; width:75px; font-size:18px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; color: #02253f;} .por_teachers_p{ font-size:14px; color:#999; width:150px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} .por_teachers_span{ color:#999;} .por_teachers_span a{ margin:0 5px; color:#999;} diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index d8b8cc74a..bde560613 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1247,6 +1247,39 @@ a.pages-big{ width:50px;} .red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} .green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} +/*20160622质量分析*/ +.analysis-tag-wrap {width:100%; color:#000; height:20px; line-height:20px; vertical-align:middle;} +.analysis-tag {width:10px; height:20px; background-color:#777;} +.analysis-block {padding:15px; border:1px solid #d9d9d9;} +.flex {display:flex;} +.analysis-genral {flex:1; display:block; text-align:center;} +.analysis-block-icon {background:url(../images/code-analysis-icon.png) -2px -8px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-serious-icon {background:url(../images/code-analysis-icon.png) -2px -34px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-main-icon {background:url(../images/code-analysis-icon.png) -2px -59px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-secondary-icon {background:url(../images/code-analysis-icon.png) -2px -85px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.analysis-info-icon {background:url(../images/code-analysis-icon.png) -2px -111px no-repeat; width:14px; height:14px; display:inline-block; vertical-align:middle;} +.quality-percentage {width:320px; height:14px; display:inline-block;} +.quality-percentage-rate {width:50%; height:14px; background-color:#0a6c99; display:inline-block;} +.image-cir {border-radius:50%;} +.analysis-genral-icon {position:absolute; padding:1px 5px; display:inline-block; top:5px;} +.contribute-list-avatar {width:80px; vertical-align:middle; text-align:center;} +.contribute-list-code {width:160px; vertical-align:middle; text-align:center;} +.contribute-list-problem {width:170px; vertical-align:middle; text-align:center;} +.contribute-list-rate {width:228px; vertical-align:middle; text-align:center;} +.contribute-list-height {height:80px;} +.contribute-list-line-height {line-height:80px;} + +/*20160623分析结果*/ +.analysis-result-list {padding:5px;} +.analysis-result-list:nth-of-type(odd){background:#fff;}/*奇数行*/ +.analysis-result-list:nth-of-type(even){background:#f5f5f5;}/*偶数行*/ +.analysis-result-name {width:200px; cursor:pointer;} +.analysis-result-version {width:90px; text-align:right; cursor:pointer;} +.analysis-result-loc {width:60px; text-align:right; cursor:pointer;} +.analysis-result-debt {width:160px; text-align:right; cursor:pointer;} +.analysis-result-time {width:150px; text-align:right; cursor:pointer;} +.analysis-name-icon {background:url(../images/code-analysis-icon.png) -2px -148px no-repeat; width:16px; height:16px; display:inline-block; vertical-align:middle;} + /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} @@ -1254,4 +1287,4 @@ a.pages-big{ width:50px;} .H60 {height:60px !important;} .W420 {width:420px;} .W300 {width:300px !important;} -.W600{ width:600px;} \ No newline at end of file +.W600{ width:600px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 333c410ca..c86e0f42d 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -27,6 +27,8 @@ a.btn_message_free{ background:#ff5722; display:block; text-align:center; color h2{ font-size:18px; } h3{ font-size:14px; } h4{ font-size:14px; } +.f8 {font-size:8px;} +.f10 {font-size:10px;} .f12{font-size:12px; font-weight:normal;} .f14{font-size:14px;} .f16{font-size:16px;} @@ -130,6 +132,7 @@ h4{ font-size:14px; } .mt12 { margin-top:12px !important;} .mt15 {margin-top:15px;} .mt19 {margin-top:19px !important;} +.mt35 {margin-top:35px;} .ml70{margin-left: 70px;} .mb0 {margin-bottom: 0px !important;} .mb4{ margin-bottom:4px;} @@ -137,6 +140,8 @@ h4{ font-size:14px; } .mb8 {margin-bottom:8px;} .mb10{ margin-bottom:10px !important;} .mb20{ margin-bottom:20px;} +.mb30 {margin-bottom:30px;} +.mb40 {margin-bottom:40px;} .pl10 {padding-left:10px;} .pl15{ padding-left:15px;} .pl5{ padding-left:5px;} @@ -228,6 +233,7 @@ a.c_green{ color:#28be6c;} .b_grey{ background: #F5F5F5;} .b_dgrey{ background: #CCC;} +.c_white {color:#fff;} .c_orange{color:#e8770d;} .c_dark{ color:#2d2d2d;} .c_lorange{ color:#ff9900;} @@ -239,6 +245,11 @@ a.c_green{ color:#28be6c;} .c_dblue{ color:#09658c;} .b_blue{background:#64bdd9;} .b_green{background:#28be6c;} +.b_slow_yellow{background:#adde18;} +.b_yellow{background:#DDDF0D;} +.b_slow_red{background:#df8538;} +.b_green2 {background:#63c360;} +.b_red {background:#d60308;} .b_w{ background:#fff !important;} /*add by Tim*/ @@ -341,6 +352,8 @@ a:hover.bgreen_n_btn{background:#08a384;} .orange_btn_cir{ background:#e67e22; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .bgreen_btn_cir{ background:#1abc9c; padding:1px 10px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal; font-size:12px;white-space:nowrap;} .grey_border{border:1px solid #dddddd !important;} +.borderRadius {border-radius:5px;} +.tac {text-align:center;} /* commonpic */ .pic_date{ display:block; background:url(../images/new_project/public_icon.png) -31px 0 no-repeat; width:16px; height:15px; float:left;} .pic_add{ display:block; background:url(../images/new_project/public_icon.png) -31px -273px no-repeat; width:16px; height:15px; float:left;} @@ -1155,8 +1168,9 @@ a.st_down{ display: block; width:8px; float:left; height:13px; background:url(.. /*消息弹框*/ .shadowbox_news{ width:305px; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); position: absolute; left: -131px; top: 45px; z-index: 9999;} .shadowbox_news_title{ height:40px; line-height:40px;padding-left:10px; font-size:12px; color:#333;border-bottom:1px solid #eee;} -.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } -.shadowbox_news_list{ max-height:200px; overflow:hidden;} +.shadowbox_news_p{ height:40px; line-height:40px; font-size:12px; color:#333;} +.shadowbox_news font{ border: 1px solid #dddddd; display: block; border-width: 8px; position: absolute; top: -15px;left: 140px; border-style:solid; border-color: transparent transparent #fff transparent;font-size: 0;line-height: 0; box-shadow:2px rgba(146, 153, 169, 0.5); } +.shadowbox_news_list{ max-height:400px; overflow:hidden;} .shadowbox_news_list a{ color:#999;} .shadowbox_news_list li{ height:40px; border-bottom:1px dashed #ebebeb; line-height:40px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis; padding:0 10px;} .shadowbox_news_list li:hover{ background-color:#eee;} @@ -1165,3 +1179,8 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;} + +/*20160622代码分析弹窗*/ +.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} diff --git a/public/stylesheets/syllabus.css b/public/stylesheets/syllabus.css new file mode 100644 index 000000000..2abbffda7 --- /dev/null +++ b/public/stylesheets/syllabus.css @@ -0,0 +1,158 @@ +/****标签(和资源库的tag样式一致)***/ +.project_Label{ width:218px; padding:10px; background:#fff; margin-top:10px; padding-top:5px; margin-bottom:10px; border:1px solid #dddddd;} +.project_Label_New {width:218px; padding-left:10px; background:#fff; margin-top:15px; margin-bottom:10px;} +a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;} +.submit{height:21px;border:0; cursor:pointer; background:url(../images/btn.png) no-repeat 0 0;width:42px; margin-top:2px; margin-left:3px; } +.isTxt{background:#fbfbfb url(../images/inputBg.png) repeat-x left top;height:22px;line-height:22px;border:1px solid #c1c1c1;padding:0 5px;color:#666666;} +.re_tag{ width: auto; padding:0 5px; padding-top:2px; border:1px solid #f8df8c; background:#fffce6; margin-right:5px; } +.re_tag a{ color:#0d90c3;} +.tag_h{ } +.tag_h span,.tag_h a{ margin-bottom:5px;} +/*信息*/ +.project_info{ background:#fff; padding:10px 8px; width:222px; margin-bottom:10px; border:1px solid #dddddd;} +.pr_info_id{ width:137px; color:#5a5a5a; font-size:14px; margin-top:5px;} +.pr_info_logo{ border:1px solid #eaeaea; width:60px; height:60px; padding:1px;} +.pr_info_logo:hover{ border:1px solid #297fb8; } + +/*课程大纲*/ +input.syllabus_input{ + border:none; + width:150px; + height:25px; + line-height:25px; + color:#333; +} +input.syllabus_input_min{ + border:none; + width:30px; + height:25px; + line-height:25px; + color:#333; +} +.syllabus_select{ + border:1px solid #ccc; + margin-left:5px; +} +.syllabus_leftinfo { + margin:10px 10px 0 10px; + width:220px; +} +.syllabus_leftinfo li{ + line-height:25px; +} +.syllabus_leftinfo label{ + display:block; + width:60px; + text-align:right; + float:left; + line-height:25px; +} +.syllabusbox{ + position:relative; + width: 718px; + color: #4b4b4b; + padding:30px 15px; + margin-bottom: 10px; + background: #fff; + border: 1px solid #dddddd; +} +.syllabuscon_title{ + color:#000; text-align:center; +} +.syllabuscon_txt p{ + font-size:14px; + line-height:1.9; + color:#000; +} +.syllabuscon_txt_title{ + font-weight:bold; + margin:10px 0; +} +.syllabusbox_tishi{ + font-size:14px; + width:733px; + color:#cb7c01; + padding:10px 0 0 15px; + margin-bottom:10px; + background:#fff7d1; + border:1px solid #fcd9b4; + height:34px; +} +a.syllabusbox_a_blue{ + color:#3b94d6 !important; +} +.syllabus_leftinfo p{ + line-height:25px; + width:150px; + overflow:hidden; + white-space: nowrap; + text-overflow:ellipsis; +} +.syllabus_info_tishi{ + font-size:16px; + width:400px; + margin:100px auto; +} +.syllabus_info_tishi a{ + color:#3b94d6; +} + +/*课程大纲-课程列表*/ +.icon_course{ background: url(../images/syllabus/icons_syllabus.png) 0 -35px no-repeat; width:18px; height:15px; display:block;} +.icons_sy_open{background: url(../images/syllabus/icons_syllabus.png) 0 -53px no-repeat; width:20px; height:23px; display:block; cursor:pointer; } +.icons_sy_close{background: url(../images/syllabus/icons_syllabus.png) -26px -53px no-repeat; width:20px; height:23px; display:block; } +.syllabus_courses_box {position:relative;} +.icons_sy_setting{background: url(../images/syllabus/icons_syllabus.png) -51px -33px no-repeat; width:20px; height:20px; display:block; position:absolute; right:10px; top:10px; } +.icons_sy_setting:hover{background: url(../images/syllabus/icons_syllabus.png) -25px -33px no-repeat; } +.icons_sy_cir{background: url(../images/syllabus/icons_syllabus.png) 0px -82px no-repeat; width:15px; height:15px; display:block; position:absolute; left:-8px; top:25px;} +.icons_sy_arrow{background: url(../images/syllabus/icons_syllabus.png) -31px -81px no-repeat; width:20px; height:20px; display:block; } +.syllabus_h2_top{ font-size:18px; color:#333; font-weight:normal; padding:10px 15px;border-bottom:1px solid #e7e7e7; } +.syllabus_category{ padding:10px 15px; background-color:#f6f6f6; border-bottom:1px solid #e7e7e7;} +.syllabus_box{ width:750px; border:1px solid #e7e7e7; background-color:#fff;} +.syllabus_courses_list{ padding:15px; border-bottom:1px solid #e7e7e7; cursor:pointer;} +.syllabus_courses_list:hover{ background:#f6fafd;} +.syllabus_courses_title{ font-size:16px; color:#333; width:650px; font-weight:normal;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.sy_p_grey{ margin-left:25px; color:#888; margin-top:5px; font-size:12px;} +.syllabus_class_box{ padding-left:30px; background:#f6f6f6;} +.syllabus_class_list{ padding:12px 0 12px 15px; height:44px;border-left:1px solid #e7e7e7;border-bottom:1px solid #e7e7e7; position:relative;} +.syllabus_class_list:hover{ background:#ececec;} +.syllabus_class_list_more{padding:8px; text-align:center;border-left:1px solid #e7e7e7;border-bottom:1px solid #e7e7e7;} +.syllabus_class_list_more:hover{ background:#ececec;} +.syllabus_class_list_more a{ color:#ff7e00;} +.syllabus_class_title{ font-size:14px; color:#333; width:500px; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.syllabus_class_w{ width:650px;} +.dis {display:block;} +.undis {display:none;} + +/*班级列表界面(用的博客列表的样式)*/ +.listbox{ width:730px; background-color:#fff; border:1px solid #ddd; padding:10px; } +.bloglistbox{ min-height:690px;} +.list-h2{ font-size:16px; font-weight:bold; color:#000; padding-bottom:5px;} +.category2{ } +.list_title{padding:10px 0; border-bottom:1px solid #ddd;} +.category2 a,.category2 span{ float:left; margin-right:5px;} +.grayTxt{ color:#9093a6;} +.sortTxt{ color:#000;} +.sortTxt:hover{ color:#28be6c;} +a.sortupbtn{ background: url(../images/syllabus/icons_syllabus.png) 0 3px no-repeat; width:12px; height:17px; display:block; margin-right:10px; cursor:pointer;} +a.sortdownbtn{ background: url(../images/syllabus/icons_syllabus.png) 0 -12px no-repeat; width:12px; height:17px; display:block;cursor:pointer; } +a.sort_no{ background: url(../images/syllabus/icons_syllabus.png) -16px -12px no-repeat; width:12px; height:17px; display:block;cursor:pointer; } +.item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} +a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block;} +a:hover.list-title{ color:#269ac9;} +.c_red{ font-weight:normal; font-size:12px;} +.list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} +.list-file li{ line-height:1.9;} +.list-info span{ margin-left:5px;} +.pages a{ display:block; border:1px solid #d1d1d1; color:#888; float:left; width:30px; text-align:center; padding:3px 0; line-height:1.9; margin-right:5px; } +.pages a:hover{ background-color:#3b94d6; border:1px solid #3b94d6; color:#fff;} +a.pages-big{ width:50px;} +.pages .active{ background-color:#3b94d6; border:1px solid #3b94d6; color:#fff;} +.pages{width:330px; margin:20px auto 10px;} +a.course-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; width:590px;} +a:hover.course-title{ color:#269ac9;} + +/*新建页面*/ +.name_input{ border:1px solid #64bdd9; height:16px; width:310px; background:#fff; margin-bottom:10px; padding:5px;} + +.homepageSyllabusName {font-size:16px; color:#484848; height:25px; float:left; font-weight: bold; max-width:120px;overflow: hidden; white-space:nowrap; text-overflow:ellipsis;} diff --git a/public/stylesheets/users.css b/public/stylesheets/users.css index eaefb8d1b..ad6fefad9 100644 --- a/public/stylesheets/users.css +++ b/public/stylesheets/users.css @@ -86,7 +86,7 @@ a.select_btn_select{ background:#64bddb; color:#fff;} .users_ctt{ font-size:14px; color:#666; margin-top:10px;} .setting_left{ width:115px; text-align:right; float:left;} .setting_left li{ height:28px;line-height:28px;} -.setting_right{width:500px; text-align:left; float:left; margin-left:8px;} +.setting_right{width:600px; text-align:left; float:left; margin-left:8px;} .setting_right li{ height:28px;line-height:28px;} .users_ctt ul li{ margin-bottom:10px;} .users_ctt input,.users_ctt select,.users_ctt textarea{ border:1px solid #CCC;} diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 6cccb3615..3360d81ee 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -2,8 +2,10 @@ /* CSS Document */ /*基本样式*/ -body,table,input,textarea,select,button { font-family: "微软雅黑","宋体";} -h1,h2,h3,h4,h5,p,pre {padding:0px; margin:0px;} +body,table,input,textarea,select,button { font-family: "微软雅黑","宋体","Helvetica Neue", Helvetica, Arial, sans-serif;} +body, ul, h1,h2,h3,h4,h5,p,pre,input {padding:0px; margin:0px;} +body{background-color: #EFEFF4;} +ul li {list-style:none;} img {max-width:100%;} blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin-left: 1.4em; margin-right: 0.4em; border-radius: 4px; font-family: "Microsoft YaHei"; background-size: 100% 100%; margin-top:5px;} .text-control {word-break:normal; word-wrap:break-word;} @@ -12,29 +14,43 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin-left: 1.4em; margin .f15 {font-size:15px;} .fb {font-weight:bold;} .mt2 {margin-top:2px;} +.mt3 {margin-top:3px;} +.mt4 {margin-top:4px;} .mt5 {margin-top:5px;} .mt10 {margin-top:10px;} +.mt11 {margin-top:11px;} +.mt15 {margin-top:15px;} +.mt30 {margin-top:30px;} +.mt70 {margin-top:70px;} .mb5 {margin-bottom:5px;} .mb10 {margin-bottom:10px;} +.mb20 {margin-bottom:20px;} .ml10 {margin-left:10px;} .mr5 {margin-right:5px;} .mr10 {margin-right:10px;} .ml15 {margin-left:15px;} .mr15 {margin-right:15px;} .mr20 {margin-right:20px;} +.ml25 {margin-left:25px;} .mr25 {margin-right:25px;} .ml55 {margin-left:55px;} .mr55 {margin-right:55px;} +.c-red {color:#e81a1a;} .c-blue {color:#269ac9;} .c-grey {color:#9a9a9a;} .c-grey2 {color:#707070;} .c-grey3 {color:#555555;} +.c-grey4 {color:#888888;} +.c-grey5 {color:#aaaaaa;} +.c-grey6 {color:#777777;} +.c-blue {color:#3b94d6;} a {color:#707070;} a.c-grey {color:#707070;} a.c-grey2 {color:#9a9a9a;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} +a.link-blue2 {color:#3b94d6;} a.underline {text-decoration:underline;} .border-radius {border-radius:5px;} .w36 {width:36px;} @@ -42,9 +58,35 @@ a.underline {text-decoration:underline;} .max-width-130 {max-width:130px;} .hidden {overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} .inline-block {display:inline-block;} +.dis {display:block;} .undis {display:none;} .text-nowrap {white-space:nowrap;} .v-top {vertical-align:top;} +.tac {text-align:center;} +.block-center {margin-left:auto; margin-right:auto; display:block;} + +/*背景色*/ +.bg-grey {background-color:#c1c1c1 !important;} +.bg-blue {background-color:#3b94d6;} + +/*按钮样式*/ +.btn1 {width:100%; height:40px; line-height:40px; vertical-align:middle; text-align:center; color:#fff; display:block; border-radius:5px;} +.bg-blue:not(.btn-disabled):active {background-color:#2780c2;} +.btn-disabled {background-color:#ccc;} + + +/*tab*/ +.tab-wrap {position:relative; line-height:38px; display:flex; font-size:13px; background-color:#fff;} +.tab-wrap a {position:relative; display:block; flex:1;} +.tab-wrap a:first-child:after {display:none;} +.tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;} +.weixin-tab {text-align:center; border-bottom:1px solid #ccc;} + +/*bottom-tab*/ +.bottom-tab-wrap {position:fixed; width:100%; bottom:0; line-height:38px; display:flex; font-size:13px; background-color:#fff;} +.bottom-tab-wrap a {display:block; flex:1; position:relative;} +.bottom-tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;} + /*动态样式*/ .post-container {width:100%;} @@ -56,7 +98,8 @@ a.underline {text-decoration:underline;} .fl {float:left;} .fr {float:right;} .cl {clear:both; overflow:hidden;} -.post-content {width:100%; font-size:13px; line-height:18px; height:95px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-all-content a {color:#136ec2;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} .post-interactive-column, .post-interactive-reply, @@ -78,6 +121,8 @@ a.underline {text-decoration:underline;} .reply-icon {background:url(/images/wechat/icon_list.gif) -150px -155px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praise-icon {background:url(/images/wechat/icon_list.gif) -36px -88px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praised-icon {background:url(/images/wechat/icon_list.gif) -152px -86px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} +.num-block {display:inline-block; vertical-align:top;} +.post-op-banner {height:20px; line-height:20px; vertical-align:middle;} /* loading 弹框*/ .loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} @@ -86,6 +131,67 @@ a.underline {text-decoration:underline;} .loading-box span {display: block; font-size:12px;} /*帖子锁定样式*/ -.locked_btn_cir {background: url("/images/locked.png") 0 0 no-repeat; cursor: default;} +.locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} + +/*20150612加入班级样式*/ +.add-class-box {width:80%; max-width:300px; min-width:240px; height:150px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; margin-top:100px;} +.add-class-tip {padding-top:20px; padding-bottom:20px;} +.class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} +.cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} +.submit-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} +.slice {width:2%; text-align:center; border-top:1px solid #ccc;} +.slice-line {width:1px; height:37px; margin:auto; background:#ccc;} + +/*20160613邀请码样式*/ +.qr-code-wrap {width:100%; padding:40px 0; background-color:#3b94d6;} +.qr-code-box {width:225px; background-color:#fff; border-radius:3px; margin:0 auto;} +.share-class-name {font-size:18px; color:#3b3b3b; text-align:center; padding:12px; border-bottom:1px solid #cccccc;} +.qr-img-wrap {width:100%; border-bottom:1px dashed #ccc;} +.qr-code-img {margin:36px auto; display:block;} +.invitation-code-wrap {text-align:center; font-size:18px; color:#3b3b3b; padding:16px;} +.share-code-wrap {width:100%; background-color:#efeff4;} +.share-code-btn, .finish-btn {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; background-color:#ff7239; margin:18px auto 20px auto; border-radius:50px; display:block;} +.share-code-instruction {max-width:228px; font-size:12px; color:#666; line-height:20px; margin:0 auto;} + +/*20160613班级详情*/ +.class-detail-name, .blue-title {width:100%; height:45px; line-height:45px; vertical-align:middle; background-color:#3b94d6; color:#fff; font-size:18px; text-align:center;} +.blue-title-sub {position:absolute; right:10px;} +.slice2 {width:2%; text-align:center; background-color:#fff; border-bottom:1px solid #ccc;} +.slice3 {width:1%; height:38px; text-align:center; background-color:#fff; border-bottom:1px solid #ccc;} +.slice-line2 {width:1px; height:38px; margin:auto; background:#ccc;} +.class-detail-tab {width:23%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-detail-tab2 {width:32%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-detail-tab3 {width:48%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-tab-active {border-bottom:1px solid #3b94d6;} +.class-search-wrap {padding:8px 12px; position:relative;} +.class-search-inner {padding:0 30px; background-color:#fff;} +.class-search-icon {position:absolute; top:16px; left:16px;} +.class-detail-search {width:100%; height:33px; color:#999; background-color:#fff; border:none; outline:none;} +.border-top {border-top:1px solid #ccc;} +.class-detail-row {width:100%; height:38px; line-height:38px; vertical-align:middle; border-bottom:1px solid #ccc; background-color:#fff;} +.class-test-tip {text-align:center; font-size:13px; color:#444; padding-top:40px;} +.img-circle {border-radius:50%;} +.member-banner {height:24px; line-height:24px; text-align:center; vertical-align:middle; background-color:#dfdfdf;} + +/*20160614班级列表*/ +.course-list-row {width:100%; height:38px; line-height:38px; vertical-align:middle; border-top:1px solid #ccc; border-bottom:1px solid #ccc; background-color:#fff;} +.class-list {width:100%; border-bottom:1px solid #ccc;} +.class-list li {height:40px; line-height:40px; vertical-align:middle; margin:0 25px; border-left:1px solid #ccc; border-bottom:1px solid #ccc; position:relative;} +.class-list-name {max-width:75%; display:inline-block;} +.class-list-dot {position:absolute; top:13px; left:-8px;} +.border-bottom-none {border-bottom:none !important;} +.students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} +.new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} +.join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} +.new-class-input {width:60%; color:#aaa; height:35px; line-height:35px; vertical-align:middle; border:none; outline:none;} -.bg-grey {background-color:#c1c1c1;} +/*20160616登录注册*/ +.login-wrap {padding:0 10px;} +.input-box-wrap {padding-right:17px;} +.input-box { -webkit-appearance: none; font-size: 16px;width:100%; height:16px; padding: 10px 0px 10px 5px; line-height:16px; border:1px solid #ccc; border-radius:5px;} +.login-op-wrap {height:30px; line-height:30px; vertical-align:middle;} +.login-box{display:inline-block; width:14px; height:14px; line-height:14px; text-align:center; vertical-align:middle; border:1px solid #ccc; background:#fff; border-radius:3px; color:#fff; cursor:pointer;} +.login-box.checked{background:#63c360;} +.login-box.checked:after{content:url(/images/wechat/checked.png);} +.forget-psw-wrap {width:60px; margin:0 auto;} +.forget-psw {position:fixed; bottom:10px;} diff --git a/script/assets b/script/assets new file mode 100644 index 000000000..bf4501127 --- /dev/null +++ b/script/assets @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cd public/javascripts/wechat && gulp && gulp minify diff --git a/spec/controllers/quality_analysis_controller_spec.rb b/spec/controllers/quality_analysis_controller_spec.rb new file mode 100644 index 000000000..d25575a85 --- /dev/null +++ b/spec/controllers/quality_analysis_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe QualityAnalysisController, :type => :controller do + +end diff --git a/spec/factories/apply_add_schools.rb b/spec/factories/apply_add_schools.rb new file mode 100644 index 000000000..a2994d28b --- /dev/null +++ b/spec/factories/apply_add_schools.rb @@ -0,0 +1,12 @@ +FactoryGirl.define do + factory :apply_add_school, :class => 'ApplyAddSchools' do + name "MyString" +province "MyString" +city "MyString" +address "MyString" +remarks "MyString" +school_id 1 +status 1 + end + +end diff --git a/spec/factories/quality_analyses.rb b/spec/factories/quality_analyses.rb new file mode 100644 index 000000000..a48e6e33f --- /dev/null +++ b/spec/factories/quality_analyses.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :quality_analyasis, class: 'QualityAnalysis' do + project_id 1 + author_login "MyString" + rep_identifier "MyString" + end +end diff --git a/spec/models/apply_add_schools_spec.rb b/spec/models/apply_add_schools_spec.rb new file mode 100644 index 000000000..de1b7c05a --- /dev/null +++ b/spec/models/apply_add_schools_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ApplyAddSchools, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/quality_analysis_spec.rb b/spec/models/quality_analysis_spec.rb new file mode 100644 index 000000000..d18ede452 --- /dev/null +++ b/spec/models/quality_analysis_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe QualityAnalysis, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end