微信项目相关功能开发,班级角色功能等

This commit is contained in:
yuanke 2016-07-28 14:49:45 +08:00
parent 4fe60bfc97
commit cf65e6748b
20 changed files with 366 additions and 145 deletions

View File

@ -461,9 +461,8 @@ module Mobile
else else
cs = CoursesService.new cs = CoursesService.new
cs.set_user_course_role params status = cs.modify_user_course_role params
present :status, status
present :status, 0
end end
end end

View File

@ -134,8 +134,11 @@ module Mobile
if !(my_member && my_member.roles[0] && my_member.roles[0].id == 3 ) || project.user_id == params[:user_id] || !(params[:role_id] == 3 || params[:role_id] == 4 || params[:role_id] == 5) if !(my_member && my_member.roles[0] && my_member.roles[0].id == 3 ) || project.user_id == params[:user_id] || !(params[:role_id] == 3 || params[:role_id] == 4 || params[:role_id] == 5)
present :status, -1 present :status, -1
else else
ps = ProjectsService.new
present :status, 0 status = ps.modify_user_project_role params
present :status, status
end end
end end
@ -147,6 +150,10 @@ module Mobile
post 'create' do post 'create' do
authenticate! authenticate!
ps = ProjectsService.new
status = ps.createNewProject params,current_user
present :status, 0 present :status, 0
@ -158,12 +165,15 @@ module Mobile
requires :token, type: String requires :token, type: String
requires :invite_code, type: String, desc: '邀请码' requires :invite_code, type: String, desc: '邀请码'
end end
post 'create' do post "join" do
authenticate! authenticate!
# ps = ProjectsService.new
# status = ps.join_project({role: "5", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
#
# present :status, status
{status:-1, message: '该功能暂未开放,敬请期待!' }
present :status, 0
end end
end end

View File

@ -4,6 +4,8 @@ module Mobile
expose :name expose :name
expose :id expose :id
expose :user_id expose :user_id
# expose :invite_code
# expose :qrcode
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user] current_user = options[:user]

View File

@ -238,6 +238,7 @@ class ProjectsController < ApplicationController
#end #end
@project.members << m @project.members << m
@project.project_infos << project_info @project.project_infos << project_info
send_wechat_create_project_notice User.current,@project
#end #end
respond_to do |format| respond_to do |format|
format.html { format.html {

View File

@ -203,6 +203,7 @@ class SchoolController < ApplicationController
end end
end end
render :json =>status render :json =>status
end end
end end

View File

@ -8,10 +8,12 @@ class WechatsController < ActionController::Base
# default text responder when no other match # default text responder when no other match
on :text do |request, content| on :text do |request, content|
#邀请码 #邀请码
if join_request(request) if join_class_request(request)
sendBindClass(request, {invite_code: content}) sendBindClass(request, {invite_code: content})
# elsif join_project_request(request)
# sendBindProject(request, {invite_code: content})
else else
request.reply.text '您的意见已收到,感谢您的反馈!' request.reply.text "您的意见已收到,非常感谢~ \n更多问题可以通过以下方式联系我们:\n官方QQ群173184401\n我们会认真聆听您的意见和建议。"
end end
end end
@ -147,7 +149,13 @@ class WechatsController < ActionController::Base
end end
on :click, with: 'JOIN_PROJECT' do |request, key| on :click, with: 'JOIN_PROJECT' do |request, key|
request.reply.text "此功能正在开发中,很快就会上线,谢谢!" request.reply.text "该功能暂未开放,敬请期待!"
# uw = user_binded?(request[:FromUserName])
# unless uw
# sendBind(request)
# else
# request.reply.text "请直接回复6位项目邀请码\n(不区分大小写):"
# end
end end
on :click, with: 'JOIN_CLASS' do |request, key| on :click, with: 'JOIN_CLASS' do |request, key|
@ -159,12 +167,18 @@ class WechatsController < ActionController::Base
end end
end end
def join_request(request) def join_class_request(request)
openid = request[:FromUserName] openid = request[:FromUserName]
wl = WechatLog.where("openid = '#{openid}' and request_raw like '%\"Event\":\"click\"%'").order('id desc').first wl = WechatLog.where("openid = '#{openid}' and request_raw like '%\"Event\":\"click\"%'").order('id desc').first
wl && JSON(wl.request_raw)["EventKey"] == 'JOIN_CLASS' wl && JSON(wl.request_raw)["EventKey"] == 'JOIN_CLASS'
end end
def join_project_request(request)
openid = request[:FromUserName]
wl = WechatLog.where("openid = '#{openid}' and request_raw like '%\"Event\":\"click\"%'").order('id desc').first
wl && JSON(wl.request_raw)["EventKey"] == 'JOIN_PROJECT'
end
def sendBindClass(request, params) def sendBindClass(request, params)
begin begin
uw = user_binded?(request[:FromUserName]) uw = user_binded?(request[:FromUserName])
@ -180,6 +194,21 @@ class WechatsController < ActionController::Base
end end
end end
def sendBindProject(request, params)
begin
uw = user_binded?(request[:FromUserName])
if !uw
return sendBind(request)
else
return join_project(params, uw.user, request)
end
rescue => e
logger.error e.inspect
logger.error e.backtrace.join("\n")
return request.reply.text e
end
end
def default_msg(request) def default_msg(request)
uw = user_binded?(request[:FromUserName]) uw = user_binded?(request[:FromUserName])
if uw && uw.user if uw && uw.user
@ -234,6 +263,36 @@ class WechatsController < ActionController::Base
end end
def join_project(params, user, request)
project = nil
project = Project.where(qrcode: params[:ticket]).first if params[:ticket]
project = Project.where(invite_code: params[:invite_code]).first if params[:invite_code]
raise "项目不存在,请确认您的邀请码是否输入正确,谢谢!" unless project
#取出用户角色类型
role = 5
ps = ProjectsService.new
status = ps.join_project({invite_code: project.invite_code}, user)
if status[:state] != 0
raise ProjectService::JoinProjectError.message(status)
end
creator = User.find(project.user_id)
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入项目,开始研发吧!',
content: "项目名称:#{project.name}\n发起人:#{creator.name}\n进入项目,和小伙伴轻松的研发吧!"} }
return request.reply.news(news) do |article, n, index| # article is return object
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities#/project?id='+project.id.to_s}&response_type=code&scope=snsapi_base&state=myproject#wechat_redirect"
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
article.item title: "#{n[:title]}",
description: n[:content],
pic_url: pic_url,
url: url
end
end
### controller method ### controller method
module Controllers module Controllers
def get_bind def get_bind
@ -304,6 +363,8 @@ class WechatsController < ActionController::Base
else else
if params[:state] == 'myclass' if params[:state] == 'myclass'
@course_id = params[:id]; @course_id = params[:id];
elsif params[:state] == 'myproject'
@project_id = params[:id];
end end
session[:wechat_openid] = open_id session[:wechat_openid] = open_id

View File

@ -956,21 +956,48 @@ class CoursesService
# student_works[index + 1 .. index + n] # student_works[index + 1 .. index + n]
# end # end
#修改班级成员角色
def modify_user_course_role params
status = -1
def set_user_course_role params c = Course.find("#{params[:id]}")
if params[role_id] == 7
member = c.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
if member
role = Role.find(params[:role_id])
elsif params[role_id] == 9 member.member_roles[0].role_id = params[:role_id]
elsif params[role_id] == 10 # 这里的判断只能通过角色名,可以弄成常量
if params[:role_id] == 10
StudentsForCourse.create(:student_id => params[:user_id], :course_id =>params[:id])
else
joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:id])
joined.each do |join|
join.delete
end
member.course_group_id = 0
end
if role.allowed_to?(:is_manager)
courseInfo = CourseInfos.new(:user_id => params[:user_id], :course_id => params[:id])
courseInfo.save
else
user_admin = CourseInfos.where("user_id = ? and course_id = ?", params[:user_id], params[:id])
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end
end
Role.givable.all[3..5]
if member.member_roles[0].save
status = 0
end
end end
status
end end
end end

View File

@ -3,30 +3,7 @@
class ProjectsService class ProjectsService
include ApplicationHelper include ApplicationHelper
# include CoursesHelper
def judge_can_setting(sy,user)
sy[:can_setting] = sy[:user_id] == user.id ? true : false
sy[:can_setting] = false if sy[:id].nil?
sy.courses.each do |c|
c[:can_setting] = false
member = c.members.where("user_id=#{user.id} and course_id=#{c.id}")[0]
roleName = member.roles[0].name if member
if roleName && (roleName == "TeachingAsistant" || roleName == "Teacher" )
c[:can_setting] = true
end
if c.tea_id == user.id
c[:can_setting] = true
end
end
sy
end
#获取指定用户的项目列表 #获取指定用户的项目列表
def user_projects(user) def user_projects(user)
projects = user.projects.not_deleted.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updated_at ").order("updated_at desc") projects = user.projects.not_deleted.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updated_at ").order("updated_at desc")
@ -36,103 +13,130 @@ class ProjectsService
#显示项目 #显示项目
def show_project(params,current_user) def show_project(params,current_user)
project = Project.find(params[:id]) project = Project.find(params[:id])
# course.generate_invite_code # project.generate_invite_code
# course.generate_qrcode # project.generate_qrcode
# unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?)
# raise '403'
# end
# {:course => course,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0}
project project
end end
def after_create_course(course, user) def send_wechat_create_project_notice user,project
#unless User.current.admin? count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => user, :roles => [r])
m.project_id = -1
course_info = CourseInfos.new(:user_id => user.id, :course_id => course.id)
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
course.members << m
course.course_infos << course_info
end
def send_wechat_create_class_notice user,course
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_project_notice user.id, "create_project_notice", project.id,title, project.name, format_time(project.created_on),"点击查看项目详情。"
end end
end end
#创建大纲
# params {title: '大纲名称', [{course}, {course}]}
def create(user, title, courses = [])
sy = Syllabus.new(title: title, user_id: user.id)
ActiveRecord::Base.transaction() do
sy.save!
courses.each do |course| def createNewProject params,user
if ::Course === course
course.syllabus_id = sy.id
course.save!
send_wechat_create_class_notice user,course
elsif Hash === course
c = ::Course.new(course)
c.tea_id = user.id
c.syllabus_id = sy.id
c.update_default_value
c.is_public = 0
c.save!
after_create_course(c, user)
send_wechat_create_class_notice user,c
end
end
end
sy[:can_setting] = true
sy
end
#修改课程大纲的名称、班级名称、新增班级
def edit(user, option)
courses = []
status = -1 status = -1
syllabus_id = option[:id] issue_custom_fields = IssueCustomField.sorted.all
trackers = Tracker.sorted.all
project = Project.new
sy = Syllabus.where("id=?",option[:id]).first project[:name] = params[:name]
project[:description] = ''
project[:is_public] = '1' #公开
project[:project_type] = 0
project[:project_new_type] = 1
project[:identifier] = Project.next_identifier if Setting.sequential_project_identifiers?
if sy && sy.user_id == user.id project.organization_id = params[:organization_id]
syllabus_title = option[:title] project.user_id = user.id
sy.title = syllabus_title # if validate_parent_id && @project.save
sy.save! if project.save
#修改班级名称 r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
modify_courses = option[:modify_courses] m = Member.new(:user => user, :roles => [r])
modify_courses.each do |c| # project's score
course = Course.where("id=?",c.id).first if ProjectScore.where("project_id=?", project.id).first.nil?
ProjectScore.create(:project_id => project.id, :score => false)
end
# end
project_info = ProjectInfo.new(:user_id => user.id, :project_id => project.id)
user_grades = UserGrade.create(:user_id => user.id, :project_id => project.id)
project_status = ProjectStatus.create(:project_id => project.id, :watchers_count => 0, :changesets_count => 0, :project_type => project.project_type,:grade => 0)
project.members << m
project.project_infos << project_info
status = 0
if course && course.tea_id == user.id send_wechat_create_project_notice user,project
course.name = c.name end
!course.save status
end
#修改项目成员角色
def modify_user_project_role params
status = -1
project = Project.find("#{params[:id]}")
member = project.member_principals.includes(:roles, :principal).where("user_id=?",params[:user_id]).first
if member
member.member_roles[0].role_id = params[:role_id]
role = Role.find(params[:role_id])
if role.allowed_to?(:is_manager)
projectInfo = ProjectInfo.new(:user_id => member.user_id, :project_id => project.id)
projectInfo.save
else
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", member.user_id, project.id)
if user_admin.size > 0
user_admin.each do |user|
user.destroy
end
end end
end end
#新增班级 if member.member_roles[0].save
add_courses = option[:add_courses] status = 0
add_courses.each do |c|
course = Course.new()
course.name = c
course.tea_id = user.id
course.syllabus_id = sy.id
course.update_default_value
course.is_public = 0
course.save!
after_create_course(course, user)
send_wechat_create_class_notice user,course
end end
status = 0 end
status
end
class JoinProjectError < Errors
define_error [
0, '加入成功',
1, '您的邀请码不正确',
2, '您还未登录',
3, '您已经是该项目的管理人员',
4, '您已经是该项目的开发人员',
5, '您已经是该项目的报告人员',
6, '该项目不存在或已被删除啦',
'未知错误,请稍后再试'
]
end
def join_project params,current_user
status = -1
project = project.find_by_invite_code(params[:invite_code]) if params[:invite_code]
if project
if project[:is_delete] == 1
status = 6
else
if current_user.member_of?(project) #如果已经是成员
member = project.member_principals.includes(:roles, :principal).where("user_id=?",current_user.id).first
status = member.member_roles[0].role_id
else
if params[:invite_code].present?
members = []
members << Member.new(:role_ids => [5], :user_id => current_user.id)
project.members << members
projectInfo = ProjectInfo.new(:user_id => current_user.id, :project_id => project.id)
projectInfo.save
status = 0
else
status = 4
end
end
end
else
status = 4
end end
status status
end end

