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 37ce76624..eef93c371 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,20 @@ 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' end -gem 'net-ssh' +gem 'net-ssh', '2.9.1' gem 'jenkins_api_client' gem 'nokogiri' -# gem 'certified' - gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' @@ -35,7 +38,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' @@ -85,7 +87,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/syllabuses.js.coffee b/app/assets/javascripts/syllabuses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/syllabuses.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/syllabuses.css.scss b/app/assets/stylesheets/syllabuses.css.scss new file mode 100644 index 000000000..2576e25f0 --- /dev/null +++ b/app/assets/stylesheets/syllabuses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the syllabuses 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/admin_controller.rb b/app/controllers/admin_controller.rb index d3f681a06..4014a91bd 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -67,12 +67,15 @@ class AdminController < ApplicationController def excellent_all_courses name = params[:name] @order = "" - if params[:order] == 'asc' - courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) asc, c.id desc") + @sort = "" + if params[:sort] && (params[:order] == 'act') + courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc") @order = params[:order] - elsif params[:order] == 'desc' - courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) DESC, c.id desc") + @sort = params[:sort] + elsif params[:sort] && (params[:order] == 'time') + courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]},id desc") @order = params[:order] + @sort = params[:sort] else courses = Course.like(name).order('created_at desc') end @@ -99,6 +102,22 @@ class AdminController < ApplicationController end end + #取消精品 + def cancel_excellent_course + @course = Course.find params[:id] + unless @course.nil? + if @course.is_excellent == 1 || @course.excellent_option == 1 + @course.update_column('is_excellent', 0) + @course.update_column('excellent_option', 0) + end + end + respond_to do |format| + format.html{ + redirect_to excellent_courses_url + } + end + end + #管理员界面课程资源列表 def course_resource_list diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e421b8c69..7dea90e4b 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 @@ -1224,7 +1224,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 +1268,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/exercise_controller.rb b/app/controllers/exercise_controller.rb index b1e5456c5..e4f637b6d 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -49,6 +49,11 @@ class ExerciseController < ApplicationController return end @exercise = Exercise.find params[:id] + @exercise.course_messages.each do |message| + if User.current.id == message.user_id && message.viewed == 0 + message.update_attributes(:viewed => true) if message.viewed == 0 + end + end @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? exercise_end = @exercise.end_time > Time.now if @exercise.time == -1 diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 1c05399c4..f06725d01 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -483,6 +483,7 @@ class FilesController < ApplicationController if !attachments.empty? && attachments[:files] && tag_name != "" attachments[:files].each do |attachment| attachment.tag_list.add(tag_name) + attachment.description = params[:description] attachment.save end end @@ -493,6 +494,7 @@ class FilesController < ApplicationController if !attachments.empty? && attachments[:files] && tag_name != "" attachments[:files].each do |attachment| attachment.tag_list.add(tag_name) + attachment.description = params[:description] attachment.save end end @@ -600,6 +602,7 @@ class FilesController < ApplicationController if !attachments.empty? && attachments[:files] && tag_name != "" attachments[:files].each do |attachment| attachment.tag_list.add(tag_name) + attachment.description = params[:description] attachment.save end end @@ -610,6 +613,7 @@ class FilesController < ApplicationController if !attachments.empty? && attachments[:files] && tag_name != "" attachments[:files].each do |attachment| attachment.tag_list.add(tag_name) + attachment.description = params[:description] attachment.save end end diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb index 642a100c3..2eaa790cd 100644 --- a/app/controllers/org_member_controller.rb +++ b/app/controllers/org_member_controller.rb @@ -54,4 +54,8 @@ class OrgMemberController < ApplicationController def index end + + def deleteOrgMember + destroy + end end diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 3edda8285..2b41983cc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -14,9 +14,10 @@ class OrgSubfieldsController < ApplicationController SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase) end end - @subfield.update_attributes(:field_type => params[:field_type]) + #默认类型为帖子 + @subfield.update_attributes(:field_type => params[:field_type]||"Post") # admin配置的类型 - update_status_by_type(@subfield, params[:field_type]) + update_status_by_type(@subfield, params[:field_type]||"Post") else @res = false end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c216491b1..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| diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 10431f01a..661770206 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1096,7 +1096,8 @@ class StudentWorkController < ApplicationController all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")" end all_students = User.where("id in #{all_student_ids}") - @commit_student_ids = @homework.student_work_projects.map{|student| student.user_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| format.js @@ -1115,6 +1116,20 @@ class StudentWorkController < ApplicationController end end + def get_user_infor + req = Hash.new(false) + user = User.where("id = #{params[:user_id].to_i}").first + if user + req[:id] = user.id + req[:name] = user.show_name + req[:student_id] = user.user_extensions.student_id + req[:valid] = true + else + req[:valid] = false + end + render :json => req + end + private def searchstudent_by_name users, name mems = [] @@ -1194,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 @@ -1208,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 @@ -1228,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 new file mode 100644 index 000000000..69982b99a --- /dev/null +++ b/app/controllers/syllabuses_controller.rb @@ -0,0 +1,23 @@ +class SyllabusesController < ApplicationController + + before_filter :is_logged, :only => [:index, :show] + before_filter :find_syllabus, :only => [:show] + def index + user = User.current + @syllabuses = user.syllabuses + end + + def show + @courses = @syllabus.courses + + end + + private + def find_syllabus + @syllabus = Syllabus.find params[:id] + end + + def is_logged + redirect_to signin_path unless User.current.logged? + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cad57b49f..b7972ff6f 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 @@ -130,9 +139,12 @@ class UsersController < ApplicationController onclick_time = User.current.onclick_time.onclick_time messages.each do |message_all| # 未读的消息存放在数组 - if (message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0) || (message_all.message_type == "SystemMessage"&& !message_all.message.nil? && message_all.message.created_at > onclick_time) - @message_alls << message_all.message - break if @message_alls.length == 5 + 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 && mess.course.is_delete == 1) + @message_alls << mess + end + break if @message_alls.length == 10 end end end @@ -154,33 +166,41 @@ class UsersController < ApplicationController update_message_viewed(@user) end # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" case params[:type] when nil # 系统消息为管理员发送,我的消息中包含有系统消息 @message_alls = [] 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| - @message_alls << message_all.message + mess = message_all.message + unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) + @message_alls << mess + end end when 'unviewed' @message_alls = [] - messages = MessageAll.where("user_id =?", @user.id).includes(:message).order("created_at desc") + messages = MessageAll.where("message_alls.user_id =?", @user.id).includes(:message).order("created_at desc") messages.each do |message_all| # 在点击或者刷新消息列表后未读的消息存放在数组 - if message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0 - @message_alls << message_all.message + 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 && mess.course.is_delete == 1) + @message_alls << mess + end end end #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") when 'course_message' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Message", @user.id).order("created_at desc") when 'course_news' # 课程通知包含发布的通知和回复的通知 - @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =?", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") when 'poll' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user.id).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Poll", @user.id).order("created_at desc") #项目相关消息 when 'issue' @message_alls = ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?" , @user.id).order("created_at desc") @@ -1478,8 +1498,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}) "+ @@ -3250,7 +3270,11 @@ class UsersController < ApplicationController @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..668269a26 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 @@ -374,28 +374,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..ee2e2d74a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3127,6 +3127,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 +3303,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..bb144472b 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 @@ -683,9 +683,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 +704,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 diff --git a/app/helpers/syllabuses_helper.rb b/app/helpers/syllabuses_helper.rb new file mode 100644 index 000000000..dac84937b --- /dev/null +++ b/app/helpers/syllabuses_helper.rb @@ -0,0 +1,2 @@ +module SyllabusesHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 44b919121..4a6dbc6b6 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -147,7 +147,9 @@ module UsersHelper # 统计未读消息数 def unviewed_message(user) - course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count + courses = user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + course_count = CourseMessage.where("user_id =? and viewed =? and course_id not in #{course_ids}", user, 0).count forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count diff --git a/app/models/course.rb b/app/models/course.rb index 69dbec5d0..0c4acce97 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 @@ -24,6 +26,7 @@ class Course < ActiveRecord::Base #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 + belongs_to :syllabus # has_many :bid has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' @@ -64,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 @@ -91,6 +94,7 @@ class Course < ActiveRecord::Base 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}) } @@ -404,6 +408,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) @@ -421,12 +426,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 @@ -443,6 +450,7 @@ class Course < ActiveRecord::Base end def delete_course_ealasticsearch_index + return if Rails.env.development? begin self.__elasticsearch__.delete_document rescue => e @@ -450,6 +458,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 d1da50469..bbc639f3d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -155,9 +155,9 @@ 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 + 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 + after_update :update_project_ealasticsearch_index def remove_references_before_destroy return if self.id.nil? Watcher.delete_all ['watchable_id = ?', id] diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb new file mode 100644 index 000000000..7d6319955 --- /dev/null +++ b/app/models/syllabus.rb @@ -0,0 +1,5 @@ +class Syllabus < ActiveRecord::Base + belongs_to :user + has_many :courses + attr_accessible :description, :title +end diff --git a/app/models/user.rb b/app/models/user.rb index 44ef54c95..daf1237cf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,6 +90,7 @@ class User < Principal has_many :homework_users has_many :homework_attaches, :through => :homework_users has_many :homework_evaluations + has_many :syllabuses, :dependent => :destroy #问卷相关关关系 has_many :poll_users, :dependent => :destroy has_many :poll_votes, :dependent => :destroy @@ -144,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 @@ -247,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 @@ -1144,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..dce3e1f18 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,7 +211,7 @@ 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.term = params[:term] @course.time = params[:time] @@ -252,7 +270,7 @@ 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.time = params[:time] course.term = params[:term] course.end_time = params[:end_time] @@ -300,23 +318,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 +348,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 +363,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 +374,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/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb index ca15a6696..bea14fd3d 100644 --- a/app/views/admin/_course_detail_tr.html.erb +++ b/app/views/admin/_course_detail_tr.html.erb @@ -27,6 +27,9 @@ <%= course.course_activities.count%> + + <%= course.time %> + <%= link_to( course.is_excellent == 1 || course.excellent_option == 1 ? "取消精品" : "设为精品", { :controller => 'admin', :action => 'set_excellent_course', :id => course.id },:remote=>true, :class => 'icon-del') %> diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb index 86e4556f9..eb5f8c1a2 100644 --- a/app/views/admin/excellent_all_courses.html.erb +++ b/app/views/admin/excellent_all_courses.html.erb @@ -45,11 +45,14 @@ 资源数 - + 帖子数 - - <%=link_to '动态数', excellent_all_courses_path(:order=> @order == "desc" ? 'asc' : 'desc') %> + + <%=link_to '动态数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'act') %> + + + <%=link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %> diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb index fef6da84d..c107713a0 100644 --- a/app/views/admin/excellent_courses.html.erb +++ b/app/views/admin/excellent_courses.html.erb @@ -2,7 +2,7 @@

