Merge branch 'weixin_guange' into develop

This commit is contained in:
yuanke 2016-07-21 17:24:05 +08:00
commit 1aba4394e9
53 changed files with 752 additions and 192 deletions

View File

@ -6,10 +6,17 @@ module Mobile
resources :blog_comments do resources :blog_comments do
desc "get special topic" desc "get special topic"
get ':id' do post ':id' do
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
blog = BlogComment.find params[:id] blog = BlogComment.find params[:id]
present :data, blog, with: Mobile::Entities::BlogComment,user: user present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -200,8 +200,13 @@ module Mobile
# course = Course.find(params[:id]) # course = Course.find(params[:id])
cs = CoursesService.new cs = CoursesService.new
course = cs.show_course(params,current_user) course = cs.show_course(params,current_user)
present :data, course, with: Mobile::Entities::Course,user: current_user
{ status: 0} if course[:course][:is_delete] == 1
{status:-1, message: '该班级不存在或已被删除啦' }
else
present :data, course, with: Mobile::Entities::Course,user: current_user
present :status, 0
end
end end
end end
@ -212,7 +217,7 @@ module Mobile
get "homeworks/:id" do get "homeworks/:id" do
cs = CoursesService.new cs = CoursesService.new
homeworks = cs.homework_list params,current_user homeworks = cs.homework_list params,current_user
present :data, homeworks, with: Mobile::Entities::Homework present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
present :status, 0 present :status, 0
end end
@ -259,7 +264,7 @@ module Mobile
post ":course_id/attachments" do post ":course_id/attachments" do
cs = CoursesService.new cs = CoursesService.new
count = cs.course_attachments params count = cs.course_attachments params
present :data, count, with: Mobile::Entities::Attachment present :data, count, with: Mobile::Entities::Attachment,user: current_user
present :status, 0 present :status, 0
end end
@ -392,8 +397,8 @@ module Mobile
authenticate! authenticate!
course = Course.find(params[:course_id]) course = Course.find(params[:course_id])
exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc")
present :data,exercises,with:Mobile::Entities::Exercise present :data,exercises,with:Mobile::Entities::Exercise,user: current_user
present :status,0 present :status,0
end end

View File

@ -7,11 +7,17 @@ module Mobile
include IssuesHelper include IssuesHelper
desc "get special issuse" desc "get special issuse"
get ':id' do post ':id' do
authenticate! authenticate!
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
issue = Issue.find params[:id] issue = Issue.find params[:id]
present :data, issue, with: Mobile::Entities::Issue,user: user present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -6,11 +6,18 @@ module Mobile
resources :journal_for_messages do resources :journal_for_messages do
desc "get special journal" desc "get special journal"
get ':id' do post ':id' do
authenticate! authenticate!
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
jour = JournalsForMessage.find params[:id] jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours,user: user present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -6,11 +6,17 @@ module Mobile
resources :messages do resources :messages do
desc "get special topic" desc "get special topic"
get ':id' do post ':id' do
authenticate! authenticate!
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
message = Message.find params[:id] message = Message.find params[:id]
present :data, message, with: Mobile::Entities::Message,user: user present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -6,11 +6,17 @@ module Mobile
resources :newss do resources :newss do
desc "get special news" desc "get special news"
get ':id' do post ':id' do
authenticate! authenticate!
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
news = News.find params[:id] news = News.find params[:id]
present :data, news, with: Mobile::Entities::News,user: user present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -85,12 +85,26 @@ module Mobile
requires :token, type: String requires :token, type: String
requires :course_ids, type: Array[Integer] requires :course_ids, type: Array[Integer]
requires :send_id, type: Integer requires :send_id, type: Integer
requires :send_type, type: Integer
end end
post 'send' do post 'send' do
authenticate! authenticate!
rs = ResourcesService.new rs = ResourcesService.new
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
ori = nil
flag = false
save_message = nil
case params[:send_type]
when 1
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
when 2
ori, flag, save_message = rs.send_homework_to_course(current_user,params)
when 3
ori, flag, save_message = rs.send_exercise_to_course(current_user,params)
end
if flag if flag
present :status, 0 present :status, 0
else else

View File

@ -6,11 +6,17 @@ module Mobile
resources :whomeworks do resources :whomeworks do
desc "get one homework" desc "get one homework"
get ':id' do post ':id' do
authenticate! authenticate!
user = current_user user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
homework = HomeworkCommon.find params[:id] homework = HomeworkCommon.find params[:id]
present :data, homework, with: Mobile::Entities::Whomework,user: user present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0 present :status, 0
end end
end end

View File

@ -25,10 +25,12 @@ module Mobile
elsif ac.act_type == "News" elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count all_comments = []
ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
elsif ac.act_type == "Issue" elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end end
when :subject when :subject
if ac.act_type == "HomeworkCommon" if ac.act_type == "HomeworkCommon"
ac.act.name unless ac.nil? || ac.act.nil? ac.act.name unless ac.nil? || ac.act.nil?

View File

@ -3,6 +3,7 @@ module Mobile
class Attachment < Grape::Entity class Attachment < Grape::Entity
include Redmine::I18n include Redmine::I18n
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include ApplicationHelper
def self.attachment_expose(field) def self.attachment_expose(field)
expose field do |f,opt| expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field) if f.is_a?(Hash) && f.key?(field)
@ -22,6 +23,7 @@ module Mobile
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s (number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename when :coursename
f.course.nil? ? "" : f.course.name f.course.nil? ? "" : f.course.name
end end
end end
end end
@ -36,6 +38,12 @@ module Mobile
attachment_expose :file_dir attachment_expose :file_dir
attachment_expose :attafile_size attachment_expose :attafile_size
attachment_expose :coursename #所属班级名 attachment_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end end
end end
end end

View File

@ -25,7 +25,9 @@ module Mobile
when :act_id when :act_id
u.id u.id
when :comment_count when :comment_count
u.children.count # u.children.count
all_comments = []
get_all_children(all_comments, u).count
end end
end end
end end
@ -51,7 +53,18 @@ module Mobile
blog_comment_expose :praise_count blog_comment_expose :praise_count
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment) if c.is_a? (::BlogComment)
c.children.reverse ##自己的父回复为空 才有子回复
if !opt[:children]
if c.parent.nil? && opt[:type] == 0
opt[:children] = true
all_comments = []
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = get_all_children(all_comments, c)[tStart..tEnd]
all_comments
end
end
end end
end end
expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options| expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options|
@ -61,6 +74,63 @@ module Mobile
has_praise = obj.empty? ? false : true has_praise = obj.empty? ? false : true
has_praise has_praise
end end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end
expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
else
[]
end
end
end
end end
end end
end end

View File

@ -27,6 +27,14 @@ module Mobile
expose :exercise_name expose :exercise_name
expose :exercise_description expose :exercise_description
exercise_expose :coursename #所属班级名 exercise_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end end
end end
end end

View File

@ -98,6 +98,14 @@ module Mobile
homework_expose :coursename #所属班级名 homework_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance[:current_user_is_teacher].nil?
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end
end end
end end
end end

View File

@ -23,7 +23,9 @@ module Mobile
when :issue_status when :issue_status
IssueStatus.find(issue.status_id).name IssueStatus.find(issue.status_id).name
when :journals_count when :journals_count
issue.journals.where("notes is not null and notes != ''").count # issue.journals.where("notes is not null and notes != ''").count
all_comments = []
get_all_children(all_comments, f).count
when :project_name when :project_name
issue.project.name issue.project.name
when :praise_count when :praise_count

View File

@ -18,7 +18,9 @@ module Mobile
when :lasted_comment when :lasted_comment
time_from_now f.created_on time_from_now f.created_on
when :reply_count when :reply_count
f.children.count # f.children.count
all_comments = []
get_all_children(all_comments, f).count
when :praise_count when :praise_count
get_activity_praise_num(f) get_activity_praise_num(f)
when :act_type when :act_type

View File

@ -30,6 +30,9 @@ module Mobile
'Message' 'Message'
when :act_id when :act_id
u.id u.id
when :replies_count
all_comments = []
get_all_children(all_comments, u).count
end end
end end
end end

View File

@ -24,6 +24,9 @@ module Mobile
'News' 'News'
when :act_id when :act_id
f.id f.id
when :comments_count
all_comments = []
get_all_children(all_comments, f).count
end end
end end
elsif f.is_a?(Hash) && !f.key?(field) elsif f.is_a?(Hash) && !f.key?(field)

View File

@ -78,12 +78,7 @@ class WechatsController < ActionController::Base
end end
# When user view URL in the menu button # When user view URL in the menu button
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
uw = user_binded?(request[:FromUserName]) request.reply.text "#{request[:FromUserName]} view #{view}"
unless uw
sendBind(request)
else
request.reply.text "#{request[:FromUserName]} view #{view}"
end
end end
# When user sent the imsage # When user sent the imsage
@ -147,6 +142,14 @@ class WechatsController < ActionController::Base
default_msg(request) default_msg(request)
end end
on :click, with: 'PROJECT' do |request, key|
request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
end
on :click, with: 'JOIN_PROJECT' do |request, key|
request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
end
on :click, with: 'JOIN_CLASS' do |request, key| on :click, with: 'JOIN_CLASS' do |request, key|
uw = user_binded?(request[:FromUserName]) uw = user_binded?(request[:FromUserName])
unless uw unless uw
@ -218,8 +221,8 @@ class WechatsController < ActionController::Base
raise CoursesService::JoinCourseError.message(status[:state]) raise CoursesService::JoinCourseError.message(status[:state])
end end
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!',
content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } 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 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#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect" url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/class?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect"
pic_url = "#{ROOT_URL}/images/wechat/class.jpg" pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
@ -274,7 +277,7 @@ class WechatsController < ActionController::Base
user: user user: user
) )
ws = WechatService.new ws = WechatService.new
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now))
render :json => {status:0, msg: "绑定成功"} render :json => {status:0, msg: "绑定成功"}
rescue Exception=>e rescue Exception=>e
render :json => {status: -1, msg: e.message} render :json => {status: -1, msg: e.message}

View File

@ -0,0 +1,20 @@
#coding=utf-8
#
module WechatsHelper
def include_wechat_jsfile
if Rails.env.production?
javascript_include_tag '/javascripts/wechat/build/app.min.js'
else
wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")
srcs = Rails.application.config.wechat_srcs
paths = []
srcs.each do |src|
Dir.glob(wechat_path+ "/#{src}" ) do |path|
paths << path[File.join(Rails.root, "public").to_s.size, path.size]
end
end
javascript_include_tag *paths
end
end
end

View File

@ -335,6 +335,7 @@ class CoursesService
8, '您已经是该班级的教师了', 8, '您已经是该班级的教师了',
9, '您已经是该班级的教辅了', 9, '您已经是该班级的教辅了',
10, '您已经是该班级的管理员了', 10, '您已经是该班级的管理员了',
11, '该班级不存在或已被删除啦',
'未知错误,请稍后再试' '未知错误,请稍后再试'
] ]
end end
@ -348,6 +349,8 @@ class CoursesService
if course if course
if course_endTime_timeout? course if course_endTime_timeout? course
@state = 2 @state = 2
elsif course[:is_delete] == 1
@state = 11
else else
if current_user.member_of_course?(course) #如果已经是成员 if current_user.member_of_course?(course) #如果已经是成员
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
@ -392,7 +395,7 @@ class CoursesService
def homework_list params,current_user def homework_list params,current_user
course = Course.find(params[:id]) course = Course.find(params[:id])
if course.is_public != 0 || current_user.member_of_course?(course) if course.is_public != 0 || current_user.member_of_course?(course)
bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).order('created_at DESC') bids = course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).page(params[:page] || 1).per(20).reorder('created_at DESC')
bids = bids.like(params[:name]) if params[:name].present? bids = bids.like(params[:name]) if params[:name].present?
homeworks = [] homeworks = []
bids.each do |bid| bids.each do |bid|
@ -495,7 +498,7 @@ class CoursesService
def course_attachments params def course_attachments params
result = [] result = []
course = Course.find(params[:course_id]) course = Course.find(params[:course_id])
attachments = course.attachments.where("is_publish = 1").order("created_on desc") attachments = course.attachments.where("is_publish = 1").reorder("created_on desc")
if !params[:name].nil? && params[:name] != "" if !params[:name].nil? && params[:name] != ""
attachments.each do |atta| attachments.each do |atta|
result << atta if atta.filename.include?(params[:name]) result << atta if atta.filename.include?(params[:name])
@ -632,7 +635,7 @@ class CoursesService
:homework_submit_num => bid.student_works.count, :homework_submit_num => bid.student_works.count,
:homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid), :homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid),
:student_evaluation_part => get_evaluation_part( bid ,3), :student_evaluation_part => get_evaluation_part( bid ,3),
:ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?} :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?,:current_user_is_teacher => is_course_teacher}
end end

View File

@ -49,6 +49,125 @@ class ResourcesService
[@ori, @flag, @save_message] [@ori, @flag, @save_message]
end end
def send_homework_to_course user,params
homework = HomeworkCommon.find params[:send_id].to_i
@ori = homework
course_ids = params[:course_ids]
@flag = false
unless course_ids.nil?
course_ids.each do |course_id|
course = Course.find course_id.to_i
new_homework = HomeworkCommon.new
new_homework.name = homework.name
new_homework.user_id = user.id
new_homework.description = homework.description
new_homework.homework_type = homework.homework_type
new_homework.late_penalty = homework.late_penalty
new_homework.course_id = course.id
new_homework.teacher_priority = homework.teacher_priority
new_homework.anonymous_comment = homework.anonymous_comment
new_homework.quotes = 0
new_homework.is_open = homework.is_open
homework.attachments.each do |attachment|
att = attachment.copy
att.container_id = nil
att.container_type = nil
att.copy_from = attachment.id
att.save
new_homework.attachments << att
end
homework_detail_manual = homework.homework_detail_manual
homework_detail_programing = homework.homework_detail_programing
homework_detail_group = homework.homework_detail_group
if homework_detail_manual
new_homework.homework_detail_manual = HomeworkDetailManual.new
new_homework_detail_manual = new_homework.homework_detail_manual
new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
new_homework_detail_manual.comment_status = 0
new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
end
if homework_detail_programing
new_homework.homework_detail_programing = HomeworkDetailPrograming.new
new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
new_homework.homework_detail_programing.language = homework_detail_programing.language
homework.homework_tests.each_with_index do |homework_test|
new_homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
end
end
if homework_detail_group
new_homework.homework_detail_group = HomeworkDetailGroup.new
new_homework.homework_detail_group.min_num = homework_detail_group.min_num
new_homework.homework_detail_group.max_num = homework_detail_group.max_num
new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
end
if new_homework.save
new_homework_detail_manual.save if new_homework_detail_manual
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
new_homework.homework_detail_group.save if new_homework.homework_detail_group
@flag = true
else
@flag = false
@save_message = new_homework.errors.full_messages
break
end
homework.update_column(:quotes, homework.quotes+1)
end
end
[@ori, @flag, @save_message]
end
def send_exercise_to_course user,params
# send_id = params[:send_id]
# @ori = Attachment.find_by_id(send_id)
# course_ids = params[:course_ids]
# @flag = false
# unless course_ids.nil?
# course_ids.each do |id|
# next if @ori.blank?
# @exist = false
# Course.find(id).attachments.each do |att| #如果课程中包含该资源
# if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
# att.created_on = Time.now
# att.save
# @exist = true
# @flag = true
# break
# end
# end
# next if @exist
# attach_copied_obj = @ori.copy
# attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
# attach_copied_obj.container = Course.find(id)
# attach_copied_obj.created_on = Time.now
# attach_copied_obj.author_id = user.id
# attach_copied_obj.is_public = 0
# attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
# if attach_copied_obj.attachtype == nil
# attach_copied_obj.attachtype = 4
# end
# if attach_copied_obj.save
# # 更新引用次数
# quotes = @ori.quotes.to_i + 1
# @ori.update_attribute(:quotes, quotes) unless @ori.nil?
# @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
# @flag = true
# else
# @flag = false
# @save_message = attach_copied_obj.errors.full_messages
# break
# end
#
# end
# end
[@ori, @flag, @save_message]
end
# 我的资源-课件 已发布的 # 我的资源-课件 已发布的
def all_course_attachments user def all_course_attachments user

View File

@ -71,8 +71,8 @@ class SyllabusesService
count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count
if count == 0 if count == 0
ws = WechatService.new ws = WechatService.new
title = "恭喜您创建班级成功" title = "恭喜您创建班级成功"
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情" ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 0, "点击查看班级详情"
end end
end end

View File

@ -229,7 +229,7 @@ class WechatService
color:"#707070" color:"#707070"
}, },
remark:{ remark:{
value:"绑定成功后可使用微信查看Trustie平台最新动态", value:"绑定成功后可使用微信查看Trustie平台最新动态",
color:"#707070" color:"#707070"
} }
} }

View File

@ -10,7 +10,7 @@
<meta content='True' name='HandheldFriendly' /> <meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weui.min.css" /> <link type="text/css" rel="stylesheet" href="/stylesheets/weui/weui.min.css" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" /> <%= stylesheet_link_tag '/stylesheets/weui/weixin.css' %>
<script type="text/javascript"> <script type="text/javascript">
window.g_debug = false; //调试标志,如果在本地请置为true window.g_debug = false; //调试标志,如果在本地请置为true
@ -28,31 +28,7 @@
<!--<script src="https://dn-demotest.qbox.me/angular.all.min.js"></script>--> <!--<script src="https://dn-demotest.qbox.me/angular.all.min.js"></script>-->
<script src="/javascripts/wechat/build/angular.all.min.js"></script> <script src="/javascripts/wechat/build/angular.all.min.js"></script>
<script src="/javascripts/wechat/build/app.min.js?version=20160715-1953"></script> <%= include_wechat_jsfile %>
<!-- <script src ="/javascripts/wechat/app.js"></script> -->
<!-- <script src="/javascripts/wechat/others/factory.js"></script> -->
<!-- <script src="/javascripts/wechat/others/filter.js"></script> -->
<!-- <script src="/javascripts/wechat/directives/alert.js"></script> -->
<!-- <script src="/javascripts/wechat/directives/form_validate.js"></script> -->
<!-- <script src="/javascripts/wechat/directives/input_auto.js"></script> -->
<!-- <script src="/javascripts/wechat/directives/loading_spinner.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/reg.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/invite_code.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/login.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/activity.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/new_class.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/edit_class.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/blog.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/course_notice.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/discussion.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/homework.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/issue.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/journals.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/class.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/class_list.js"></script> -->
<!-- <script src="/javascripts/wechat/controllers/myresource.js?version=20160715&#45;1737"></script> -->
<!-- <script src="/javascripts/wechat/controllers/send_class_list.js"></script> -->
<!-- <script src="/javascripts/wechat/others/routes.js"></script> -->
</body> </body>
</html> </html>

View File

@ -66,6 +66,7 @@ module RedmineApp
# Version of your assets, change this if you want to expire all your assets # Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0' config.assets.version = '1.0'
config.assets.digest = true
config.action_mailer.perform_deliveries = false config.action_mailer.perform_deliveries = false
@ -82,6 +83,8 @@ module RedmineApp
end end
end end
config.wechat_srcs = ['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js']
config.before_initialize do config.before_initialize do
end end
@ -93,4 +96,4 @@ module RedmineApp
end end
end end
end end

View File

@ -2,18 +2,22 @@ button:
- -
type: "view" type: "view"
name: "我的动态" name: "我的动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.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=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect"
- -
name: "我的课程" name: "我的群组"
sub_button: sub_button:
- -
type: "click" type: "view"
name: "课程" name: "我的课程"
key: "DEV" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect"
- -
type: "click" type: "click"
name: "资源" name: "我的项目"
key: "DEV" key: "PROJECT"
-
type: "view"
name: "我的宝库"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect"
- -
name: "更多" name: "更多"
@ -22,6 +26,10 @@ button:
type: "click" type: "click"
name: "加入班级" name: "加入班级"
key: "JOIN_CLASS" key: "JOIN_CLASS"
-
type: "click"
name: "加入项目"
key: "JOIN_PROJECT"
- -
type: "click" type: "click"
name: "反馈" name: "反馈"

View File

@ -2,18 +2,22 @@ button:
- -
type: "view" type: "view"
name: "我的动态" name: "我的动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect"
- -
name: "我的课程" name: "我的群组"
sub_button: sub_button:
- -
type: "view" type: "view"
name: "课程" name: "我的课程"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect"
-
type: "click"
name: "我的项目"
key: "PROJECT"
- -
type: "view" type: "view"
name: "资源" name: "我的宝库"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect"
- -
name: "更多" name: "更多"
@ -22,6 +26,10 @@ button:
type: "click" type: "click"
name: "加入班级" name: "加入班级"
key: "JOIN_CLASS" key: "JOIN_CLASS"
-
type: "click"
name: "加入项目"
key: "JOIN_PROJECT"
- -
type: "click" type: "click"
name: "反馈" name: "反馈"

View File

@ -8,38 +8,38 @@ default: &default
#secret: "743e038392f1d89540e95f8f7645849a" #secret: "743e038392f1d89540e95f8f7645849a"
#production #production
appid: "wx8e1ab05163a28e37" # appid: "wx8e1ab05163a28e37"
secret: "beb4d3bc4b32b3557811680835357841" # secret: "beb4d3bc4b32b3557811680835357841"
#test #test
# appid: "wxc09454f171153c2d" appid: "wxc09454f171153c2d"
# secret: "dff5b606e34dcafe24163ec82c2715f8" secret: "dff5b606e34dcafe24163ec82c2715f8"
token: "123456" token: "123456"
access_token: "1234567" access_token: "1234567"
encrypt_mode: false # if true must fill encoding_aes_key encrypt_mode: false # if true must fill encoding_aes_key
#production #production
encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw" # encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw"
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
#template
binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc"
journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM"
homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps"
class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA"
create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw"
#test
# encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6"
# jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" # jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
# #
# #template # #template
# binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU" # binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc"
# journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE" # journal_notice: "uC1zAw4F2q6HTA3Pcj8VUO6wKKKiYFwnPJB4iXxpdoM"
# homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" # homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps"
# class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" # class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA"
# create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" # create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw"
#test
encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6"
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
#template
binding_succ_notice: "n4KLwcWNrIMYkKxWL2hUwzunm5RTT54EbWem2MIUapU"
journal_notice: "XpHHYkqSGkwuF9vHthRdmPQLvCFRQ4_NbRBP12T7ciE"
homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ"
class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk"
create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I"
production: production:
<<: *default <<: *default

31
lib/tasks/wechat.rake Normal file
View File

@ -0,0 +1,31 @@
#coding=utf-8
#
def compress(srcs, outfile)
wechat_path = File.join(Rails.root, "public", "javascripts", "wechat")
out_buffer = ''
srcs.each do |src|
Dir.glob("#{wechat_path}/#{src}").each do |path|
puts "assets #{path}"
out_buffer = out_buffer + "\n//#{File.basename(path)}\n" + Uglifier.compile(File.read(path))
end
end
File.open(File.join(wechat_path, "build/#{outfile}"), 'w+') {|f| f.write(out_buffer)}
end
namespace :wechat do
desc "assets javascript file"
task :assets => :environment do
srcs = Rails.application.config.wechat_srcs
compress(srcs, 'app.min.js')
end
desc "minify angularjs"
task :minify => :environment do
srcs = ['../jquery-1.3.2.js','angular.js', 'angular-route.js', 'angular-sanitize.min.js']
compress(srcs, 'angular.all.min.js')
end
end

View File

@ -160,7 +160,7 @@
</div> </div>
<div class="post-dynamic-time fr f13">{{act.latest_update}}</div> <div class="post-dynamic-time fr f13">{{act.latest_update}}</div>
<div class="cl"></div> <div class="cl"></div>
<div class="post-dynamic-title c-grey3 hidden mt12 fb">帖子】{{act.subject|safeHtml}}</div> <div class="post-dynamic-title c-grey3 hidden mt12 fb">问题】{{act.subject|safeHtml}}</div>
<div class="post-content c-grey3 mt10 mb10"> <div class="post-content c-grey3 mt10 mb10">
<div class="post-all-content" ng-bind-html="act.description|safeHtml"></div> <div class="post-all-content" ng-bind-html="act.description|safeHtml"></div>
<span class="mr15 f12 c-grey2">状态:{{act.issue_detail.issue_status}}</span> <span class="mr15 f12 c-grey2">优先级:{{act.issue_detail.issue_priority}}</span> <br /> <span class="mr15 f12 c-grey2">状态:{{act.issue_detail.issue_status}}</span> <span class="mr15 f12 c-grey2">优先级:{{act.issue_detail.issue_priority}}</span> <br />

View File

@ -6,9 +6,9 @@
<meta charset='utf-8' /> <meta charset='utf-8' />
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="apple-mobile-web-app-capable" content="no"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta content='True' name='HandheldFriendly' /> <meta content='True' name='HandheldFriendly' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weui.min.css" /> <link type="text/css" rel="stylesheet" href="/stylesheets/weui/weui.min.css" />
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" /> <link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />

View File

@ -42,11 +42,61 @@
</div> </div>
<div class="post-dynamic-time fr f13">{{journal.lasted_comment}}</div> <div class="post-dynamic-time fr f13">{{journal.lasted_comment}}</div>
<div class="cl"></div> <div class="cl"></div>
<div class="post-reply-content c-grey2 mt12" ng-bind-html="journal.content|safeHtml"></div> <!--<div class="post-reply-content c-grey2 mt12" ng-bind-html="journal.content|safeHtml"></div>-->
<div class="cl"></div> <div ng-show="journal.parents_count > 0" class="mult-reply-container mt10">
<!--<div ng-repeat="reply_top in journal.parents_reply_top" >-->
<div class="mult-reply-container mt2">
<ul ng-if="journal.parents_reply_top[1]" ng-include="'comment_reply'" ng-init="i=1;journal=journal"></ul>
<div class="post-avatar fl mr10"><img ng-src="{{journal.parents_reply_top[0].user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{journal.parents_reply_top[0].user.realname}}
<img ng-if="journal.parents_reply_top[0].user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="journal.parents_reply_top[0].user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{journal.parents_reply_top[0].lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="journal.parents_reply_top[0].content|safeHtml"></div>
<div class="cl"></div>
</div>
<!--</div>-->
<!--['weixin-tab', {'class-tab-active': currentTab == $index+1}]-->
<!--一层end-->
<!--<div class="mt10">-->
<!--<div class="post-avatar fl mr10"><img src="images/pic01.jpg" ng-src="/images/avatars/User/0" class="border-radius img-circle" height="30" width="30"></div>-->
<!--<div class="post-dynamic-author hidden fl ng-binding">yixin<img src="images/female.png" class="ml5" width="14"></div>-->
<!--<div class="post-dynamic-time fr f13">5分钟前</div>-->
<!--<div class="cl"></div>-->
<!--<div class="post-reply-content c-grey2 mt12 border-bottom-none">烤活牛你见过似的,美国那边吃人你怎么不信?</div>-->
<!--<div class="cl"></div>-->
<!--</div>-->
<!--二层end-->
<div ng-click="showMoreReply(1,journal)" ng-show="journal.parents_reply_top.length + journal.parents_reply_bottom.length < journal.parents_count" class="mult-reply-hide"><span class="mult-reply-arrow" >&darr; </span><span class="mult-reply-arrow" style="display:none;" > &uarr;</span>点击展开更多楼层</div>
<div class="mt10" ng-repeat="reply_bottom in journal.parents_reply_bottom">
<div class="post-avatar fl mr10"><img ng-src="{{reply_bottom.user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{reply_bottom.user.realname}}
<img ng-if="reply_bottom.user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="reply_bottom.user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{reply_bottom.lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="reply_bottom.content|safeHtml"></div>
<div class="cl"></div>
</div>
</div>
<div class="post-reply-content">
<div class="mult-reply-content">
<div class="mt10" ng-bind-html="journal.content|safeHtml"></div>
</div>
<div class="cl"></div>
</div>
</div> </div>
</div> </div>
<div ng-if="has_more">
<div id="more_reply" class="more-events mt10" ng-click="showMoreReply(0,blog);">更多</div>
</div>
</div> </div>
<div ng-if="!blog.locked" id="post_input_1" class="post-input-wrap post-box-shadow"> <div ng-if="!blog.locked" id="post_input_1" class="post-input-wrap post-box-shadow">
@ -63,4 +113,20 @@
</div> </div>
</div> </div>
</div> </div>
<script id="comment_reply" type="text/ng-template">
<div class="mult-reply-container mt2">
<ul ng-if="journal.parents_reply_top[i+1]" ng-include="'comment_reply'" ng-init="i=i+1;journal=journal"></ul>
<div class="post-avatar fl mr10"><img ng-src="{{journal.parents_reply_top[i].user.img_url}}" class="border-radius img-circle" height="30" width="30"></div>
<div class="post-dynamic-author hidden fl ng-binding">
{{journal.parents_reply_top[i].user.realname}}
<img ng-if="journal.parents_reply_top[i].user.gender == '0'" src="images/wechat/male.png" width="14" class="ml5" />
<img ng-if="journal.parents_reply_top[i].user.gender != '0'" src="images/wechat/female.png" width="14" class="ml5" />
</div>
<div class="post-dynamic-time fr f13">{{journal.parents_reply_top[i].lasted_comment}}</div>
<div class="cl"></div>
<div class="post-reply-content c-grey2 mt12 border-bottom-none" ng-bind-html="journal.parents_reply_top[i].content|safeHtml"></div>
<div class="cl"></div>
</div>
</script>

View File

@ -23,7 +23,7 @@
</div> </div>
<div ng-class="{'undis': !showResources}"> <div ng-class="{'undis': !showResources}">
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2" ng-click="sendFile(r,1)">发送</a><div class="cl"></div></div>
<p ng-show="resources_tag == true && resources.length<=0" class="class-test-tip">暂无课件,<br /> <p ng-show="resources_tag == true && resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站在PC浏览器中上传课件。</p> 请登录Trustie网站在PC浏览器中上传课件。</p>
</div> </div>
@ -42,19 +42,19 @@
</div> </div>
<div ng-class="{'undis': !showHomework}"> <div ng-class="{'undis': !showHomework}">
<div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 " ng-click="sendFile(r,2)">发送</a><div class="cl"></div></div>
<p ng-show="homeworks_tag == true && homeworks.length<=0" class="class-test-tip">暂无作业,<br /> <p ng-show="homeworks_tag == true && homeworks.length<=0" class="class-test-tip">暂无作业,<br />
请登录Trustie网站在PC浏览器中上传作业。</p> 请登录Trustie网站在PC浏览器中上传作业。</p>
</div> </div>
<div ng-class="{'undis': !showTestcase}"> <div ng-class="{'undis': !showTestcase}">
<div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r,3)">发送</a><div class="cl"></div></div>
<p ng-show="exercises_tag == true && exercises.length<=0" class="class-test-tip">暂无小测验,<br /> <p ng-show="exercises_tag == true && exercises.length<=0" class="class-test-tip">暂无小测验,<br />
请登录Trustie网站在PC浏览器中上传小测验。</p> 请登录Trustie网站在PC浏览器中上传小测验。</p>
</div> </div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div> </div>

View File

@ -3,8 +3,9 @@
<div class="blue-title">课程列表</div> <div class="blue-title">课程列表</div>
<div> <div>
<div class="course-diff-row"><span class="c-blue f13 ml10">我创建的课程</span></div> <div class="course-diff-row"><span class="c-blue f13 ml10">我创建的课程</span></div>
<div ng-show = "syllabus.can_setting" ng-repeat="syllabus in syllabuses"> <div ng-show = "syllabus.can_setting" ng-repeat="syllabus in syllabuses" style="position:relative;">
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3 border-top-none"><img src="/images/wechat/plus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div> <div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3 border-top-none"><img src="/images/wechat/plus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10 class-list-name hidden">{{syllabus.title}}</span></div>
<img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="class-list-setting" ng-click="onSetting(syllabus)" />
<ul ng-show="syllabus.show_plus" class="class-list f13 c-grey3"> <ul ng-show="syllabus.show_plus" class="class-list f13 c-grey3">
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}"> <li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /> <img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
@ -17,8 +18,9 @@
</div> </div>
<div> <div>
<div class="course-diff-row border-top mt10"><span class="c-blue f13 ml10">我参与的课程</span></div> <div class="course-diff-row border-top mt10"><span class="c-blue f13 ml10">我参与的课程</span></div>
<div ng-show = "!syllabus.can_setting" ng-repeat="syllabus in syllabuses"> <div ng-show = "!syllabus.can_setting" ng-repeat="syllabus in syllabuses" style="position:relative;">
<div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3 border-top-none"><img src="/images/wechat/plus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">{{syllabus.title}}</span><img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="fr mr10 mt10" ng-click="onSetting(syllabus)" /></div> <div ng-click="syllabus.show_plus = !syllabus.show_plus" class="course-list-row f13 c-grey3 border-top-none"><img src="/images/wechat/plus.png" ng-show="!syllabus.show_plus" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" ng-show="syllabus.show_plus" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10 class-list-name hidden">{{syllabus.title}}</span></div>
<img src="/images/wechat/setting.png" ng-show = "syllabus.can_setting" width="15" class="class-list-setting" ng-click="onSetting(syllabus)" />
<ul ng-show="syllabus.show_plus" class="class-list f13 c-grey3"> <ul ng-show="syllabus.show_plus" class="class-list f13 c-grey3">
<li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}"> <li ng-show="course.id" ng-click="goClass(course.id)" ng-repeat="course in syllabus.courses" ng-class="{'border-bottom-none': $last}">
<img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /> <img src="/images/wechat/dot.png" width="15px" class="class-list-dot" />
@ -36,5 +38,6 @@
<a ng-click="goResource()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">我的资源</a> <a ng-click="goResource()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">我的资源</a>
</div> </div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert> <my-alert message="alertService_1.message" title="alertService_1.title" visible="alertService_1.visible" cb="alertService_1.cb"></my-alert>
<my-alert3 message="alertService_3.message" title="alertService_3.title" visible="alertService_3.visible" cb="alertService_3.cb" invite="alertService_3.invite" ></my-alert3>
</div> </div>

View File

@ -3,9 +3,9 @@
<div class="blue-title">管理课程</div> <div class="blue-title">管理课程</div>
<form novalidate name="classForm"> <form novalidate name="classForm">
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input ng-change="fadeText()" ng-class="['new-class-input ml25', {'c-grey':change} ]" ng-model="syllabus.tmptitle" required placeholder="请输入课程名" /></div> <div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input ng-change="syllabus.change = true" ng-class="['new-class-input ml25', {'c-grey':syllabus.change} ]" ng-model="syllabus.tmptitle" required placeholder="请输入课程名,如:软件工程" /></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses" ng-show="course.can_setting"><span class="fl ml15 c-grey3">班级</span><input ng-change="fadeText()" required ng-class="['new-class-input ml25', {'c-grey':change} ]" ng-model="course.tmpname" placeholder="请输入班级名" /><a ng-click="deleteClass($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div> <div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses" ng-show="course.can_setting"><span class="fl ml15 c-grey3">班级</span><input ng-change="course.change = true" required ng-class="['new-class-input ml25', {'c-grey':course.change} ]" ng-model="course.tmpname" placeholder="请输入班级名计算机学院A班" /><a ng-click="deleteClass($index)" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div> <div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a> <a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
</form> </form>

View File

@ -12,7 +12,7 @@
<div ng-class="{'undis': currentTab!=1}"> <div ng-class="{'undis': currentTab!=1}">
<div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"> <div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]">
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div> <img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,1)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 fl courseware-from-width hidden">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4 fl">大小:{{r.attafile_size}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 fl courseware-from-width hidden">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4 fl">大小:{{r.attafile_size}}</span><div class="cl"></div>
</div> </div>
<div ng-if="has_more"> <div ng-if="has_more">
@ -20,9 +20,10 @@
</div> </div>
<p ng-show="resources_tag && resources.length<=0" class="class-test-tip">暂无课件,<br /> <p ng-show="resources_tag && resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站在PC浏览器中上传课件。</p> 请登录Trustie网站在PC浏览器中上传课件。</p>
</div> </div>
<div ng-class="{'undis': currentTab!=2}"> <div ng-class="{'undis': currentTab!=2}">
<div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2 undis">发送</a><div class="cl"></div> <div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,2)" class="fr mr10 link-blue2 ">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 fl other-from-width hidden">作业来源:{{r.coursename}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 fl other-from-width hidden">作业来源:{{r.coursename}}</span><div class="cl"></div>
</div> </div>
<div ng-if="homework_has_more"> <div ng-if="homework_has_more">
@ -32,7 +33,7 @@
请登录Trustie网站在PC浏览器中创建作业。</p> 请登录Trustie网站在PC浏览器中创建作业。</p>
</div> </div>
<div ng-class="{'undis': currentTab!=3}"> <div ng-class="{'undis': currentTab!=3}">
<div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2 undis">发送</a><div class="cl"></div> <div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,3)" class="fr mr10 link-blue2 undis">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 other-from-width hidden">题目来源:{{r.coursename}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 other-from-width hidden">题目来源:{{r.coursename}}</span><div class="cl"></div>
</div> </div>
<div ng-if="exercise_has_more"> <div ng-if="exercise_has_more">

View File

@ -3,9 +3,9 @@
<div class="blue-title">新建课程</div> <div class="blue-title">新建课程</div>
<form novalidate name="classForm"> <form novalidate name="classForm">
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入课程名" /></div> <div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" ng-model="syllabus.title" required placeholder="请输入课程名,如:软件工程" /></div>
<div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses"><span class="fl ml15 c-grey3">班级</span><input required class="new-class-input ml25" ng-model="course.name" placeholder="请输入班级名" /><a ng-click="deleteClass($index)" ng-show="!$first" class="fr mr10 c-grey6 delete-class-link">删除</a></div> <div class="course-list-row f13 c-grey3 mt10" ng-repeat="course in syllabus.courses"><span class="fl ml15 c-grey3">班级</span><input required class="new-class-input ml25" ng-model="course.name" placeholder="请输入班级名计算机学院A班" /><a ng-click="deleteClass($index)" ng-show="!$first" class="fr mr10 c-grey6 delete-class-link">删除</a></div>
<div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div> <div class="tac"><a ng-click="addClass()" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
<a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a> <a ng-click="newClass(classForm, syllabus)" ng-class="['finish-btn', {'btn-disabled':!classForm.$valid} ]" >完成</a>
</form> </form>

View File

@ -19,6 +19,6 @@
<!--<li ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>--> <!--<li ng-click="selectCourse(course)" ng-class="{'border-bottom-none': $last }" ng-repeat="course in courses"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span ng-class="['login-box', 'fr', 'mr5', 'mt12', {'checked': course.checked}]"></span></li>-->
<!--</ul>--> <!--</ul>-->
<div class="btn2 bg-blue" ng-click="sendToCourses()">发送</div> <div ng-show="syllabuses.length>0" class="btn2 bg-blue" ng-click="sendToCourses()">发送</div>
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert> <my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
</div> </div>

View File

@ -0,0 +1,15 @@
<div class="post-container" ng-show="visible">
<div class="weui_mask">
<div class="add-class-box">
<p class="tac add-class-tip">{{message}}</p>
<form class="mb20">
<input type="text" class="class-number-input" ng-model="invite" />
</form>
<a href="javascript:void(0);" class="c-grey3 fl cancel-btn" ng-click="dismiss()" >取消</a>
<div class="slice fl">
<div class="slice-line"></div>
</div>
<a href="javascript:void(0);" class="c-green fl submit-btn" ng-click="confirm()" >确定</a>
</div>
</div>
</div>

View File

@ -1,24 +1,49 @@
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,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},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,i,e,a,c){var s=function(){var c=e.defer(),s=o();if(s&&s.length>10)c.resolve(s);else{window.g_code||i.code||a.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},o=function(){return a.get("token")};return{get_bind:s,token:o}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"<br/>"),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(t){c.disabled=!1,"function"==typeof s&&s()},function(t){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(t){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(t){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]); //app.js
app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"教辅":""}}); 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){g_redirect_path&&g_redirect_path.length>1&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(){})}]);
app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["所有动态","课程动态","项目动态"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("has_more",t.has_more),o.save("page",a.data.page);break;case"Course":o.save("course_activities",t.course_activities),t.course_has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("course_has_more",t.course_has_more),o.save("course_page",a.data.page);break;case"Project":o.save("project_activities",t.project_activities),t.project_has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("project_has_more",t.project_has_more),o.save("project_page",a.data.page);break;case 3:}console.log(a.data)},function(a){})},t.tab=function(a){switch(t.currentTab=a,a){case 1:t.activities.length<=0&&t.loadActData(a,0);break;case 2:t.course_activities.length<=0&&t.loadActData(a,0);break;case 3:t.project_activities.length<=0&&t.loadActData(a,0)}},t.currentTab=1,t.activities.length<=0?t.loadActData(1,0):c(function(){window.scrollTo(0,o.get("yoffset"))}),t.goDetail=function(a,i,c){o.save("yoffset",window.document.body.scrollTop),o.save("activities",t.activities),o.save("course_activities",t.course_activities),o.save("project_activities",t.project_activities),e.path("/"+a+"/"+i)},t.addPraise=function(a){for(var e in t.activities)if(t.activities[e].act_id==a.act_id){t.activities[e].praise_count+=1,t.activities[e].has_praise=!0;break}for(var e in t.course_activities)if(t.course_activities[e].act_id==a.act_id){t.course_activities[e].praise_count+=1,t.course_activities[e].has_praise=!0;break}for(var e in t.project_activities)if(t.project_activities[e].act_id==a.act_id){t.project_activities[e].praise_count+=1,t.project_activities[e].has_praise=!0;break}r.addCommonPraise(a)},t.decreasePraise=function(a){for(var e in t.activities)if(t.activities[e].act_id==a.act_id){t.activities[e].praise_count-=1,t.activities[e].has_praise=!1;break}for(var e in t.course_activities)if(t.course_activities[e].act_id==a.act_id){t.course_activities[e].praise_count-=1,t.course_activities[e].has_praise=!1;break}for(var e in t.project_activities)if(t.project_activities[e].act_id==a.act_id){t.project_activities[e].praise_count-=1,t.project_activities[e].has_praise=!1;break}r.decreaseCommonPraise(a)}}]); //factory.js
app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,i,e){this.message=i,this.title=t,this.visible=!0,this.cb=e},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,i,e,a){var c=function(){var c=e.defer(),o=s();if(o&&o.length>10)c.resolve(o);else{{window.g_code||i.code||a.get("code")}t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?c.reject(t.data.message):(a.save("token",t.data.token),c.resolve(t.data.token))})["catch"](function(t){c.reject(t)})}return c.promise},s=function(){return a.get("token")};return{get_bind:c,token:s}}]),app.factory("session",function(){return{save:function(t,i){sessionStorage.setItem(t,i)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},i=function(i,e){t[i]=e},e=function(i){return t[i]};return{save:i,get:e}}),app.factory("common",["$http","auth","$routeParams","rms",function(t,i,e,a){var c=function(e,a,c,s){if(c.comment&&!(c.comment.length<=0)){var o=c.comment.replace(/\n/g,"<br/>"),n={type:a,content:o,token:i.token()};c.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+e,data:n}).then(function(){c.disabled=!1,"function"==typeof s&&s()},function(){})}},s=function(e,a){return t({method:"GET",url:apiUrl+a+"/"+e+"?token="+i.token()})},o=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},n=function(e){t({method:"POST",url:apiUrl+"praise/"+e.act_id,data:{token:i.token(),type:e.act_type}}).then(function(t){console.log(t.data)},function(){})},r=function(t){t.scope.formData={comment:""};var i=function(i){s(i,t.type).then(function(i){t.loadCallback(i.data)},function(){})};i(t.id),t.scope.addReply=function(e){console.log(e.comment),c(t.id,t.replyType,e,function(){t.scope.formData={comment:""},i(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count+=1,activities[i].has_praise=!0;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count+=1,course_activities[i].has_praise=!0;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count+=1,project_activities[i].has_praise=!0;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count+=1,t.has_praise=!0,o(t)},t.scope.decreasePraise=function(t){activities=a.get("activities")||[],course_activities=a.get("course_activities")||[],project_activities=a.get("project_activities")||[];for(var i in activities)if(activities[i].act_id==t.act_id){activities[i].praise_count-=1,activities[i].has_praise=!1;break}for(var i in course_activities)if(course_activities[i].act_id==t.act_id){course_activities[i].praise_count-=1,course_activities[i].has_praise=!1;break}for(var i in project_activities)if(project_activities[i].act_id==t.act_id){project_activities[i].praise_count-=1,project_activities[i].has_praise=!1;break}a.save("activities",activities),a.save("course_activities",course_activities),a.save("project_activities",project_activities),t.praise_count-=1,t.has_praise=!1,n(t)}};return{init:r,addCommonReply:c,loadCommonData:s,addCommonPraise:o,decreaseCommonPraise:n}}]);
//filter.js
app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]),app.filter("identify",function(){return function(t){return"TeachingAsistant"==t?"\u6559\u8f85":""}});
//activity.js
app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,e,t,i,c,s,o,r,_){t.replaceUrl=function(a){return a},t.menus=["\u6240\u6709\u52a8\u6001","\u8bfe\u7a0b\u52a8\u6001","\u9879\u76ee\u52a8\u6001"],t.alertService=_.create(),console.log("ActivityController load"),t.page=o.get("page")||0,t.activities=o.get("activities")||[],t.has_more=o.get("has_more"),t.course_page=o.get("course_page")||0,t.course_activities=o.get("course_activities")||[],t.course_has_more=o.get("course_has_more"),t.project_page=o.get("project_page")||0,t.project_activities=o.get("project_activities")||[],t.project_has_more=o.get("project_has_more"),t.loadActData=function(a,e){switch(container_type="All",a){case 1:container_type="All",t.page=e;break;case 2:container_type="Course",t.course_page=e;break;case 3:container_type="Project",t.project_page=e}i({method:"POST",url:apiUrl+"activities",data:{token:s.token(),page:e,container_type:container_type}}).then(function(a){if(a.data.page>0)switch(a.data.container_type){case"All":t.activities=t.activities.concat(a.data.data);break;case"Course":t.course_activities=t.course_activities.concat(a.data.data);break;case"Project":t.project_activities=t.project_activities.concat(a.data.data);break;case 3:}else switch(a.data.container_type){case"All":t.activities=a.data.data;break;case"Course":t.course_activities=a.data.data;break;case"Project":t.project_activities=a.data.data;break;case 3:}switch(a.data.container_type){case"All":o.save("activities",t.activities),t.has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("has_more",t.has_more),o.save("page",a.data.page);break;case"Course":o.save("course_activities",t.course_activities),t.course_has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("course_has_more",t.course_has_more),o.save("course_page",a.data.page);break;case"Project":o.save("project_activities",t.project_activities),t.project_has_more=a.data.count+10*a.data.page<a.data.all_count,o.save("project_has_more",t.project_has_more),o.save("project_page",a.data.page);break;case 3:}console.log(a.data)},function(){})},t.tab=function(a){switch(t.currentTab=a,a){case 1:t.activities.length<=0&&t.loadActData(a,0);break;case 2:t.course_activities.length<=0&&t.loadActData(a,0);break;case 3:t.project_activities.length<=0&&t.loadActData(a,0)}},t.currentTab=1,t.activities.length<=0?t.loadActData(1,0):c(function(){window.scrollTo(0,o.get("yoffset"))}),t.goDetail=function(a,i){o.save("yoffset",window.document.body.scrollTop),o.save("activities",t.activities),o.save("course_activities",t.course_activities),o.save("project_activities",t.project_activities),e.path("/"+a+"/"+i)},t.addPraise=function(a){for(var e in t.activities)if(t.activities[e].act_id==a.act_id){t.activities[e].praise_count+=1,t.activities[e].has_praise=!0;break}for(var e in t.course_activities)if(t.course_activities[e].act_id==a.act_id){t.course_activities[e].praise_count+=1,t.course_activities[e].has_praise=!0;break}for(var e in t.project_activities)if(t.project_activities[e].act_id==a.act_id){t.project_activities[e].praise_count+=1,t.project_activities[e].has_praise=!0;break}r.addCommonPraise(a)},t.decreasePraise=function(a){for(var e in t.activities)if(t.activities[e].act_id==a.act_id){t.activities[e].praise_count-=1,t.activities[e].has_praise=!1;break}for(var e in t.course_activities)if(t.course_activities[e].act_id==a.act_id){t.course_activities[e].praise_count-=1,t.course_activities[e].has_praise=!1;break}for(var e in t.project_activities)if(t.project_activities[e].act_id==a.act_id){t.project_activities[e].praise_count-=1,t.project_activities[e].has_praise=!1;break}r.decreaseCommonPraise(a)}}]);
//blog.js
app.controller("BlogController",["$scope","$http","$routeParams","auth","common",function(o,l,t,n,a){a.init({id:t.id,scope:o,type:"blog_comments",replyType:"BlogComment",loadCallback:function(l){o.blog=l.data},replyCallback:function(){}})}]); app.controller("BlogController",["$scope","$http","$routeParams","auth","common",function(o,l,t,n,a){a.init({id:t.id,scope:o,type:"blog_comments",replyType:"BlogComment",loadCallback:function(l){o.blog=l.data},replyCallback:function(){}})}]);
app.controller("ClassController",["$scope","config","$http","auth","$location","$routeParams",function(e,s,t,o,a,n){var r=e,c=n.id,u=function(){r.teachers.length<=0&&t.get(s.apiUrl+"courses/teachers?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.teachers=e.data.data}),r.students.length<=0&&t.get(s.apiUrl+"courses/students?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.students=e.data.data})},i=function(){r.resources.length<=0&&t.post(s.apiUrl+"courses/"+c+"/attachments",{token:o.token(),name:""}).then(function(e){r.resources=e.data.data,r.resources_tag=!0})},h=function(){r.homeworks.length<=0&&t.get(s.apiUrl+"courses/homeworks/"+c+"?token="+o.token()).then(function(e){r.homeworks=e.data.data,console.log(e.data),r.homeworks_tag=!0})},l=function(){r.exercises.length<=0&&t.get(s.apiUrl+"courses/"+c+"/exercises?token="+o.token()).then(function(e){r.exercises=e.data.data,console.log(e.data),r.exercises_tag=!0})};r.isTeacher=!1,r.currentTab=1,r.tab=function(e){r.currentTab=e,r.searchText="",r.showClassMate=!1,r.showResources=!1,r.showHomework=!1,r.showTestcase=!1,r.resources_tag=!1,r.homeworks_tag=!1,r.exercises_tag=!1,r.isTeacher?1==e?(i(),r.showResources=!0):2==e?(h(),r.showHomework=!0):3==e?(l(),r.showTestcase=!0):4==e&&(u(),r.showClassMate=!0):2==e?(u(),r.showClassMate=!0):1==e&&(i(),r.showResources=!0)},r.course={},r.students=[],r.teachers=[],r.resources=[],r.homeworks=[],r.exercises=[],r.invite=function(){a.path("/invite_code").search({id:c})},r.sendFile=function(e){a.path("/send_class_list").search({id:e.id})},t.get(s.apiUrl+"courses/"+c+"?token="+o.token()).then(function(e){console.log(e.data),r.course=e.data.data,d(r.course.current_user_is_teacher),r.tab(1)});var d=function(e){r.isTeacher=e,e?r.menus=["课件","作业","小测验","学生管理"]:r.menus=["课件","我的同学"]}}]); //class.js
app.controller("ClassListController",["$scope","config","auth","$http","$location","alertService","rms",function(e,s,a,t,o,l,n){var c=e;c.syllabuses=n.get("syllabuses")||[],c.alertService=l.create();var i=function(){t.get(s.apiUrl+"syllabuses?token="+a.token()).then(function(e){console.log(e.data),c.syllabuses=e.data.data,n.save("syllabuses",c.syllabuses)})};c.syllabuses.length<=0&&i(),c.goClass=function(e){console.log(e),o.path("/class").search({id:e})},c.newClass=function(){t.post(s.apiUrl+"syllabuses/auth",{token:a.token()}).then(function(e){console.log(e.data),0==e.data.auth?c.alertService.showMessage("提示","非教师身份不能创建课程哦~"):o.path("/new_class")})},c.goResource=function(){o.path("/myresource")},c.joinClass=function(){var e=window.prompt("请输入5位班级邀请码(不区分大小写)");e&&5==e.length?t.post(s.apiUrl+"courses/join",{token:a.token(),invite_code:e}).then(function(e){console.log(e.data),0!=e.data.status?c.alertService.showMessage("错误",e.data.message):(c.alertService.showMessage("提示","加入课程成功"),i())}):e&&c.alertService.showMessage("错误","邀请码格式不正确")},c.onSetting=function(e){console.log(e),n.save("current_edit_syllobus",e),o.path("/edit_class").search({id:e.id})}}]); app.controller("ClassController",["$scope","config","$http","auth","$location","$routeParams",function(e,s,t,o,a,n){var r=e,c=n.id,i=function(){r.teachers.length<=0&&t.get(s.apiUrl+"courses/teachers?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.teachers=e.data.data}),r.students.length<=0&&t.get(s.apiUrl+"courses/students?token="+o.token()+"&course_id="+c).then(function(e){console.log(e.data),r.students=e.data.data})},u=function(){r.resources.length<=0&&t.post(s.apiUrl+"courses/"+c+"/attachments",{token:o.token(),name:""}).then(function(e){r.resources=e.data.data,r.resources_tag=!0})},h=function(){r.homeworks.length<=0&&t.get(s.apiUrl+"courses/homeworks/"+c+"?token="+o.token()).then(function(e){r.homeworks=e.data.data,console.log(e.data),r.homeworks_tag=!0})},l=function(){r.exercises.length<=0&&t.get(s.apiUrl+"courses/"+c+"/exercises?token="+o.token()).then(function(e){r.exercises=e.data.data,console.log(e.data),r.exercises_tag=!0})};r.isTeacher=!1,r.currentTab=1,r.tab=function(e){r.currentTab=e,r.searchText="",r.showClassMate=!1,r.showResources=!1,r.showHomework=!1,r.showTestcase=!1,r.resources_tag=!1,r.homeworks_tag=!1,r.exercises_tag=!1,r.isTeacher?1==e?(u(),r.showResources=!0):2==e?(h(),r.showHomework=!0):3==e?(l(),r.showTestcase=!0):4==e&&(i(),r.showClassMate=!0):2==e?(i(),r.showClassMate=!0):1==e&&(u(),r.showResources=!0)},r.course={},r.students=[],r.teachers=[],r.resources=[],r.homeworks=[],r.exercises=[],r.invite=function(){a.path("/invite_code").search({id:c})},r.sendFile=function(e){a.path("/send_class_list").search({id:e.id})},t.get(s.apiUrl+"courses/"+c+"?token="+o.token()).then(function(e){console.log(e.data),r.course=e.data.data,d(r.course.current_user_is_teacher),r.tab(1)});var d=function(e){r.isTeacher=e,r.menus=e?["\u8bfe\u4ef6","\u4f5c\u4e1a","\u5c0f\u6d4b\u9a8c","\u5b66\u751f\u7ba1\u7406"]:["\u8bfe\u4ef6","\u6211\u7684\u540c\u5b66"]}}]);
//class_list.js
app.controller("ClassListController",["$scope","config","auth","$http","$location","alertService","rms",function(e,s,a,t,o,l,n){var c=e;c.syllabuses=n.get("syllabuses")||[],c.alertService=l.create();var i=function(){t.get(s.apiUrl+"syllabuses?token="+a.token()).then(function(e){console.log(e.data),c.syllabuses=e.data.data,n.save("syllabuses",c.syllabuses)})};c.syllabuses.length<=0&&i(),c.goClass=function(e){console.log(e),o.path("/class").search({id:e})},c.newClass=function(){t.post(s.apiUrl+"syllabuses/auth",{token:a.token()}).then(function(e){console.log(e.data),0==e.data.auth?c.alertService.showMessage("\u63d0\u793a","\u975e\u6559\u5e08\u8eab\u4efd\u4e0d\u80fd\u521b\u5efa\u8bfe\u7a0b\u54e6~"):o.path("/new_class")})},c.goResource=function(){o.path("/myresource")},c.joinClass=function(){var e=window.prompt("\u8bf7\u8f93\u51655\u4f4d\u73ed\u7ea7\u9080\u8bf7\u7801(\u4e0d\u533a\u5206\u5927\u5c0f\u5199)");e&&5==e.length?t.post(s.apiUrl+"courses/join",{token:a.token(),invite_code:e}).then(function(e){console.log(e.data),0!=e.data.status?c.alertService.showMessage("\u9519\u8bef",e.data.message):(c.alertService.showMessage("\u63d0\u793a","\u52a0\u5165\u8bfe\u7a0b\u6210\u529f"),i())}):e&&c.alertService.showMessage("\u9519\u8bef","\u9080\u8bf7\u7801\u683c\u5f0f\u4e0d\u6b63\u786e")},c.onSetting=function(e){console.log(e),n.save("current_edit_syllobus",e),o.path("/edit_class").search({id:e.id})}}]);
//course_notice.js
app.controller("CourseNoticeController",["$scope","$http","$routeParams","auth","common",function(o,e,t,n,a){a.init({id:t.id,scope:o,type:"newss",replyType:"News",loadCallback:function(e){o.news=e.data},replyCallback:function(){}})}]); app.controller("CourseNoticeController",["$scope","$http","$routeParams","auth","common",function(o,e,t,n,a){a.init({id:t.id,scope:o,type:"newss",replyType:"News",loadCallback:function(e){o.news=e.data},replyCallback:function(){}})}]);
//discussion.js
app.controller("DiscussionController",["$scope","$http","$routeParams","auth","common",function(o,s,a,e,n){n.init({id:a.id,scope:o,type:"messages",replyType:"Message",loadCallback:function(s){o.discussion=s.data},replyCallback:function(){}})}]); app.controller("DiscussionController",["$scope","$http","$routeParams","auth","common",function(o,s,a,e,n){n.init({id:a.id,scope:o,type:"messages",replyType:"Message",loadCallback:function(s){o.discussion=s.data},replyCallback:function(){}})}]);
app.controller("EditClassController",["$scope","$http","auth","config","alertService","$location","$routeParams","rms",function(s,e,a,l,t,o,r,n){var u=s;u.syllabus=n.get("current_edit_syllobus");var i=r.id;if(u.syllabus||e.get(l.apiUrl+"syllabuses/"+i+"?token="+a.token()).then(function(s){if(console.log(s.data),u.syllabus=s.data.data,u.syllabus){for(var e in u.syllabus.courses){var a=u.syllabus.courses[e];a.tmpname=a.name}u.syllabus.tmptitle=u.syllabus.title}}),console.log(u.syllabus),u.syllabus){for(var c in u.syllabus.courses){var d=u.syllabus.courses[c];d.tmpname=d.name}u.syllabus.tmptitle=u.syllabus.title}u.alertService_1=t.create(),u.alertService_2=t.create(),u.addClass=function(){u.syllabus.courses.push({can_setting:!0})},u.deleteClass=function(s){var t=u.syllabus.courses[s];t.id>0?u.alertService_2.showMessage("提示","您确定要删除该班级吗?",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("出错了",e.data.message):u.alertService_1.showMessage("提示","删除班级成功",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("出错了",s.data.message):u.alertService_1.showMessage("提示","保存课程成功",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]); //edit_class.js
app.controller("EditClassController",["$scope","$http","auth","config","alertService","$location","$routeParams","rms",function(s,e,a,l,t,o,r,n){var u=s;u.syllabus=n.get("current_edit_syllobus");var i=r.id;if(u.syllabus||e.get(l.apiUrl+"syllabuses/"+i+"?token="+a.token()).then(function(s){if(console.log(s.data),u.syllabus=s.data.data,u.syllabus){for(var e in u.syllabus.courses){var a=u.syllabus.courses[e];a.tmpname=a.name}u.syllabus.tmptitle=u.syllabus.title}}),console.log(u.syllabus),u.syllabus){for(var c in u.syllabus.courses){var d=u.syllabus.courses[c];d.tmpname=d.name}u.syllabus.tmptitle=u.syllabus.title}u.alertService_1=t.create(),u.alertService_2=t.create(),u.addClass=function(){u.syllabus.courses.push({can_setting:!0})},u.deleteClass=function(s){var t=u.syllabus.courses[s];t.id>0?u.alertService_2.showMessage("\u63d0\u793a","\u60a8\u786e\u5b9a\u8981\u5220\u9664\u8be5\u73ed\u7ea7\u5417\uff1f",function(){e.post(l.apiUrl+"courses/"+t.id+"/del",{token:a.token()}).then(function(e){0!=e.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",e.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u5220\u9664\u73ed\u7ea7\u6210\u529f",function(){u.syllabus.courses.splice(s,1)}),console.log(e.data.data)})}):u.syllabus.courses.splice(s,1)},u.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var r=[],c=[];for(var d in u.syllabus.courses){var b=u.syllabus.courses[d];b.id?b.tmpname!=b.name&&c.push({id:b.id,name:b.tmpname}):r.push(b.tmpname)}e.post(l.apiUrl+"syllabuses/"+i+"/edit",{token:a.token(),id:i,title:u.syllabus.tmptitle,add_courses:r,modify_courses:c}).then(function(s){0!=s.data.status?u.alertService_1.showMessage("\u51fa\u9519\u4e86",s.data.message):u.alertService_1.showMessage("\u63d0\u793a","\u4fdd\u5b58\u8bfe\u7a0b\u6210\u529f",function(){n.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})},u.fadeText=function(){s.change=!0}}]);
//homework.js
app.controller("HomeworkController",["$scope","$http","$routeParams","auth","common",function(o,e,l,n,r){r.init({id:l.id,scope:o,type:"whomeworks",replyType:"HomeworkCommon",loadCallback:function(e){console.log(e),o.homework=e.data},replyCallback:function(){}})}]); app.controller("HomeworkController",["$scope","$http","$routeParams","auth","common",function(o,e,l,n,r){r.init({id:l.id,scope:o,type:"whomeworks",replyType:"HomeworkCommon",loadCallback:function(e){console.log(e),o.homework=e.data},replyCallback:function(){}})}]);
app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",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(t){})}}]); //invite_code.js
app.controller("InviteCodeController",["$scope","$http","$routeParams","config","auth",function(t,e,i,n,o){var a=t;a.course={};var c=i.id;e.get(n.apiUrl+"courses/"+c+"?token="+o.token()).then(function(t){console.log(t.data),a.course=t.data.data}),a.share=function(){window.WeixinJSBridge.invoke("sendAppMessage",{appid:"wxf694495398c7d470",type:"link",data_url:"",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(){})}}]);
//issue.js
app.controller("IssueController",["$scope","$http","$routeParams","auth","common",function(o,e,l,s,t){t.init({id:l.id,scope:o,type:"issues",replyType:"Issue",loadCallback:function(e){console.log(e),o.issue=e.data},replyCallback:function(){}})}]); app.controller("IssueController",["$scope","$http","$routeParams","auth","common",function(o,e,l,s,t){t.init({id:l.id,scope:o,type:"issues",replyType:"Issue",loadCallback:function(e){console.log(e),o.issue=e.data},replyCallback:function(){}})}]);
//journals.js
app.controller("JournalsController",["$scope","$http","$routeParams","auth","common",function(o,a,e,l,n){n.init({id:e.id,scope:o,type:"journal_for_messages",replyType:"JournalsForMessage",loadCallback:function(a){o.message=a.data},replyCallback:function(){}})}]); app.controller("JournalsController",["$scope","$http","$routeParams","auth","common",function(o,a,e,l,n){n.init({id:e.id,scope:o,type:"journal_for_messages",replyType:"JournalsForMessage",loadCallback:function(a){o.message=a.data},replyCallback:function(){}})}]);
app.controller("LoginController",["$scope","$http","$location","$routeParams","alertService","config","auth","session",function(e,o,t,a,i,n,s,l){s.get_bind().then(function(){t.path("/activities")}),a.code&&l.save("code",a.code);var r=e;r.loginFailed=!1,r.alertService=i.create(),r.findPwdDialog=i.create(),r.login=function(a,i){return a.$setSubmitted(),console.log(i),a.$valid?(console.log(apiUrl+"auth"),void o.post(n.apiUrl+"users/wxbind",{login:i.login,password:i.password}).then(function(o){console.log(o.data),r.loginFailed=0!=o.data.status,e.loginFailed?r.alertService.showMessage("出错了",o.data.message):r.alertService.showMessage("提示",o.data.message,function(){t.path("/activities")})})["catch"](function(e){r.alertService.showMessage("出错了",e)})):void console.log(a.$error)},r.showBox=function(){r.findPwdDialog.showMessage("提示","请访问www.trustie.net获取密码谢谢")},r.goReg=function(){t.path("/reg")}}]); //login.js
app.controller("MyResourceController",["$scope","$http","auth","config","$location","rms",function(e,a,o,s,r,t){var c=e;c.menus=["课件","作业","测验"],c.resources=[],c.homeworks=[],c.exercise=[],c.resources_tag=!1,c.homeworks_tag=!1,c.exercises_tag=!1,c.page=t.get("page")||0,c.resources=t.get("resources")||[],c.has_more=t.get("has_more"),c.homework_page=t.get("homework_page")||0,c.homeworks=t.get("homeworks")||[],c.homework_has_more=t.get("homework_has_more"),c.exercise_page=t.get("exercise_page")||0,c.exercise=t.get("exercise")||[],c.exercise_has_more=t.get("exercise_has_more"),c.searchText="",c.sendFile=function(e){r.path("/send_class_list").search({id:e.id})},c.loadResourceData=function(e,s){1==e?(c.page=s,a({method:"POST",url:apiUrl+"resources",data:{token:o.token(),page:s}}).then(function(e){c.resources_tag=!0,e.data.page>0?c.resources=c.resources.concat(e.data.data):c.resources=e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("has_more",c.has_more),t.save("page",e.data.page),console.log(e.data)},function(e){})):2==e?(c.homework_page=s,a({method:"POST",url:apiUrl+"resources/homeworks",data:{token:o.token(),page:s}}).then(function(e){c.homeworks_tag=!0,e.data.page>0?c.homeworks=c.homeworks.concat(e.data.data):c.homeworks=e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("homework_has_more",c.has_more),t.save("homework_page",e.data.page),console.log(e.data)},function(e){})):3==e&&(c.exercise_page=s,a({method:"POST",url:apiUrl+"resources/exercises",data:{token:o.token(),page:s}}).then(function(e){c.exercises_tag=!0,e.data.page>0?c.exercise=c.exercise.concat(e.data.data):c.exercise=e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("exercise_has_more",c.exercise_has_more),t.save("exercise_page",e.data.page),console.log(e.data)},function(e){}))},c.tab=function(e){switch(c.currentTab=e,c.searchText="",e){case 1:c.resources.length<=0&&c.loadResourceData(e,0);break;case 2:c.homeworks.length<=0&&c.loadResourceData(e,0);break;case 3:c.exercise.length<=0&&c.loadResourceData(e,0)}},c.tab(1)}]); app.controller("LoginController",["$scope","$http","$location","$routeParams","alertService","config","auth","session",function(e,o,t,a,i,n,s,l){s.get_bind().then(function(){t.path("/activities")}),a.code&&l.save("code",a.code);var r=e;r.loginFailed=!1,r.alertService=i.create(),r.findPwdDialog=i.create(),r.login=function(a,i){return a.$setSubmitted(),console.log(i),a.$valid?(console.log(apiUrl+"auth"),void o.post(n.apiUrl+"users/wxbind",{login:i.login,password:i.password}).then(function(o){console.log(o.data),r.loginFailed=0!=o.data.status,e.loginFailed?r.alertService.showMessage("\u51fa\u9519\u4e86",o.data.message):r.alertService.showMessage("\u63d0\u793a",o.data.message,function(){t.path("/activities")})})["catch"](function(e){r.alertService.showMessage("\u51fa\u9519\u4e86",e)})):void console.log(a.$error)},r.showBox=function(){r.findPwdDialog.showMessage("\u63d0\u793a","\u8bf7\u8bbf\u95eewww.trustie.net\u83b7\u53d6\u5bc6\u7801\uff0c\u8c22\u8c22\uff01")},r.goReg=function(){t.path("/reg")}}]);
app.controller("NewClassController",["$scope","$http","auth","config","alertService","$location","rms",function(s,e,a,l,t,o,r){var n=s;n.alertService=t.create(),n.syllabus={courses:[{name:""}]},n.addClass=function(){n.syllabus.courses.push({})},n.deleteClass=function(s){n.syllabus.courses.splice(s,1)},n.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var c=[];for(var u in n.syllabus.courses)c.push(n.syllabus.courses[u].name);e.post(l.apiUrl+"syllabuses",{token:a.token(),title:t.title,courses:c}).then(function(s){0!=s.data.status?n.alertService.showMessage("出错了",s.data.message):n.alertService.showMessage("提示","新建课程成功",function(){r.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})}}]); //myresource.js
app.controller("RegController",["$scope","$http","$location","alertService","$location",function(e,o,a,s,a){var t=e;t.errDialog=s.create(),t.successDialog=s.create(),t.goLogin=function(){a.path("/login")},t.isagreed=!0,t.agreed=function(e){t.isagreed=!e},t.reg=function(e,s){return e.$setSubmitted(),console.log(e),e.$valid?(console.log(s),void o.post(apiUrl+"users",{login:s.username,password:s.password,mail:s.email}).then(function(e){0!=e.data.status?t.errDialog.showMessage("出错了",e.data.message):t.successDialog.showMessage("提示","注册且绑定微信成功",function(){a.path("/activities")})},function(e){t.errDialog.showMessage("出错了",e.data)})):void console.log(e.$error)}}]); app.controller("MyResourceController",["$scope","$http","auth","config","$location","rms",function(e,a,o,s,r,t){var c=e;c.menus=["\u8bfe\u4ef6","\u4f5c\u4e1a","\u6d4b\u9a8c"],c.resources=[],c.homeworks=[],c.exercise=[],c.resources_tag=!1,c.homeworks_tag=!1,c.exercises_tag=!1,c.page=t.get("page")||0,c.resources=t.get("resources")||[],c.has_more=t.get("has_more"),c.homework_page=t.get("homework_page")||0,c.homeworks=t.get("homeworks")||[],c.homework_has_more=t.get("homework_has_more"),c.exercise_page=t.get("exercise_page")||0,c.exercise=t.get("exercise")||[],c.exercise_has_more=t.get("exercise_has_more"),c.searchText="",c.sendFile=function(e){r.path("/send_class_list").search({id:e.id})},c.loadResourceData=function(e,s){1==e?(c.page=s,a({method:"POST",url:apiUrl+"resources",data:{token:o.token(),page:s}}).then(function(e){c.resources_tag=!0,c.resources=e.data.page>0?c.resources.concat(e.data.data):e.data.data,t.save("resources",c.resources),c.has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("has_more",c.has_more),t.save("page",e.data.page),console.log(e.data)},function(){})):2==e?(c.homework_page=s,a({method:"POST",url:apiUrl+"resources/homeworks",data:{token:o.token(),page:s}}).then(function(e){c.homeworks_tag=!0,c.homeworks=e.data.page>0?c.homeworks.concat(e.data.data):e.data.data,t.save("homeworks",c.homeworks),c.homework_has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("homework_has_more",c.has_more),t.save("homework_page",e.data.page),console.log(e.data)},function(){})):3==e&&(c.exercise_page=s,a({method:"POST",url:apiUrl+"resources/exercises",data:{token:o.token(),page:s}}).then(function(e){c.exercises_tag=!0,c.exercise=e.data.page>0?c.exercise.concat(e.data.data):e.data.data,t.save("exercise",c.exercise),c.exercise_has_more=e.data.count+10*e.data.page<e.data.all_count,t.save("exercise_has_more",c.exercise_has_more),t.save("exercise_page",e.data.page),console.log(e.data)},function(){}))},c.tab=function(e){switch(c.currentTab=e,c.searchText="",e){case 1:c.resources.length<=0&&c.loadResourceData(e,0);break;case 2:c.homeworks.length<=0&&c.loadResourceData(e,0);break;case 3:c.exercise.length<=0&&c.loadResourceData(e,0)}},c.tab(1)}]);
app.controller("SendClassListController",["$scope","$http","$routeParams","config","auth","alertService","rms",function(e,s,o,a,t,r,c){var n=e,l=o.id;n.alertService=r.create(),n.syllabuses=[];var i=function(){s.get(a.apiUrl+"syllabuses?token="+t.token()).then(function(e){console.log(e.data),n.syllabuses=e.data.data})};i(),n.selectCourse=function(e){"boolean"!=typeof e.checked&&(e.checked=!1),e.checked=!e.checked},n.sendToCourses=function(){var e=[];for(var o in n.syllabuses)for(var r in n.syllabuses[o].courses)n.syllabuses[o].courses[r].checked&&e.push(n.syllabuses[o].courses[r].id);return e.length<=0?void n.alertService.showMessage("提醒","请先选择班级"):void s.post(a.apiUrl+"resources/send",{token:t.token(),course_ids:e,send_id:l}).then(function(e){console.log(e.data),0==e.data.status?n.alertService.showMessage("提示","发送成功",function(){window.history.back()}):n.alertService.showMessage("发送出错",e.data.message)})}}]); //new_class.js
app.controller("NewClassController",["$scope","$http","auth","config","alertService","$location","rms",function(s,e,a,l,t,o,r){var n=s;n.alertService=t.create(),n.syllabus={courses:[{name:""}]},n.addClass=function(){n.syllabus.courses.push({})},n.deleteClass=function(s){n.syllabus.courses.splice(s,1)},n.newClass=function(s,t){if(s.$setSubmitted(),console.log(t),!s.$valid)return void console.log(s.$error);var c=[];for(var u in n.syllabus.courses)c.push(n.syllabus.courses[u].name);e.post(l.apiUrl+"syllabuses",{token:a.token(),title:t.title,courses:c}).then(function(s){0!=s.data.status?n.alertService.showMessage("\u51fa\u9519\u4e86",s.data.message):n.alertService.showMessage("\u63d0\u793a","\u65b0\u5efa\u8bfe\u7a0b\u6210\u529f",function(){r.save("syllabuses",[]),o.path("/class_list")}),console.log(s.data.data)})}}]);
//reg.js
app.controller("RegController",["$scope","$http","$location","alertService","$location",function(e,o,a,s,a){var t=e;t.errDialog=s.create(),t.successDialog=s.create(),t.goLogin=function(){a.path("/login")},t.isagreed=!0,t.agreed=function(e){t.isagreed=!e},t.reg=function(e,s){return e.$setSubmitted(),console.log(e),e.$valid?(console.log(s),void o.post(apiUrl+"users",{login:s.username,password:s.password,mail:s.email}).then(function(e){0!=e.data.status?t.errDialog.showMessage("\u51fa\u9519\u4e86",e.data.message):t.successDialog.showMessage("\u63d0\u793a","\u6ce8\u518c\u4e14\u7ed1\u5b9a\u5fae\u4fe1\u6210\u529f",function(){a.path("/activities")})},function(e){t.errDialog.showMessage("\u51fa\u9519\u4e86",e.data)})):void console.log(e.$error)}}]);
//send_class_list.js
app.controller("SendClassListController",["$scope","$http","$routeParams","config","auth","alertService","rms",function(e,s,o,a,t,r){var c=e,n=o.id;c.alertService=r.create(),c.syllabuses=[];var l=function(){s.get(a.apiUrl+"syllabuses?token="+t.token()).then(function(e){console.log(e.data),c.syllabuses=e.data.data})};l(),c.selectCourse=function(e){"boolean"!=typeof e.checked&&(e.checked=!1),e.checked=!e.checked},c.sendToCourses=function(){var e=[];for(var o in c.syllabuses)for(var r in c.syllabuses[o].courses)c.syllabuses[o].courses[r].checked&&e.push(c.syllabuses[o].courses[r].id);return e.length<=0?void c.alertService.showMessage("\u63d0\u9192","\u8bf7\u5148\u9009\u62e9\u73ed\u7ea7"):void s.post(a.apiUrl+"resources/send",{token:t.token(),course_ids:e,send_id:n}).then(function(e){console.log(e.data),0==e.data.status?c.alertService.showMessage("\u63d0\u793a","\u53d1\u9001\u6210\u529f",function(){window.history.back()}):c.alertService.showMessage("\u53d1\u9001\u51fa\u9519",e.data.message)})}}]);
//alert.js
app.directive("myAlert",["config",function(t){return{templateUrl:t.rootPath+"templates/alert.html",scope:{title:"=",message:"=",visible:"=",cb:"="},link:function(t){t.dismiss=function(){t.visible=!1,"function"==typeof t.cb&&t.cb()}}}}]),app.directive("myAlert2",["config",function(t){return{templateUrl:t.rootPath+"templates/alert2.html",scope:{title:"=",message:"=",visible:"=",cb:"="},link:function(t){t.dismiss=function(){t.visible=!1},t.confirm=function(){t.visible=!1,"function"==typeof t.cb&&t.cb()}}}}]); app.directive("myAlert",["config",function(t){return{templateUrl:t.rootPath+"templates/alert.html",scope:{title:"=",message:"=",visible:"=",cb:"="},link:function(t){t.dismiss=function(){t.visible=!1,"function"==typeof t.cb&&t.cb()}}}}]),app.directive("myAlert2",["config",function(t){return{templateUrl:t.rootPath+"templates/alert2.html",scope:{title:"=",message:"=",visible:"=",cb:"="},link:function(t){t.dismiss=function(){t.visible=!1},t.confirm=function(){t.visible=!1,"function"==typeof t.cb&&t.cb()}}}}]);
//form_validate.js
app.directive("pwdconfirm",function(){return{require:"ngModel",link:function(r,n,i,e){e.$validators.pwdconfirm=function(n,i){return r.user&&r.user.password==i}}}}); app.directive("pwdconfirm",function(){return{require:"ngModel",link:function(r,n,i,e){e.$validators.pwdconfirm=function(n,i){return r.user&&r.user.password==i}}}});
//input_auto.js
app.directive("inputAuto",function(){return{restrict:"A",scope:{},link:function(n,t){var i=t.parent().children().children().eq(0),c=t.next();t.on("input",function(){console.log(c),i.html(t[0].value);var n=i[0].scrollHeight;t.css("height",n+"px")}),c.on("click",function(){t.css("height","28px")})}}}); app.directive("inputAuto",function(){return{restrict:"A",scope:{},link:function(n,t){var i=t.parent().children().children().eq(0),c=t.next();t.on("input",function(){console.log(c),i.html(t[0].value);var n=i[0].scrollHeight;t.css("height",n+"px")}),c.on("click",function(){t.css("height","28px")})}}});
//loading_spinner.js
app.directive("loadingSpinner",["$http","config",function(t,e){return{templateUrl:e.rootPath+"templates/loading.html"}}]); app.directive("loadingSpinner",["$http","config",function(t,e){return{templateUrl:e.rootPath+"templates/loading.html"}}]);
//routes.js
app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,l,t,o){var r=o.rootPath,s={delay:["auth",function(e){return e.get_bind()}]},n=function(e,l){return{templateUrl:r+e,controller:l,resolve:s}};e.when("/login",{templateUrl:r+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:r+"reg.html",controller:"RegController"}).when("/activites",n("activities.html","ActivityController")).when("/issues/:id",n("issue_detail.html","IssueController")).when("/project_discussion/:id",n("project_discussion.html","DiscussionController")).when("/homework/:id",n("homework_detail.html","HomeworkController")).when("/course_notice/:id",n("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",n("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",n("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",n("blog_detail.html","BlogController")).when("/class",n("class.html","ClassController")).when("/new_class",n("new_class.html","NewClassController")).when("/edit_class",n("edit_class.html","EditClassController")).when("/class_list",n("class_list.html","ClassListController")).when("/myresource",n("myresource.html","MyResourceController")).when("/invite_code",{templateUrl:r+"invite_code.html",controller:"InviteCodeController"}).when("/send_class_list",n("send_class_list.html","SendClassListController")).otherwise({redirectTo:"/activites"}),l.interceptors.push(["$q","$rootScope",function(e,l){return void 0==l.activeCalls&&(l.activeCalls=0),{request:function(e){return l.activeCalls+=1,e},requestError:function(e){return l.activeCalls-=1,e},response:function(e){return l.activeCalls-=1,e},responseError:function(e){return l.activeCalls-=1,e}}}])}]); app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,l,t,o){var r=o.rootPath,s={delay:["auth",function(e){return e.get_bind()}]},n=function(e,l){return{templateUrl:r+e,controller:l,resolve:s}};e.when("/login",{templateUrl:r+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:r+"reg.html",controller:"RegController"}).when("/activites",n("activities.html","ActivityController")).when("/issues/:id",n("issue_detail.html","IssueController")).when("/project_discussion/:id",n("project_discussion.html","DiscussionController")).when("/homework/:id",n("homework_detail.html","HomeworkController")).when("/course_notice/:id",n("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",n("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",n("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",n("blog_detail.html","BlogController")).when("/class",n("class.html","ClassController")).when("/new_class",n("new_class.html","NewClassController")).when("/edit_class",n("edit_class.html","EditClassController")).when("/class_list",n("class_list.html","ClassListController")).when("/myresource",n("myresource.html","MyResourceController")).when("/invite_code",{templateUrl:r+"invite_code.html",controller:"InviteCodeController"}).when("/send_class_list",n("send_class_list.html","SendClassListController")).otherwise({redirectTo:"/activites"}),l.interceptors.push(["$q","$rootScope",function(e,l){return void 0==l.activeCalls&&(l.activeCalls=0),{request:function(e){return l.activeCalls+=1,e},requestError:function(e){return l.activeCalls-=1,e},response:function(e){return l.activeCalls-=1,e},responseError:function(e){return l.activeCalls-=1,e}}}])}]);

View File

@ -136,7 +136,7 @@ app.controller('ActivityController',
//跳到详情页 //跳到详情页
$scope.goDetail = function(type, act_id,id){ $scope.goDetail = function(type, act_id,id){
rms.save("yoffset", window.document.body.scrollTop); rms.save("yoffset", document.documentElement.scrollTop);
rms.save("activities",$scope.activities); rms.save("activities",$scope.activities);
rms.save("course_activities",$scope.course_activities); rms.save("course_activities",$scope.course_activities);
rms.save("project_activities",$scope.project_activities); rms.save("project_activities",$scope.project_activities);

View File

@ -8,7 +8,33 @@ app.controller('BlogController',
type: 'blog_comments', type: 'blog_comments',
replyType: 'BlogComment', replyType: 'BlogComment',
loadCallback: function(data){ loadCallback: function(data){
$scope.blog = data.data; console.log(data.data);
//回复级别 0 一级回复 1 二级回复
replytype = data.type;
page = data.page;
if (replytype == 0){
if (page == 0){
$scope.blog = data.data;
$scope.page = 0;
}
else{
$scope.blog.blog_comment_children = $scope.blog.blog_comment_children.concat(data.data.blog_comment_children);
}
$scope.has_more = $scope.blog.blog_comment_children.length < $scope.blog.comment_count;
console.log($scope.has_more);
}
else{
comment_id = data.data.id;
for (var i in $scope.blog.blog_comment_children) {
var comment = $scope.blog.blog_comment_children[i];
if(comment.id == comment_id){
// comment.parents_reply_top = comment.parents_reply_top.concat(data.data.parents_reply_top);
comment.parents_reply_top = data.data.parents_reply_top.concat(comment.parents_reply_top);
}
}
}
}, },
replyCallback: function(){ replyCallback: function(){
} }

View File

@ -1,4 +1,4 @@
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){
var vm = $scope; var vm = $scope;
var courseid = $routeParams.id; var courseid = $routeParams.id;
@ -97,30 +97,41 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
} }
} }
vm.course = {}; vm.course = {};
vm.students = []; vm.students = [];
vm.teachers = []; vm.teachers = [];
vm.resources = []; vm.resources = [];
vm.homeworks = []; vm.homeworks = [];
vm.exercises = []; vm.exercises = [];
//发送类别 1课件 2作业 3测验
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
vm.alertService = alertService.create();
vm.invite = function(){ vm.invite = function(){
$location.path("/invite_code").search({id: courseid}); $location.path("/invite_code").search({id: courseid});
}; };
vm.sendFile = function(r){ vm.sendFile = function(r,index){
vm.myresource_sendIndex = index;
rms.save('myresource_sendIndex',index);
$location.path("/send_class_list").search({id: r.id}); $location.path("/send_class_list").search({id: r.id});
} }
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
function(response) { function(response) {
console.log(response.data); console.log(response.data);
vm.course = response.data.data;
resetMenu(vm.course.current_user_is_teacher); if (response.data.status == 0){
vm.tab(1); vm.course = response.data.data;
resetMenu(vm.course.current_user_is_teacher);
vm.tab(1);
}
else{
vm.alertService.showMessage('提示', response.data.message);
}
} }
); );

View File

@ -8,7 +8,8 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo
var vm = $scope; var vm = $scope;
vm.syllabuses = rms.get('syllabuses') || []; vm.syllabuses = rms.get('syllabuses') || [];
vm.alertService = alertService.create(); vm.alertService_1 = alertService.create();
vm.alertService_3 = alertService.create();
var loadClassList = function () { var loadClassList = function () {
$http.get(config.apiUrl + "syllabuses?token=" + auth.token()).then( $http.get(config.apiUrl + "syllabuses?token=" + auth.token()).then(
@ -36,7 +37,7 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo
function (response) { function (response) {
console.log(response.data); console.log(response.data);
if (response.data.auth == 0) { if (response.data.auth == 0) {
vm.alertService.showMessage('提示', '非教师身份不能创建课程哦~'); vm.alertService_1.showMessage('提示', '非教师身份不能创建课程哦~');
} }
else{ else{
$location.path("/new_class"); $location.path("/new_class");
@ -50,26 +51,27 @@ app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$lo
} }
vm.joinClass = function () { vm.joinClass = function () {
var code = window.prompt("请输入5位班级邀请码(不区分大小写)"); vm.alertService_3.showMessage('提示', '请输入5位班级邀请码(不区分大小写)', function(){
if (code && code.length == 5) { if (vm.alertService_3.invite && vm.alertService_3.invite.length == 5) {
$http.post(config.apiUrl + "courses/join", { $http.post(config.apiUrl + "courses/join", {
token: auth.token(), token: auth.token(),
invite_code: code invite_code: vm.alertService_3.invite
}).then(function (response) { }).then(function (response) {
console.log(response.data); console.log(response.data);
if (response.data.status != 0) { if (response.data.status != 0) {
vm.alertService.showMessage('错误', response.data.message); vm.alertService_1.showMessage('提示', response.data.message);
} else { } else {
vm.alertService.showMessage('提示', '加入课程成功'); vm.alertService_1.showMessage('提示', '加入课程成功');
loadClassList(); vm.alertService_3.invite = "";
loadClassList();
}
});
} else {
if(vm.alertService_3.invite){
vm.alertService_1.showMessage('提示', '邀请码格式不正确');
} }
});
} else {
if(code){
vm.alertService.showMessage('错误', '邀请码格式不正确');
} }
});
}
}; };
vm.onSetting = function (syllabus) { vm.onSetting = function (syllabus) {

View File

@ -107,8 +107,4 @@ app.controller('EditClassController', ['$scope', '$http', 'auth', 'config', 'ale
} }
vm.fadeText = function () {
$scope.change = true;
}
}] ); }] );

View File

@ -33,7 +33,8 @@ app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams
vm.loginFailed = (response.data.status != 0); vm.loginFailed = (response.data.status != 0);
if (!$scope.loginFailed) { //绑定成功 if (!$scope.loginFailed) { //绑定成功
vm.alertService.showMessage('提示', response.data.message, function(){ vm.alertService.showMessage('提示', response.data.message, function(){
$location.path("/activities"); // $location.path("/activities");
window.WeixinJSBridge.call('closeWindow');
}); });
} else { } else {
vm.alertService.showMessage('出错了', response.data.message); vm.alertService.showMessage('出错了', response.data.message);

View File

@ -10,21 +10,30 @@ app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$l
vm.homeworks_tag = false; vm.homeworks_tag = false;
vm.exercises_tag = false; vm.exercises_tag = false;
//课件
vm.page = rms.get('page') || 0; vm.page = rms.get('page') || 0;
vm.resources = rms.get("resources") || []; vm.resources = rms.get("resources") || [];
vm.has_more = rms.get("has_more"); vm.has_more = rms.get("has_more");
//作业
vm.homework_page = rms.get('homework_page') || 0; vm.homework_page = rms.get('homework_page') || 0;
vm.homeworks = rms.get("homeworks") || []; vm.homeworks = rms.get("homeworks") || [];
vm.homework_has_more = rms.get("homework_has_more"); vm.homework_has_more = rms.get("homework_has_more");
//测验
vm.exercise_page = rms.get('exercise_page') || 0; vm.exercise_page = rms.get('exercise_page') || 0;
vm.exercise = rms.get("exercise") || []; vm.exercise = rms.get("exercise") || [];
vm.exercise_has_more = rms.get("exercise_has_more"); vm.exercise_has_more = rms.get("exercise_has_more");
vm.searchText = ""; vm.searchText = "";
vm.sendFile = function(r){ //发送类别 1课件 2作业 3测验
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
vm.sendFile = function(r,index){
vm.myresource_sendIndex = index;
rms.save('myresource_sendIndex',index);
$location.path("/send_class_list").search({id: r.id}); $location.path("/send_class_list").search({id: r.id});
} }

View File

@ -34,7 +34,8 @@ app.controller('RegController', ['$scope', '$http', '$location', 'alertService',
vm.errDialog.showMessage('出错了',response.data.message); vm.errDialog.showMessage('出错了',response.data.message);
} else { } else {
vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){ vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){
$location.path("/activities"); // $location.path("/activities");
window.WeixinJSBridge.call('closeWindow');
}); });
} }
}, function (response) { }, function (response) {

View File

@ -2,6 +2,9 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co
var vm = $scope; var vm = $scope;
var send_id = $routeParams.id; var send_id = $routeParams.id;
//发送类别 1课件 2作业 3测验
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
vm.alertService = alertService.create(); vm.alertService = alertService.create();
vm.syllabuses = []; vm.syllabuses = [];
@ -39,11 +42,19 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co
} }
$http.post(config.apiUrl + "resources/send", { $http.post(config.apiUrl + "resources/send", {
token: auth.token(), course_ids: course_ids, send_id: send_id token: auth.token(), course_ids: course_ids, send_id: send_id,send_type:vm.myresource_sendIndex
}).then(function(response){ }).then(function(response){
console.log(response.data); console.log(response.data);
if(response.data.status == 0){ if(response.data.status == 0){
vm.alertService.showMessage('提示', '发送成功', function () { var tip = "";
if (vm.myresource_sendIndex == 1){
tip = "课件已发送到目标班级。";
}
else if(vm.myresource_sendIndex == 2){
tip = "题目已发送到目标班级的作业列表但需要您访问Trustie网站设置发布和截止时间以激活相应作业谢谢。";
}
vm.alertService.showMessage('发送成功', tip, function () {
window.history.back(); window.history.back();
}); });
} else { } else {

View File

@ -40,3 +40,27 @@ app.directive('myAlert2', ['config', function(config){
} }
} }
}]); }]);
app.directive('myAlert3', ['config', function(config){
return {
templateUrl: config.rootPath+ 'templates/alert3.html',
scope: {
title: "=",
message: "=",
visible: "=",
cb: "=",
invite: "="
},
link: function(scope){
scope.dismiss = function(){
scope.visible = false;
};
scope.confirm = function(){
scope.visible = false;
if(typeof scope.cb === 'function'){
scope.cb();
}
}
}
}
}]);

View File

@ -8,11 +8,11 @@ app.directive('inputAuto',function(){
element.on('input',function(){ element.on('input',function(){
console.log(sendButton); console.log(sendButton);
copyContainer.html(element[0].value); copyContainer.html(element[0].value);
var textHeight = copyContainer[0].scrollHeight; var textHeight = copyContainer[0].scrollHeight-10;
element.css('height', textHeight + 'px'); element.css('height', textHeight + 'px');
}); });
sendButton.on('click',function(){ sendButton.on('click',function(){
element.css('height','28px'); element.css('height','18px');
}); });
} }
} }

View File

@ -4,6 +4,7 @@ app.factory('alertService', function(){
this.message = null; this.message = null;
this.visible = null; this.visible = null;
this.cb = null; this.cb = null;
this.invite = "";
} }
Alert.prototype.showMessage = function(title, msg, cb){ Alert.prototype.showMessage = function(title, msg, cb){
@ -11,12 +12,14 @@ app.factory('alertService', function(){
this.title = title; this.title = title;
this.visible = true; this.visible = true;
this.cb = cb; this.cb = cb;
this.invite = "";
} }
Alert.prototype.dismiss = function(){ Alert.prototype.dismiss = function(){
this.message = null; this.message = null;
this.title = null; this.title = null;
this.visible = false; this.visible = false;
this.invite = "";
if(this.cb) {this.cb();} if(this.cb) {this.cb();}
} }
@ -118,10 +121,18 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au
}); });
}; };
var loadCommonData = function(id, type){ // var loadCommonData = function(id, type,replytype,page){
// return $http({
// method: 'GET',
// url: apiUrl+ type + "/" + id+"?token="+auth.token(),
// })
// };
var loadCommonData = function(id, type,replytype,page){
return $http({ return $http({
method: 'GET', method: 'POST',
url: apiUrl+ type + "/" + id+"?token="+auth.token() url: apiUrl+ type + "/" + id,
data:{token:auth.token(),type:replytype,page:page}
}) })
}; };
@ -155,19 +166,19 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au
var init = function(args){ var init = function(args){
args.scope.formData = {comment: ''}; args.scope.formData = {comment: ''};
var loadData = function(id){ var loadData = function(id,replytype,page){
loadCommonData(id, args.type).then(function successCallback(response) { loadCommonData(id, args.type,replytype,page).then(function successCallback(response) {
args.loadCallback(response.data); args.loadCallback(response.data);
}, function errorCallback(response) { }, function errorCallback(response) {
}); });
}; };
loadData(args.id); loadData(args.id,0,0);
args.scope.addReply = function(data){ args.scope.addReply = function(data){
console.log(data.comment); console.log(data.comment);
addCommonReply(args.id, args.replyType, data, function(){ addCommonReply(args.id, args.replyType, data, function(){
args.scope.formData = {comment: ''}; args.scope.formData = {comment: ''};
loadData(args.id); loadData(args.id,0,0);
if(typeof args.replyCallback === 'function'){ if(typeof args.replyCallback === 'function'){
args.replyCallback(); args.replyCallback();
} }
@ -242,6 +253,21 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms', function($http, au
act.has_praise = false; act.has_praise = false;
decreaseCommonPraise(act); decreaseCommonPraise(act);
}; };
args.scope.showMoreReply = function(replytype,data){
if(!data.page){
data.page = 1;
}
else{
data.page = data.page + 1;
}
loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) {
args.loadCallback(response.data);
}, function errorCallback(response) {
});
};
} }
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};

View File

@ -55,6 +55,8 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin: 5px 0.4em 5px 1.4e
a {color:#707070;} a {color:#707070;}
a.c-grey {color:#707070;} a.c-grey {color:#707070;}
a.c-grey2 {color:#9a9a9a;} a.c-grey2 {color:#9a9a9a;}
a.c-grey3 {color:#353535;}
a.c-green {color:#0bb20c;}
a:link,a:visited{text-decoration:none;} a:link,a:visited{text-decoration:none;}
a:hover,a:active{cursor:pointer;} a:hover,a:active{cursor:pointer;}
a.link-blue {color:#269ac9;} a.link-blue {color:#269ac9;}
@ -84,7 +86,7 @@ a.underline {text-decoration:underline;}
.btn2 {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; margin:18px auto 20px auto; border-radius:50px; display:block;} .btn2 {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; margin:18px auto 20px auto; border-radius:50px; display:block;}
/*tab*/ /*tab*/
.tab-wrap {position:relative; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;} .tab-wrap {position:relative; width:100%; line-height:38px; display:-webkit-box; display:-moz-box; display:-ms-flexbox; display:-webkit-flex; display:flex; font-size:13px; background-color:#fff;}
.tab-wrap a {position:relative; display:block; -webkit-box-flex:1; -moz-box-flex:1; -ms-flex:1; flex:1;} .tab-wrap a {position:relative; display:block; -webkit-box-flex:1; -moz-box-flex:1; -ms-flex:1; flex:1;}
.tab-wrap a:first-child:after {display:none;} .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;} .tab-wrap a:after {content:" "; position:absolute; left:0; top:0; width:1px; height:100%; border-left:1px solid #ccc; color:#707070;}
@ -127,8 +129,8 @@ a.underline {text-decoration:underline;}
.post-reply-date, .post-reply-trigger {font-size:13px;} .post-reply-date, .post-reply-trigger {font-size:13px;}
.post-input-container {position:relative; padding-right:70px;} .post-input-container {position:relative; padding-right:70px;}
.copy-input-container {position:relative; padding-right:70px;} .copy-input-container {position:relative; padding-right:70px;}
.copy-input {width:100%; height:28px; line-height:28px; padding:0 5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;} .copy-input {width:100%; height:18px; line-height:18px; padding:5px; vertical-align: middle; font-size:12px; border-radius:3px; position:absolute; left:-999em;}
.post-reply-input {width:100%; height:28px; max-height:84px; line-height:28px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:0 5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;} .post-reply-input {width:100%; height:18px; max-height:54px; line-height:18px; vertical-align: middle; font-size:13px; border:1px solid #e6e6e6; outline:none; padding:5px; margin:0; border-radius:3px; overflow-y:auto; resize:none; background-color:#f0eff4;}
.post-reply-submit {position:absolute; font-size:13px; height:30px; line-height:30px; vertical-align:middle; padding:0 8px; color:#fff; background-color:#269ac9; outline:none; border:none; top:0; right:0;} .post-reply-submit {position:absolute; font-size:13px; height:30px; line-height:30px; vertical-align:middle; padding:0 8px; color:#fff; background-color:#269ac9; outline:none; border:none; top:0; right:0;}
.reply-icon {background:url(/images/wechat/icon_list.gif) -150px -155px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .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;} .praise-icon {background:url(/images/wechat/icon_list.gif) -36px -88px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;}
@ -153,8 +155,8 @@ a.underline {text-decoration:underline;}
.locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} .locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;}
/*20150612加入班级样式*/ /*20150612加入班级样式*/
.add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; 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; top:50%; left:50%; transform: translate(-50%,-50%);} .add-class-box {position:fixed; width:80%; max-width:300px; min-width:240px; font-size:15px; color:#444; background-color:#fff; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; top:50%; left:50%; transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%); -moz-transform: translate(-50%,-50%); -webkit-transform: translate(-50%,-50%); -o-transform: translate(-50%,-50%);}
.add-class-tip {padding-top:20px; padding-bottom:20px;} .add-class-tip {padding-top:1.2em; padding-bottom:.5em; font-weight:400;}
.class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} .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;} .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;} .submit-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;}
@ -209,7 +211,8 @@ a.underline {text-decoration:underline;}
.students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} .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;} .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;} .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:#555; height:35px; line-height:35px; vertical-align:middle; border:none; outline:none;} .new-class-input {width:60%; color:#555; height:16px; line-height:16px; vertical-align:middle; border:none; outline:none; padding:8px 0;}
.class-list-setting {position:absolute; top:10px; right:10px;}
/*20160616登录注册*/ /*20160616登录注册*/
.login-wrap {padding:0 10px;} .login-wrap {padding:0 10px;}
@ -220,4 +223,10 @@ a.underline {text-decoration:underline;}
.login-box.checked{background:#63c360; border:1px solid #63c360;} .login-box.checked{background:#63c360; border:1px solid #63c360;}
.login-box.checked:after{content:url(/images/wechat/checked.png);} .login-box.checked:after{content:url(/images/wechat/checked.png);}
.forget-psw-wrap {width:60px; margin:0 auto;} .forget-psw-wrap {width:60px; margin:0 auto;}
.forget-psw {position:fixed; bottom:10px;} .forget-psw {position:fixed; bottom:10px;}
/*二级回复*/
.mult-reply-container{ border:solid 1px #f3ddb3; background:#fffef4; padding:4px;color:#999;}
.mult-reply-content{ color:#707070; font-size:13px;}
.mult-reply-hide{ text-align:center; display:block; font-size:14px; color:#aaa; border-bottom:1px solid #F3DDB3; padding:8px 0;}
.mult-reply-arrow{ color:#aaa; margin-right:10px; font-size:14px; font-weight:bold;}