<commit_before>/* jshint browser: true */

(function() {
'use strict';

// authoring
angular.module('authoringTool.authoring', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/authoring', {
		templateUrl: 'authoring/authoring.html',
		controller: 'MainCtrl',
	});
}])

.controller('MainCtrl', function ($scope, $rootScope) {

	$scope.data = {
		test: {},
		global: {
			quiz: {
				alwaysSkippable: false,
				skippableOnceCorrect: false,
				showCorrectAnswerWhenSubmitted: false
			},
			polls: {
				showResponsesWhen: "afterEach",
				pollsAlwaysSkippable: false
			},
		},
		questionSet: [],
	};

	$scope.exportBtn = function() {
		console.log($scope.data);

		var data = exportWebWorker($scope.data);

		// URL.createObjectURL
		window.URL = window.URL || window.webkitURL;

		var blob = new Blob([data], {type: 'application/javascript'});

		var url = URL.createObjectURL(blob);

		console.log(url);

		$rootScope.$emit("blob_url", url);

		console.log(data);
	};

})

.controller('AccordionCtrl', function ($scope) {
	$scope.oneAtATime = true;

	$scope.status = {
		isFirstOpen: true,
		isFirstDisabled: false,
	};

})

.controller('AuthoringVideoCtrl', function($scope, $sce, $rootScope) {
	$scope.config = {
		autoHide: false,
		autoHideTime: 3000,
		sources: [
			{
				src: $sce.trustAsResourceUrl("caesar-cipher.mp4"), type: "video/mp4"
			},
		],
		theme: {
			url: "authoring/videogular.css",
		},
		plugins: {
			cuepoints: {
				theme: {
					url: "bower_components/videogular-cuepoints/cuepoints.css",
				},
			},
			questions: {
				data:{
					url: "",
				},
			},
		},
	};

	$rootScope.$on("blob_url", function(event, url) {
		console.log("got url " + url);

		$scope.config.plugins.questions.data.url = url;
	});

})

.controller('SetAddCtrl',  function ($scope){
	$scope.sets = [{id: 0, header: 'Question Set 1'}];

	$scope.addQuestionSet = function() {
		var newSetNo = $scope.sets.length;
		$scope.sets.push({id: newSetNo, header: 'Question Set ' + (newSetNo + 1)});
	};
})

.directive('defaultOptionsBlock', function(){
	return {
		restrict: 'E',
		templateUrl: 'authoring/defaultOptions.html',
	};
})

.directive('questionOptionsBlock', function(){
	return {
		restrict: 'E',
		templateUrl: 'authoring/questionOptions.html',
		scope: {
			heading: '@',
			questionSetId: '@',
		},
		controller: 'questionOptionsBlockCtrl',
	};
})

.controller('questionOptionsBlockCtrl', function($scope) {
	$scope.options = {
		override: false,
		quiz: {
			alwaysSkippable: false,
			skippableOnceCorrect: false,
			showCorrectAnswerWhenSubmitted: false,
			ifIncorrectReturnToTime: false,
		},
		poll: {
			pollsAlwaysSkippable: false,
			showResponsesWhen: 'afterEach',
		},
	};

	$scope.$watch('options', function(newVal, oldVal) {
		$scope.$parent.questionSetData.options = newVal;
	}, true); //note this is a deep watch and is slow

})

.controller('SectionAddCtrl',  function ($scope){
	$scope.questions = [
		{
			questionId: 0,
			name: 'Question 1',
			type: 'quiz',
		},
	];

	var pollNo = 0;
	var quizNo = 1;

	$scope.addPoll = function() {
		pollNo = pollNo + 1;

		return $scope.questions.push({
			questionId: $scope.questions.length,<commit_msg>Don't start with a question set or question added<commit_after>/* jshint browser: true */

(function() {
'use strict';

// authoring
angular.module('authoringTool.authoring', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/authoring', {
		templateUrl: 'authoring/authoring.html',
		controller: 'MainCtrl',
	});
}])

.controller('MainCtrl', function ($scope, $rootScope) {

	$scope.data = {
		test: {},
		global: {
			quiz: {
				alwaysSkippable: false,
				skippableOnceCorrect: false,
				showCorrectAnswerWhenSubmitted: false
			},
			polls: {
				showResponsesWhen: "afterEach",
				pollsAlwaysSkippable: false
			},
		},
		questionSet: [],
	};

	$scope.exportBtn = function() {
		console.log($scope.data);

		var data = exportWebWorker($scope.data);

		// URL.createObjectURL
		window.URL = window.URL || window.webkitURL;

		var blob = new Blob([data], {type: 'application/javascript'});

		var url = URL.createObjectURL(blob);

		console.log(url);

		$rootScope.$emit("blob_url", url);

		console.log(data);
	};

})

.controller('AccordionCtrl', function ($scope) {
	$scope.oneAtATime = true;

	$scope.status = {
		isFirstOpen: true,
		isFirstDisabled: false,
	};

})

.controller('AuthoringVideoCtrl', function($scope, $sce, $rootScope) {
	$scope.config = {
		autoHide: false,
		autoHideTime: 3000,
		sources: [
			{
				src: $sce.trustAsResourceUrl("caesar-cipher.mp4"), type: "video/mp4"
			},
		],
		theme: {
			url: "authoring/videogular.css",
		},
		plugins: {
			cuepoints: {
				theme: {
					url: "bower_components/videogular-cuepoints/cuepoints.css",
				},
			},
			questions: {
				data:{
					url: "",
				},
			},
		},
	};

	$rootScope.$on("blob_url", function(event, url) {
		console.log("got url " + url);

		$scope.config.plugins.questions.data.url = url;
	});

})

.controller('SetAddCtrl',  function ($scope){
	$scope.sets = [];

	$scope.addQuestionSet = function() {
		var newSetNo = $scope.sets.length;
		$scope.sets.push({id: newSetNo, header: 'Question Set ' + (newSetNo + 1)});
	};
})

.directive('defaultOptionsBlock', function(){
	return {
		restrict: 'E',
		templateUrl: 'authoring/defaultOptions.html',
	};
})

.directive('questionOptionsBlock', function(){
	return {
		restrict: 'E',
		templateUrl: 'authoring/questionOptions.html',
		scope: {
			heading: '@',
			questionSetId: '@',
		},
		controller: 'questionOptionsBlockCtrl',
	};
})

.controller('questionOptionsBlockCtrl', function($scope) {
	$scope.options = {
		override: false,
		quiz: {
			alwaysSkippable: false,
			skippableOnceCorrect: false,
			showCorrectAnswerWhenSubmitted: false,
			ifIncorrectReturnToTime: false,
		},
		poll: {
			pollsAlwaysSkippable: false,
			showResponsesWhen: 'afterEach',
		},
	};

	$scope.$watch('options', function(newVal, oldVal) {
		$scope.$parent.questionSetData.options = newVal;
	}, true); //note this is a deep watch and is slow

})

.controller('SectionAddCtrl',  function ($scope){
	$scope.questions = [];

	var pollNo = 0;
	var quizNo = 1;

	$scope.addPoll = function() {
		pollNo = pollNo + 1;

		return $scope.questions.push({
			questionId: $scope.questions.length,
{'fraction_non_alphanumeric': 0.17075086396481307, 'fraction_numerical': 0.003770028275212064, 'mean_word_length': 3.9128086419753085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209596', 'n_tokens_mistral': 2575, 'n_tokens_neox': 2223, 'n_words': 402}