<commit_before>/**
 * Experience Sampling submission functionality.
 *
 * This file contains classes and functions for saving and processing completed
 * surveys and sending them to the backend server.
 */

/**
 * SurveySubmission namespace.
 */
var SurveySubmission = SurveySubmission || {};

// Submission settings.
SurveySubmission.SERVER_URL = 'https://chrome-experience-sampling.appspot.com';
SurveySubmission.SUBMIT_SURVEY_ACTION = '/_ah/api/cesp/v1/submitsurvey';
SurveySubmission.XHR_TIMEOUT = 4000;  // milliseconds
SurveySubmission.DB_NAME = 'pendingResponsesDB';
SurveySubmission.DB_VERSION = 2;
SurveySubmission.QUEUE_ALARM_NAME = 'surveySubmissionAlarm';

/**
 * A question and response.
 * @constructor
 * @param {string} question The question being answered.
 * @param {string} answer The answer to that question.
 */
SurveySubmission.Response = function(question, answer) {
  this.question = question;
  this.answer = answer;
  if (typeof this.question !== "string")
    console.error(JSON.stringify(question) + " is not a string!");
  if (typeof this.answer !== "string")
    console.error(JSON.stringify(question) + " is not a string!");
}

/**
 * A completed survey.
 * @constructor
 * @param {string} type The type of survey.
 * @param {int} participantId The participant ID.
 * @param {Date} dateTaken The date and time when the survey was taken.
 * @param {Array.Response} responses An array of Response objects.
*/
SurveySubmission.SurveyRecord = function(type, participantId, dateTaken,
    responses) {
  this.type = type;
  this.participantId = participantId;
  this.dateTaken = dateTaken;
  this.responses = responses;
}

/**
 * A completed survey pending submission to the backend.<commit_msg>check the right property<commit_after>/**
 * Experience Sampling submission functionality.
 *
 * This file contains classes and functions for saving and processing completed
 * surveys and sending them to the backend server.
 */

/**
 * SurveySubmission namespace.
 */
var SurveySubmission = SurveySubmission || {};

// Submission settings.
SurveySubmission.SERVER_URL = 'https://chrome-experience-sampling.appspot.com';
SurveySubmission.SUBMIT_SURVEY_ACTION = '/_ah/api/cesp/v1/submitsurvey';
SurveySubmission.XHR_TIMEOUT = 4000;  // milliseconds
SurveySubmission.DB_NAME = 'pendingResponsesDB';
SurveySubmission.DB_VERSION = 2;
SurveySubmission.QUEUE_ALARM_NAME = 'surveySubmissionAlarm';

/**
 * A question and response.
 * @constructor
 * @param {string} question The question being answered.
 * @param {string} answer The answer to that question.
 */
SurveySubmission.Response = function(question, answer) {
  this.question = question;
  this.answer = answer;
  if (typeof this.question !== "string")
    console.error(JSON.stringify(this.question) + " is not a string!");
  if (typeof this.answer !== "string")
    console.error(JSON.stringify(this.answer) + " is not a string!");
}

/**
 * A completed survey.
 * @constructor
 * @param {string} type The type of survey.
 * @param {int} participantId The participant ID.
 * @param {Date} dateTaken The date and time when the survey was taken.
 * @param {Array.Response} responses An array of Response objects.
*/
SurveySubmission.SurveyRecord = function(type, participantId, dateTaken,
    responses) {
  this.type = type;
  this.participantId = participantId;
  this.dateTaken = dateTaken;
  this.responses = responses;
}

/**
 * A completed survey pending submission to the backend.
{'fraction_non_alphanumeric': 0.1138399306558798, 'fraction_numerical': 0.0034672060098237503, 'mean_word_length': 4.5303514376996805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2205185', 'n_tokens_mistral': 1021, 'n_tokens_neox': 1004, 'n_words': 296}