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/Gemfile b/Gemfile index 11acafe3c..b482cb6fd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,16 @@ 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' + gem "rmagick", "= 2.13.1" ## centos yum install ImageMagick-devel + gem 'certified' end 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 +34,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' diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 9ffac4e10..c555eb633 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -18,6 +18,7 @@ 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 @@ -71,6 +72,7 @@ module Mobile mount Apis::BlogComments mount Apis::NewComment mount Apis::Praise + mount Apis::Resources add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 6696b8360..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 @@ -384,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/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/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/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 4014a91bd..2e3612b94 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -72,10 +72,42 @@ class AdminController < ApplicationController 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] @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") + 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] + + elsif params[:sort] && (params[:order] == 'post') + courses = Course.find_by_sql("SELECT c.*, count(m.id) count FROM boards b, courses c, messages m WHERE m.board_id = b.id AND b.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count #{params[:sort]}, c.id desc") + @order = params[:order] + @sort = params[:sort] + + elsif params[:sort] && (params[:order] == 'res') + courses = Course.find_by_sql("SELECT c.*, count(at.container_id) cat FROM attachments at, courses c WHERE at.container_type = 'Course' AND at.container_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY cat #{params[:sort]}, id desc") + @order = params[:order] + @sort = params[:sort] + + elsif params[:sort] && (params[:order] == 'works') + courses = Course.find_by_sql("SELECT c.*, count(hc.id) chc FROM courses c, homework_commons hc,student_works sw WHERE c.id = hc.course_id AND sw.homework_common_id = hc.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY chc #{params[:sort]}, id desc") @order = params[:order] @sort = params[:sort] + + elsif params[:sort] && (params[:order] == 'homework') + courses = Course.find_by_sql("SELECT c.*, count(sw.id) csw FROM student_works sw, courses c, homework_commons hc WHERE c.id = hc.course_id AND sw.id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY csw #{params[:sort]}, id desc") + @order = params[:order] + @sort = params[:sort] + + elsif params[:sort] && (params[:order] == 'std') + courses = Course.find_by_sql("SELECT c.*, count(sfc.id) sfc FROM courses c, students_for_courses sfc WHERE sfc.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY sfc #{params[:sort]}, id desc") + @order = params[:order] + @sort = params[:sort] + + elsif params[:sort] && (params[:order] == 'open') + courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY is_public #{params[:sort]},id desc") + @order = params[:order] + @sort = params[:sort] + else courses = Course.like(name).order('created_at desc') end diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index e4f637b6d..c3964c567 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -511,7 +511,7 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) - if @exercise.publish_time.nil? + if @exercise.publish_time.nil? || @exercise.publish_time <= Time.now @exercise.update_attributes(:show_result => params[:show_result]) @exercise.update_attributes(:exercise_status => 2) @exercise.update_attributes(:publish_time => Time.now) 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/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 9006c8a79..661770206 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1096,7 +1096,7 @@ class StudentWorkController < ApplicationController all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")" end all_students = User.where("id in #{all_student_ids}") - student_work_id = @homework.student_work_projects.where("user_id=?",User.current.id).empty? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id + student_work_id = @homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id @commit_student_ids = @homework.student_work_projects.where("student_work_id != #{student_work_id}").map{|student| student.user_id} @users = searchstudent_by_name all_students,name respond_to do |format| diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 7dcfa1948..4a79d6d93 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -3,8 +3,8 @@ class WechatsController < ActionController::Base wechat_responder include ApplicationHelper - # ROOT_URL = "#{Setting.protocol}://#{Setting.host_name}/" - ROOT_URL = "http://www.trustie.net" + 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| #邀请码 @@ -65,7 +65,7 @@ class WechatsController < ActionController::Base end on :click, with: 'DEV' do |request, key| - request.reply.text "此功能正在开发中,请耐心等待。" + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| @@ -138,7 +138,7 @@ class WechatsController < ActionController::Base unless uw sendBind(request) else - request.reply.text "请直接回复6位班级邀请码\n(不区分大小写):" + request.reply.text "请直接回复5位班级邀请码\n(不区分大小写):" end end @@ -163,7 +163,6 @@ class WechatsController < ActionController::Base if uw && uw.user request.reply.text "欢迎回来, #{uw.user.show_name}" else - request.reply.text "欢迎关注Trustie创新实践社区" sendBind(request) end end @@ -188,7 +187,7 @@ class WechatsController < ActionController::Base 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 + raise "班级不存在,请确认您的邀请码是否输入正确,谢谢!" unless course cs = CoursesService.new status = cs.join_course({invite_code: course.invite_code}, user) @@ -239,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, diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index dd3abe3a8..55a4da73a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -44,9 +44,9 @@ module CoursesHelper def visible_excellent_course obj # if course.is_pu end - + # 返回x项目成员数量,即roles表中定义的所有成员 - def projectCount project + def projectCount project #searchCountByRoles project, AllPeople project.members.count end @@ -147,10 +147,10 @@ module CoursesHelper # 返回学生数量,即roles表中定义的Reporter #def studentCount project - # searchStudent(project).count - # or - # searchStudent(project).count - # end + # searchStudent(project).count + # or + # searchStudent(project).count + # end # 判断用户是否是课程的管理员 # add by nwb @@ -225,11 +225,11 @@ module CoursesHelper #end # 注意:此方法有问题,速度慢且结果不准 - # alias studentCountOrigin studentCount + # alias studentCountOrigin studentCount #def studentCount course - # count = studentCountOrigin course - #garble count - # end + # count = studentCountOrigin course + #garble count + # end #获取课程所有成员 def course_all_member course @@ -265,27 +265,18 @@ 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 # ===================================================================================== # return people list - def searchPeopleByName(course, role_name) - course.members.select{|m| - m.roles.any?{|r|r.name == role_name} - } - end - def searchTeacherAndAssistant project - searchPeopleByName(project, 'Manager').concat( - searchPeopleByName(project, 'Teacher') - ).concat( - searchPeopleByName(project, 'TeachingAsistant') - ) - end - - def searchStudent project - searchPeopleByName(project, 'Student') + #searchPeopleByRoles(project, TeacherRoles) + members = [] + project.members.includes(:user).each do |m| + members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) + end + members end def TeacherAndAssistantCount course @@ -302,6 +293,19 @@ module CoursesHelper members end + def searchStudent project + #searchPeopleByRoles(project, StudentRoles) + members = [] + project.members.each do |m| + if m && m.user && m.user.allowed_to?(:as_student,project) + members << m + end + end + members + end + + + def searchStudent_by_name project, name #searchPeopleByRoles(project, StudentRoles) members = [] @@ -320,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 @@ -454,7 +458,7 @@ module CoursesHelper content = content_tag('ul', content) content_tag('div', content, :class => "tabs") end - + def findCourseTime project str = "" begin @@ -695,9 +699,9 @@ module CoursesHelper #file_count Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment| if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin? - activities[attachment.container_id]+=1 + activities[attachment.container_id]+=1 else - activities[attachment.container_id] + activities[attachment.container_id] end end @@ -716,8 +720,8 @@ module CoursesHelper #news News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news| if news.author.member_of_course?(@course) - activities[news.course_id]+=1 - end + activities[news.course_id]+=1 + end end #homework_count diff --git a/app/models/course.rb b/app/models/course.rb index 7420e653f..1591ff797 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -95,6 +95,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}) } @@ -458,15 +459,20 @@ 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 = invite_code - if !invite_code || invite_code.size <5 - self.invite_code = CODES.sample(5).join - return generate_invite_code if Course.where(invite_code: invite_code).present? + 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? + self[:invite_code] = code save! && reload - code = invite_code end code end diff --git a/app/models/user.rb b/app/models/user.rb index 3d491c8ab..daf1237cf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -145,6 +145,7 @@ class User < Principal has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'" + has_many :course_attachments , :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Course'" #### # added by bai has_many :join_in_contests, :dependent => :destroy diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 68d062b65..f6bf59af0 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -32,6 +32,18 @@ class CoursesService course_list end + + def user_courses_list(current_user) + courses = current_user.courses.not_deleted + courses.inject([]) {|course_list, course| + course_list << {:course => course,:img_url => url_to_avatar(course), + :current_user_is_member => current_user.member_of_course?(course), + :current_user_is_teacher => is_course_teacher(current_user,course), + course_student_num: searchStudent(course).count + } + } + end + #搜索课程 def search_course params,current_user courses_all = Course.all_course diff --git a/app/views/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb index bea14fd3d..189cbc8f6 100644 --- a/app/views/admin/_course_detail_tr.html.erb +++ b/app/views/admin/_course_detail_tr.html.erb @@ -6,6 +6,9 @@ <%= link_to(course.name, course_path(course.id)) %> + + <%= checked_image course.is_public? %> + <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %> @@ -22,7 +25,7 @@ <%= visable_attachemnts_incourse(course).count%> - <%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %> + <%= Message.where("board_id =?", course.boards.first.id).count %> <%= course.course_activities.count%> diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb index 8e2f146a0..65e442a3e 100644 --- a/app/views/admin/courses.html.erb +++ b/app/views/admin/courses.html.erb @@ -25,10 +25,10 @@ 序号 - + 课程 - + 主讲老师 @@ -37,9 +37,12 @@ <%=l(:field_is_public)%> - + <%=l(:field_created_on)%> + + 动态时间 + @@ -65,6 +68,9 @@ <%= format_date(course.created_at) %> + + <%= course.updated_at.strftime('%Y-%m-%d %H:%M:%S') %> + <% end %> diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb index eb5f8c1a2..805c81d1f 100644 --- a/app/views/admin/excellent_all_courses.html.erb +++ b/app/views/admin/excellent_all_courses.html.erb @@ -27,32 +27,35 @@ 序号 - + 课程名 - + + <%= link_to '公开', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'open') %> + + 主讲老师 - - 学生数 + + <%= link_to '学生数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'std') %> - - 作业数 + + <%= link_to '作业数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'homework') %> - - 作品数 + + <%= link_to '作品数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'works') %> - - 资源数 + + <%= link_to '资源数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'res') %> - - 帖子数 + + <%= link_to '帖子数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'post') %> - - <%=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 => 'act') %> - <%=link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %> + <%= link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %> diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index f8fe7896c..9d70511e8 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -145,11 +145,11 @@ alert("测验标题不能为空"); } else if($.trim($("#exercise_end_time").val()) =="") { alert("截止时间不能为空"); - } else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) { + } else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) <= Date.now()) { alert("截止时间不能小于当前时间"); } else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) { alert("测验时长必须为非零开头的数字"); - } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) { + } else if($.trim($("#exercise_publish_time").val()) !="" && ((Date.parse($("#exercise_publish_time").val())+(24*60*60-1)*1000) < Date.now())) { alert("发布时间不能小于当前时间"); } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) { alert("截止时间不能小于发布时间"); diff --git a/app/views/files/_hidden_file.html.erb b/app/views/files/_hidden_file.html.erb index 8e359c605..1ace422b7 100644 --- a/app/views/files/_hidden_file.html.erb +++ b/app/views/files/_hidden_file.html.erb @@ -3,7 +3,7 @@ <%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
- +
<%#= calendar_for('attachment_publish_time')%> @@ -11,7 +11,7 @@
-
diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 0edf22e58..85e0dc8d3 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -8,11 +8,11 @@
<%# 如果有历史版本则提供历史版本下载 %> <% if file.attachment_histories.count == 0 %> - <%= link_to truncate(file.filename,length: 35, omission: '...'), + <%= link_to truncate(file.filename,length: 40, omission: '...'), download_named_attachment_path(file.id, file.filename), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <% else %> - <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + <%= link_to truncate(file.filename,length: 40, omission: '...'), attachment_history_download_path(file.id), :title => file.filename+"\n"+file.description.to_s, :class => "linkGrey3 f_14", :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 0a35c783c..1171f296b 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -32,7 +32,7 @@ <% if User.current.allowed_to?(:as_teacher,course) %>
- +
<%#= calendar_for('attachment_publish_time')%> 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/organizations/_org_member_list.html.erb b/app/views/organizations/_org_member_list.html.erb index 8e8a23b60..8af7986fc 100644 --- a/app/views/organizations/_org_member_list.html.erb +++ b/app/views/organizations/_org_member_list.html.erb @@ -1,6 +1,7 @@ <% members.each do |member|%>
    - + <% username = User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %> +
  • <%= get_org_member_role_name member %> <%= form_for(member, {:as => :org_member, :remote => true, :url => Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s, @@ -32,7 +33,8 @@
  • <% if ( (User.current.id == member.organization.creator_id || User.current.admin_of_org?(member.organization) ) && member.user_id != member.organization.creator_id )%> 编辑 - <%= link_to '删除', Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %> + 删除 + <%#= link_to '删除', Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 124e3ef4d..22a64a219 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -2,13 +2,13 @@

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

ZIP下载 - <% if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> + <%# if is_project_manager?(User.current, @project.id) && QualityAnalysis.where(:project_id => @project.id).first.nil? %> <%# if User.current.member_of?(@project) %> - <%= link_to "质量分析", quality_analysis_path(:id => @project.id), :remote => true, :class => "btn_zipdown fr" %> + <%#= link_to "质量分析", quality_analysis_path(:id => @project.id), :remote => true, :class => "btn_zipdown fr" %> + <%# end %> + <%# else %> + <%#= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %> <%# end %> - <% else %> - <%= link_to "质量分析", project_quality_analysis_path(:project_id => @project.id, :resource_id => @proje), :class => "btn_zipdown fr" %> - <% end %>
<% if @entries.nil? %> diff --git a/app/views/student_work/search_course_students.js.erb b/app/views/student_work/search_course_students.js.erb index 2ac4eeaab..65179317f 100644 --- a/app/views/student_work/search_course_students.js.erb +++ b/app/views/student_work/search_course_students.js.erb @@ -8,19 +8,19 @@ $("#all_students_list").empty(); $("#all_students_list").append(link); var str = $("#group_member_ids").val(); - /*var str = ""; + var choose_str = ""; var lists = $("#choose_students_list li"); if(lists.length > 0) { for(var i=0; i - if (str.indexOf(<%=user.id.to_s %>) < 0) { + if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) { $("#student_<%=user.id %>").one("click",function choose_student() { var li = "
  • diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 80d254dae..1e3957ea9 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -2,7 +2,7 @@ - 我的动态 + Trustie平台 @@ -40,14 +40,16 @@ - + - + + + diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 4f434757f..3316cbc8a 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -19,7 +19,7 @@
  • <%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
  • 加入时间:<%= format_date( User.find(item.id).created_on)%> - 最后登陆时间:<%= format_date( User.find(item.id).last_login_on)%> + 最后登录时间:<%= format_date( User.find(item.id).last_login_on)%> <%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%>
  • diff --git a/app/views/welcome/_search_user_results.html.erb b/app/views/welcome/_search_user_results.html.erb index d1c8c2393..06a40d021 100644 --- a/app/views/welcome/_search_user_results.html.erb +++ b/app/views/welcome/_search_user_results.html.erb @@ -13,7 +13,7 @@
  • <%= User.find(user.id).user_extensions && User.find(user.id).user_extensions.brief_introduction.present? ? User.find(user.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
  • 加入时间:<%= format_date( User.find(user.id).created_on)%> - 最后登陆时间:<%= format_date( User.find(user.id).last_login_on)%> + 最后登录时间:<%= format_date( User.find(user.id).last_login_on)%> <%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%>
  • diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 996def8c0..fc3e39980 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1139,7 +1139,7 @@ zh: text_account_destroy_confirmation: |- 确定继续处理? 您的账号一旦删除,将无法再次激活使用。 - error_session_expired: 您的会话已过期。请重新登陆。 + error_session_expired: 您的会话已过期。请重新登录。 text_session_expiration_settings: "警告: 更改这些设置将会使包括你在内的当前会话失效。" setting_session_lifetime: 会话最大有效时间 setting_session_timeout: 会话闲置超时 diff --git a/config/menu.yml b/config/menu.yml index 735cd202f..213130240 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ 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: @@ -19,9 +19,13 @@ button: name: "更多" sub_button: - - type: "view" + type: "click" name: "加入班级" - url: "https://www.trustie.net/" + key: "JOIN_CLASS" + - + type: "click" + name: "反馈" + key: "FEEDBACK" - type: "view" name: "历史推文" diff --git a/config/routes.rb b/config/routes.rb index 215267cb8..4465c9e1b 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 diff --git a/config/wechat.yml b/config/wechat.yml index 1e3389837..9bc33029e 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -15,7 +15,7 @@ default: &default 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" diff --git a/public/assets/kindeditor/pasteimg.js b/public/assets/kindeditor/pasteimg.js index 479b1101a..9f848b8e2 100644 --- a/public/assets/kindeditor/pasteimg.js +++ b/public/assets/kindeditor/pasteimg.js @@ -328,27 +328,27 @@ function enablePasteImg(_editor) { $(nodeBody).on('pasteImage', function(ev, data) { //粘贴图片时走这里会出现两张图片走df()即可 -// console.log('pasteImage'); -// console.log("dataURL: " + data.dataURL); -// console.log("width: " + data.width); -// console.log("height: " + data.height); -// var blob = dataURItoBlob(data.dataURL); -// if (data.blob !== null) { -// var data = new FormData(); -// data.append("imgFile",blob, "imageFilename.png"); -// console.log(data); -// $.ajax({ -// url: '/kindeditor/upload?dir=image', -// contentType: false, -// type: 'POST', -// data: data, -// processData: false, -// success: function(data) { -// console.log(data); -// editor.exec('insertimage', JSON.parse(data).url); -// } -// }); -// } + console.log('pasteImage'); + console.log("dataURL: " + data.dataURL); + console.log("width: " + data.width); + console.log("height: " + data.height); + var blob = dataURItoBlob(data.dataURL); + if (data.blob !== null) { + var data = new FormData(); + data.append("imgFile",blob, "imageFilename.png"); + console.log(data); + $.ajax({ + url: '/kindeditor/upload?dir=image', + contentType: false, + type: 'POST', + data: data, + processData: false, + success: function(data) { + console.log(data); + editor.exec('insertimage', JSON.parse(data).url); + } + }); + } }); return; }; diff --git a/public/assets/wechat/add_class.html b/public/assets/wechat/add_class.html deleted file mode 100644 index 2543d5cc4..000000000 --- a/public/assets/wechat/add_class.html +++ /dev/null @@ -1,13 +0,0 @@ -
    -
    -

    输入班级邀请码,即刻加入班级!

    -
    - -
    - 取消 -
    -
    -
    - 确定 -
    -
    diff --git a/public/assets/wechat/myclass.html b/public/assets/wechat/class.html similarity index 50% rename from public/assets/wechat/myclass.html rename to public/assets/wechat/class.html index 30a8b9083..dc575dc64 100644 --- a/public/assets/wechat/myclass.html +++ b/public/assets/wechat/class.html @@ -2,11 +2,15 @@
    {{course.name}}邀请码
    - -
    -
    + + +
    + +
    +
    +
    - +
    @@ -14,10 +18,13 @@
    -
    -
    {{r.filename}}
    + +
    +
    {{r.filename}}发送
    +

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

    -
    +
    授课老师
    @@ -27,6 +34,22 @@
    {{student.name}}
    +
    + +
    +
    {{r.homework_name}}发送
    +

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

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

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

    +
    + + + +
    diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html new file mode 100644 index 000000000..8ec8bcaa5 --- /dev/null +++ b/public/assets/wechat/class_list.html @@ -0,0 +1,21 @@ +
    +
    +
    课程列表
    +
    未命名课程
    +
      +
    • + + + > + {{course.course_student_num}}人 +
    • +
    + + + + +
    \ No newline at end of file diff --git a/public/assets/wechat/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/javascripts/application.js b/public/javascripts/application.js index 142b0be42..525a1fb1a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1555,6 +1555,20 @@ function edit_file_description(url,id){ } ); } +//删除组织成员 +function ifDeleteOrgMember(id,name){ + var htmlvalue = "
    您确定要删除"+name+"吗?

    " + + ""; + pop_up_box(htmlvalue,580,30,50); +} //展开课程大纲列表中的班级 function expand_course_list(id, target, btnid, count) { diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js index 52dcd34ca..1fea6f08a 100644 --- a/public/javascripts/wechat/build/app.min.js +++ b/public/javascripts/wechat/build/app.min.js @@ -2,8 +2,9 @@ var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/a 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,t,r){var l=r.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},i=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",i("activities.html","ActivityController")).when("/issues/:id",i("issue_detail.html","IssueController")).when("/project_discussion/:id",i("project_discussion.html","DiscussionController")).when("/homework/:id",i("homework_detail.html","HomeworkController")).when("/course_notice/:id",i("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",i("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",i("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",i("blog_detail.html","BlogController")).when("/add_class",i("add_class.html","AddClassController")).when("/myclass",i("myclass.html","MyClassController")).when("/invite_code",i("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 +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/add_class.js b/public/javascripts/wechat/controllers/add_class.js deleted file mode 100644 index 099bb8e8e..000000000 --- a/public/javascripts/wechat/controllers/add_class.js +++ /dev/null @@ -1,4 +0,0 @@ - -app.controller('AddClassController', ['$scope',function($scope){ - -}]); \ 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/myclass.js b/public/javascripts/wechat/controllers/myclass.js deleted file mode 100644 index b689e0f55..000000000 --- a/public/javascripts/wechat/controllers/myclass.js +++ /dev/null @@ -1,54 +0,0 @@ -app.controller('MyClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ - - var vm = $scope; - var courseid = $routeParams.id; - - vm.currentTab = 1; - vm.tab = function(index){ - vm.currentTab = index; - vm.searchText = ''; - console.log(vm.currentTab); - if(index == 2){ - 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; - } - ) - } - } - } - vm.course = {}; - vm.students = []; - vm.teachers = []; - vm.resources = []; - - vm.invite = function(){ - $location.path("/invite_code").search({id: courseid}); - }; - - $http.post(config.apiUrl + "courses/"+courseid+"/attachments", - {token: auth.token(), name: ''} - ).then(function(response){ - vm.resources = response.data.data; - }); - - $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( - function(response){ - console.log(response.data); - vm.course = response.data.data; - } - ); - - - 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; - } - ) - } - -}]); \ No newline at end of file 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/others/routes.js b/public/javascripts/wechat/others/routes.js index 3fa7ca6df..80efa71e9 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -30,8 +30,10 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func .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('/add_class', makeRoute('add_class.html', 'AddClassController')) - .when('/myclass', makeRoute('myclass.html', 'MyClassController')) + .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' diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 955a7ab73..3360d81ee 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -74,7 +74,19 @@ a.underline {text-decoration:underline;} .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%;}