-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,80 @@ | ||
var tutorials = []; | ||
|
||
function syncIVLE() { | ||
$.ajax({ | ||
method:'POST', | ||
url:'/api/dashboard/forceSyncIVLE', | ||
dataType:'json', | ||
success: function(data){ | ||
if (data.success){ | ||
console.log("Successful Sync"); | ||
getTutorials(); | ||
angular.module("dashboardApp", []); | ||
|
||
angular.module("dashboardApp").factory ('ivle', function ($rootScope) { | ||
var tutorials = []; | ||
|
||
var getTutorials = function () { | ||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/dashboard/getTutorials', | ||
data: { }, | ||
dataType: 'json', | ||
success: function(data) { | ||
tutorials = data.data.rows; | ||
$rootScope.$apply(); | ||
} | ||
else { | ||
console.log('Failed Sync, Error: ' + data.message); | ||
}); | ||
}; | ||
|
||
var syncIVLE = function () { | ||
$.ajax({ | ||
method:'POST', | ||
url:'/api/dashboard/forceSyncIVLE', | ||
dataType:'json', | ||
success: function(data){ | ||
if (data.success){ | ||
console.log("Successful Sync"); | ||
getTutorials(); | ||
} | ||
else { | ||
console.log('Failed Sync, Error: ' + data.message); | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
var syncUser = function() { | ||
$.ajax({ | ||
method: 'POST', | ||
url: '/api/dashboard/syncUser', | ||
dataType: 'json', | ||
success: function(data) { | ||
if (data.success) { | ||
console.log(data); | ||
} else { | ||
console.log('Failed Sync, Error: ' + data.message); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
//syncIVLE(); | ||
getTutorials(); | ||
|
||
return { | ||
tutorials: function () { | ||
return tutorials; | ||
} | ||
}); | ||
} | ||
|
||
function getTutorials() { | ||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/dashboard/getTutorials', | ||
data: { }, | ||
dataType: 'json', | ||
success: function(data) { | ||
showTutorials(data.data); | ||
} | ||
}); | ||
} | ||
|
||
function showTutorials(tuts) { | ||
for (i = 0; i < tuts.count; i++) { | ||
var tut = tuts.rows[i]; | ||
tutorials.push(tut); | ||
$('#tutorials').append(tut.coursecode + " " + tut.coursename + " <button class='btn btn-primary' id='lobby-button' data-id='" + i + "' value='' name='tut-id'> Join Class </button><br><br>"); | ||
}; | ||
}); | ||
|
||
angular.module("dashboardApp").controller ('userCtrl', function ($scope, ivle) { | ||
|
||
}); | ||
|
||
angular.module("dashboardApp").controller ('moduleCtrl', function ($scope, ivle) { | ||
$scope.ivle = ivle; | ||
|
||
$scope.redirect = function(tut) { | ||
$('#form').attr('action', 'lobby/'+tut.coursecode+'/'+tut.name) | ||
} | ||
} | ||
|
||
}); | ||
|
||
|
||
$(document).on('click', '#lobby-button', function () { | ||
var index = $(this).attr('data-id'); | ||
var tut = tutorials[index]; | ||
$(this).attr('value', tut.id); | ||
$('#form').attr('action', 'lobby/'+tut.coursecode+'/'+tut.name); | ||
}); | ||
|
||
syncIVLE(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters