<commit_before>(function() {
	'use strict';

	function QuizDataService($http, $q, baseUrl) {

		this.addQuiz = function addQuiz(quiz) {
			var deffered = $q.defer();
			$http.post(baseUrl + 'api/quizzes', quiz)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
				});

			return deffered.promise;
		};

		this.getCategories = function getCategories (pattern) {
			if (!pattern) { return; }

			var deffered = $q.defer();
			$http.get(baseUrl + 'api/quizzes/categories?pattern=' + pattern)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				});

			return deffered.promise;	
		};

		this.getQuizzes = function getQuizzes(query) {
			var deffered = $q.defer(),
				url = baseUrl + 'api/quizzes';

			if (query !== null) {
				url += '?' + toQueryString(query);
				console.log(url);
			}

			$http.get(url)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
				});

			return deffered.promise;
		};
	}

	function toQueryString(obj) {
		var str = [];
		for (var p in obj) {
			if (obj.hasOwnProperty(p)) {
				str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
			}
		}

		return str.join("&");
	}

	angular.module('quizProjectApp.services')
		.service('QuizDataService', ['$http', '$q', 'baseUrl', QuizDataService]);
}());<commit_msg>added methods: getQuiz(id), removeQuiz(id), submitSolution(quiz)<commit_after>(function() {
	'use strict';

	function QuizDataService($http, $q, baseUrl) {
		var self = this;

		this.addQuiz = function addQuiz(quiz) {
			var deffered = $q.defer();
			$http.post(baseUrl + 'api/quizzes', quiz)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
					alert(error);
				});

			return deffered.promise;
		};

		this.removeQuiz = function removeQuiz(id) {
			var deffered = $q.defer();
			console.log('deleting...');

			$http.delete(baseUrl + 'api/quizzes/' + id)
				.then(function(response) {
					console.log('deleted');
					console.log(response);
					deffered.resolve(response);
				}, function(error) {
					deffered.reject(error);
					alert(error);
				});

			return deffered.promise;
		};

		this.getCategories = function getCategories(pattern) {
			if (!pattern) {
				return;
			}

			var deffered = $q.defer();
			$http.get(baseUrl + 'api/quizzes/categories?pattern=' + pattern)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				});

			return deffered.promise;
		};

		this.getQuizzes = function getQuizzes(query) {
			var deffered = $q.defer(),
				url = baseUrl + 'api/quizzes';

			if (query !== null) {
				url += '?' + toQueryString(query);
				console.log(url);
			}

			$http.get(url)
				.then(function(response) {
					console.log(response);
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
				});

			return deffered.promise;
		};

		this.getQuiz = function getQuiz(id) {
			var deffered = $q.defer();

			$http.get(baseUrl + 'api/quizzes/' + id)
				.then(function(response) {
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
				});

			return deffered.promise;
		};

		this.submitSolution = function submitSolution(quiz) {
			var deffered = $q.defer();

			$http.post(baseUrl + 'api/quizzes/solve', quiz)
				.then(function(response) {
					self.resultResponse = response.data;
					deffered.resolve(response.data);
				}, function(error) {
					deffered.reject(error);
				});

			return deffered.promise;
		};

		this.resultResponse = {};
	}

	function toQueryString(obj) {
		var str = [];
		for (var p in obj) {
			if (obj.hasOwnProperty(p)) {
				str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
			}
		}

		return str.join("&");
	}

	angular.module('quizProjectApp.services')
		.service('QuizDataService', ['$http', '$q', 'baseUrl', QuizDataService]);
}());
{'fraction_non_alphanumeric': 0.17052580800771827, 'fraction_numerical': 0.0, 'mean_word_length': 3.275257731958763, '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': '3003200', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1431, 'n_words': 229}