<commit_before>/**
 * Copyright 2014 <NAME> and <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
define([], function() {

	var PageController = ['$scope', 'api', '$state', '$rootScope', '$stateParams', function($scope, api, $state, $rootScope, $stateParams) {
		$rootScope.pageTitle = "Contact us";

		$scope.user.$promise.then(function() {
			$scope.contactForm = {"firstName" : $scope.user.givenName, "lastName" : $scope.user.familyName, "emailAddress" : $scope.user.email};				
		
			if ($stateParams.preset == 'teacherRequest') {
				if ($scope.user.role != 'TEACHER') {
					$scope.contactForm.subject = "Teacher Account Request",
					$scope.contactForm.message = "Hello,\n\nPlease could you convert my Isaac Physics account into a teacher account.\n\nMy school is: \nI have changed my account email address to be my school email: [Yes/No]\nA link to my school website with a staff list showing my name and email (or a phone number to contact the school) is: \n\nThanks, \n\n" + $scope.contactForm.firstName + " " + $scope.contactForm.lastName;
				} else {
					alert("Your account has already been upgraded to a teacher account.")
				}
			} else if ($stateParams.preset == 'accountDeletion') {
			    $scope.contactForm.subject = "Account Deletion Request",
			    $scope.contactForm.message = "Hello,\n\nPlease could you delete my Isaac Physics account.\n\nThanks, \n\n" + $scope.contactForm.firstName + " " + $scope.contactForm.lastName;
			} else if ($stateParams.subject != null && $stateParams.subject != '' && $stateParams.subject != 'true') {
				$scope.contactForm.subject = $stateParams.subject;
			}
		}).catch(function(){
			if (!$scope.user._id && $stateParams.preset == 'teacherRequest') {
				$state.go('login', {target:"/contact?preset=teacherRequest"})
			} else if (!$scope.user._id && $stateParams.preset == 'accountDeletion') {
			    $state.go('login', {target:"/contact?preset=accountDeletion"})
			}
		})

		$scope.invalidForm = false;
		$scope.formSubmitted = false;
		$scope.errorDuringSubmit = false;

		$scope.sendForm = function() {
			if($scope.form.$invalid) {
				$scope.invalidForm = true;
				$scope.form.$pristine= false;

				// This will mark all invalid fields as dirty to highlight errors in the view.
	        	for(var i in $scope.form.$error.required){
	        		$scope.form.$error.required[i].$setViewValue($scope.form.$error.required[i].$viewValue);
	        	}

				return;
			}

			var message = {
				"firstName": $scope.contactForm.firstName,
				"lastName": $scope.contactForm.lastName,
				"emailAddress": $scope.contactForm.emailAddress,
				"subject": $scope.contactForm.subject,
				"message": $scope.contactForm.message
			};

			api.contactForm.send({}, message).$promise.then(function(response) {
				$scope.invalidForm = false;
				$scope.formSubmitted = true;
			}, function(e) {
				console.error("Error submitting form", e);
				$scope.errorDuringSubmit = true;
			});
		}
<commit_msg>Send user ID in contact form, remove explicit Physics references from default responses<commit_after>/**
 * Copyright 2014 <NAME> and <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 * 		http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
define([], function() {

	var PageController = ['$scope', 'api', '$state', '$rootScope', '$stateParams', function($scope, api, $state, $rootScope, $stateParams) {
		$rootScope.pageTitle = "Contact us";

		$scope.user.$promise.then(function() {
			$scope.contactForm = {"firstName" : $scope.user.givenName, "lastName" : $scope.user.familyName, "emailAddress" : $scope.user.email};				
		
			if ($stateParams.preset == 'teacherRequest') {
				if ($scope.user.role != 'TEACHER') {
					$scope.contactForm.subject = "Teacher Account Request",
					$scope.contactForm.message = "Hello,\n\nPlease could you convert my Isaac account into a teacher account.\n\nMy school is: \nI have changed my account email address to be my school email: [Yes/No]\nA link to my school website with a staff list showing my name and email (or a phone number to contact the school) is: \n\nThanks, \n\n" + $scope.contactForm.firstName + " " + $scope.contactForm.lastName;
				} else {
					alert("Your account has already been upgraded to a teacher account.")
				}
			} else if ($stateParams.preset == 'accountDeletion') {
			    $scope.contactForm.subject = "Account Deletion Request",
			    $scope.contactForm.message = "Hello,\n\nPlease could you delete my Isaac account.\n\nThanks, \n\n" + $scope.contactForm.firstName + " " + $scope.contactForm.lastName;
			} else if ($stateParams.subject != null && $stateParams.subject != '' && $stateParams.subject != 'true') {
				$scope.contactForm.subject = $stateParams.subject;
			}
		}).catch(function(){
			if (!$scope.user._id && $stateParams.preset == 'teacherRequest') {
				$state.go('login', {target:"/contact?preset=teacherRequest"})
			} else if (!$scope.user._id && $stateParams.preset == 'accountDeletion') {
			    $state.go('login', {target:"/contact?preset=accountDeletion"})
			}
		})

		$scope.invalidForm = false;
		$scope.formSubmitted = false;
		$scope.errorDuringSubmit = false;

		$scope.sendForm = function() {
			if($scope.form.$invalid) {
				$scope.invalidForm = true;
				$scope.form.$pristine= false;

				// This will mark all invalid fields as dirty to highlight errors in the view.
	        	for(var i in $scope.form.$error.required){
	        		$scope.form.$error.required[i].$setViewValue($scope.form.$error.required[i].$viewValue);
	        	}

				return;
			}

			var message = {
				"firstName": $scope.contactForm.firstName,
				"lastName": $scope.contactForm.lastName,
				"emailAddress": $scope.contactForm.emailAddress,
				"subject": $scope.contactForm.subject,
				"message": $scope.contactForm.message,
				"userId": $scope.user._id
			};

			api.contactForm.send({}, message).$promise.then(function(response) {
				$scope.invalidForm = false;
				$scope.formSubmitted = true;
			}, function(e) {
				console.error("Error submitting form", e);
				$scope.errorDuringSubmit = true;
			});
		}

{'fraction_non_alphanumeric': 0.14312135438896, 'fraction_numerical': 0.0022762839664248113, 'mean_word_length': 3.753211629479378, 'pattern_counts': {'":': 11, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2484022', 'n_tokens_mistral': 2388, 'n_tokens_neox': 2082, 'n_words': 584}