Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend', ['ngRoute', 'ngLocale', 'ngSanitize', 'ui.bootstrap', 'angular-loading-bar']);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.constant('eCompletionStatus', {
- NotStarted: 400,
- Started: 401,
- Completed: 402
- });
- app.constant('eModuleType', {
- Text: 300,
- Test: 301,
- Survey: 302,
- Video: 303,
- Live: 304,
- Scorm: 305,
- GuidedNote: 306,
- GuidedNoteExport: 307
- });
- app.constant('eTextCompletionMode', {
- AtOpening: 800,
- AtLastPage: 801
- });
- app.constant('eNoteTarget', {
- Installation: 200,
- Course: 201,
- Module: 202
- });
- app.constant('eTestRepeatMode', {
- Free: 2000,
- Limited: 2001,
- LimitedByDay: 2002
- });
- app.constant('eVideoCompletionMode', {
- AtStart: 2200,
- AtEnd: 2201
- });
- app.constant('eVideoTemplate', {
- BigVideo: 2300,
- BigText: 2301,
- BigSlides: 2302,
- AudioOnly: 2303
- });
- app.constant('eSurveyQuestionType', {
- SingleChoice: 4000,
- MultipleChoice: 4001,
- FreeText: 4002
- });
- app.constant('eSurveyDetailsMode', {
- NoDetail: 4500,
- DetailsAllowed: 4501,
- DetailsRequired: 4502
- });
- app.constant('eGuidedNoteFieldType', {
- ShortText: 5000,
- LongText: 5001,
- Number: 5002
- });
- })(angular);
- (function (angular, ApLearning, bootbox, Gauge) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.service('bootbox', function () {
- return bootbox;
- });
- app.service('Gauge', function () {
- return Gauge;
- });
- app.service('ApLearning', function () {
- return ApLearning;
- });
- app.service('Installation', ['$http', '$q', 'ApLearning', function ($http, $q, ApLearning) {
- var installation = null;
- function init() {
- var deferred = $q.defer();
- if (installation) {
- deferred.resolve();
- } else {
- $http({
- url: '/' + ApLearning.lang + '/App/GetInstallation',
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- installation = data.result;
- deferred.resolve();
- } else {
- deferred.reject();
- }
- }).error(function () {
- deferred.reject();
- });
- }
- return deferred.promise;
- }
- return {
- init: init,
- getInstallation: function () {
- return installation;
- }
- }
- }]);
- app.service('SessionManager', ['$http', '$timeout', 'ApLearning', '$q', 'eCompletionStatus', function ($http, $timeout, ApLearning, $q, eCompletionStatus) {
- var id = null, sessionID = null, courseID = null, unitID = null, moduleID = null, timer = null;
- function startSession(courseid, unitid, moduleid) {
- var deferred = $q.defer();
- courseid = courseid || null;
- unitid = unitid || null;
- moduleid = moduleid || null;
- if (id === null || courseid !== courseID || unitid !== unitID || moduleid !== moduleID) {
- if (timer) {
- $timeout.cancel(timer);
- }
- courseID = courseid;
- unitID = unitid;
- moduleID = moduleid;
- id = null;
- sessionID = null;
- $http({
- url: '/' + ApLearning.lang + '/App/StartSession',
- method: 'POST',
- data: {courseID: courseID, unitID: unitID, moduleID: moduleID},
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- id = data.id;
- sessionID = data.sessionID;
- timer = $timeout(ping, ApLearning.sessionTickSeconds * 1000);
- deferred.resolve({id: id, sessionID: sessionID});
- } else {
- deferred.reject(data.error);
- }
- }).error(function () {
- deferred.reject();
- });
- } else {
- deferred.resolve();
- }
- return deferred.promise;
- }
- function ping() {
- if (id && sessionID) {
- $http({
- url: '/' + ApLearning.lang + '/App/Ping',
- method: 'POST',
- data: {id: id, sessionID: sessionID},
- responseType: 'json'
- }).success(function () {
- timer = $timeout(ping, ApLearning.sessionTickSeconds * 1000);
- }).error(function () {
- timer = $timeout(ping, ApLearning.sessionTickSeconds * 1000);
- });
- }
- }
- function setStarted(courseid, unitid, moduleid, status) {
- var deferred = $q.defer(),
- req = {
- SessionID: id,
- SessionCode: sessionID,
- CourseID: courseid,
- UnitID: unitid,
- ModuleID: moduleid,
- CompletionStatus: eCompletionStatus.Started,
- CustomStatus: status
- };
- if (courseid == courseID && unitid == unitID && moduleid == moduleID) {
- $http({
- url: '/' + ApLearning.lang + '/App/SetStatus',
- method: 'POST',
- data: req,
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- deferred.resolve();
- } else {
- deferred.reject(data.error);
- }
- }).error(function () {
- deferred.reject();
- });
- } else {
- deferred.reject("Session changed");
- }
- return deferred.promise;
- }
- function setCompleted(courseid, unitid, moduleid, status, pointsMin, pointsMax, pointsRaw) {
- var deferred = $q.defer(),
- req = {
- SessionID: id,
- SessionCode: sessionID,
- CourseID: courseid,
- UnitID: unitid,
- ModuleID: moduleid,
- CompletionStatus: eCompletionStatus.Completed,
- CustomStatus: status,
- PointsMin: pointsMin,
- PointsMax: pointsMax,
- PointsRaw: pointsRaw
- };
- if (courseid == courseID && unitid == unitID && moduleid == moduleID) {
- $http({
- url: '/' + ApLearning.lang + '/App/SetStatus',
- method: 'POST',
- data: req,
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- deferred.resolve();
- } else {
- deferred.reject(data.error);
- }
- }).error(function () {
- deferred.reject();
- });
- } else {
- deferred.reject("Session changed");
- }
- return deferred.promise;
- }
- function setCustomStatus(courseid, unitid, moduleid, status) {
- var deferred = $q.defer(),
- req = {
- SessionID: id,
- SessionCode: sessionID,
- CourseID: courseid,
- UnitID: unitid,
- ModuleID: moduleid,
- CustomStatus: status
- };
- if (courseid == courseID && unitid == unitID && moduleid == moduleID) {
- $http({
- url: '/' + ApLearning.lang + '/App/SetCustomStatus',
- method: 'POST',
- data: req,
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- deferred.resolve();
- } else {
- deferred.reject(data.error);
- }
- }).error(function () {
- deferred.reject();
- });
- } else {
- deferred.reject("Session changed");
- }
- return deferred.promise;
- }
- function stopSession() {
- id = null;
- sessionID = null;
- }
- function getSessionData() {
- return {
- id: id,
- sessionID: sessionID
- };
- }
- return {
- startSession: startSession,
- setStarted: setStarted,
- setCompleted: setCompleted,
- setCustomStatus: setCustomStatus,
- stopSession: stopSession,
- getSessionData: getSessionData
- };
- }]);
- app.service('Structure', ['$http', '$q', 'ApLearning', function ($http, $q, ApLearning) {
- var structure = null, courses = {};
- function init() {
- var deferred = $q.defer();
- if (structure) {
- deferred.resolve();
- } else {
- $http({
- url: '/' + ApLearning.lang + '/App/GetCourses',
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- var i, item, j, unit, k, module, previousModule = null;
- if (data.ok) {
- structure = data.courses;
- // Creo i dizionari per l'accesso diretto
- for (i in structure) {
- item = structure[i];
- courses[item.ID] = item;
- item.units = {};
- previousModule = null;
- for (j in item.Course.UnitsStatus) {
- unit = item.Course.UnitsStatus[j];
- item.units[unit.Unit.ID] = unit;
- unit.modules = {};
- for (k in unit.ModulesStatus) {
- module = unit.ModulesStatus[k];
- unit.modules[module.Module.ID] = module;
- if (previousModule) {
- previousModule.next = module;
- module.prev = previousModule;
- }
- previousModule = module;
- }
- }
- }
- deferred.resolve();
- } else {
- deferred.reject();
- }
- }).error(function () {
- deferred.reject();
- });
- }
- return deferred.promise;
- }
- return {
- init: init,
- getStructure: function () {
- return structure;
- },
- getCourse: function (courseId) {
- return courses[courseId];
- },
- getUnit: function (courseId, unitId) {
- return courses[courseId].units[unitId];
- },
- getModule: function (courseId, unitId, moduleId) {
- return courses[courseId].units[unitId].modules[moduleId];
- },
- reload: function () {
- structure = null;
- courses = {};
- return init();
- }
- }
- }]);
- app.service('UserNotes', ['$http', '$q', 'ApLearning', 'eNoteTarget', function ($http, $q, ApLearning, eNoteTarget) {
- var notes = null;
- function loadNotes() {
- var deferred = $q.defer();
- if (notes != null) {
- deferred.resolve(notes);
- } else {
- $http({
- url: '/' + ApLearning.lang + '/App/GetNotes',
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- notes = data.notes;
- deferred.resolve(notes);
- } else {
- deferred.reject(data.error);
- }
- }).error(function () {
- deferred.reject('Network error');
- });
- }
- return deferred.promise;
- }
- return {
- getAllNotes: function () {
- var deferred = $q.defer();
- loadNotes().then(function (data) {
- deferred.resolve(data);
- }, function (error) {
- deferred.reject(error);
- });
- return deferred.promise;
- },
- getNotes: function (courseID, moduleID) {
- var deferred = $q.defer();
- loadNotes().then(function () {
- var res = [], i, item;
- for (i in notes) {
- item = notes[i];
- if (!courseID && !moduleID && item.Note.Target == eNoteTarget.Installation) {
- res.push(item);
- continue;
- }
- if (moduleID && item.Note.Target == eNoteTarget.Module && item.Note.TargetEntityID == moduleID) {
- res.push(item);
- continue;
- }
- if (courseID && item.Note.Target == eNoteTarget.Course && item.Note.TargetEntityID == courseID) {
- res.push(item);
- }
- }
- deferred.resolve(res);
- }, function (error) {
- deferred.reject(error);
- });
- return deferred.promise;
- },
- reload: function () {
- notes = null;
- return loadNotes();
- }
- }
- }]);
- })(angular, ApLearning, bootbox, Gauge);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.config(['$routeProvider', function ($routeProvider) {
- $routeProvider
- .when('/dashboard', {
- templateUrl: '/App/Views/dashboard/dashboard.html',
- controller: 'DashboardController'
- })
- .when('/calendar', {
- templateUrl: '/App/Views/calendar.html',
- controller: 'CalendarEventsController'
- })
- .when('/statistics', {
- templateUrl: '/App/Views/statistics/statistics.html',
- controller: 'StatisticsController'
- })
- .when('/course/:courseId/:unitId?', {
- templateUrl: '/App/Views/course/course.html',
- controller: 'CourseController'
- })
- .when('/teachers/:courseId', {
- templateUrl: '/App/Views/course/teachers.html',
- controller: 'CourseController'
- })
- .when('/library/:courseId', {
- templateUrl: '/App/Views/course/library.html',
- controller: 'CourseController'
- })
- .when('/completed/:courseId', {
- templateUrl: '/App/Views/course/completed.html',
- controller: 'CourseController'
- })
- .when('/forums/:courseId', {
- templateUrl: '/App/Views/course/forum/forums.html',
- controller: 'CourseController'
- })
- .when('/module/:courseId/:unitId/:moduleId', {
- templateUrl: '/App/Views/module/module.html',
- controller: 'ModuleController'
- })
- .otherwise({
- redirectTo: '/dashboard'
- });
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('HeaderController', ['$scope', 'ApLearning', 'Installation', 'Labels', '$location', '$window', '$rootScope',
- function ($scope, ApLearning, Installation, Labels, $location, $window, $rootScope) {
- $scope.ApLearning = ApLearning;
- $scope.Installation = null;
- $scope.Labels = Labels;
- $scope.helpVisible = false;
- $scope.notesVisible = false;
- $scope.section = 'dashboard';
- $scope.toggleHelp = function () {
- $scope.helpVisible = !$scope.helpVisible;
- if ($scope.helpVisible) {
- $rootScope.$broadcast('popupOpen', 'help');
- }
- };
- $scope.toggleNotes = function () {
- $scope.notesVisible = !$scope.notesVisible;
- if ($scope.notesVisible) {
- $rootScope.$broadcast('popupOpen', 'notes');
- }
- };
- $scope.goToHome = function () {
- $location.path('/dashboard');
- };
- $scope.goToCalendar = function () {
- $location.path('/calendar');
- };
- $scope.goToStatistics = function () {
- $location.path('/statistics');
- };
- $scope.toggleLang = function () {
- $window.location.href = ApLearning.lang == 'it' ? '/en/App#' + $location.path() : '/it/App#' + $location.path();
- };
- Installation.init().then(function () {
- $scope.Installation = Installation.getInstallation();
- });
- function parseLocation() {
- var parts = $location.path().split('/');
- if (parts.length > 1) {
- $scope.section = parts[1];
- } else {
- $scope.section = "dashboard";
- }
- }
- $scope.$on("$routeChangeSuccess", function () {
- parseLocation();
- $scope.helpVisible = false;
- $scope.notesVisible = false;
- });
- $scope.$on("popupOpen", function (e, popup) {
- if (popup != 'help') {
- $scope.helpVisible = false;
- }
- if (popup != 'notes') {
- $scope.notesVisible = false;
- }
- });
- }]);
- app.controller('HelpTopicController', ['$scope', function ($scope) {
- $scope.topicVisible = false;
- $scope.toggleTopicVisible = function () {
- $scope.topicVisible = !$scope.topicVisible;
- }
- }]);
- app.controller('CalendarEventsController', ['$scope', '$http', 'ApLearning', 'bootbox', 'Labels',
- function ($scope, $http, ApLearning, bootbox, Labels) {
- var now = new Date(), year = now.getFullYear(), month = now.getMonth() + 1;
- $scope.Labels = Labels;
- $scope.date = null;
- $scope.calendar = null;
- $scope.events = null;
- $scope.next = function () {
- month++;
- if (month > 12) {
- month = 1;
- year++;
- }
- loadCalendar();
- };
- $scope.prev = function () {
- month--;
- if (month < 1) {
- month = 12;
- year--;
- }
- loadCalendar();
- };
- function loadCalendar() {
- $http({
- url: '/' + ApLearning.lang + '/App/GetMonthEvents/' + year + '-' + month,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.date = data.events.date;
- $scope.calendar = data.events.calendar;
- $scope.events = data.events.events;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadCalendar();
- $("body").css("background-image", "url('" + ApLearning.defaultBackgroundUrl + "')");
- }]);
- app.controller('CalendarItemController', ['$scope', function ($scope) {
- $scope.detailVisible = false;
- $scope.toggleDetail = function () {
- $scope.detailVisible = !$scope.detailVisible;
- };
- }]);
- app.controller('NotesListController', ['$scope', 'Labels', 'UserNotes', '$http', 'ApLearning', 'bootbox', '$rootScope', '$window',
- function ($scope, Labels, UserNotes, $http, ApLearning, bootbox, $rootScope, $window) {
- var pageSize = 10;
- $scope.notes = null;
- $scope.page = 0;
- $scope.pages = 1;
- $scope.pageNotes = null;
- $scope.currentNote = null;
- $scope.next = function () {
- $scope.page++;
- setupPage();
- };
- $scope.prev = function () {
- $scope.page--;
- setupPage();
- };
- $scope.selectAll = function () {
- var i, item, select = false;
- for (i in $scope.pageNotes) {
- item = $scope.pageNotes[i];
- if (!item.Selected) {
- select = true;
- break;
- }
- }
- for (i in $scope.pageNotes) {
- item = $scope.pageNotes[i];
- item.Selected = select;
- }
- };
- $scope.deleteMulti = function () {
- var ids = [];
- $scope.pageNotes.forEach(function (item) {
- if (item.Selected) {
- ids.push(item.ID);
- }
- });
- if (ids.length) {
- bootbox.confirm(Labels.confirmDeleteNotes, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/DeleteNoteMulti/' + ids.join('-'),
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- UserNotes.reload().then(function () {
- $rootScope.$broadcast('NotesChanged');
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- });
- } else {
- bootbox.alert(Labels.chooseNotes);
- }
- };
- $scope.exportMulti = function () {
- var ids = [], url;
- $scope.pageNotes.forEach(function (item) {
- if (item.Selected) {
- ids.push(item.ID);
- }
- });
- if (ids.length) {
- url = '/' + ApLearning.lang + '/App/ExportMulti/' + ids.join('-');
- $window.location.href = url;
- } else {
- bootbox.alert(Labels.chooseNotes);
- }
- };
- $scope.backToListing = function () {
- $scope.currentNote = null;
- };
- $scope.exportSingle = function () {
- $scope.pageNotes.forEach(function (item) {
- item.Selected = item.ID == $scope.currentNote.ID;
- });
- $scope.exportMulti();
- };
- $scope.deleteSingle = function () {
- bootbox.confirm(Labels.confirmDeleteNote, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/DeleteNoteMulti/' + $scope.currentNote.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- UserNotes.reload().then(function () {
- $rootScope.$broadcast('NotesChanged');
- $scope.backToListing();
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- });
- };
- $scope.open = function (note) {
- $scope.currentNote = note;
- };
- $scope.save = function (frm) {
- if (frm.$valid) {
- $http({
- url: '/' + ApLearning.lang + '/App/SaveNote',
- method: 'POST',
- data: JSON.stringify($scope.currentNote.Note),
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- UserNotes.reload().then(function () {
- $rootScope.$broadcast('NotesChanged');
- //bootbox.alert(Labels.noteSaved);
- frm.$setPristine();
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- };
- $scope.$on('NotesChanged', loadNotes);
- function setupPage() {
- var mod = $scope.notes.length % pageSize,
- pages = ($scope.notes.length - mod) / pageSize;
- $scope.notes.forEach(function (item) {
- item.Selected = false;
- });
- $scope.pages = pages + (mod ? 1 : 0);
- $scope.pageNotes = $scope.notes.slice($scope.page * pageSize, ($scope.page + 1) * pageSize);
- }
- function loadNotes() {
- UserNotes.getAllNotes().then(function (notes) {
- $scope.notes = notes;
- setupPage();
- });
- }
- loadNotes();
- }]);
- app.controller('NotesWidgetController', ['$scope', 'Labels', '$routeParams', 'UserNotes', '$http', 'eNoteTarget', 'ApLearning', 'bootbox', '$rootScope',
- function ($scope, Labels, $routeParams, UserNotes, $http, eNoteTarget, ApLearning, bootbox, $rootScope) {
- $scope.Labels = Labels;
- $scope.visible = false;
- $scope.notes = null;
- $scope.currentNoteID = null;
- $scope.currentNote = null;
- $scope.toggle = function () {
- $scope.visible = !$scope.visible;
- if ($scope.visible) {
- $rootScope.$broadcast('popupOpen', 'notesWidget');
- }
- };
- $scope.goToNote = function (noteID) {
- if (noteID >= 0 && $scope.notes && $scope.notes.length > noteID) {
- $scope.currentNote = $scope.notes[noteID].Note;
- $scope.currentNoteID = noteID;
- } else {
- $scope.currentNote = {ID: 0, Date: new Date()};
- $scope.currentNoteID = -1;
- }
- };
- $scope.saveNote = function (frm) {
- if (frm.$valid) {
- if (!$scope.currentNote.ID) {
- if ($routeParams.moduleId) {
- $scope.currentNote.Target = eNoteTarget.Module;
- $scope.currentNote.TargetEntityID = $routeParams.moduleId;
- } else if ($routeParams.courseId) {
- $scope.currentNote.Target = eNoteTarget.Course;
- $scope.currentNote.TargetEntityID = $routeParams.courseId;
- } else {
- $scope.currentNote.Target = eNoteTarget.Installation;
- $scope.currentNote.TargetEntityID = null;
- }
- }
- $http({
- url: '/' + ApLearning.lang + '/App/SaveNote',
- method: 'POST',
- data: JSON.stringify($scope.currentNote),
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- UserNotes.reload().then(function () {
- $rootScope.$broadcast('NotesChanged');
- frm.$setPristine();
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- };
- $scope.deleteNote = function () {
- if ($scope.currentNote && $scope.currentNote.ID) {
- bootbox.confirm(Labels.confirmDeleteNote, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/DeleteNote/' + $scope.currentNote.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- UserNotes.reload().then(function () {
- $rootScope.$broadcast('NotesChanged');
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- })
- }
- });
- }
- };
- $scope.goBack = function () {
- if ($scope.currentNoteID == -1) {
- $scope.goToNote($scope.notes.length - 1);
- } else {
- if ($scope.currentNoteID > 0) {
- $scope.goToNote($scope.currentNoteID - 1);
- }
- }
- };
- $scope.goNext = function () {
- if ($scope.currentNoteID < ($scope.notes.length - 1)) {
- $scope.goToNote($scope.currentNoteID + 1);
- }
- };
- $scope.$on('NotesChanged', loadNotes);
- function loadNotes() {
- $scope.visible = false;
- UserNotes.getNotes($routeParams.courseId, $routeParams.moduleId).then(function (notes) {
- $scope.notes = notes;
- if ($scope.notes.length) {
- $scope.goToNote($scope.notes.length - 1);
- } else {
- $scope.goToNote(-1);
- }
- });
- }
- loadNotes();
- $scope.$on('$routeChangeSuccess', loadNotes);
- $scope.$on("popupOpen", function (e, popup) {
- if (popup != 'notesWidget') {
- $scope.visible = false;
- }
- });
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.directive('header', function () {
- return {
- restrict: 'E',
- templateUrl: '/App/Views/header.html',
- controller: 'HeaderController'
- }
- });
- app.directive('gauge', ['Gauge', function () {
- var link = function ($scope, jelement, attrs) {
- var canvas = jelement.find('canvas');
- var size = jelement.parent().width();
- canvas.attr('height', size + 'px').attr('width', size + 'px');
- $scope.gauge = new Gauge(canvas[0], {
- color: "#FFF",
- bgcolor: "rgba(255,255,255,0.5)",
- font: "30px Helvetica"
- });
- $scope.gauge.value($scope.value || 0);
- $scope.$watch('value', function () {
- $scope.gauge.value($scope.value || 0);
- })
- };
- return {
- restrict: 'E',
- link: link,
- scope: {value: '='},
- template: '<canvas />'
- }
- }]);
- app.directive('noteslist', function () {
- return {
- restrict: 'E',
- templateUrl: '/App/Views/notes.html',
- controller: 'NotesListController'
- }
- });
- app.directive('note', function () {
- return {
- restrict: 'E',
- templateUrl: '/App/Views/notes_widget.html',
- controller: 'NotesWidgetController'
- }
- });
- app.directive('resizedimage', function () {
- function link($scope, element, attrs) {
- $scope.width = attrs.width;
- $scope.height = attrs.height;
- $scope.title = attrs.title || '';
- }
- return {
- restrict: 'E',
- template: '<img ng-src="{{ url }}" title="{{ title }}" alt="{{ title }}" />',
- replace: true,
- link: link,
- scope: {
- imageurl: '='
- },
- controller: ['$scope', function ($scope) {
- function loadImage() {
- $scope.url = '/img/Resize/' + $scope.width + 'x' + $scope.height + $scope.imageurl;
- }
- $scope.$watch('imageurl', loadImage)
- }]
- };
- });
- app.directive('fittedimage', function () {
- function link($scope, element, attrs) {
- $scope.width = attrs.width;
- $scope.height = attrs.height;
- $scope.title = attrs.title || '';
- }
- return {
- restrict: 'E',
- template: '<img ng-src="{{ url }}" title="{{ title }}" alt="{{ title }}" />',
- replace: true,
- link: link,
- scope: {
- imageurl: '='
- },
- controller: ['$scope', function ($scope) {
- function loadImage() {
- $scope.url = '/img/Fit/' + $scope.width + 'x' + $scope.height + $scope.imageurl;
- }
- $scope.$watch('imageurl', loadImage)
- }]
- };
- });
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('DashboardController', ['$scope', '$http', 'ApLearning', 'Installation', 'SessionManager', 'Structure', 'Labels', 'bootbox', 'eCompletionStatus', '$location',
- function ($scope, $http, ApLearning, Installation, SessionManager, Structure, Labels, bootbox, eCompletionStatus, $location) {
- $scope.Labels = Labels;
- $scope.eCompletionStatus = eCompletionStatus;
- $scope.courses = null;
- $scope.Installation = null;
- $scope.goToCourse = function (id) {
- $location.path('/course/' + id);
- };
- Installation.init().then(function () {
- $scope.Installation = Installation.getInstallation();
- });
- SessionManager.startSession();
- Structure.init().then(function () {
- $scope.courses = Structure.getStructure();
- $("body").css("background-image", "url('" + ApLearning.defaultBackgroundUrl + "')");
- });
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('CourseController', ['$scope', '$routeParams', '$location', 'Structure', 'SessionManager', 'Labels',
- function ($scope, $routeParams, $location, Structure, SessionManager, Labels) {
- $scope.courseId = Number($routeParams.courseId);
- $scope.unitId = $routeParams.unitId ? Number($routeParams.unitId) : null;
- $scope.Labels = Labels;
- $scope.section = "course";
- $scope.goToDashboard = function () {
- $location.path('/dashboard');
- };
- $scope.goToCourse = function () {
- $location.path('/course/' + $scope.courseId);
- };
- $scope.goToCompleted = function () {
- $location.path('/completed/' + $scope.courseId);
- };
- $scope.goToModule = function (unitId, module) {
- if (module.CanAccess) {
- $location.path('/module/' + $scope.courseId + '/' + unitId + '/' + module.Module.ID);
- }
- };
- $scope.goToTeachers = function () {
- $location.path('/teachers/' + $scope.courseId);
- };
- $scope.goToLibrary = function () {
- $location.path('/library/' + $scope.courseId);
- };
- $scope.goToForums = function () {
- var url = '/forums/' + $scope.courseId;
- if ($location.path() == url) {
- document.location.reload();
- }
- else {
- $location.path(url);
- }
- };
- $scope.course = null;
- Structure.init().then(function () {
- var i;
- $scope.course = Structure.getCourse($scope.courseId);
- if ($scope.course.Course.UnitsStatus.length === 1) {
- for (i in $scope.course.units) {
- $scope.course.units[i].showContent = true;
- break;
- }
- }
- if ($scope.course.CustomBackgroundUrl) {
- $("body").css("background-image", "url('" + $scope.course.CustomBackgroundUrl + "')");
- }
- });
- SessionManager.startSession($scope.courseId);
- function parseLocation() {
- var parts = $location.path().split('/');
- if (parts.length > 1) {
- $scope.section = parts[1];
- } else {
- $scope.section = "dashboard";
- }
- }
- $scope.$on("$routeChangeSuccess", function () {
- parseLocation();
- });
- }]);
- app.controller('TeacherBoxController', ['$scope', '$http', 'bootbox', 'ApLearning', function ($scope, $http, bootbox, ApLearning) {
- $scope.request = {Text: null};
- $scope.contactBoxOpen = false;
- $scope.formSubmitted = false;
- $scope.messageSent = false;
- $scope.toggleContactBox = function () {
- $scope.contactBoxOpen = !$scope.contactBoxOpen
- };
- $scope.send = function (frm) {
- var req;
- $scope.formSubmitted = true;
- console.log(frm);
- if (frm.$valid) {
- req = {
- CourseID: $scope.courseId,
- TeacherID: $scope.teacher.ID,
- MessageText: $scope.request.Text
- };
- $http({
- url: '/' + ApLearning.lang + '/App/SendMessageToTeacher',
- method: 'POST',
- data: JSON.stringify(req),
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- $scope.messageSent = true;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- })
- }
- };
- }]);
- app.controller('ForumsController', ['$scope', '$routeParams', '$http', 'ApLearning', 'Labels', 'bootbox', '$q',
- function ($scope, $routeParams, $http, ApLearning, Labels, bootbox, $q) {
- $scope.courseId = Number($routeParams.courseId);
- $scope.Labels = Labels;
- $scope.forums = null;
- $scope.currentForum = null;
- $scope.threads = null;
- $scope.newThreadSubmitted = false;
- $scope.newThread = null;
- $scope.threadsPaging = {
- currentPage: 1,
- pageSize: 10,
- threadsCount: null,
- pager: []
- };
- $scope.currentThread = null;
- $scope.posts = null;
- $scope.newPostSubmitted = false;
- $scope.postsPaging = {
- currentPage: 1,
- pageSize: 10,
- postsCount: null,
- pager: []
- };
- $scope.currentPost = null;
- $scope.goToCourse = function () {
- $location.path('/course/' + $scope.courseId);
- };
- $scope.goToList = function () {
- $scope.currentPost = null;
- $scope.posts = null;
- $scope.currentThread = null;
- $scope.threads = null;
- $scope.currentForum = null;
- };
- $scope.goToThreads = function () {
- $scope.currentPost = null;
- $scope.posts = null;
- $scope.currentThread = null;
- };
- $scope.goToForum = function () {
- $scope.currentThread = null;
- };
- $scope.openForum = function (forum) {
- $scope.currentForum = forum;
- $scope.threadsPaging.currentPage = 1;
- return loadThreads();
- };
- $scope.showNewThread = function () {
- $scope.newThreadSubmitted = false;
- $scope.newThread = {
- ID: 0,
- ForumID: $scope.currentForum.ID
- };
- };
- $scope.hideNewThread = function () {
- $scope.newThreadSubmitted = false;
- $scope.newThread = null;
- };
- $scope.createNewThread = function (frm) {
- var req = {
- courseID: $scope.courseId,
- forumID: $scope.currentForum.ID,
- thread: $scope.newThread,
- text: $scope.newThread.Text
- };
- $scope.newThreadSubmitted = true;
- if (frm.$valid) {
- $http({
- url: '/' + ApLearning.lang + '/App/CreateThread',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json',
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- $scope.newThread = null;
- $scope.newThreadSubmitted = false;
- $scope.postsPaging.currentPage = 1;
- $scope.threadsPaging.currentPage = 1;
- loadForums().then(function () {
- var i, item;
- // Recupero il precedente forum corrente
- for (i in $scope.forums) {
- item = $scope.forums[i];
- if (item.ID == $scope.currentForum.ID) {
- $scope.openForum(item).then(function () {
- $scope.currentThread = data.entity;
- loadPosts();
- });
- break;
- }
- }
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error.');
- });
- }
- };
- $scope.goToThreadPage = function (pageNr) {
- $scope.threadsPaging.currentPage = pageNr;
- loadThreads();
- };
- $scope.nextThreadPage = function () {
- $scope.threadsPaging.currentPage++;
- loadThreads();
- };
- $scope.prevThreadPage = function () {
- $scope.threadsPaging.currentPage--;
- loadThreads();
- };
- $scope.goToPostPage = function (pageNr) {
- $scope.postsPaging.currentPage = pageNr;
- loadPosts();
- };
- $scope.nextPostPage = function () {
- $scope.postsPaging.currentPage++;
- loadPosts();
- };
- $scope.prevPostPage = function () {
- $scope.postsPaging.currentPage--;
- loadPosts();
- };
- $scope.openThread = function (thread) {
- $scope.currentThread = thread;
- $scope.postsPaging.currentPage = 1;
- $scope.currentPost = null;
- loadPosts();
- };
- $scope.showPostReply = function (post) {
- var reRx = /^[\s]*re:/i;
- post = post ? angular.copy(post) : {
- ThreadID: $scope.currentThread.ID,
- Title: $scope.currentThread.Thread.Title
- };
- post.ID = 0;
- if (!reRx.test(post.Title)) {
- post.Title = 'Re: ' + post.Title;
- }
- if (post.Text) {
- post.Text = '[quote]' + post.Text + '[/quote]';
- }
- $scope.currentPost = post;
- $scope.newPostSubmitted = post.ID > 0;
- };
- $scope.editPost = function (post) {
- $scope.newPostSubmitted = true;
- $scope.currentPost = angular.copy(post);
- };
- $scope.savePost = function (frm) {
- var req, isNew;
- $scope.newPostSubmitted = true;
- if (frm.$valid) {
- isNew = $scope.currentPost.ID == 0;
- req = {
- courseID: $scope.courseId,
- forumID: $scope.currentForum.ID,
- threadID: $scope.currentThread.ID,
- pageSize: $scope.postsPaging.pageSize,
- post: $scope.currentPost
- };
- $http({
- url: '/' + ApLearning.lang + '/App/SavePost',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json',
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- $scope.postsPaging.currentPage = data.pageNr;
- loadForums().then(function () {
- loadThreads().then(function () {
- loadPosts();
- $scope.currentPost = null;
- $scope.newPostSubmitted = false;
- });
- })
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert("Network error");
- });
- }
- };
- $scope.deleteCurrentPost = function () {
- bootbox.confirm(Labels.confirmPostDeletion, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/DeletePost/' + $scope.courseId + '-' + $scope.currentForum.ID + '-' + $scope.currentThread.ID + '-' + $scope.currentPost.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.currentPost = null;
- loadForums().then(function () {
- loadThreads().then(function () {
- loadPosts();
- });
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error')
- });
- }
- });
- };
- $scope.deleteCurrentThread = function () {
- bootbox.confirm(Labels.confirmThreadDeletion, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/DeleteThread/' + $scope.courseId + '-' + $scope.currentForum.ID + '-' + $scope.currentThread.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.currentPost = null;
- loadForums().then(function () {
- loadThreads().then(function () {
- $scope.goToThreads();
- });
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error')
- });
- }
- });
- };
- $scope.lockCurrentThread = function () {
- bootbox.confirm(Labels.confirmThreadLocking, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/LockThread/' + $scope.courseId + '-' + $scope.currentForum.ID + '-' + $scope.currentThread.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.currentPost = null;
- loadForums().then(function () {
- loadThreads().then(function () {
- var i, item;
- for (i in $scope.threads) {
- item = $scope.threads[i];
- if (item.ID == $scope.currentThread.ID) {
- $scope.currentThread = item;
- break;
- }
- }
- loadPosts();
- });
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error')
- });
- }
- });
- };
- $scope.unlockCurrentThread = function () {
- bootbox.confirm(Labels.confirmThreadUnlocking, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/App/UnlockThread/' + $scope.courseId + '-' + $scope.currentForum.ID + '-' + $scope.currentThread.ID,
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.currentPost = null;
- loadForums().then(function () {
- loadThreads().then(function () {
- var i, item;
- for (i in $scope.threads) {
- item = $scope.threads[i];
- if (item.ID == $scope.currentThread.ID) {
- $scope.currentThread = item;
- break;
- }
- }
- loadPosts();
- });
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error')
- });
- }
- });
- };
- $scope.closePostEdit = function () {
- $scope.currentPost = null;
- };
- function loadForums() {
- var deferred = $q.defer();
- $http({
- url: '/' + ApLearning.lang + '/App/GetForumsList/' + $scope.courseId,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.forums = data.result;
- deferred.resolve();
- } else {
- bootbox.alert("Error: " + data.error);
- deferred.reject();
- }
- }).error(function () {
- bootbox.alert('Network Error.');
- deferred.reject();
- });
- return deferred.promise;
- }
- function loadThreads() {
- var deferred = $q.defer();
- $http({
- url: '/' + ApLearning.lang + '/App/GetThreadsList',
- method: 'POST',
- data: {
- courseID: $scope.courseId,
- forumID: $scope.currentForum.ID,
- pageNr: $scope.threadsPaging.currentPage,
- pageSize: $scope.threadsPaging.pageSize
- },
- responseType: 'json'
- }).success(function (data) {
- var i;
- if (data.ok) {
- $scope.threads = data.result.Threads;
- $scope.threadsPaging.threadsCount = data.result.Count;
- $scope.threadsPaging.pager = [];
- for (i = 1; i <= data.result.Pages; i++) {
- $scope.threadsPaging.pager.push({
- page: i,
- isCurrent: i == $scope.threadsPaging.currentPage
- });
- }
- deferred.resolve();
- } else {
- bootbox.alert('Error: ' + data.error)
- deferred.reject();
- }
- }).error(function () {
- bootbox.alert('Network error.');
- deferred.reject();
- });
- return deferred.promise;
- }
- function loadPosts() {
- var deferred = $q.defer();
- $http({
- url: '/' + ApLearning.lang + '/App/GetPostsList',
- method: 'POST',
- data: {
- courseID: $scope.courseId,
- forumID: $scope.currentForum.ID,
- threadID: $scope.currentThread.ID,
- pageNr: $scope.postsPaging.currentPage,
- pageSize: $scope.postsPaging.pageSize
- },
- responseType: 'json'
- }).success(function (data) {
- var i;
- if (data.ok) {
- $scope.posts = data.result.Posts;
- $scope.postsPaging.postsCount = data.result.Count;
- $scope.postsPaging.pager = [];
- for (i = 1; i <= data.result.Pages; i++) {
- $scope.postsPaging.pager.push({
- page: i,
- isCurrent: i == $scope.postsPaging.currentPage
- });
- }
- deferred.resolve();
- } else {
- bootbox.alert('Error: ' + data.error);
- deferred.reject();
- }
- }).error(function () {
- bootbox.alert('Network error.');
- deferred.reject();
- });
- return deferred.promise;
- }
- loadForums();
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('ModuleController', ['$scope', '$routeParams', '$location', 'Labels', 'eModuleType', 'Structure',
- function ($scope, $routeParams, $location, Labels, eModuleType, Structure) {
- var courseId = Number($routeParams.courseId), unitId = Number($routeParams.unitId), moduleId = Number($routeParams.moduleId);
- $scope.Labels = Labels;
- $scope.course = null;
- $scope.unit = null;
- $scope.module = null;
- $scope.moduleTemplateUrl = '/App/Views/module/loading.html';
- $scope.goToCourse = function () {
- $location.path('/course/' + courseId + '/' + unitId);
- };
- $scope.goToNextModule = function () {
- if ($scope.module.next) {
- $location.path('/module/' + courseId + '/' + $scope.module.next.Module.UnitID + '/' + $scope.module.next.Module.ID);
- }
- };
- $scope.goToPrevModule = function () {
- if ($scope.module.prev) {
- $location.path('/module/' + courseId + '/' + $scope.module.prev.Module.UnitID + '/' + $scope.module.prev.Module.ID);
- }
- };
- $scope.statusChanged = function () {
- Structure.reload().then(function () {
- $scope.course = Structure.getCourse(courseId);
- $scope.unit = Structure.getUnit(courseId, unitId);
- $scope.module = Structure.getModule(courseId, unitId, moduleId);
- })
- };
- $scope.goToTeachers = function () {
- $location.path('/teachers/' + courseId);
- };
- $scope.goToLibrary = function () {
- $location.path('/library/' + courseId);
- };
- $scope.goToCompleted = function () {
- $location.path('/completed/' + courseId);
- };
- $scope.goToForums = function () {
- $location.path('/forums/' + courseId);
- };
- Structure.init().then(function () {
- $scope.course = Structure.getCourse(courseId);
- $scope.unit = Structure.getUnit(courseId, unitId);
- $scope.module = Structure.getModule(courseId, unitId, moduleId);
- if (!$scope.module.CanAccess) {
- $scope.moduleTemplateUrl = '/App/Views/module/unauthorized.html';
- } else {
- switch ($scope.module.Module.ModuleType) {
- case eModuleType.Text:
- $scope.moduleTemplateUrl = "/App/Views/module/text/text.html";
- break;
- case eModuleType.Test:
- $scope.moduleTemplateUrl = "/App/Views/module/test/test.html";
- break;
- case eModuleType.Video:
- $scope.moduleTemplateUrl = "/App/Views/module/video/video.html";
- break;
- case eModuleType.Scorm:
- $scope.moduleTemplateUrl = "/App/Views/module/scorm/scormlesson.html";
- break;
- case eModuleType.Survey:
- $scope.moduleTemplateUrl = "/App/Views/module/survey/survey.html";
- break;
- case eModuleType.GuidedNote:
- $scope.moduleTemplateUrl = "/App/Views/module/guidednote/guidednote.html";
- break;
- case eModuleType.GuidedNoteExport:
- $scope.moduleTemplateUrl = "/App/Views/module/guidednoteexport/guidednoteexport.html";
- break;
- }
- }
- });
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('StatisticsController', ['$scope', '$http', 'ApLearning', 'bootbox', 'SessionManager', function ($scope, $http, ApLearning, bootbox, SessionManager) {
- $scope.courses = null;
- function loadCurses() {
- $http({
- url: '/' + ApLearning.lang + '/CourseStats/GetCoursesWithStatistics',
- method: 'POST',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.courses = data.courses;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadCurses();
- $("body").css("background-image", "url('" + ApLearning.defaultBackgroundUrl + "')");
- SessionManager.startSession();
- }]);
- app.controller('CourseStatisticsController', ['$scope', '$http', 'ApLearning', 'Labels', '$window', 'cfpLoadingBar', "$modal",
- function ($scope, $http, ApLearning, Labels, $window, cfpLoadingBar, $modal) {
- $scope.detailsVisible = false;
- $scope.unitStatistics = null;
- $scope.courseStatistics = null;
- $scope.Labels = Labels;
- function loadStatistics() {
- $http
- .post('/' + ApLearning.lang + '/CourseStats/GetCourseStatistics/' + $scope.course.ID, null)
- .then(function (resp) {
- if (resp.data.ok) {
- $scope.unitStatistics = resp.data.result;
- $scope.courseStatistics = resp.data.courseStats;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- });
- }
- $scope.exportDetails = function () {
- $window.location.href = '/' + ApLearning.lang + '/CourseStats/GetCourseStatisticsExport/' + $scope.course.ID;
- };
- $scope.sendDetails = function () {
- var modalInstance = $modal.open({
- templateUrl: '/App/Views/statistics/send/template.html',
- controller: 'CourseStatisticsSendController',
- size: 'md',
- scope: $scope
- });
- };
- $scope.toggleDetails = function () {
- $scope.detailsVisible = !$scope.detailsVisible;
- if ($scope.detailsVisible) {
- loadStatistics();
- }
- }
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('CourseStatisticsSendController', ['$scope', '$http', 'ApLearning', 'Labels', "$modalInstance",
- function ($scope, $http, ApLearning, Labels, $modalInstance) {
- $scope.states = {
- submitted: false,
- posting: false
- };
- $scope.data = {
- courseID: $scope.course.ID,
- recipient: "",
- title: Labels.statSendSubjectDefault,
- message: Labels.statSendMessageDefault
- };
- $scope.send = function (form) {
- $scope.states.submitted = true;
- if (!form.$valid) {
- return;
- }
- $scope.states.posting = true;
- $http
- .post('/' + ApLearning.lang + '/CourseStats/SendCourseStatisticsExport/', $scope.data)
- .then(function (resp) {
- $scope.states.posting = false;
- if (resp.data.ok) {
- bootbox.alert("Report inviato");
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- $modalInstance.close();
- });
- };
- $scope.cancel = function () {
- $modalInstance.close();
- };
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('TextModuleController', ['$scope', '$http', 'ApLearning', 'bootbox', 'SessionManager', 'eTextCompletionMode', 'eCompletionStatus',
- function ($scope, $http, ApLearning, bootbox, SessionManager, eTextCompletionMode, eCompletionStatus) {
- $scope.completionMode = null;
- $scope.completionStatus = eCompletionStatus.NotStarted;
- $scope.pages = null;
- $scope.status = {currentPageID: 0};
- $scope.show = false;
- $scope.currentPage = null;
- $scope.nextPage = function () {
- if ($scope.status.currentPageID < ($scope.pages.length - 1)) {
- $scope.status.currentPageID++;
- $scope.currentPage = $scope.pages[$scope.status.currentPageID];
- if ($scope.status.currentPageID == ($scope.pages.length - 1) && $scope.completionMode == eTextCompletionMode.AtLastPage && $scope.completionStatus != eCompletionStatus.Completed) {
- SessionManager.setCompleted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID, JSON.stringify($scope.status))
- .then(function () {
- $scope.statusChanged();
- $scope.completionStatus = eCompletionStatus.Completed;
- },
- function (error) {
- bootbox.alert("Error completing session: " + error);
- });
- } else {
- storeCurrentPage();
- }
- }
- };
- $scope.prevPage = function () {
- if ($scope.status.currentPageID > 0) {
- $scope.status.currentPageID--;
- $scope.currentPage = $scope.pages[$scope.status.currentPageID];
- storeCurrentPage();
- }
- };
- function storeCurrentPage() {
- SessionManager.setCustomStatus($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID, JSON.stringify($scope.status));
- }
- function goToStoredPage() {
- if ($scope.pages && $scope.status.currentPageID < $scope.pages.length) {
- $scope.currentPage = $scope.pages[$scope.status.currentPageID];
- }
- }
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetTextModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.completionMode = data.config.CompletionMode;
- $scope.completionStatus = data.config.CompletionStatus;
- $scope.pages = data.config.Pages;
- $scope.status = data.config.Status ? JSON.parse(data.config.Status) : $scope.status;
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function () {
- if ($scope.completionStatus != eCompletionStatus.Completed && ($scope.completionMode == eTextCompletionMode.AtOpening || $scope.pages.length === 1)) {
- SessionManager.setCompleted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID, JSON.stringify($scope.status))
- .then(function () {
- $scope.show = true;
- $scope.statusChanged();
- $scope.completionStatus = eCompletionStatus.Completed;
- goToStoredPage();
- },
- function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- if ($scope.completionStatus == eCompletionStatus.NotStarted) {
- SessionManager.setStarted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID, JSON.stringify($scope.status))
- .then(function () {
- $scope.show = true;
- $scope.statusChanged();
- $scope.eCompletionStatus = eCompletionStatus.Started;
- goToStoredPage();
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- $scope.show = true;
- goToStoredPage();
- }
- }
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('TestModuleController', ['$scope', '$http', 'ApLearning', 'eTestRepeatMode', 'Labels', 'SessionManager', 'bootbox', '$timeout',
- function ($scope, $http, ApLearning, eTestRepeatMode, Labels, SessionManager, bootbox, $timeout) {
- var startTime = null;
- $scope.Labels = Labels;
- $scope.eTestRepeatMode = eTestRepeatMode;
- $scope.eStep = {
- INTRO: 1,
- QUESTIONS: 2,
- RESULTS: 3,
- TIMEOUT: 4
- };
- // aggiunte mdg
- $scope.introView = "default"; // default|completed
- $scope.canRepeat = false;
- // fine aggiunte mdg
- $scope.instructions = null;
- $scope.limitTimeMinutes = null;
- $scope.allowShowAnswers = null;
- $scope.completionStatus = null;
- $scope.repeatMode = null;
- $scope.repeatsLeft = 0;
- $scope.currentSession = null;
- $scope.questions = null;
- $scope.currentQuestionID = null;
- $scope.currentQuestion = null;
- $scope.hasAllAnswers = false;
- $scope.remainingTime = "";
- $scope.result = null;
- $scope.success = false;
- $scope.correctAnswers = null;
- $scope.currentStep = $scope.eStep.INTRO;
- function reset() {
- $scope.instructions = null;
- $scope.limitTimeMinutes = null;
- $scope.completionStatus = null;
- $scope.repeatMode = null;
- $scope.repeatsLeft = 0;
- $scope.currentSession = null;
- $scope.questions = null;
- $scope.currentQuestionID = null;
- $scope.currentQuestion = null;
- $scope.hasAllAnswers = false;
- $scope.result = null;
- $scope.success = false;
- }
- function timerTick() {
- var now = new Date(), diffSeconds = parseInt("" + (now - startTime) / 1000),
- remainingSeconds = (60 * $scope.limitTimeMinutes) - diffSeconds,
- seconds = remainingSeconds % 60, minutes = (remainingSeconds - seconds) / 60;
- if (remainingSeconds < 0 && $scope.currentStep == $scope.eStep.QUESTIONS) {
- $scope.currentStep = $scope.eStep.TIMEOUT;
- SessionManager.stopSession();
- reset();
- return;
- }
- $scope.remainingTime = minutes + ':' + (seconds < 10 ? '0' + seconds : seconds);
- if ($scope.currentStep == $scope.eStep.QUESTIONS) {
- $timeout(timerTick, 200);
- }
- }
- $scope.startTest = function () {
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID).then(function (sessionCreated) {
- var req = {
- courseID: $scope.course.ID,
- unitID: $scope.unit.Unit.ID,
- moduleID: $scope.module.Module.ID,
- sessionID: sessionCreated.id,
- sessionCode: sessionCreated.sessionID
- };
- $scope.currentSession = sessionCreated;
- $http({
- url: '/' + ApLearning.lang + '/Module/StartTest',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json', headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- startTime = new Date();
- $scope.statusChanged();
- $scope.questions = data.questions;
- $scope.currentQuestionID = 0;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionID];
- $scope.currentStep = $scope.eStep.QUESTIONS;
- $scope.hasAllAnswers = false;
- if ($scope.limitTimeMinutes) {
- timerTick();
- }
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- })
- }, function (error) {
- bootbox.alert('Error: ' + error);
- })
- };
- $scope.prevQuestion = function () {
- if ($scope.currentQuestionID === 0) {
- return;
- }
- $scope.currentQuestionID--;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionID];
- };
- $scope.nextQuestion = function () {
- if ($scope.currentQuestionID === ($scope.questions.length - 1)) {
- return;
- }
- $scope.currentQuestionID++;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionID];
- };
- $scope.checkAllAnswers = function () {
- var i, item;
- for (i in $scope.questions) {
- item = $scope.questions[i];
- if (!item.AnswerID) {
- $scope.hasAllAnswers = false;
- return;
- }
- }
- $scope.hasAllAnswers = true;
- };
- $scope.evaluate = function () {
- var answers = [], i, item,
- req = {
- courseID: $scope.course.ID,
- unitID: $scope.unit.Unit.ID,
- moduleID: $scope.module.Module.ID,
- sessionID: $scope.currentSession.id,
- sessionCode: $scope.currentSession.sessionID,
- answers: answers
- };
- for (i in $scope.questions) {
- item = $scope.questions[i];
- if (item.AnswerID) {
- answers.push(item.AnswerID);
- }
- }
- $http({
- url: '/' + ApLearning.lang + '/Module/EvaluateTest',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json', headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- SessionManager.stopSession();
- reset();
- $scope.result = data.result;
- $scope.success = data.success;
- $scope.currentStep = $scope.eStep.RESULTS;
- $scope.statusChanged();
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- })
- };
- $scope.showCorrectAnswers = function () {
- if ($scope.canRepeat) {
- bootbox.confirm(Labels.showCorrectAnswersConfirm, function (confirm) {
- if (confirm) {
- showCorrectAnswers();
- }
- });
- }
- else {
- showCorrectAnswers();
- }
- };
- function showCorrectAnswers() {
- var req = {
- courseID: $scope.course.ID,
- unitID: $scope.unit.Unit.ID,
- moduleID: $scope.module.Module.ID
- };
- $http({
- url: '/' + ApLearning.lang + '/Module/GetTestAnswers',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json',
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- $scope.correctAnswers = data.answers;
- // aggiunta mdg
- $scope.canRepeat = false;
- // fine aggiunta mdg
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- })
- }
- $scope.goToStart = function () {
- $scope.allowShowAnswers = null;
- $scope.currentStep = $scope.eStep.INTRO;
- loadConfig();
- };
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetTestModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.instructions = data.config.Instructions;
- $scope.limitTimeMinutes = data.config.LimitTimeSeconds;
- $scope.completionStatus = data.config.CompletionStatus;
- $scope.repeatMode = data.config.RepeatMode;
- $scope.repeatsLeft = data.config.RepeatsLeft;
- $scope.allowShowAnswers = data.config.AllowShowAnswers;
- // aggiunta mdg
- $scope.canRepeat = $scope.repeatsLeft > 0;
- if ($scope.completionStatus == 402) {
- $scope.introView = "completed";
- }
- // fine aggiunta mdg
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('VideoModuleController', ['$scope', '$http', 'eVideoTemplate', 'bootbox', 'SessionManager', 'eVideoCompletionMode',
- function ($scope, $http, eVideoTemplate, bootbox, SessionManager, eVideoCompletionMode) {
- $scope.templateUrl = null;
- $scope.videoUrl = null;
- $scope.videoStreamType = null;
- $scope.completionMode = null;
- $scope.slides = null;
- $scope.useTimeline = false;
- $scope.currentSlide = null;
- $scope.currentSlideID = null;
- $scope.title = null;
- $scope.abstract = null;
- $scope.videoPosition = {position: 0, duration: 0};
- $scope.videoStarted = function () {
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function () {
- if ($scope.completionMode == eVideoCompletionMode.AtStart) {
- SessionManager.setCompleted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function () {
- $scope.statusChanged();
- },
- function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- SessionManager.setStarted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function () {
- $scope.statusChanged();
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- }
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- })
- };
- $scope.videoCompleted = function () {
- SessionManager.setCompleted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function () {
- $scope.statusChanged();
- },
- function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- };
- $scope.videoStopped = function () {
- SessionManager.stopSession();
- };
- $scope.previousSlide = function () {
- $scope.loadSlide($scope.currentSlideID - 1);
- };
- $scope.nextSlide = function () {
- $scope.loadSlide($scope.currentSlideID + 1);
- };
- $scope.loadSlide = function (slideID) {
- $scope.currentSlideID = slideID;
- $scope.currentSlide = $scope.slides[slideID];
- };
- $scope.checkSlide = function () {
- var i, item;
- if ($scope.useTimeline) {
- for (i = $scope.slides.length - 1; i >= 0; i--) {
- item = $scope.slides[i];
- if ($scope.videoPosition.position >= item.TimelineSeconds) {
- if ($scope.currentSlideID != i) {
- $scope.loadSlide(i);
- }
- break;
- }
- }
- }
- };
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetVideoModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- if (data.config.UrlType == "full") {
- $scope.videoUrl = data.config.File;
- }
- else {
- $scope.videoUrl = ApLearning.videoStreamingEndpoint + '/' + data.config.File;
- }
- console.log("video url: " + $scope.videoUrl);
- $scope.videoStreamType = data.config.StreamType;
- $scope.completionMode = data.config.CompletionMode;
- $scope.title = data.config.Title;
- $scope.abstract = data.config.Abstract;
- $scope.useTimeline = data.config.UseTimeline;
- $scope.slides = data.config.Slides;
- if ($scope.slides.length > 0) {
- $scope.loadSlide(0);
- }
- switch (data.config.Template) {
- case eVideoTemplate.BigVideo:
- $scope.templateUrl = '/App/Views/module/video/tpl_bigvideo.html';
- break;
- case eVideoTemplate.BigText:
- $scope.templateUrl = '/App/Views/module/video/tpl_bigtext.html';
- break;
- case eVideoTemplate.BigSlides:
- $scope.templateUrl = '/App/Views/module/video/tpl_bigslides.html';
- break;
- case eVideoTemplate.AudioOnly:
- $scope.templateUrl = '/App/Views/module/video/tpl_audioonly.html';
- break;
- }
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- app.directive('videoplayer', ['ApLearning', 'eVideoCompletionMode', '$timeout', function (ApLearning, eVideoCompletionMode, $timeout) {
- function link($scope, element, attrs) {
- $scope.width = attrs.width + 'px';
- var video_url = $scope.video + "/playlist.m3u8";
- //var video_url = $scope.video;
- $scope.player = jwplayer('videoplayer').setup({
- file: video_url,
- width: "100%",
- aspectratio: "16:9",
- controls: $scope.mode == eVideoCompletionMode.AtStart,
- autostart: true
- }).onPlay(function () {
- $timeout(function () {
- $scope.isPlaying = true;
- $scope.duration = $scope.player.getDuration();
- if ($scope.onStart) {
- $scope.onStart();
- }
- }, 10);
- }).onPause(function () {
- $timeout(function () {
- $scope.isPlaying = false;
- if ($scope.onStop) {
- $scope.onStop();
- }
- }, 10);
- }).onComplete(function () {
- $timeout(function () {
- $scope.isPlaying = false;
- if ($scope.onComplete) {
- $scope.onComplete();
- }
- }, 10);
- }).onTime(function (e) {
- $timeout(function () {
- var positionSeconds = parseInt(e.position);
- $scope.position = 100 * e.position / e.duration;
- if ($scope.positionSeconds != positionSeconds) {
- if ($scope.bookmark) {
- $scope.bookmark.position = parseInt(e.position);
- $scope.bookmark.duration = parseInt(e.duration);
- }
- $scope.positionSeconds = positionSeconds;
- $scope.onPlaying();
- }
- }, 10);
- });
- }
- return {
- restrict: 'E',
- templateUrl: '/App/Views/module/video/player.html',
- scope: {
- video: '=',
- urlType: '=',
- stream: '=',
- mode: '=',
- bookmark: '=',
- onStart: '&',
- onStop: '&',
- onComplete: '&',
- onPlaying: '&'
- },
- link: link,
- controller: ['$scope', function ($scope) {
- $scope.isPlaying = false;
- $scope.position = 0;
- $scope.positionSeconds = 0;
- $scope.showHtmlControls = $scope.mode == eVideoCompletionMode.AtEnd;
- $scope.play = function () {
- $scope.player.play(true);
- $scope.isPlaying = true;
- };
- $scope.pause = function () {
- $scope.player.pause(true);
- $scope.isPlaying = false;
- };
- }]
- };
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('ScormLessonController', ['$scope', 'ApLearning', '$window', '$timeout',
- function ($scope, ApLearning, $window, $timeout) {
- function openPanel() {
- var wnd = $window.open("/" + ApLearning.lang + '/Module/ScormPlayer/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- "Lesson",
- "fullscreen=yes,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no");
- wnd.focus();
- wnd.onbeforeunload = function () {
- $scope.statusChanged();
- };
- }
- $timeout(openPanel, 1000);
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('SurveyModuleController', ['$scope', '$http', 'ApLearning', 'Labels', 'SessionManager', 'bootbox', 'eSurveyQuestionType', 'eSurveyDetailsMode',
- function ($scope, $http, ApLearning, Labels, SessionManager, bootbox, eSurveyQuestionType, eSurveyDetailsMode) {
- $scope.emptyRegex = /^[\s]*$/;
- $scope.Labels = Labels;
- $scope.eStep = {
- INTRO: 1,
- SURVEY: 2,
- SUMMARY: 3,
- FINAL: 4
- };
- $scope.eSurveyQuestionType = eSurveyQuestionType;
- $scope.eSurveyDetailsMode = eSurveyDetailsMode;
- $scope.questions = null;
- $scope.final = null;
- $scope.completed = false;
- $scope.canRepeat = false;
- $scope.currentStep = $scope.eStep.INTRO;
- $scope.currentQuestion = null;
- $scope.currentQuestionIndex = null;
- $scope.allOk = false;
- $scope.summaryReached = false;
- $scope.startSurvey = function () {
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID).then(function () {
- SessionManager.setStarted($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID).then(function () {
- $scope.currentStep = $scope.eStep.SURVEY;
- $scope.currentQuestionIndex = 0;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionIndex];
- $scope.statusChanged();
- });
- });
- };
- function checkAnswers() {
- var quest, subq, i, j;
- $scope.allOk = $scope.questions.length > 0;
- for (i = 0; i < $scope.questions.length; i++) {
- quest = $scope.questions[i];
- quest.Ok = false;
- switch (quest.Type) {
- case eSurveyQuestionType.SingleChoice:
- if (quest.HasSubquestions) {
- quest.Ok = quest.SubQuestions.length > 0;
- for (j = 0; j < quest.SubQuestions.length; j++) {
- subq = quest.SubQuestions[j];
- quest.Ok = quest.Ok && subq.AnswerID ? true : false;
- if (subq.AnswerID == -1 && $scope.emptyRegex.test(subq.FreeAnswer || '')) {
- quest.Ok = false;
- }
- if (quest.DetailsMode == eSurveyDetailsMode.DetailsRequired && $scope.emptyRegex.test(subq.Details || '')) {
- quest.Ok = false;
- }
- if (!quest.Ok) {
- break;
- }
- }
- } else {
- quest.Ok = quest.AnswerID ? true : false;
- if (quest.AnswerID == -1 && $scope.emptyRegex.test(quest.FreeAnswer || '')) {
- quest.Ok = false;
- }
- if (quest.DetailsMode == eSurveyDetailsMode.DetailsRequired && $scope.emptyRegex.test(quest.Details || '')) {
- quest.Ok = false;
- }
- }
- break;
- case eSurveyQuestionType.MultipleChoice:
- quest.Ok = true;
- if (quest.FreeAnswerSelected && $scope.emptyRegex.test(quest.FreeAnswer || '')) {
- quest.Ok = false;
- }
- if (quest.DetailsMode == eSurveyDetailsMode.DetailsRequired && $scope.emptyRegex.test(quest.Details || '')) {
- quest.Ok = false;
- }
- break;
- case eSurveyQuestionType.FreeText:
- quest.Ok = !$scope.emptyRegex.test(quest.AnswerDetail || '');
- break;
- }
- $scope.allOk = $scope.allOk && quest.Ok;
- }
- }
- $scope.goToNext = function () {
- if ($scope.currentQuestionIndex < $scope.questions.length - 1) {
- $scope.currentQuestionIndex++;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionIndex];
- }
- };
- $scope.goToPrev = function () {
- if ($scope.currentQuestionIndex > 0) {
- $scope.currentQuestionIndex--;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionIndex];
- }
- };
- $scope.goToSummary = function () {
- checkAnswers();
- $scope.summaryReached = true;
- $scope.currentStep = $scope.eStep.SUMMARY;
- };
- $scope.goToQuestion = function (index) {
- $scope.currentStep = $scope.eStep.SURVEY;
- $scope.currentQuestionIndex = index;
- $scope.currentQuestion = $scope.questions[$scope.currentQuestionIndex];
- };
- $scope.submitAnswers = function () {
- var i, j, quest, subq, ans, req = {
- courseID: $scope.course.ID,
- unitID: $scope.unit.Unit.ID,
- moduleID: $scope.module.Module.ID,
- sessionID: SessionManager.getSessionData().id,
- sessionCode: SessionManager.getSessionData().sessionID,
- answers: []
- };
- if (!$scope.allOk) {
- return;
- }
- for (i = 0; i < $scope.questions.length; i++) {
- quest = $scope.questions[i];
- switch (quest.Type) {
- case eSurveyQuestionType.SingleChoice:
- if (quest.HasSubquestions) {
- for (j = 0; j < quest.SubQuestions.length; j++) {
- subq = quest.SubQuestions[j];
- quest.Ok = quest.Ok && subq.AnswerID ? true : false;
- req.answers.push({
- QuestionID: quest.ID,
- SubquestionID: subq.ID,
- AnswerID: subq.AnswerID > 0 ? subq.AnswerID : null,
- CustomAnswer: subq.FreeAnswer,
- AnswerDetails: subq.Details
- });
- }
- } else {
- req.answers.push({
- QuestionID: quest.ID,
- AnswerID: quest.AnswerID > 0 ? quest.AnswerID : null,
- CustomAnswer: quest.FreeAnswer,
- AnswerDetails: quest.Details
- });
- }
- break;
- case eSurveyQuestionType.MultipleChoice:
- for (j = 0; j < quest.Answers.length; j++) {
- ans = quest.Answers[j];
- if (ans.Selected) {
- req.answers.push({
- QuestionID: quest.ID,
- AnswerID: ans.ID,
- });
- }
- }
- quest.Ok = true;
- if (!$scope.emptyRegex.test(quest.FreeAnswer || '') || !$scope.emptyRegex.test(quest.Details || '')) {
- req.answers.push({
- QuestionID: quest.ID,
- CustomAnswer: quest.FreeAnswer,
- AnswerDetails: quest.Details
- });
- }
- break;
- case eSurveyQuestionType.FreeText:
- req.answers.push({
- QuestionID: quest.ID,
- CustomAnswer: quest.AnswerDetail
- });
- break;
- }
- }
- bootbox.confirm(Labels.surveySubmitConfirm, function (confirm) {
- if (confirm) {
- $http({
- url: '/' + ApLearning.lang + '/Module/SaveSurveyAnswers',
- method: 'POST',
- data: JSON.stringify(req),
- responseType: 'json',
- headers: {
- 'Content-Type': "application/json"
- }
- }).success(function (data) {
- if (data.ok) {
- SessionManager.stopSession();
- $scope.currentStep = $scope.eStep.FINAL;
- $scope.statusChanged();
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- });
- };
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetSurveyModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.questions = data.config.questions;
- $scope.final = data.config.final;
- $scope.completed = data.config.completed;
- $scope.canRepeat = data.config.canRepeat;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('GuidedNoteModuleController', ['$scope', '$http', 'ApLearning', 'bootbox', 'SessionManager', 'eGuidedNoteFieldType', 'Labels',
- function ($scope, $http, ApLearning, bootbox, SessionManager, eGuidedNoteFieldType, Labels) {
- $scope.Labels = Labels;
- $scope.eGuidedNoteFieldType = eGuidedNoteFieldType;
- $scope.saving = false;
- $scope.saved = false;
- $scope.show = false;
- $scope.fields = null;
- $scope.currentSession = null;
- $scope.submitted = false;
- $scope.saveValues = function (frm) {
- var req = {
- courseID: $scope.course.ID,
- unitID: $scope.unit.Unit.ID,
- moduleID: $scope.module.Module.ID,
- sessionID: SessionManager.getSessionData().id,
- sessionCode: SessionManager.getSessionData().sessionID,
- values: []
- };
- $scope.submitted = true;
- if (frm.$valid) {
- $scope.saving = true;
- $scope.fields.forEach(function (f) {
- req.values.push({
- FieldID: f.ID,
- Value: f.Value
- });
- });
- $http({
- url: '/' + ApLearning.lang + '/Module/SaveGuidedNoteUserValues',
- method: 'POST',
- headers: {'Content-Type': "application/json"},
- data: JSON.stringify(req)
- }).success(function (data) {
- $scope.saving = false;
- if (data.ok) {
- $scope.saved = true;
- $scope.statusChanged();
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- $scope.saving = false;
- });
- }
- };
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetGuidedNoteModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.fields = data.config.fields;
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function (sessionCreated) {
- $scope.currentSession = sessionCreated;
- $scope.show = true;
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- })(angular);
- (function (angular) {
- "use strict";
- var app = angular.module('ApLearningFrontend');
- app.controller('GuidedNoteExportModuleController', ['$scope', '$http', '$window', 'ApLearning', 'SessionManager',
- function ($scope, $http, $window, ApLearning, SessionManager) {
- $scope.show = false;
- $scope.config = null;
- $scope.currentSession = null;
- $scope.saving = false;
- $scope.export = function () {
- var urlPart = $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID + '-' + SessionManager.getSessionData().id + '-' + SessionManager.getSessionData().sessionID;
- var setExportedUrl = '/' + ApLearning.lang + '/Module/SetGuidedNoteExported/' + urlPart;
- var downloadUrl = '/' + ApLearning.lang + '/Module/GetGuidedNoteExportFile/' + urlPart;
- $scope.saving = true;
- $http({
- url: setExportedUrl,
- method: 'POST'
- }).success(function (data) {
- $scope.saving = false;
- if (data.ok) {
- $scope.statusChanged();
- $window.location.href = downloadUrl;
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- $scope.saving = false;
- bootbox.alert('Network error');
- });
- };
- function loadConfig() {
- $http({
- url: '/' + ApLearning.lang + '/Module/GetGuidedNoteExportModule/' + $scope.course.ID + '-' + $scope.unit.Unit.ID + '-' + $scope.module.Module.ID,
- method: 'GET',
- responseType: 'json'
- }).success(function (data) {
- if (data.ok) {
- $scope.config = data.config;
- SessionManager.startSession($scope.course.ID, $scope.unit.Unit.ID, $scope.module.Module.ID)
- .then(function (sessionCreated) {
- $scope.currentSession = sessionCreated;
- $scope.show = true;
- }, function (error) {
- bootbox.alert("Error starting session: " + error);
- });
- } else {
- bootbox.alert('Error: ' + data.error);
- }
- }).error(function () {
- bootbox.alert('Network error');
- });
- }
- loadConfig();
- }]);
- })(angular);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement