123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- {
- "id": "87dd8641a7c746a68768e58b62d31c71",
- "defaultTitle": "dd-nb",
- "defaultDescription": "dd-nb",
- "alias": "dd-nb",
- "electionEvent": {
- "id": "6fb1403ab44d4fedb86a6f73adcf17fc"
- },
- "template": "options",
- "fullBlank": false,
- "options": [
- {
- "id": "d6c1e4e93ad8446f9a1e2e597b00ffdd",
- "representation": "100003",
- "attribute": "9b9434cd5d5e43bab2b9e064aa0d12e0"
- },
- {
- "id": "8bb64eaef5d34da7b142e94eaf93b31f",
- "representation": "100019",
- "attribute": "cf2a9da6b424478fa5e535b0174c5e26"
- }
- ],
- "attributes": [
- {
- "id": "26d0d77f147c4620b9264977feb868f7",
- "alias": "dd-nb",
- "correctness": true,
- "related": []
- },
- {
- "id": "9b9434cd5d5e43bab2b9e064aa0d12e0",
- "alias": "dd-nb1",
- "correctness": false,
- "related": [
- "26d0d77f147c4620b9264977feb868f7"
- ]
- },
- {
- "id": "cf2a9da6b424478fa5e535b0174c5e26",
- "alias": "dd-nb2",
- "correctness": false,
- "related": [
- "26d0d77f147c4620b9264977feb868f7"
- ]
- },
- {
- "id": "000",
- "alias": "Question is blank",
- "correctness": false,
- "related": [
- "26d0d77f147c4620b9264977feb868f7"
- ]
- }
- ],
- "questions": [
- {
- "id": "05c48fc43fe04da79486ba76b5c1663f",
- "max": 1,
- "min": 1,
- "cumul": 1,
- "writeIn": "false",
- "fusions": [],
- "blankAttribute": "000",
- "attribute": "26d0d77f147c4620b9264977feb868f7"
- }
- ],
- "encryptedCorrectnessRule": "function evaluateCorrectness(selection, callbackFunction){if (typeof(callbackFunction)==='undefined') { callbackFunction = function (type, reference, extra) {};};var result = true;result = function (subSelection, callbackFunction) {var partialResult = true;var selectionName = '87dd8641a7c746a68768e58b62d31c71';var attributeName = '26d0d77f147c4620b9264977feb868f7';var min = 1;var max = 1;var count = 0;for (i = 0; i < subSelection.length; i++) {var submittedOption = subSelection[i];if (submittedOption.indexOf(attributeName) > -1) {count++;}}if (count < min) {callbackFunction('MIN_ERROR', selectionName);partialResult = false;}if (count > max) {callbackFunction('MAX_ERROR', selectionName);partialResult = false;}return partialResult;}(selection, callbackFunction) && result;return result;}",
- "decryptedCorrectnessRule": "function evaluateCorrectness(selection, callbackFunction){if (typeof(callbackFunction)==='undefined') { callbackFunction = function (type, reference, extra) {};};var B64 = {encode: function (r) {return r;},decode: function (r) {return r;}};var encodedSelection = [];for (i = 0; i < selection.length; i++) {encodedSelection.push(B64.encode(selection[i]));}var CorrectnessFunctions = {getRelevantVotingOptions : function (votingOptions, selection){var selectionRelevantVotingOptions = [];for (i = 0; i < selection.length; i++) {if (votingOptions.indexOf(selection[i]) > -1) {selectionRelevantVotingOptions.push(selection[i]);}}return selectionRelevantVotingOptions;},isMaxMatch : function (selectionRelevantVotingOptions, maxReq, selectionName, callbackFunction){var maxMatch = maxReq >= selectionRelevantVotingOptions.length;if (!maxMatch) {callbackFunction('MAX_ERROR', B64.decode(selectionName));}return maxMatch;},isMinMatch : function (selectionRelevantVotingOptions, minReq, selectionName, callbackFunction){var minMatch = minReq <= selectionRelevantVotingOptions.length;if (!minMatch) {callbackFunction('MIN_ERROR', B64.decode(selectionName));}return minMatch;},isMinWithBlankMatch: function (selectionRelevantVotingOptions, minReq, blankOption, selectionName, callbackFunction) {var minMatch = minReq <= selectionRelevantVotingOptions.length - 1;var blankMatch = (selectionRelevantVotingOptions.indexOf(blankOption) > -1) && selectionRelevantVotingOptions.length == 1;if (!(minMatch || blankMatch)) {callbackFunction('MIN_WITH_BLANK_ERROR', B64.decode(selectionName));}return (minMatch || blankMatch);},areAllSelectionsValid: function (globalVotingOptions, encodedSelection, callbackFunction) {var partialResult = true;for (i = 0; i < encodedSelection.length; i++) {var selectionIsValid = globalVotingOptions.indexOf(encodedSelection[i]) > -1;if (!selectionIsValid) {callbackFunction('SELECTION_ERROR', B64.decode(encodedSelection[i]));}partialResult = partialResult && selectionIsValid;}return partialResult;},areAllSelectionsUnique: function (encodedSelection, callbackFunction) {var partialResult = true;var duplicates = encodedSelection.reduce(function(acc, el, i, arr) {if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;}, []);if (duplicates.length != 0) {callbackFunction('MULTIPLE_SELECTION_ERROR', B64.decode(encodedSelection[duplicates[0]]));partialResult = false;}return partialResult;},checkAlliance: function (allianceVotingOptions, cumulNumber, encodedSelection, callbackFunction) {var partialResult = true;for (i = 0; i < encodedSelection.length; i++) {for (j = 0; j < allianceVotingOptions.length; j++) {if(allianceVotingOptions[j].indexOf(encodedSelection[i]) > -1){var count = 0;for (k = 0; k < allianceVotingOptions[j].length; k++) {if (encodedSelection.indexOf(allianceVotingOptions[j][k]) > -1) {count++;}}if (count > cumulNumber){callbackFunction('CUMULATION_ERROR', B64.decode(encodedSelection[i]));partialResult = false;}}}}return partialResult;}};var result = true;result = function (subSelection, callbackFunction){var partialResult = true;var selectionName = '87dd8641a7c746a68768e58b62d31c71';var votingOptions = ['d6c1e4e93ad8446f9a1e2e597b00ffdd', '8bb64eaef5d34da7b142e94eaf93b31f'];var selectionRelevantVotingOptions = CorrectnessFunctions.getRelevantVotingOptions(votingOptions, subSelection);partialResult = partialResult && CorrectnessFunctions.isMinMatch(selectionRelevantVotingOptions, 1, selectionName, callbackFunction);partialResult = partialResult && CorrectnessFunctions.isMaxMatch(selectionRelevantVotingOptions, 1, selectionName, callbackFunction);return partialResult;}(encodedSelection, callbackFunction) && result;;var globalVotingOptions = ['d6c1e4e93ad8446f9a1e2e597b00ffdd', '8bb64eaef5d34da7b142e94eaf93b31f'];result = CorrectnessFunctions.areAllSelectionsValid(globalVotingOptions, encodedSelection, callbackFunction) && result;result = CorrectnessFunctions.areAllSelectionsUnique(encodedSelection, callbackFunction) && result;return result;}"
- }
|