<%=l(:label_excellent_courses_list)%>

-<%= render 'tab_excellent_courses' %> +<%= render 'admin/tab_excellent_courses' %>

<%=l(:label_excellent_courses_list)%> @@ -33,12 +33,14 @@ 资源数 - + 帖子数 - + 动态数 + + @@ -74,6 +76,9 @@ <%= course.course_activities.count%> + + <%= link_to( course.is_excellent == 1 || course.excellent_option == 1 ? "取消精品" : "设为精品", { :controller => 'admin', :action => 'cancel_excellent_course', :id => course.id }, :class => 'icon-del') %> + <% end %> diff --git a/app/views/admin/leave_messages.html.erb b/app/views/admin/leave_messages.html.erb index dee8b7443..986823faa 100644 --- a/app/views/admin/leave_messages.html.erb +++ b/app/views/admin/leave_messages.html.erb @@ -59,12 +59,12 @@ <%= format_date(journal.created_on) %> - + <%case journal.jour_type %> <% when 'Principal' %> - <%= link_to(journal.notes.html_safe, feedback_path(journal.jour_id)) %> + <%= link_to(strip_html(journal.notes), feedback_path(journal.jour_id)) %> <% when 'Course' %> - <%= link_to(journal.notes.html_safe, course_feedback_path(journal.jour_id)) %> + <%= link_to(strip_html(journal.notes), course_feedback_path(journal.jour_id)) %> <% end %> diff --git a/app/views/attachments/_show_attachment_history.html.erb b/app/views/attachments/_show_attachment_history.html.erb index 6e2994a8d..61ccef344 100644 --- a/app/views/attachments/_show_attachment_history.html.erb +++ b/app/views/attachments/_show_attachment_history.html.erb @@ -1,7 +1,7 @@ 更新资源版本 -
+
当前版本 @@ -39,19 +39,19 @@
+
+ (未选择文件) + 您可以上传小于50MB的文件 +
- +

描述:

