Merge branch 'master' into API_Dev
Conflicts: Testing/CoursesAPI_test.py
This commit is contained in:
commit
805b952281
8 changed files with 155 additions and 241 deletions
|
@ -1,91 +0,0 @@
|
||||||
__author__ = 'etye'
|
|
||||||
import unittest
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
from Testing.config import __CONFIG__
|
|
||||||
class CoursesTestPlan(unittest.TestCase):
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
debug = __CONFIG__['DEBUG']
|
|
||||||
if debug:
|
|
||||||
url = __CONFIG__['PATHS']['DEBUG']
|
|
||||||
else:
|
|
||||||
url = __CONFIG__['PATHS']['PRODUCTION']
|
|
||||||
cls.url_ = url
|
|
||||||
request = requests.get(url+'api/qa/init')
|
|
||||||
if 200 <= request.status_code <= 299:
|
|
||||||
print 'Initialized'
|
|
||||||
|
|
||||||
def test_coursesCreate_Lecturer(self):
|
|
||||||
headers = {'content-type': 'application/json'}
|
|
||||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
|
||||||
params = {'seToken': 'seToken' }
|
|
||||||
data = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
|
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
|
||||||
'''
|
|
||||||
payload = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
|
||||||
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
|
||||||
#self.assertEquals(r.status_code, 201)
|
|
||||||
|
|
||||||
def test_coursesCreate_InvalidToken(self):
|
|
||||||
headers = {'content-type': 'application/json'}
|
|
||||||
url = self.__class__.url_+'api/courses/create/invalidToken'
|
|
||||||
data = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
params = {'seToken': 'seToken' }
|
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
|
||||||
self.assertEquals(r.status_code, 403)
|
|
||||||
'''
|
|
||||||
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
|
||||||
payload = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
|
|
||||||
'''
|
|
||||||
def test_coursesCreate_Student(self):
|
|
||||||
headers = {'content-type': 'application/json'}
|
|
||||||
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
|
||||||
params = {'seToken': 'seToken' }
|
|
||||||
data = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
|
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
|
||||||
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
|
||||||
|
|
||||||
def test_getCourseByCampusName(self):
|
|
||||||
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
|
||||||
self.assertEquals(r.status_code, 200)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
|
@ -3,7 +3,8 @@ import unittest
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from Testing.config import __CONFIG__
|
from Testing.config import __CONFIG__
|
||||||
class CoursesTestPlan(unittest.TestCase):
|
|
||||||
|
class UserTestPlan(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
debug = __CONFIG__['DEBUG']
|
debug = __CONFIG__['DEBUG']
|
||||||
|
@ -16,75 +17,80 @@ class CoursesTestPlan(unittest.TestCase):
|
||||||
if 200 <= request.status_code <= 299:
|
if 200 <= request.status_code <= 299:
|
||||||
print 'Initialized'
|
print 'Initialized'
|
||||||
|
|
||||||
def test_coursesCreate_Lecturer(self):
|
def test_courseCreate_lecturer(self):
|
||||||
headers = {'content-type': 'application/json'}
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
url = 'http://se-hub.appspot.com/api/courses/create/_QA_TOKEN_TEST_LECTURER'
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
params = {'seToken': 'seToken' }
|
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'QA COURSE',
|
'courseName': 'matan',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'projects': '@gay.lord.ultima.multi.omega',
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 201)
|
||||||
|
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
def test_courseCreate_lecturerExsistingCourse(self):
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
'''
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER']
|
||||||
payload = {
|
|
||||||
'courseName': 'QA COURSE',
|
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
# r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['LECTURER'],data=payload)
|
|
||||||
#r = requests.post('http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER',data=payload)
|
|
||||||
#self.assertEquals(r.status_code, 201)
|
|
||||||
|
|
||||||
def test_coursesCreate_InvalidToken(self):
|
|
||||||
headers = {'content-type': 'application/json'}
|
|
||||||
url = self.__class__.url_+'api/courses/create/invalidToken'
|
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'QA COURSE',
|
'courseName': 'matan',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'projects': '@gay.lord.ultima.multi.omega',
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
params = {'seToken': 'seToken' }
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
self.assertEquals(r.status_code, 403)
|
self.assertEquals(r.status_code, 403)
|
||||||
'''
|
|
||||||
payload = {'courseName': 'Advance Math', 'campusName': 'JCE', 'startDate':'2015-14-3','endDate': '2015-29-6','taskFlag': 'False'}
|
def test_courseCreate_student(self):
|
||||||
payload = {
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
'courseName': 'QA COURSE',
|
url=self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT']
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
|
||||||
}
|
|
||||||
r = requests.post(self.__class__.url_+'api/courses/create/invalidToken',data=payload)
|
|
||||||
'''
|
|
||||||
def test_coursesCreate_Student(self):
|
|
||||||
headers = {'content-type': 'application/json'}
|
|
||||||
url = self.__class__.url_+'api/courses/create/_QA_TOKEN_TEST_STUDENT'
|
|
||||||
params = {'seToken': 'seToken' }
|
|
||||||
data = {
|
data = {
|
||||||
'courseName': 'QA COURSE',
|
'courseName': 'matan',
|
||||||
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
'projects': '@gay.lord.ultima.multi.omega',
|
'projects': '@gay.lord.ultima.multi.omega',
|
||||||
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||||
}
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
#r = requests.post(self.__class__.url_+'api/courses/create/'+__CONFIG__['TOKENS']['STUDENT'],data=payload)
|
def test_courseCreate_invalidToken(self):
|
||||||
r = requests.post(url, params=params, data=json.dumps(data), headers=headers)
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
self.assertEquals(r.status_code, 403, 'message: ' + r.json()['message'])
|
url=self.__class__.url_+'api/courses/create/invalidToken'
|
||||||
|
data = {
|
||||||
|
'courseName': 'matan',
|
||||||
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
|
'projects': '@gay.lord.ultima.multi.omega',
|
||||||
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
|
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 403)
|
||||||
|
|
||||||
def test_getCourseByCampusName(self):
|
def test_courseCreate_hebrewToken(self):
|
||||||
r = requests.get(self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['TOKENS']['CAMPUS_NAME'])
|
#url = "http://localhost:8080/api/courses/create/_QA_TOKEN_TEST_LECTURER"
|
||||||
|
url=self.__class__.url_+'api/courses/create/????'
|
||||||
|
data = {
|
||||||
|
'courseName': 'matan',
|
||||||
|
'campusName': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg',
|
||||||
|
'projects': '@gay.lord.ultima.multi.omega',
|
||||||
|
'startDate': {'year': 2015, 'month' : 4, 'day' : 3},
|
||||||
|
'endDate': {'year': 2016,'month' : 6,'day' : 6}
|
||||||
|
}
|
||||||
|
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||||
|
r = requests.post(url, data=json.dumps(data), headers=headers)
|
||||||
|
self.assertEquals(r.status_code, 404)
|
||||||
|
|
||||||
|
#/api/courses/getCourseByCampusName/<string:name>
|
||||||
|
def test_getCourseByCampusName_EXSISTING_CAMPUS(self):
|
||||||
|
url=self.__class__.url_+'api/courses/getCourseByCampusName/'+__CONFIG__['CAMPUS_NAME']['JCE']
|
||||||
|
r = requests.get(url)
|
||||||
self.assertEquals(r.status_code, 200)
|
self.assertEquals(r.status_code, 200)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
angular.module('SeHub')
|
angular.module('SeHub')
|
||||||
.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope)
|
.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope)
|
||||||
{
|
{
|
||||||
$scope.threeSizedArray =[];
|
|
||||||
$scope.campusesEmpty = false;
|
$scope.campusesEmpty = false;
|
||||||
var token = $cookies['com.sehub.www'];
|
var token = $cookies['com.sehub.www'];
|
||||||
|
|
||||||
|
@ -23,9 +22,7 @@ angular.module('SeHub')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.threeSizedArray.push(tempArr);
|
$scope.threeSizedArray.push(tempArr);
|
||||||
console.log($scope.threeSizedArray); // TODO REMOVE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.goToCampus = function(campusId) // Will pass you to courses by specific campus
|
$scope.goToCampus = function(campusId) // Will pass you to courses by specific campus
|
||||||
|
@ -45,7 +42,9 @@ angular.module('SeHub')
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
});
|
});
|
||||||
if($scope.campuses != null)
|
// console.log($scope.campuses.length.toString());
|
||||||
|
|
||||||
|
if(!$scope.campuses) // If campuses is empty
|
||||||
{
|
{
|
||||||
$scope.campusesEmpty = true;
|
$scope.campusesEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,6 @@ angular.module('SeHub')
|
||||||
console.log("choose project Clicked!!");
|
console.log("choose project Clicked!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// animation
|
// animation
|
||||||
$scope.isEnterd = top.setIsEnterd;
|
$scope.isEnterd = top.setIsEnterd;
|
||||||
}]);
|
}]);
|
|
@ -14,23 +14,6 @@ angular.module('SeHub')
|
||||||
$scope.coursesEmpty = false;
|
$scope.coursesEmpty = false;
|
||||||
var campusId = $routeParams.campusId;
|
var campusId = $routeParams.campusId;
|
||||||
|
|
||||||
var displayCourses = function()
|
|
||||||
{
|
|
||||||
apiService.getCoursesByUser(token, campusId).success(function(data) // Get all the courses for display
|
|
||||||
{
|
|
||||||
$scope.courses = data;
|
|
||||||
console.log("success " + $scope.courses);
|
|
||||||
init(); // Executing the function to initialize course display
|
|
||||||
}).error(function(err)
|
|
||||||
{
|
|
||||||
console.log("error: " + err);
|
|
||||||
});
|
|
||||||
if($scope.courses = null)
|
|
||||||
{
|
|
||||||
$scope.coursesEmpty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.goToClass = function(classId)
|
$scope.goToClass = function(classId)
|
||||||
{
|
{
|
||||||
console.log("Done! " + $scope.courses);
|
console.log("Done! " + $scope.courses);
|
||||||
|
@ -102,37 +85,42 @@ angular.module('SeHub')
|
||||||
|
|
||||||
var init = function()
|
var init = function()
|
||||||
{
|
{
|
||||||
var i, j, counter = 0;
|
$scope.holdArrays = [];
|
||||||
var newLength = 0;
|
var tempArr = [];
|
||||||
|
var sizeOfSmallArrays = 3;
|
||||||
if(($scope.courses.length % 3) === 0)
|
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
||||||
{
|
if(i % sizeOfSmallArrays !== 0){
|
||||||
newLength = ($scope.courses.length / 3);
|
tempArr.push($scope.courses[i]);
|
||||||
|
}else{
|
||||||
|
if(i !== 0){
|
||||||
|
$scope.holdArrays.push(tempArr);
|
||||||
|
tempArr = [];
|
||||||
|
tempArr.push($scope.courses[i]);
|
||||||
|
}else{
|
||||||
|
tempArr.push($scope.courses[i]);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
};
|
||||||
newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up
|
$scope.holdArrays.push(tempArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("length: " + newLength);
|
//$scope.courses = ["lala", "aaa", "bbb", "ccc", "rrr"];
|
||||||
$scope.holdArrays.length = newLength;
|
|
||||||
|
|
||||||
for(j = 0; j < newLength; j++)
|
var displayCourses = function()
|
||||||
{
|
{
|
||||||
$scope.holdArrays[j] = [3]; // Creating array in size of 3 in each array cell
|
apiService.getCourseByCampusName(token).success(function(data) // Shows all classes from this campus
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < newLength; i++)
|
|
||||||
{
|
{
|
||||||
for(j = 0; j < newLength; j++)
|
$scope.courses = data;
|
||||||
|
console.log("success " + $scope.courses);
|
||||||
|
init(); // Executing the function to initialize course display
|
||||||
|
if(!$scope.courses)
|
||||||
{
|
{
|
||||||
if($scope.courses[(3*i) + j] != null)
|
$scope.coursesEmpty = true;
|
||||||
|
}
|
||||||
|
}).error(function(err)
|
||||||
{
|
{
|
||||||
$scope.holdArrays[i][j] = $scope.courses[(3*i) + j];
|
console.log("error: " + err);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log($scope.holdArrays);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,37 +41,23 @@ angular.module('SeHub')
|
||||||
|
|
||||||
var init = function()
|
var init = function()
|
||||||
{
|
{
|
||||||
var i, j, counter = 0;
|
$scope.arrayHolder = [];
|
||||||
var newLength = 0;
|
var tempArr = [];
|
||||||
|
var sizeOfSmallArrays = 3;
|
||||||
if(($scope.projects.length % 3) === 0)
|
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
||||||
{
|
if(i % sizeOfSmallArrays !== 0){
|
||||||
newLength = ($scope.projects.length / 3);
|
tempArr.push($scope.courses[i]);
|
||||||
}
|
}else{
|
||||||
else
|
if(i !== 0){
|
||||||
{
|
$scope.arrayHolder.push(tempArr);
|
||||||
newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up
|
tempArr = [];
|
||||||
}
|
tempArr.push($scope.courses[i]);
|
||||||
|
}else{
|
||||||
console.log("length: " + newLength);
|
tempArr.push($scope.courses[i]);
|
||||||
$scope.arrayHolder.length = newLength;
|
|
||||||
|
|
||||||
for(j = 0; j < newLength; j++)
|
|
||||||
{
|
|
||||||
$scope.arrayHolder[j] = [3]; // Creating array in size of 3 in each array cell
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < newLength; i++)
|
|
||||||
{
|
|
||||||
for(j = 0; j < newLength; j++)
|
|
||||||
{
|
|
||||||
if($scope.projects[(3*i) + j] != null)
|
|
||||||
{
|
|
||||||
$scope.arrayHolder[i][j] = $scope.projects[(3*i) + j];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
console.log($scope.arrayHolder);
|
$scope.arrayHolder.push(tempArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</md-content>
|
</md-content>
|
||||||
<md-card class="cardAllCampuses">
|
<md-card class="cardAllCampuses">
|
||||||
<div ng-if = "!scope.campusesEmpty">
|
<div ng-if = "!scope.campusesEmpty">
|
||||||
<div class = "allCampusesShow" flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
|
<div flex = "99" layout = "row" ng-repeat = "t in threeSizedArray" value = "{{t}}" layout-padding>
|
||||||
<div flex = "32" layout = "column" ng-repeat = "campus in t" value = "{{campus}}" >
|
<div flex = "32" layout = "column" ng-repeat = "campus in t" value = "{{campus}}" >
|
||||||
<div ng-if="t.length != 1">
|
<div ng-if="t.length != 1">
|
||||||
<md-button ng-click = "goToCampus(campus.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
<md-button ng-click = "goToCampus(campus.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
</md-card>
|
</md-card>
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="t.length == 1">
|
<div ng-if="t.length == 1">
|
||||||
<md-button ng-click = "goToCampus(campus.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
<md-button ng-click = "goToCampus(campus.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||||
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
|
<!-- <img src="{{campus.avatar_url}}" style = "width:14%; height:auto;"> -->
|
||||||
|
@ -33,9 +32,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if = "scope.campusesEmpty">>
|
<div ng-if = "scope.campusesEmpty">
|
||||||
<md-card>
|
<md-card layout-padding>
|
||||||
You Are Not Related To Any Course, You Can Join A Course By Press 'Join'.
|
You Are Not Related To Any Campus, You May Join A Campus.
|
||||||
</md-card>
|
</md-card>
|
||||||
</div>
|
</div>
|
||||||
</md-card>
|
</md-card>
|
||||||
|
|
|
@ -3,9 +3,39 @@
|
||||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
|
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
|
||||||
</md-content>
|
</md-content>
|
||||||
<md-card class="cardAllcourses">
|
<md-card class="cardAllcourses">
|
||||||
<div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
|
|
||||||
|
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
||||||
|
<div flex = "32" layout = "column" ng-repeat = "course in t" value = "{{course}}" >
|
||||||
|
<div ng-if = "scope.coursesEmpty">
|
||||||
|
<div ng-if="t.length != 1">
|
||||||
|
<md-button ng-click = "goToClass(course.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
|
||||||
|
<md-card style="width:97%;height:97%">
|
||||||
|
<md-card-content>
|
||||||
|
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
|
||||||
|
</md-card-content>
|
||||||
|
</md-2card>
|
||||||
|
</md-button>
|
||||||
|
</div>
|
||||||
|
<div ng-if="t.length == 1">
|
||||||
|
<md-button ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
|
||||||
|
<md-card style="width:97%;height:97%">
|
||||||
|
<md-card-content>
|
||||||
|
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
|
||||||
|
</md-card-content>
|
||||||
|
</md-card>
|
||||||
|
</md-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<div ng-if = "!scope.coursesEmpty">
|
||||||
|
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
|
||||||
<div flex ="32" layout = "column" ng-repeat = "course in t" value = "{{course}}" layout-padding>
|
<div flex ="32" layout = "column" ng-repeat = "course in t" value = "{{course}}" layout-padding>
|
||||||
<div ng-of = "!scope.coursesEmpty">
|
<div ng-if = "!scope.coursesEmpty">
|
||||||
<md-card ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "campusCard">
|
<md-card ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "campusCard">
|
||||||
{{course.id}}
|
{{course.id}}
|
||||||
</md-card>
|
</md-card>
|
||||||
|
@ -14,9 +44,8 @@
|
||||||
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
You Are Not Related To Any Course, You May Join Any Course You Wish.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
</md-card>
|
</md-card>
|
||||||
<!-- <md-button ng-click="joinCourseClicked()" ng class="md-raised md-primary">Join Class</md-button> -->
|
|
||||||
<div ng-if="user.isLecturer"> <!-- Lecturer Mode -->
|
<div ng-if="user.isLecturer"> <!-- Lecturer Mode -->
|
||||||
<div layout="row">
|
<div layout="row">
|
||||||
<div layout-margin layout-padding>
|
<div layout-margin layout-padding>
|
||||||
|
|
Loading…
Reference in a new issue