View File

@ -323,4 +323,41 @@ class WechatService
end end
end end
def create_project_notice(user_id, type, id, first, key1, key2,remark="")
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = {
touser:uw.openid,
template_id:Wechat.config.create_project_notice,
url:"#{Setting.protocol}://#{Setting.host_name}/wechat/user_activities#/project?id="+id.to_s,
topcolor:"#FF0000",
data:{
first: {
value:first,
color:"#707070"
},
keyword1:{
value:key1,
color:"#707070"
},
keyword2:{
value:key2,
color:"#707070"
},
remark:{
value:remark,
color:"#707070"
}
}
}
#data = three_keys_template uw.openid,Wechat.config.create_class_notice, type, id, first, key1, key2, key3, remark
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
Rails.logger.error "[wechat_create_project_notice] ===> #{e}"
end
Rails.logger.info "send over. #{req}"
end
end
end end

View File

@ -18,6 +18,8 @@
window.g_redirect_path = '<%= @path %>'; window.g_redirect_path = '<%= @path %>';
<% if @course_id %> <% if @course_id %>
window.g_courseid = <%= @course_id %>; window.g_courseid = <%= @course_id %>;
<% elsif @project_id %>
window.g_projectid = <%= @project_id %>;
<% end %> <% end %>
</script> </script>

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=http://www.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=wx8e1ab05163a28e37&redirect_uri=https://www.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=wx8e1ab05163a28e37&redirect_uri=http://www.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=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect"
-
type: "click"
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=project_list#wechat_redirect"
- -
type: "view" type: "view"
name: "资源" name: "我的宝库"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=http://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" 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=myresource#wechat_redirect"
- -
name: "更多" name: "更多"
@ -24,9 +28,13 @@ button:
key: "JOIN_CLASS" key: "JOIN_CLASS"
- -
type: "click" type: "click"
name: "反馈" name: "加入项目"
key: "FEEDBACK" key: "JOIN_PROJECT"
- -
type: "view" type: "view"
name: "历史推文" name: "历史推文"
url: "http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzIwOTM2NDkxMA==#wechat_webview_type=1&wechat_redirect" url: "http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzIwOTM2NDkxMA==#wechat_webview_type=1&wechat_redirect"
-
type: "click"
name: "联系我们"
key: "FEEDBACK"