- +
-
-
(未选择文件)
-
您可以上传小于50MB的文件
-
diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb index ac953b254..8339ae5ad 100644 --- a/app/views/blog_comments/_simple_ke_reply_form.html.erb +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -1,20 +1,24 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
- <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> - - <% if course_id%> - - <% end %> - -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + <% if course_id%> + + <% end %> + +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 9617b7f76..7d8aaed86 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -87,11 +87,7 @@
- <% 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)%>
@@ -126,11 +122,6 @@
-
<%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> @@ -146,11 +137,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/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 3b6d55d96..dbe03d67f 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/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ad5baac41..62ccb3a86 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -57,6 +57,12 @@
<%=render :partial=>'layouts/project_info' %>
+ <% if (User.current.logged? && User.current.member_of_course?(@course)) || is_teacher %> +
+

邀请码

+

<%=@course.generate_invite_code %>

+
+ <% end %>
  • <%= l(:label_main_teacher)%> :  <%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %>
  • @@ -173,7 +179,7 @@
<%= render :partial => 'courses/recommendation', :locals => {:course => @course} %> -
访问计数 <%= @course.visits.to_i %> (自<%= Time.now.year %>年<%= Time.now.month %>月)
+
访问计数 <%= @course.visits.to_i %> (自2016年5月)
diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 114bb7219..9ba31bfe6 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -136,7 +136,7 @@ <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %>
-
访问计数 <%= @organization.visits.to_i %> (自<%= Time.now.year %>年<%= Time.now.month %>月)
+
访问计数 <%= @organization.visits.to_i %> (自2016年5月)
<%= render_flash_messages %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 52e42f1be..f7b04924d 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -146,7 +146,7 @@
-
访问计数 <%= @project.visits.to_i %> (自<%= Time.now.year %>年<%= Time.now.month %>月)
+
访问计数 <%= @project.visits.to_i %> (自2016年5月)
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index a7d908212..8455d5693 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -284,7 +284,7 @@
-
访问计数 <%= @user.visits.to_i %> (自<%= Time.now.year %>年<%= Time.now.month %>月)
+
访问计数 <%= @user.visits.to_i %> (自2016年5月)
<%= yield %> diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index ca179f9fc..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| %> @@ -119,19 +114,23 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
- <%= form_for('memo',:url=>forum_memos_path,:method => "post") do |f|%> - <%= f.hidden_field :subject, :required => true, value: @memo.subject %> - <%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %> - <%= f.hidden_field :parent_id, :required => true, value: @memo.id %> - <%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %> -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for('memo',:url=>forum_memos_path,:method => "post") do |f|%> + <%= f.hidden_field :subject, :required => true, value: @memo.subject %> + <%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %> + <%= f.hidden_field :parent_id, :required => true, value: @memo.id %> + <%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %> +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
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/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb index faa0bd0ce..d4d9d77a0 100644 --- a/app/views/messages/_reply_message.html.erb +++ b/app/views/messages/_reply_message.html.erb @@ -2,17 +2,21 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
- <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'new_form'} do |f| %> - - -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/org_document_comments/_simple_ke_reply_form.html.erb b/app/views/org_document_comments/_simple_ke_reply_form.html.erb index 1813f5b5f..2494687b4 100644 --- a/app/views/org_document_comments/_simple_ke_reply_form.html.erb +++ b/app/views/org_document_comments/_simple_ke_reply_form.html.erb @@ -1,17 +1,21 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
- <%= form_for @org_comment, :as => :reply, :url => {:controller => 'org_document_comments',:action => 'reply', :id => @org_comment.id}, :method => 'post', :html => {:multipart => true, :id => 'new_form'} do |f| %> - - -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for @org_comment, :as => :reply, :url => {:controller => 'org_document_comments',:action => 'reply', :id => @org_comment.id}, :method => 'post', :html => {:multipart => true, :id => 'new_form'} do |f| %> + + +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/org_member/deleteOrgMember.js.erb b/app/views/org_member/deleteOrgMember.js.erb new file mode 100644 index 000000000..d87e62c17 --- /dev/null +++ b/app/views/org_member/deleteOrgMember.js.erb @@ -0,0 +1,3 @@ +$("#org_members_count_id").html(""); +$("#org_members_count_id").html("<%= @org.org_members.count %>") +$("#org_member_list").html('<%= escape_javascript( render :partial=>"organizations/org_member_list",:locals=> {:members=>@org.org_members}) %>'); \ No newline at end of file diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb index a7647b0ad..a65f53719 100644 --- a/app/views/org_subfields/create.js.erb +++ b/app/views/org_subfields/create.js.erb @@ -1,9 +1,11 @@ <% if @res %> -$("#org_subfield_list").html(""); -$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => subfield_to_addmin?(@organization)}) %>"); -$("#sub_field_left_lists").html(""); -$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); -$("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>"); + $("#org_subfield_list").html(""); + $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => subfield_to_addmin?(@organization)}) %>"); + $("#sub_field_left_lists").html(""); + $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); + $("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>"); + //默认选中第一个 + $("input[name='field_type']").get(0).checked=true; <% end %> $("#subfield_name").val(""); $("#sub_dir").val(""); \ No newline at end of file diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index bcbeca778..e33787a09 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -387,17 +387,21 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> - <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index 03e986716..80125a03e 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -131,18 +131,22 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - - -
- - + <% if User.current.logged? %> +
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + +
+ + +
+

+ <% end%>
-

- <% end%> -
-
+
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 8c260c21c..24870b470 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -98,16 +98,20 @@
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -
- - -
-

- <% end%> -
+ <% if User.current.logged? %> +
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + +
+ + +
+

+ <% end%> +
+ <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
diff --git a/app/views/organizations/_org_custom_header.html.erb b/app/views/organizations/_org_custom_header.html.erb index c7aca1e6a..cf3fabb0e 100644 --- a/app/views/organizations/_org_custom_header.html.erb +++ b/app/views/organizations/_org_custom_header.html.erb @@ -1,11 +1,11 @@
- <%= image_tag(url_to_avatar(@organization), width:"67", height: "61", :id => 'nh_user_tx', :class => "por_logo fl ", :target => "_blank") %> + <%= image_tag(url_to_avatar(@organization), width:"51", height: "51", :id => 'nh_user_tx', :class => "por_logo fl mt1", :target => "_blank") %> <% if User.current.logged? %> diff --git a/app/views/organizations/_org_custom_left1.html.erb b/app/views/organizations/_org_custom_left1.html.erb index 4c1271ab8..8632dd57a 100644 --- a/app/views/organizations/_org_custom_left1.html.erb +++ b/app/views/organizations/_org_custom_left1.html.erb @@ -8,11 +8,11 @@

<%# if acts.count > 3 %> @@ -114,9 +66,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(document.content)}", :width => "299", :height => "246"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank" %> <% end %> - <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => document.title %> -

<%= time_from_now(document.created_at) %><%= link_to document.creator.show_name, user_path(document.creator), :class => "por_hot_name link-blue", :target => "_blank" %>

- <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => document.id, :content=> document.content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
+ <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => document.title %> +

<%= time_from_now(document.created_at) %><%= link_to document.creator.show_name, user_path(document.creator), :class => "por_hot_name link-blue", :target => "_blank" %>

+ <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => document.id, :content=> document.content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
<% else activity.container_type == 'OrgSubfield' %> @@ -131,9 +85,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(content)}", :width => "299", :height => "246"), board_message_url_in_org(message.board.id, message.id), :target => "_blank" %> <% end %> - <%= link_to title, board_message_url_in_org(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> -

<%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

- <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
+ <%= link_to title, board_message_url_in_org(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> +

<%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

+ <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
<% else %>
@@ -142,9 +98,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{get_image_path_from_content(content)}", :width => "299", :height => "246"), board_message_path(message.board.id, message.id), :target => "_blank" %> <% end %> - <%= link_to title, board_message_path(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> -

<%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

- <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
+ <%= link_to title, board_message_path(message.board.id, message.id), :class => 'por_hot_title_r link-black', :target => "_blank", :title => title %> +

<%= time_from_now(message.created_on) %><%= link_to message.author.show_name, user_path(message.author), :class => "por_hot_name link-blue", :target => "_blank" %>

+ <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => message.id, :content=> content, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
<% end %> <% end %> @@ -157,9 +115,11 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{path}", :width => "299", :height => "246"), news_path(news), :target => "_blank" %> <% end %> - <%= link_to news.title, news_path(news), :class => 'por_hot_title_r link-black', :target => "_blank", :title => news.title %> -

<%= time_from_now(news.created_on) %><%= link_to news.author.show_name, user_path(news.author), :class => "por_hot_name link-blue", :target => "_blank" %>

- <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => news.id, :content=> news.description, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
+ <%= link_to news.title, news_path(news), :class => 'por_hot_title_r link-black', :target => "_blank", :title => news.title %> +

<%= time_from_now(news.created_on) %><%= link_to news.author.show_name, user_path(news.author), :class => "por_hot_name link-blue", :target => "_blank" %>

+ <%=render :partial =>"organizations/organization_content_extension", :locals => {:user_activity_id => news.id, :content=> news.description, :maxheight => 80, :maxwordsnum => 90, :maxwidth => 0, :cl => "por_hot_txt_r"} %> +
<% end %> <% end %> @@ -167,4 +127,8 @@ <%# end %>
- \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/organizations/_org_custom_left3.html.erb b/app/views/organizations/_org_custom_left3.html.erb index 3d5d01dee..ff412d869 100644 --- a/app/views/organizations/_org_custom_left3.html.erb +++ b/app/views/organizations/_org_custom_left3.html.erb @@ -71,8 +71,8 @@ <% end %> <% end %> - <% unless acts[1..5].nil? %> - <% acts[1..5].each do |activity| %> + <% 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 %> -
- -
<% end %> \ No newline at end of file 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/_no_teacher_score_notice.html.erb b/app/views/student_work/_no_teacher_score_notice.html.erb index 5a8c768cc..0926e3c74 100644 --- a/app/views/student_work/_no_teacher_score_notice.html.erb +++ b/app/views/student_work/_no_teacher_score_notice.html.erb @@ -1,7 +1,8 @@

- 当前作品未进行评分,是否确定提交? + <%#A if work.teacher_score.nil? || work. %> + 您当次评阅未对作品进行评分,分数将取上次的评分结果,若没有评分记录则不评分,是否确定提交?

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/_set_score_rule_detail.html.erb b/app/views/student_work/_set_score_rule_detail.html.erb index fe2c734e5..eaabc81df 100644 --- a/app/views/student_work/_set_score_rule_detail.html.erb +++ b/app/views/student_work/_set_score_rule_detail.html.erb @@ -2,12 +2,14 @@ 评分设置
    迟交扣分 - + + 请输入0-50数值
    <% if homework.anonymous_comment == 0 %> -
    +
    缺评扣分 - + + 请输入0-50数值
    <% end %> @@ -55,11 +57,23 @@
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index eaf6b9304..cc078bf9c 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -4,14 +4,21 @@ (<%= @student_work_count%>人已交) - <% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %> + <%# my_work = @homework.student_works.where("user_id = #{User.current.id}").first %> + <% my_work = cur_user_works_for_homework @homework %> <% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %> 您尚未提交作品 - <%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %> + <% unless @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + <%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %> + <% end %> <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> - 您已提交且不可再修改,因为截止日期已过 + 已提交且不可再修改,因为截止日期已过 <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> - 您已提交,您还可以修改 + <% if @homework.homework_type == 3 %> + 组长已提交,组长还可修改 + <% else %> + 您已提交,您还可以修改 + <% end %> <% end %> <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3 || @homework.is_open == 1%> diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 8e1a2a546..ed0b369e8 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -103,21 +103,11 @@ } function popupRegex(){ - if($("#group_member_ids").length > 0) { - if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } - } else { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } + $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); + $('#ajax-modal').parent().addClass("anonymos"); } function nh_check_field(params){ @@ -140,6 +130,12 @@ params.contentmsg.html(''); } } + if(!result) { + return result; + } + } + if($("#group_member_ids").length > 0) { + result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html()))); } return result; } 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/new.html.erb b/app/views/student_work/new.html.erb index 453f717c9..dfddea306 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -62,21 +62,11 @@ } // 作品校验 function popupRegex(){ - if($("#group_member_ids").length > 0) { - if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } - } else { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } + $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); + $('#ajax-modal').parent().addClass("anonymos"); } function nh_check_field(params){ @@ -99,6 +89,12 @@ params.contentmsg.html(''); } } + if(!result) { + return result; + } + } + if($("#group_member_ids").length > 0) { + result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html()))); } return result; } diff --git a/app/views/student_work/retry_work.js.erb b/app/views/student_work/retry_work.js.erb index c6f354875..c15b81e09 100644 --- a/app/views/student_work/retry_work.js.erb +++ b/app/views/student_work/retry_work.js.erb @@ -1,2 +1,3 @@ hideModal('#popbox02'); -$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false})%>"); \ No newline at end of file +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false})%>"); +$("#group_member_ids").val("<%=User.current.id %>"); \ No newline at end of file diff --git a/app/views/student_work/search_course_students.js.erb b/app/views/student_work/search_course_students.js.erb index c7aa982b9..65179317f 100644 --- a/app/views/student_work/search_course_students.js.erb +++ b/app/views/student_work/search_course_students.js.erb @@ -7,19 +7,20 @@ $("#all_students_list").empty(); link += ""; $("#all_students_list").append(link); - var str = ""; + var str = $("#group_member_ids").val(); + 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/users/_all_replies.html.erb b/app/views/users/_all_replies.html.erb index 20a3289ff..a74acc77c 100644 --- a/app/views/users/_all_replies.html.erb +++ b/app/views/users/_all_replies.html.erb @@ -13,7 +13,7 @@
    <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> - <%= format_activity_day(comment.created_time) %> <%= format_time(comment.created_time, false) %> + <%= time_from_now(comment.created_time) %> <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> diff --git a/app/views/users/_comment_reply_detail.html.erb b/app/views/users/_comment_reply_detail.html.erb index caac3ee62..4ced798d0 100644 --- a/app/views/users/_comment_reply_detail.html.erb +++ b/app/views/users/_comment_reply_detail.html.erb @@ -1,20 +1,9 @@ -
    <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "用户头像" %>
    -<% if comment.try(:user).try(:realname) == ' ' %> - <%= link_to comment.try(:user), user_path(comment.user_id), :class => "content-username" %> -<% else %> - <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "content-username" %> -<% end %> -<%= time_from_now(comment.created_on) %> -
    <%= comment.notes.html_safe %>
    + <%= link_to comment.user.show_name, user_path(comment.user_id), :class => "content-username" %> + <%= time_from_now(comment.created_on) %> +
    <%= comment.notes.html_safe %>
    \ 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 701f81da1..ee12c04dd 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -7,11 +7,8 @@
    - <% 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.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"%>
    - <% 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? || User.current.allowed_to?(:as_teacher,activity.course)) %> + <%# count = fetch_user_leaveWord_reply(activity).count %>
    -
    -
    回复 - <%= 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 %>
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%> - <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %> - <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %> - <%= 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 %> -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %> + <%= 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 %> +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 76971e240..135013a62 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -6,11 +6,7 @@
    - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id, :host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id, :host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> + <%= link_to activity.author.show_name, user_path(activity.author_id, :host=>Setting.host_user), :class => "newsBlue mr15" %> TO <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
    @@ -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) %> @@ -116,18 +99,22 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> - - -
    - - + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> + + +
    + + +
    +

    + <% end%>
    -

    - <% end%> -
    -
    +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 5ffa78158..efd3770aa 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_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.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 %> @@ -92,16 +76,20 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    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 1f4c4b44b..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 %> @@ -27,16 +12,20 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %> - -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %> + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index f82dc35e7..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) %> @@ -111,17 +98,21 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - - -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index 43b22b193..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 %>
    @@ -89,16 +73,20 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    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 30f4e3542..621b56fbd 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -1,20 +1,39 @@ -
    -
    <%= 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 User.current.logged? %> +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    +
    + <% 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/_show_unlogged_reply.html.erb b/app/views/users/_show_unlogged_reply.html.erb new file mode 100644 index 000000000..b428fd249 --- /dev/null +++ b/app/views/users/_show_unlogged_reply.html.erb @@ -0,0 +1,4 @@ +
    + 登录后可添加回复 + <%#= link_to "登录", signin_path, :class => "linkBlue", :target => "_blank" %> +
    \ No newline at end of file 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_at_message.html.erb b/app/views/users/_user_at_message.html.erb index 8f0c6acaf..81139ab8e 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -1,4 +1,4 @@ -<% if AtMessage === ma && ma.at_valid? %> +<% if ma.class == AtMessage && ma.at_valid? %>
    - <% 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 %> @@ -74,21 +56,25 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%> - - - - - - -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%> + + + + + + +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_user_group_attr.html.erb b/app/views/users/_user_group_attr.html.erb index 681f158e7..952a3396e 100644 --- a/app/views/users/_user_group_attr.html.erb +++ b/app/views/users/_user_group_attr.html.erb @@ -3,11 +3,14 @@
    每组最小人数: 人 +
    每组最大人数: 人 +
    +

    - <% 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 %>
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    -
    - <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%> - <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %> - <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %> - <%= 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 %> -
    - - -
    -

    - <% end%> -
    + <% if User.current.logged? %> +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %> + <%= 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 %> +
    + + +
    +

    + <% end%> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %>
    diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb index afd498d06..517d66038 100644 --- a/app/views/users/_user_jours_list.html.erb +++ b/app/views/users/_user_jours_list.html.erb @@ -5,13 +5,13 @@ <%if jours %> <% jours.each do |jour|%> - <% unless jour.private == 1 && (!User.current || (User.current && jour.jour_id != User.current.id && jour.user_id != User.current.id)) %> + <% unless jour.private == 1 && (!User.current || (User.current && jour.jour_id != User.current.id && jour.user_id != User.current.id && !User.current.admin?)) %> - <%= 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..3e83b0f7a 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -326,7 +326,7 @@ <% end %> - <% if ma.course_message_type == "StudentWorksScore" %> + <% if ma.course_message_type == "StudentWorksScore" && ma.course_message %>
    • <% if ma.course_message.reviewer_role == 3 %> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index c18c6aae4..6d227e93b 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,5 +1,7 @@ <% if params[:type] == 'HomeworkCommon' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); +<% elsif params[:type] == 'JournalsForMessage' %> +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); <% else %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); <% end %> diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index 4a7e5cee3..238102879 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -7,6 +7,15 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); + <%if @homework.anonymous_comment == 0 && @homework.homework_detail_manual.comment_status != 1%> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/new_student_work_alert') %>'); + showModal('ajax-modal', '360px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().css("top","65%").css("left","60%").css("border","3px solid #269ac9"); + $('#ajax-modal').parent().addClass("anonymos_work"); + <% end%> }); diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index 99ab73b46..5f5ea6c3f 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -1,3 +1,7 @@ <% unless @comment.parent.nil? %> -$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); + <% else %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 391709b52..1ff8adc57 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -4,8 +4,9 @@ <% if (!@message_alls.nil? && @message_alls.count >0) %> <% if params[:type].nil? || params[:type] == "unviewed" %>
      - 有 <%= unviewed_message(@user) %> 条未读 - <% unless (unviewed_message(@user) == 0 || User.current != @user) %> + <% count = unviewed_message(@user) %> + 有 <%= count %> 条未读 + <% unless (count == 0 || User.current != @user) %> <%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %> <% end %>
      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/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/zh.yml b/config/locales/zh.yml index 4c0f531a5..3dbd2e8ef 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1865,12 +1865,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: 作业积分 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 2a6204bbf..5dc509abd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do end collection do get 'org_member_autocomplete' + get 'deleteOrgMember' end end @@ -130,6 +131,7 @@ RedmineApp::Application.routes.draw do end member do match "quote_resource_show_org_subfield", :via => [:get] + get "update_file_description" end end @@ -329,6 +331,7 @@ RedmineApp::Application.routes.draw do post 'last_codecomparetime' post 'set_score_rule' get 'work_canrepeat' + get 'get_user_infor' end end @@ -779,6 +782,7 @@ RedmineApp::Application.routes.draw do member do match "quote_resource_show", :via => [:get] get "file_hidden" + get "update_file_description" end end @@ -1028,6 +1032,7 @@ RedmineApp::Application.routes.draw do get 'admin/excellent_courses', as: :excellent_courses get 'admin/excellent_all_courses', as: :excellent_all_courses match 'admin/set_excellent_course/:id', :to => 'admin#set_excellent_course' + match 'admin/cancel_excellent_course/:id', :to => 'admin#cancel_excellent_course' get 'admin/course_resource_list' get 'admin/project_resource_list' match 'admin/users', :via => :get @@ -1259,7 +1264,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/20160613064914_create_syllabuses.rb b/db/migrate/20160613064914_create_syllabuses.rb new file mode 100644 index 000000000..a9a926d7e --- /dev/null +++ b/db/migrate/20160613064914_create_syllabuses.rb @@ -0,0 +1,12 @@ +class CreateSyllabuses < ActiveRecord::Migration + def change + create_table :syllabuses do |t| + t.string :title + t.text :description + t.references :user + + t.timestamps + end + add_index :syllabuses, :user_id + end +end diff --git a/db/migrate/20160613065840_add_syllabus_to_course.rb b/db/migrate/20160613065840_add_syllabus_to_course.rb new file mode 100644 index 000000000..b40d187d0 --- /dev/null +++ b/db/migrate/20160613065840_add_syllabus_to_course.rb @@ -0,0 +1,6 @@ +class AddSyllabusToCourse < ActiveRecord::Migration + def change + add_column :courses, :syllabus_id, :integer + add_index :courses, :syllabus_id + end +end 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/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/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/kindeditor/pasteimg.js b/public/assets/kindeditor/pasteimg.js index 97d5e33c5..9f848b8e2 100644 --- a/public/assets/kindeditor/pasteimg.js +++ b/public/assets/kindeditor/pasteimg.js @@ -327,6 +327,7 @@ function enablePasteImg(_editor) { }; $(nodeBody).on('pasteImage', function(ev, data) { + //粘贴图片时走这里会出现两张图片走df()即可 console.log('pasteImage'); console.log("dataURL: " + data.dataURL); console.log("width: " + data.width); @@ -348,7 +349,6 @@ function enablePasteImg(_editor) { } }); } - }); return; }; @@ -371,7 +371,8 @@ function df(myself) { sstr += that.attr("src") + "|"; } else if (that.attr("src").indexOf("data:image") >= 0){ - that.parents().removeAttr("href"); //删除所有父节点的href + //去掉外链 +// that.parents().removeAttr("href"); //删除所有父节点的href } } }); @@ -421,10 +422,10 @@ function uploadpic(piclist,myself) { //复制过来带的链接class等都要去掉 和视频图片有关系 that.removeAttr("class"); - that.parent().removeAttr("class"); - that.parents().removeAttr("href"); //删除所有父节点的href -// that.parent().removeAttr("href"); - that.parent().removeAttr("data-ke-src"); + //去掉外链 +// that.parent().removeAttr("class"); +// that.parents().removeAttr("href"); //删除所有父节点的href +// that.parent().removeAttr("data-ke-src"); tIndex = tIndex + 1; } } 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 @@ +
    +
    +
    课程列表
    +
    未命名课程
    + + + +
    + 新建课程 + 加入班级 + 我的资源 +
    + +
    \ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 2e7ed3151..cc188f978 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -15,7 +15,7 @@
    序号 来   源: {{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..e3346ea93 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -14,7 +14,7 @@ 来   源: {{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/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 0437125e8..d56b5f940 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -547,6 +547,7 @@ function observeSearchfield(fieldId, targetId, url) { $.ajax({ url: url, type: 'get', + dataType: 'jsonp', data: {q: $this.val()}, success: function(data){ if(targetId) $('#'+targetId).html(data); }, beforeSend: function(){ $this.addClass('ajax-loading'); }, @@ -1045,6 +1046,12 @@ function showNormalImage(id) { $(image).attr('src',_src); return; } + + //已被加链接则不处理 + if ($(image).parent() && $(image).parent().attr('href')){ + return; + } + //无格式的图片不让点击显示大图,显示的话会有问题 var tmpsrc = image.attr('src'); if (tmpsrc.indexOf('.gif') >= 0 || tmpsrc.indexOf('.jpg') >= 0 || tmpsrc.indexOf('.jpeg') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.bmp') >= 0 || tmpsrc.indexOf('.png') >= 0 || tmpsrc.indexOf('.BMP') >= 0 || tmpsrc.indexOf('.JPEG') >= 0 || tmpsrc.indexOf('.JPG') >= 0 || tmpsrc.indexOf('.PNG') >= 0 || tmpsrc.indexOf('.GIF') >= 0) { @@ -1283,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') { @@ -1316,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); @@ -1497,4 +1555,18 @@ function edit_file_description(url,id){ } ); } +//删除组织成员 +function ifDeleteOrgMember(id,name){ + var htmlvalue = "
    您确定要删除"+name+"吗?

    确定取消
    " + + ""; + pop_up_box(htmlvalue,580,30,50); +} diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 9f6b6aabd..8b5e58618 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -185,7 +185,7 @@ function regex_course_password(str) //提交新建课程 function submit_new_course() { - if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')&®ex_course_password('new')) + if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')) { $("#new_course").submit(); } @@ -193,7 +193,7 @@ 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_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')) { $("#edit_course_"+id).submit(); } @@ -550,7 +550,7 @@ function check_late_penalty(id) } else { - obj.val("0"); + obj.val(""); } } diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index e9ef7ad6c..1578d72df 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -194,9 +194,11 @@ $(function(){ $("#GroupPopupBox").dialog("open"); $(".ui-dialog-titlebar").hide(); $("a.popClose").on('click', function(){ + reset_group_attr(); $("#GroupPopupBox" ).dialog("close"); }); $("#cancel_group").on('click', function(){ + reset_group_attr(); $("#GroupPopupBox" ).dialog("close"); }); $('#min_num').focus(); @@ -351,29 +353,67 @@ $(function(){ $("#GroupPopupBox").dialog("open"); $(".ui-dialog-titlebar").hide(); $("a.popClose").on('click', function () { + reset_group_attr(); $("#GroupPopupBox").dialog("close"); }); $("#cancel_group").on('click', function () { + reset_group_attr(); $("#GroupPopupBox").dialog("close"); }); $('#min_num').focus(); } }); + var reset_group_attr = function() { + $("#min_num_notice").hide(); + $("#min_max_num_notice").hide(); + $("#max_num_notice").hide(); + if($("input[name=min_num]").length > 0 && $("input[name=max_num]").length > 0) { + $("#min_num").val($("input[name=min_num]").val()); + $("#max_num").val($("input[name=max_num]").val()); + } else { + $("#min_num").val(2); + $("#max_num").val(10); + } + }; var saveGroupAttr = function() { var valid = true; var base_on_project = 0; var min = $.trim($("#min_num").val()); var max = $.trim($("#max_num").val()); - if(min.length <= 0) { + var regex = /^\d+$/; + if(!regex.test(min) || parseInt(min) <= 0) { + $("#min_num_notice").html("请输入正整数"); + $("#max_num_notice").html(""); + $("#min_max_num_notice").html(""); + $("#min_num_notice").show(); $("#min_num").focus(); - valid = false; return false; + } else { + $("#min_num_notice").html(""); + $("#min_num_notice").hide(); + } + if(!regex.test(max) || parseInt(max) <= 0) { + $("#max_num_notice").html("请输入正整数"); + $("#min_num_notice").html(""); + $("#min_max_num_notice").html(""); + $("#max_num_notice").show(); + $("#max_num").focus(); + return false; + } else { + $("#max_num_notice").html(""); + $("#max_num_notice").hide(); } - if(max.length <= 0) { + if(parseInt(min) > parseInt(max)) { + $("#min_max_num_notice").html("最小人数不得大于最大人数"); + $("#min_num_notice").html(""); + $("#max_num_notice").html(""); + $("#min_max_num_notice").show(); $("#max_num").focus(); - valid = false; return false; + } else { + $("#min_max_num_notice").html(""); + $("#min_max_num_notice").hide(); } if ($("#base_on_project").is(":checked")) { base_on_project = 1; diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index d2eb7a168..8db3fbc20 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -259,6 +259,24 @@ function regex_evaluation_end(){ } } +//处理迟交、缺评扣分 +function check_late_penalty(id) +{ + var obj = $("#" + id); + var regex = /^\d+$/; + if(regex.test(obj.val())) + { + if(obj.val() > 50) + { + obj.val("50"); + } + } + else + { + obj.val(""); + } +} + //验证匿评数量 function regex_evaluation_num(){ var evaluation_num = $.trim($("#evaluation_num").val()); @@ -675,4 +693,4 @@ function register(){ $('#user_password').blur(); $('#user_password_confirmation').blur(); } -} \ No newline at end of file +} 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/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 56ae81f8d..d0a5e7ab3 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;} @@ -1372,6 +1372,7 @@ a:hover.comment_ding_link{ color:#269ac9;} .comment_content{ color:#333;} .t_txt{ margin-top:10px;} .orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;} +.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;} .orig_textarea{width:90%; margin-bottom:10px;} .orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;} .orig_sub:hover{ background:#297fb8;} @@ -1418,3 +1419,11 @@ 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;} +/*未登录回复提示*/ +.visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index ba7836a3e..7fad9854f 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1553,6 +1553,7 @@ a:hover.comment_ding_link{ color:#269ac9;} .comment_content{ color:#333;} .t_txt{ margin-top:10px;} .orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;} +.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;} .orig_textarea{width:90%; margin-bottom:10px;} .orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;} .orig_sub:hover{ background:#297fb8;} @@ -1620,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;} @@ -1792,3 +1794,12 @@ input.new_loggin_input{ .new_register_left{ margin-top:250px; } + +/*未登录回复提示*/ +.visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/org2.css b/public/stylesheets/org2.css index 9e19fb5cb..23e53fd7b 100644 --- a/public/stylesheets/org2.css +++ b/public/stylesheets/org2.css @@ -197,7 +197,7 @@ a.sn-reply-username { color:#24366e; margin-right:15px; } .topnav_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-7px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 1px;} .topnav_login_list a{color:#269ac9;} .topnav_login_list li{ } -.homepageProfileMenuIcon {background:url(../images/nav_icon.png) 30px -155px no-repeat; width:65px; height:54px; position:relative; display:inline-block; line-height:0;} +.homepageProfileMenuIcon {background:url(../images/nav_icon.png) 30px -155px no-repeat; width:65px; height:50px; position:relative; display:inline-block; line-height:0;} .homepageLeft {width:240px; float:left; margin-right:10px; margin-bottom:10px;} .none {display: none;} .user-img,.user-img img{ margin-right:10px; -moz-border-radius: 50px; -webkit-border-radius: 50px;border-radius: 50px; display:block; width:40px; height:40px;} diff --git a/public/stylesheets/org_custom.css b/public/stylesheets/org_custom.css index 0bdc8a670..5ff340272 100644 --- a/public/stylesheets/org_custom.css +++ b/public/stylesheets/org_custom.css @@ -1,74 +1,74 @@ /* 门户首页 */ #por_header{ width:100%; } -.por_header_top{ width:100%; height:70px; background:#3b94d6; } -.por_header_con{ width:1000px; margin:0 auto; height:70px; } -.por_logo{ margin-top:5px;} +.por_header_top{ width:100%; height:55px; background:#3b94d6; } +.por_header_con{ width:1000px; margin:0 auto; height:55px; } +.por_logo img{ margin-top:2px; height:51px;} .por_login li{ float:left;} -.por_login li a{ display:block; padding:0 15px; height:70px; line-height:70px;font-size:16px; color:#fff; } +.por_login li a{ display:block; padding:0 15px; height:55px; line-height:55px;font-size:16px; color:#fff; } .por_login li a:hover{ background-color:#1173bc;} -.por_search{ margin-top:15px; margin-right:20px;} +.por_search{ margin-top:10px; margin-right:20px;} .pro_input_search{ background-color:#daeefc; height:36px; width:355px; border:none; padding:0 5px; color:#3b94d6;} -a.por_search_btn{ display:block;background:#daeefc url(../images/org_custom/icons_por.png) 0 8px no-repeat; width:25px; height:36px;} -a:hover.por_search_btn{background:#daeefc url(../images/org_custom/icons_por.png) -35px 8px no-repeat; } -.por_nav{ width:1000px; height:70px; overflow:hidden; margin: 0 auto; position:relative; } -a.por_edit_index{ position:absolute; font-size:14px; right:5px; top:20px;} -.por_nav ul{ border-bottom:7px solid #ccc; height:63px;} +a.por_search_btn{ display:block;background:#daeefc url(../images/icons_por.png) 0 8px no-repeat; width:25px; height:36px;} +a:hover.por_search_btn{background:#daeefc url(../images/icons_por.png) -35px 8px no-repeat; } +.por_nav{ width:100%; height:50px; background-color:#eeefef; } +.por_nav ul{ width:1000px;height:50px; overflow:hidden; margin: 0 auto; position:relative;} +a.por_edit_index{ position:absolute; font-size:14px; right:5px; top:15px;} .por_nav ul li{ float:left; } -.por_nav ul li a{ display: block; height:63px; padding:0 20px; line-height:63px; font-size:18px; color:#333; } -.por_nav ul li a:hover{ border-bottom:7px solid #3b94d6; } -.por_index_act{border-bottom:7px solid #3b94d6; } +.por_nav ul li a{ display: block; height:63px; padding:0 20px; line-height:50px; font-size:16px; color:#333; } +.por_nav ul li a:hover{ color:#3b94d6; } +.por_nav ul li a.por_index_act{color:#3b94d6; } #por_container{ width:1000px; margin:10px auto;} .por_left{ width:685px; margin-right:15px; float:left; } .por_right{ width:300px; float:left;} .por_icons_hot{ background:url(../images/org_custom/icons_por.png) 0 -78px no-repeat; height:22px; width:55px; padding-left:3px; color:#fff; font-size:12px; line-height:22px; font-weight:normal;} -.por_h2_index{ font-size:20px; font-weight:normal; color:#3b94d6; width:100%; border-bottom:1px solid #e8e5e5; height:40px; line-height:40px;} +.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{ border:1px solid #e8e5e5; padding:5px; margin-top:15px; width:300px;} +.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; border-bottom:1px solid #e8e5e5;} -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;} +.por_course_bar{ width:328px; margin:0 7px; padding:20px 0 0px;} +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{ border-bottom:1px solid #e8e5e5; padding-bottom:5px;} -.por_post_left{ width:394px; margin-top:15px;} +.por_post{ padding-bottom:5px;} +.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; } -.post_icons_grey{ width:5px; height:5px; margin:10px 5px 0 0; background-color:#b3b3b3; display:block; line-height:20px;} -.por_post_list li{ height:20px; height:30px;} +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; border:1px solid #e8e5e5;} +.por_users_img{ width:40px; height:40px; -webkit-border-radius:50px;-moz-border-radius:50px;-o-border-radius:50px;border-radius:50px;} .por_news_txt{ width:245px; margin-left:10px;} .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_projects{border-bottom:1px solid #e8e5e5; padding-bottom:10px; margin-top:10px;} +.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; } #por_teachers_nav {border-bottom:1px solid #d0d0d0; height:31px;} #por_teachers_nav li {float:left; padding:0px 5px; text-align:center; } -#por_teachers_nav li a{font-size:20px;} -.por_teachers_hover {border:1px solid #d0d0d0; border-bottom:1px solid #fff; } +#por_teachers_nav li a{font-size:18px;} +.por_teachers_hover { } .por_teachers_hover a{color:#3b94d6;} .por_teachers_nomal {border-bottom:none; } .por_teachers_nomal a{color:#999;} @@ -76,9 +76,9 @@ a.por_zan:hover{background:url(../images/org_custom/icons_por.png) -34px -42px n .dis {display:block;} a.por_more_teacher{ font-size:12px; } .por_teachers_li{ margin-top:10px;} -.por_teachers_li li{ padding:10px 0;border-bottom:1px solid #e8e5e5;} +.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;} @@ -88,22 +88,4 @@ a.por_teachers_name{ display:block; width:75px; font-size:18px;overflow:hidden; .por_footer_con ul li{ float:left; text-align:center;} .por_footer_con ul li a{ font-size:14px;} .por_footer_con ul li a span{ color:#999; margin:0 15px ;} -.por_footer_con p{ text-align:center; margin-top:20px; color:#777;} - - - - - - - - - - - - - - - - - - +.por_footer_con p{ text-align:center; margin-top:20px; color:#777;} \ No newline at end of file diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 0d1c4fe85..bde560613 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1278,4 +1278,13 @@ a.pages-big{ width:50px;} .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;} \ No newline at end of file +.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;} + +/*更新资源文件的描述框*/ +.H60 {height:60px !important;} +.W420 {width:420px;} +.W300 {width:300px !important;} +.W600{ width:600px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 2ab150405..80340f77f 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1042,7 +1042,8 @@ span.at a{color:#269ac9;text-decoration: none;} .blueBtn:hover {background-color:#298fbd;} a.blue-btn{ padding:4px 7px; color:#FFF; border:none; background-color:#269ac9; cursor:pointer; text-align:center;} a.blue-btn:hover {background-color:#298fbd;} - +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;} /*文本描述展开高度*/ .maxh360 {max-height: 810px;} .lh18 { line-height: 18px;} @@ -1167,13 +1168,19 @@ 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;} span.shadowbox_news_user{ color:#3b94d6;} a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; color:#3b94d6; text-align:center;border-top:1px solid #eee;} +/*未登录回复提示*/ +.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;} +.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;} 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/syllabuses_controller_spec.rb b/spec/controllers/syllabuses_controller_spec.rb new file mode 100644 index 000000000..72c43dff1 --- /dev/null +++ b/spec/controllers/syllabuses_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SyllabusesController, :type => :controller do + +end diff --git a/spec/factories/syllabuses.rb b/spec/factories/syllabuses.rb new file mode 100644 index 000000000..436972e39 --- /dev/null +++ b/spec/factories/syllabuses.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :syllabus do + title "MyString" + description "MyText" + user nil + end +end diff --git a/spec/models/syllabus_spec.rb b/spec/models/syllabus_spec.rb new file mode 100644 index 000000000..6072c09ce --- /dev/null +++ b/spec/models/syllabus_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Syllabus, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end