<commit_before>//MultiChoiceQuestionView Component Constructor
var _ = require('lib/underscore')._;
var OptionView = require('ui/common/questions/OptionView');
var SeparatorView = require('ui/common/components/SeparatorView');
var Palette = require('ui/common/components/Palette');
var Response = require('models/response');

function MultiChoiceQuestionView(question, answer, response, number, pageNumber) {

  var optionIDs = answer ? answer.optionIDs() : null;

	var self = Ti.UI.createView({
    layout : 'vertical',
    height : Titanium.UI.SIZE
  });

	var optionViews = {};

	_(question.options()).each(function(option, index) {
		var checked = optionIDs && _(optionIDs).contains(option.id);
		var optionNumber = number + String.fromCharCode(97 + index);
		optionViews[option.id] = new OptionView(option, checked, response, optionNumber, pageNumber);
	});

	_.chain(optionViews).values().each(function(view, index){
		self.add(view);
	});

	self.getValue = function() {
		var option_ids = [];
		_(optionViews).each(function(row, option_id) {
			if (row.children[0].children[0].getValue() === true)
				option_ids.push(option_id);
		});
		return option_ids;
	};

	return self;
}

module.exports = MultiChoiceQuestionView;
<commit_msg>Fixed mandatory validation for multi-choice questions.<commit_after>//MultiChoiceQuestionView Component Constructor
var _ = require('lib/underscore')._;
var OptionView = require('ui/common/questions/OptionView');
var SeparatorView = require('ui/common/components/SeparatorView');
var Palette = require('ui/common/components/Palette');
var Response = require('models/response');

function MultiChoiceQuestionView(question, answer, response, number, pageNumber) {

  var optionIDs = answer ? answer.optionIDs() : null;

	var self = Ti.UI.createView({
    layout : 'vertical',
    height : Titanium.UI.SIZE
  });

	var optionViews = {};

	_(question.options()).each(function(option, index) {
		var checked = optionIDs && _(optionIDs).contains(option.id);
		var optionNumber = number + String.fromCharCode(97 + index);
		optionViews[option.id] = new OptionView(option, checked, response, optionNumber, pageNumber);
	});

	_.chain(optionViews).values().each(function(view, index){
		self.add(view);
	});

	self.getValue = function() {
		var option_ids = [];
		_(optionViews).each(function(row, option_id) {
			if (row.children[0].children[0].getValue() === true)
				option_ids.push(option_id);
		});
		if (_(option_ids).isEmpty())
			return "";
		else
			return option_ids;
	};

	return self;
}

module.exports = MultiChoiceQuestionView;

{'fraction_non_alphanumeric': 0.14996114996114995, 'fraction_numerical': 0.003108003108003108, 'mean_word_length': 5.160287081339713, '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': '133516', 'n_tokens_mistral': 817, 'n_tokens_neox': 767, 'n_words': 157}