diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 9ffac4e10..c555eb633 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -18,6 +18,7 @@ module Mobile require_relative 'apis/blog_comments' require_relative 'apis/new_comment' require_relative 'apis/praise' + require_relative 'apis/resources' class API < Grape::API version 'v1', using: :path @@ -71,6 +72,7 @@ module Mobile mount Apis::BlogComments mount Apis::NewComment mount Apis::Praise + mount Apis::Resources add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb new file mode 100644 index 000000000..fca94a642 --- /dev/null +++ b/app/api/mobile/apis/resources.rb @@ -0,0 +1,55 @@ +#coding=utf-8 +module Mobile + module Apis + class Resources < Grape::API + + resource :resources do + + desc '获取所有课件' + params do + requires :token, type: String + end + get do + authenticate! + data = current_user.course_attachments + present :data, data, with: Mobile::Entities::Attachment + present :status, 0 + + end + + + + desc '获取所有作业' + params do + requires :token, type: String + end + get 'homeworks' do + authenticate! + + homeworks = current_user.homework_commons + + present :data, homeworks, with: Mobile::Entities::Homework + present :status, 0 + + end + + desc '获取所有测验' + params do + requires :token, type: String + end + get 'exercies' do + authenticate! + + exercises = current_user.exercises + present :data, exercises, with: Mobile::Entities::Exercise + present :status, 0 + end + + + end + + + + end + end +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 3d491c8ab..daf1237cf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -145,6 +145,7 @@ class User < Principal has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'" + has_many :course_attachments , :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Course'" #### # added by bai has_many :join_in_contests, :dependent => :destroy diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index e21f5d6c7..08221d00d 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -40,7 +40,7 @@ - + @@ -49,6 +49,7 @@ + diff --git a/public/assets/wechat/add_class.html b/public/assets/wechat/add_class.html deleted file mode 100644 index 2543d5cc4..000000000 --- a/public/assets/wechat/add_class.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
-

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

-
- -
- 取消 -
-
-
- 确定 -
-
diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index a449279f8..8ec8bcaa5 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -13,9 +13,9 @@
- 新建课程 + 新建课程 加入班级 - 我的资源 + 我的资源
\ No newline at end of file diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html new file mode 100644 index 000000000..9d3bf0fda --- /dev/null +++ b/public/assets/wechat/myresource.html @@ -0,0 +1,26 @@ +
+
我的资源
+
+ {{menu}} +
+
+
+ +
+
+
+
{{r.filename}}发送
+

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

+
+
+
{{r.homework_name}}发送
+

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

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

暂无测验,
+ 请登录Trustie网站,在PC浏览器中创建测验。

+
+
diff --git a/public/assets/wechat/new_class.html b/public/assets/wechat/new_class.html new file mode 100644 index 000000000..2bb5d2aac --- /dev/null +++ b/public/assets/wechat/new_class.html @@ -0,0 +1,7 @@ +
+
新建课程
+
课程
+
班级
+
+新增班级
+ 完成 +
diff --git a/public/javascripts/wechat/controllers/add_class.js b/public/javascripts/wechat/controllers/add_class.js deleted file mode 100644 index 099bb8e8e..000000000 --- a/public/javascripts/wechat/controllers/add_class.js +++ /dev/null @@ -1,4 +0,0 @@ - -app.controller('AddClassController', ['$scope',function($scope){ - -}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/class_list.js b/public/javascripts/wechat/controllers/class_list.js index 81e485453..7c40f57a0 100644 --- a/public/javascripts/wechat/controllers/class_list.js +++ b/public/javascripts/wechat/controllers/class_list.js @@ -19,5 +19,12 @@ app.controller('ClassListController', ['$scope','config','auth','$http','$locati $location.path("/myclass").search({id: course_id}); } + vm.newClass = function(){ + $location.path("/new_class"); + } + + vm.goResource =function(){ + $location.path("/myresource"); + } }]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/myresource.js b/public/javascripts/wechat/controllers/myresource.js new file mode 100644 index 000000000..87b2a4d82 --- /dev/null +++ b/public/javascripts/wechat/controllers/myresource.js @@ -0,0 +1,30 @@ +app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){ + var vm = $scope; + vm.menus = ['课件', '作业', '测验']; + + vm.resources = []; + vm.homeworks = []; + vm.exercise = []; + + vm.tab = function(index){ + vm.currentTab = index; + if(index==1){ + $http.get(config.apiUrl + "resources?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.resources = response.data.data; + }); + } else if(index==2){ + $http.get(config.apiUrl + "resources/homeworks?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.homeworks = response.data.data; + }); + } else if(index==3){ + $http.get(config.apiUrl + "resources/exercies?token="+auth.token()).then(function(response){ + console.log(response.data); + vm.exercise = response.data.data; + }); + } + } + + vm.tab(1); +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/new_class.js b/public/javascripts/wechat/controllers/new_class.js new file mode 100644 index 000000000..488db31c6 --- /dev/null +++ b/public/javascripts/wechat/controllers/new_class.js @@ -0,0 +1,12 @@ + + +app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){ + var vm = $scope; + + vm.resources = []; + vm.homeworks = []; + vm.exercises = []; + + + +}] ); \ No newline at end of file diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js index 36f54863a..af274cfd9 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -30,9 +30,10 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func .when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController')) .when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController')) .when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController')) - .when('/add_class', makeRoute('add_class.html', 'AddClassController')) .when('/myclass', makeRoute('myclass.html', 'MyClassController')) + .when('/new_class', makeRoute('new_class.html', 'NewClassController')) .when('/class_list', makeRoute('class_list.html', 'ClassListController')) + .when('/myresource', makeRoute('myresource.html', 'MyResourceController')) .when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController')) .otherwise({ redirectTo: '/activites'