LabExercController.js 3.36 KB
/// <reference path="../../content/data/json/le/LabExercise.js" />
AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService','$filter','$location',
function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location) {
    $scope.LabExerciseName;
    $scope.LabExerciseQuiz = null;
    $scope.TotalNumberofQuiz = "0";
    $scope.quiznumber = 1;
    $scope.activityTitle = "";
    $scope.Title = "";
    $scope.$on('$viewContentLoaded', function (event) {
        // code that will be executed ... 
        // every time this view is loaded
        $scope.showme = false;
        $rootScope.currentActiveModuleTitle = pages[8].name;
        $scope.getLabExerciseModules();
        $scope.scroll();

    });

    // $scope.showme = false;
    $scope.IsVisible = function () {
        // $scope.scroll();

    }

    $scope.scroll = function () {
        // $window.scrollTo(0, 0);
        $("html,body").scrollTop(0);
        //alert("scroll");
    }
    // $rootScope.currentActiveModuleTitle = pages[8].Name;

    //to get all lab exercise modules from json files
    $scope.getLabExerciseModules = function () {
        //debugger;
        $scope.LabExerciseModules = null;
        var commondataJsonPath = '~/../content/data/json/le/LabExercise.json';

        DataService.getAnotherJson(commondataJsonPath).then(
        function (result) {
            //debugger;
            //alert(JSON.stringify(result));
            $scope.LabExerciseModules = result;
        },
        function (error) {
            console.log(error.statusText)
        }
        )
    }

    $scope.getLabExerciseTitle = function (title) {
              
        
        if(title!=null)
        {
            $scope.LabExerciseQuiz = title;
            $scope.LabExerciseName = title.Topic;
            $location.url("/lab-exercises-detail?topic=" + (title.Topic || ""));
        }
        
    }


    $scope.GetQuizByTopic=function()
    {
        var keywords = $location.search();
        $scope.LabExerciseName = keywords.topic;
        $scope.LabExerciseModules = null;
        var commondataJsonPath = '~/../content/data/json/le/LabExercise.json';

        DataService.getAnotherJson(commondataJsonPath).then(
        function (result) {
            //debugger;
            $.each(result.LabExercise, function (index, value) {
                if (result.LabExercise[index].Topic == keywords.topic)
                {
                    
                    $scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions;
                    $.each(result.LabExercise[index].Questions, function (index1, value1) {
                        if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber)
                        {
                            $scope.LabExerciseModules = result.LabExercise[index].Questions[index1];
                            $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle;
                            $scope.Title = result.LabExercise[index].Questions[index1].Title;
                        }
                    });
                    alert(JSON.stringify($scope.LabExerciseModules));
                    //$scope.quiznumber++;
                }
               
            });
            
        },
        function (error) {
            console.log(error.statusText)
        }
        )
    }

}]

);