View File

@ -29,6 +29,7 @@ default: &default
homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps" homework_message_notice: "tCf7teCVqc2vl2LZ_hppIdWmpg8yLcrI8XifxYePjps"
class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA" class_notice: "MQ_mFupbXP-9jWbeHT3C5xqNBvPo8EIlNv4ULakSpJA"
create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw" create_class_notice: "2GtJJGzzNlNy2i0UrsjEDlvfSVIUXQfSo47stpcQAVw"
create_project_notice: "R2ZaQKJfDJgujPcHWPzadKHIRkIyj2CjX2o_qIuRqig"
#test #test
# encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" # encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6"
@ -40,6 +41,7 @@ default: &default
# homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ" # homework_message_notice: "Kom0TsYYKsNKCS6luweYVRo9z-mH0wRPr24b1clGCPQ"
# class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk" # class_notice: "8LVu33l6bP-56SDomVgHn-yJc57YpCwwJ81rAJgRONk"
# create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I" # create_class_notice: "9CDIvHIKiGwPEQWRw_-wieec1o50tMXQPPZIfECKu0I"
# create_project_notice: "R2ZaQKJfDJgujPcHWPzadKHIRkIyj2CjX2o_qIuRqig"
production: production:
<<: *default <<: *default

View File

@ -31,9 +31,10 @@
<div class="member-banner f13 c-grey3">授课老师</div> <div class="member-banner f13 c-grey3">授课老师</div>
<div class="class-member-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText"> <div class="class-member-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText">
<img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{teacher.name}}</span><span class="fr mr10 c-grey2">{{teacher.role_name|identify}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" /> <img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.jpg" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{teacher.name}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
<span class = "fr mr10 mt5" ng-show ="teacher.id == course.tea_id">管理员</span> <img src="/images/wechat/setting.png" ng-show = "course.is_creator && teacher.id != course.tea_id" width="15" class="fr mr10" style="margin-top:7px;" ng-click="onSetting(teacher)" />
<img src="/images/wechat/setting.png" ng-show = "course.is_creator && teacher.id != course.tea_id" width="15" class="class-list-setting" ng-click="onSetting(teacher)" /> <span class = "fr mr25 mt5" ng-show ="teacher.id == course.tea_id">管理员</span>
<span ng-class="['fr','mt5',{'mr10': course.is_creator,'mr25': !course.is_creator}]" ng-show ="teacher.id != course.tea_id && teacher.roles_id == 7">教辅</span>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div class="member-banner f13 mt10 c-grey3">我的同学</div> <div class="member-banner f13 mt10 c-grey3">我的同学</div>

View File

@ -32,15 +32,15 @@
<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': 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-show="r.current_user_is_teacher" ng-click="sendFile(r,3)" 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">-->
<div id="more_exercises" class="more-events mt10" ng-click="loadResourceData(3,exercise_page+1);">更多</div> <!--<div id="more_exercises" class="more-events mt10" ng-click="loadResourceData(3,exercise_page+1);">更多</div>-->
</div> <!--</div>-->
<p ng-show="exercises_tag == true && exercise.length<=0" class="class-test-tip">暂无测验,<br /> <!--<p ng-show="exercises_tag == true && exercise.length<=0" class="class-test-tip">暂无测验,<br />-->
请登录Trustie网站在PC浏览器中创建测验。</p> <!--请登录Trustie网站在PC浏览器中创建测验。</p>-->
</div> <!--</div>-->
</div> </div>

View File

@ -0,0 +1,16 @@
<div class="post-container">
<div class="qr-code-wrap">
<div class="qr-code-box">
<div class="share-class-name">{{project.name}}</div>
<div class="qr-img-wrap"><img ng-src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={{project.qrcode}}" width="152" class="qr-code-img" /></div>
<div class="invitation-code-wrap">邀请码:{{project.invite_code}}</div>
</div>
</div>
<div class="share-code-wrap">
<!--<a ng-click="share()" href="javascript:void(0);" class="share-code-btn">分享邀请码</a>-->
<p/>
<div class="share-code-instruction"> 1.点击右上角"发送给朋友",邀请朋友加入项目<br />
2.长按二维码,通过“识别图中二维码”功能加入项目<br />
3.通过“加入项目”菜单输入邀请码加入项目(长按邀请码可以复制哦~</div>
</div>
</div>

View File

@ -1,6 +1,7 @@
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$location', 'rms', function($scope, $http, auth, config, $location,rms){ app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$location', 'rms', function($scope, $http, auth, config, $location,rms){
var vm = $scope; var vm = $scope;
vm.menus = ['课件', '作业', '测验']; // vm.menus = ['课件', '作业', '测验'];
vm.menus = ['课件', '作业'];
vm.resources = []; vm.resources = [];
vm.homeworks = []; vm.homeworks = [];

View File

@ -22,6 +22,14 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut
vm.alertService = alertService.create(); vm.alertService = alertService.create();
//跳入邀请界面
vm.invite = function(){
vm.alertService.showMessage('提示', "该功能暂未开放,敬请期待!");
// $location.path("/project_invite_code").search({id: projectid});
};
//获取项目动态 //获取项目动态
vm.getActivities = function(page){ vm.getActivities = function(page){
$http({ $http({

View File

@ -0,0 +1,34 @@
/**
* Created by guange on 16/6/22.
*/
app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){
var vm = $scope;
vm.project = {};
var projectid = $routeParams.id;
$http.get(config.apiUrl+ 'projects/'+projectid+"?token="+auth.token()).then(
function(response){
console.log(response.data);
vm.project = response.data.data;
}
);
vm.share = function(){
window.WeixinJSBridge.invoke('sendAppMessage',{
'appid': 'wxf694495398c7d470', // 公众号appID
'type': 'link', // 非必填music,vido或link,默认为link。
'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用
'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址
'img_height':370, // 缩略图高度
'img_width':550, // 缩略图宽度
'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址
'desc':'desc', // 描述
'title':'title' // 标题
},function(res){
//alert(res.err_msg);
});
}
}]);

View File

@ -49,14 +49,20 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co
var tip = ""; var tip = "";
if (vm.myresource_sendIndex == 1){ if (vm.myresource_sendIndex == 1){
tip = "课件已发送到目标班级。"; tip = "课件已发送到目标班级。";
vm.alertService.showMessage('发送成功', tip, function () {
rms.save('page',0);
rms.save("resources",[]);
rms.save("has_more",false);
window.history.back();
});
} }
else if(vm.myresource_sendIndex == 2){ else if(vm.myresource_sendIndex == 2){
tip = "题目已发送到目标班级的作业列表但需要您访问Trustie网站设置发布和截止时间以激活相应作业谢谢。"; tip = "题目已发送到目标班级的作业列表但需要您访问Trustie网站设置发布和截止时间以激活相应作业谢谢。";
vm.alertService.showMessage('发送成功', tip, function () {
window.history.back();
});
} }
vm.alertService.showMessage('发送成功', tip, function () {
window.history.back();
});
} else { } else {
vm.alertService.showMessage('发送出错', response.data.message); vm.alertService.showMessage('发送出错', response.data.message);
} }

View File

@ -42,6 +42,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/project', makeRoute('project.html', 'ProjectController')) .when('/project', makeRoute('project.html', 'ProjectController'))
.when('/edit_project_member', makeRoute('edit_project_member.html', 'EditProjectMemberController')) .when('/edit_project_member', makeRoute('edit_project_member.html', 'EditProjectMemberController'))
.when('/new_project', makeRoute('new_project.html', 'NewProjectController')) .when('/new_project', makeRoute('new_project.html', 'NewProjectController'))
.when('/project_invite_code', {templateUrl: rootPath + 'project_invite_code.html', controller: 'ProjectInviteCodeController'})
.otherwise({ .otherwise({
redirectTo: '/activites' redirectTo: '/activites'
}); });