发送课程完成
This commit is contained in:
parent
c248249983
commit
b010ce2e61
|
@ -1 +1 @@
|
||||||
{"access_token":"oEEf8ZKAB8Y2G0o_xnTPkPJHKKk8iHkLC-f5ptvQ2nCMj9IpC86ivLD2-p38GfOkuG-HuQp3pWZqhs3NJXUMdPLWsr5k67hPZYuqg4ozLccx0xdLswapj0mn8ovZhK1tKIKiAFAOMO","expires_in":7200,"got_token_at":1467012449}
|
{"access_token":"m8kGwb7G0laM6-0uHmPtxETR6WJk5PgR37te_h8aBwgqGXkml2ZZAvPUBldmzF5hDZsQBHEn8PUACSL60eDKlCWigwwUJReK2wB4UbXIc1UA-rrkpHuWl84H3rcswtlvHENjAHAZWF","expires_in":7200,"got_token_at":1467472907}
|
|
@ -107,7 +107,7 @@ module Mobile
|
||||||
status = cs.join_course({role: "10", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
|
status = cs.join_course({role: "10", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
|
||||||
{
|
{
|
||||||
status: status[:state],
|
status: status[:state],
|
||||||
messsge:CoursesService::JoinCourseError.message(status[:state])
|
message:CoursesService::JoinCourseError.message(status[:state])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,25 @@ module Mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc '发送资源'
|
||||||
|
params do
|
||||||
|
requires :token, type: String
|
||||||
|
requires :course_ids, type: Array[Integer]
|
||||||
|
requires :send_id, type: Integer
|
||||||
|
end
|
||||||
|
post 'send' do
|
||||||
|
authenticate!
|
||||||
|
|
||||||
|
rs = ResourcesService.new
|
||||||
|
ori, flag, save_message = rs.send_resource_to_course(params)
|
||||||
|
if flag
|
||||||
|
present :status, 0
|
||||||
|
else
|
||||||
|
{status: -1, message: save_message.first}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1977,44 +1977,8 @@ class UsersController < ApplicationController
|
||||||
def add_exist_file_to_course
|
def add_exist_file_to_course
|
||||||
@flag = true
|
@flag = true
|
||||||
if params[:send_id].present?
|
if params[:send_id].present?
|
||||||
send_id = params[:send_id]
|
rs = ResourcesService.new
|
||||||
@ori = Attachment.find_by_id(send_id)
|
@ori, @flag, @save_message = rs.send_resource_to_course(params)
|
||||||
course_ids = params[:course_ids]
|
|
||||||
if course_ids.nil?
|
|
||||||
@flag = false
|
|
||||||
end
|
|
||||||
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
|
|
||||||
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.current.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)
|
|
||||||
end
|
|
||||||
@save_message = attach_copied_obj.errors.full_messages
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elsif params[:send_ids].present?
|
elsif params[:send_ids].present?
|
||||||
send_ids = params[:send_ids].split(",")
|
send_ids = params[:send_ids].split(",")
|
||||||
course_ids = params[:course_ids]
|
course_ids = params[:course_ids]
|
||||||
|
|
|
@ -324,7 +324,7 @@ class CoursesService
|
||||||
1, '密码错误',
|
1, '密码错误',
|
||||||
2, '课程已过期 请联系课程管理员重启课程。',
|
2, '课程已过期 请联系课程管理员重启课程。',
|
||||||
3, '您已经加入了课程',
|
3, '您已经加入了课程',
|
||||||
4, '您加入的课程不存在',
|
4, '您的邀请码不正确',
|
||||||
5, '您还未登录',
|
5, '您还未登录',
|
||||||
6, '申请成功,请等待审核完毕',
|
6, '申请成功,请等待审核完毕',
|
||||||
7, '您已经发送过申请了,请耐心等待',
|
7, '您已经发送过申请了,请耐心等待',
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
class ResourcesService
|
||||||
|
|
||||||
|
#发送资源到课程
|
||||||
|
def send_resource_to_course 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.current.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
|
||||||
|
|
||||||
|
end
|
|
@ -319,4 +319,8 @@ class UsersService
|
||||||
my_jours_arr
|
my_jours_arr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
<script src="/javascripts/wechat/controllers/class.js"></script>
|
<script src="/javascripts/wechat/controllers/class.js"></script>
|
||||||
<script src="/javascripts/wechat/controllers/class_list.js"></script>
|
<script src="/javascripts/wechat/controllers/class_list.js"></script>
|
||||||
<script src="/javascripts/wechat/controllers/myresource.js"></script>
|
<script src="/javascripts/wechat/controllers/myresource.js"></script>
|
||||||
|
<script src="/javascripts/wechat/controllers/send_class_list.js"></script>
|
||||||
<script src="/javascripts/wechat/others/routes.js"></script>
|
<script src="/javascripts/wechat/others/routes.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||||
<div loading-spinner></div>
|
<div loading-spinner></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="class-detail-name">我的动态</div>
|
||||||
|
|
||||||
<div ng-repeat="act in activities">
|
<div ng-repeat="act in activities">
|
||||||
<div ng-if="act.container_type=='Course'">
|
<div ng-if="act.container_type=='Course'">
|
||||||
<div ng-if="act.act_type=='HomeworkCommon'">
|
<div ng-if="act.act_type=='HomeworkCommon'">
|
||||||
|
|
|
@ -20,7 +20,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}]"><span class="fl ml10">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2" ng-click="sendFile(r)">发送</a></div>
|
||||||
<p ng-show="resources.length<=0" class="class-test-tip">暂无课件,<br />
|
<p ng-show="resources.length<=0" class="class-test-tip">暂无课件,<br />
|
||||||
请登录Trustie网站,在PC浏览器中上传课件。</p>
|
请登录Trustie网站,在PC浏览器中上传课件。</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,14 +37,14 @@
|
||||||
</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}]"><span class="fl ml10">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.homework_name}}</span></div>
|
||||||
<p ng-show="homeworks.length<=0" class="class-test-tip">暂无作业,<br />
|
<p ng-show="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}]"><span class="fl ml10">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.exercise_name}}</span></div>
|
||||||
<p ng-show="exercises.length<=0" class="class-test-tip">暂无小测验,<br />
|
<p ng-show="exercises.length<=0" class="class-test-tip">暂无小测验,<br />
|
||||||
请登录Trustie网站,在PC浏览器中上传小测验。</p>
|
请登录Trustie网站,在PC浏览器中上传小测验。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="post-container" style="padding-bottom: 50px;">
|
<div class="post-container" style="padding-bottom: 50px;">
|
||||||
<div loading-spinner></div>
|
<div loading-spinner></div>
|
||||||
<div class="blue-title">课程列表</div>
|
<div class="blue-title">课程列表</div>
|
||||||
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn undis" /><span class="fl ml10">未命名课程</span><img src="/images/wechat/setting.png" width="15" class="fr mr10 mt10" /></div>
|
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn undis" /><span class="fl ml10">未命名课程</span><img src="/images/wechat/setting.png" width="15" class="fr mr10 mt10" ng-click="onSetting()" /></div>
|
||||||
<ul class="class-list f13 c-grey3">
|
<ul class="class-list f13 c-grey3">
|
||||||
<li ng-click="goClass(course.id)" ng-repeat="course in courses" ng-class="{'border-bottom-none': $last}">
|
<li ng-click="goClass(course.id)" ng-repeat="course in 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" />
|
||||||
|
@ -14,8 +14,9 @@
|
||||||
|
|
||||||
<div class="bottom-tab-wrap mt10">
|
<div class="bottom-tab-wrap mt10">
|
||||||
<a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a>
|
<a ng-click="newClass()" href="javascript:void(0);" class="weixin-tab link-blue2 border-top">新建课程</a>
|
||||||
<a href="javascript:void(0);" class="weixin-tab link-blue2 border-top">加入班级</a>
|
<a ng-click="joinClass()" class="weixin-tab link-blue2 border-top">加入班级</a>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
|
@ -9,17 +9,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-class="{'undis': currentTab!=1}">
|
<div ng-class="{'undis': currentTab!=1}">
|
||||||
<div ng-repeat="r in resources" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in resources" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.filename}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a></div>
|
||||||
<p ng-show="resources.length<=0" class="class-test-tip">暂无课件,<br />
|
<p ng-show="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" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.homework_name}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in homeworks" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.homework_name}}</span></div>
|
||||||
<p ng-show="homeworks.length<=0" class="class-test-tip">暂无作业,<br />
|
<p ng-show="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" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.exercise_name}}</span><a herf="javascript:void(0);" class="fr mr10 link-blue2">发送</a></div>
|
<div ng-repeat="r in exercise" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><span class="fl ml10">{{r.exercise_name}}</span></div>
|
||||||
<p ng-show="exercise.length<=0" class="class-test-tip">暂无测验,<br />
|
<p ng-show="exercise.length<=0" class="class-test-tip">暂无测验,<br />
|
||||||
请登录Trustie网站,在PC浏览器中创建测验。</p>
|
请登录Trustie网站,在PC浏览器中创建测验。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,5 +3,8 @@
|
||||||
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" placeholder="请输入课程名" /></div>
|
<div class="course-list-row f13 c-grey3 mt30"><span class="fl ml15 c-grey3">课程</span><input class="new-class-input ml25" placeholder="请输入课程名" /></div>
|
||||||
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">班级</span><input class="new-class-input ml25" placeholder="请输入班级名" /></div>
|
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">班级</span><input class="new-class-input ml25" placeholder="请输入班级名" /></div>
|
||||||
<div class="tac"><a herf="javascript:void(0);" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
|
<div class="tac"><a herf="javascript:void(0);" class="link-blue2 f13 mt15 inline-block add-class-link">+新增班级</a></div>
|
||||||
<a href="javascript:void(0);" class="finish-btn">完成</a>
|
<a ng-click="newClass()" class="finish-btn">完成</a>
|
||||||
|
|
||||||
|
|
||||||
|
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
<div class="post-container">
|
||||||
|
<div loading-spinner></div>
|
||||||
|
|
||||||
|
<div class="blue-title">发送课程列表</div>
|
||||||
|
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn undis" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn " /><span class="fl ml10">未命名课程</span></div>
|
||||||
|
<ul class="class-list f13 c-grey3">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div class="btn2 bg-blue" ng-click="sendToCourses()">发送</div>
|
||||||
|
<my-alert message="alertService.message" title="alertService.title" visible="alertService.visible" cb="alertService.cb"></my-alert>
|
||||||
|
</div>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!-- loading toast -->
|
||||||
|
<div id="loadingToast" class="weui_loading_toast" ng-show="activeCalls>0">
|
||||||
|
<div class="weui_mask_transparent"></div>
|
||||||
|
<div class="weui_toast">
|
||||||
|
<div class="weui_loading">
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_0"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_1"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_2"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_3"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_4"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_5"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_6"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_7"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_8"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_9"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_10"></div>
|
||||||
|
<div class="weui_loading_leaf weui_loading_leaf_11"></div>
|
||||||
|
</div>
|
||||||
|
<p class="weui_toast_content">数据加载中</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -105,6 +105,10 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
|
||||||
$location.path("/invite_code").search({id: courseid});
|
$location.path("/invite_code").search({id: courseid});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.sendFile = function(r){
|
||||||
|
$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);
|
||||||
|
|
|
@ -3,28 +3,63 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
app.controller('ClassListController', ['$scope','config','auth','$http','$location', function($scope, config, auth, $http, $location){
|
app.controller('ClassListController', ['$scope', 'config', 'auth', '$http', '$location', 'alertService',
|
||||||
|
function ($scope, config, auth, $http, $location, alertService) {
|
||||||
var vm = $scope;
|
var vm = $scope;
|
||||||
vm.courses = [];
|
vm.courses = [];
|
||||||
|
|
||||||
$http.get(config.apiUrl + "courses?token="+ auth.token() + "&per_page_count=10&page=1").then(
|
vm.alertService = alertService.create();
|
||||||
function(response){
|
|
||||||
|
|
||||||
|
var loadClassList = function () {
|
||||||
|
$http.get(config.apiUrl + "courses?token=" + auth.token() + "&per_page_count=10&page=1").then(
|
||||||
|
function (response) {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
vm.courses = response.data.data;
|
vm.courses = response.data.data;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
vm.goClass = function(course_id){
|
loadClassList();
|
||||||
|
|
||||||
|
vm.goClass = function (course_id) {
|
||||||
console.log(course_id);
|
console.log(course_id);
|
||||||
$location.path("/class").search({id: course_id});
|
$location.path("/class").search({id: course_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.newClass = function(){
|
vm.newClass = function () {
|
||||||
$location.path("/new_class");
|
$location.path("/new_class");
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.goResource =function(){
|
vm.goResource = function () {
|
||||||
$location.path("/myresource");
|
$location.path("/myresource");
|
||||||
}
|
}
|
||||||
|
|
||||||
}]);
|
vm.joinClass = function () {
|
||||||
|
var code = window.prompt("请输入5位班级邀请码(不区分大小写)");
|
||||||
|
if (code && code.length == 5) {
|
||||||
|
$http.post(config.apiUrl + "courses/join", {
|
||||||
|
token: auth.token(),
|
||||||
|
invite_code: code
|
||||||
|
}).then(function (response) {
|
||||||
|
console.log(response.data);
|
||||||
|
if (response.data.status != 0) {
|
||||||
|
vm.alertService.showMessage('错误', response.data.message);
|
||||||
|
} else {
|
||||||
|
vm.alertService.showMessage('提示', '加入课程成功');
|
||||||
|
loadClassList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if(code){
|
||||||
|
vm.alertService.showMessage('错误', '邀请码格式不正确');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.onSetting = function () {
|
||||||
|
vm.alertService.showMessage('提示', '此功能正在开发中');
|
||||||
|
}
|
||||||
|
|
||||||
|
}]);
|
|
@ -1,4 +1,4 @@
|
||||||
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
|
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', '$location', function($scope, $http, auth, config, $location){
|
||||||
var vm = $scope;
|
var vm = $scope;
|
||||||
vm.menus = ['课件', '作业', '测验'];
|
vm.menus = ['课件', '作业', '测验'];
|
||||||
|
|
||||||
|
@ -27,4 +27,8 @@ app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', fun
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.tab(1);
|
vm.tab(1);
|
||||||
|
|
||||||
|
vm.sendFile = function(r){
|
||||||
|
$location.path("/send_class_list").search({id: r.id});
|
||||||
|
}
|
||||||
}] );
|
}] );
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
|
app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService', function($scope, $http, auth, config, alertService){
|
||||||
var vm = $scope;
|
var vm = $scope;
|
||||||
|
|
||||||
vm.resources = [];
|
vm.alertService = alertService.create();
|
||||||
vm.homeworks = [];
|
|
||||||
vm.exercises = [];
|
|
||||||
|
|
||||||
|
|
||||||
|
vm.newClass = function () {
|
||||||
|
vm.alertService.showMessage('提示', '此功能正在开发中');
|
||||||
|
}
|
||||||
|
|
||||||
}] );
|
}] );
|
|
@ -0,0 +1,47 @@
|
||||||
|
app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'config','auth','alertService', function($scope, $http, $routeParams, config, auth, alertService){
|
||||||
|
var vm = $scope;
|
||||||
|
var send_id = $routeParams.id;
|
||||||
|
|
||||||
|
vm.alertService = alertService.create();
|
||||||
|
vm.courses = [];
|
||||||
|
|
||||||
|
var loadClassList = function () {
|
||||||
|
$http.get(config.apiUrl + "courses?token=" + auth.token() + "&per_page_count=10&page=1").then(
|
||||||
|
function (response) {
|
||||||
|
console.log(response.data);
|
||||||
|
vm.courses = response.data.data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
loadClassList();
|
||||||
|
|
||||||
|
vm.selectCourse = function(course){
|
||||||
|
if( typeof course.checked !== 'boolean' ) course.checked = false;
|
||||||
|
course.checked = !course.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.sendToCourses = function(){
|
||||||
|
var course_ids = [];
|
||||||
|
|
||||||
|
for(var i in vm.courses){
|
||||||
|
if(vm.courses[i].checked){
|
||||||
|
course_ids.push(vm.courses[i].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$http.post(config.apiUrl + "resources/send", {
|
||||||
|
token: auth.token(), course_ids: course_ids, send_id: send_id
|
||||||
|
}).then(function(response){
|
||||||
|
console.log(response.data);
|
||||||
|
if(response.data.status == 0){
|
||||||
|
vm.alertService.showMessage('提示', '发送成功', function () {
|
||||||
|
window.history.back();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
vm.alertService.showMessage('发送出错', response.data.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}]);
|
|
@ -1,7 +1,5 @@
|
||||||
app.directive('loadingSpinner', ['$http', function ($http) {
|
app.directive('loadingSpinner', ['$http', 'config', function ($http, config) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
templateUrl: config.rootPath+ 'templates/loading.html',
|
||||||
replace: true,
|
|
||||||
template: '<div ng-show="activeCalls>0" class="loading-bg"><div class="loading-box"><img src="/images/loading.gif" alt=""/><span>加载中...</span></div></div>',
|
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -35,6 +35,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
|
||||||
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
|
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
|
||||||
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
|
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
|
||||||
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
|
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
|
||||||
|
.when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController'))
|
||||||
.otherwise({
|
.otherwise({
|
||||||
redirectTo: '/activites'
|
redirectTo: '/activites'
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue