options.json 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {
  2. "id": "87dd8641a7c746a68768e58b62d31c71",
  3. "defaultTitle": "dd-nb",
  4. "defaultDescription": "dd-nb",
  5. "alias": "dd-nb",
  6. "electionEvent": {
  7. "id": "6fb1403ab44d4fedb86a6f73adcf17fc"
  8. },
  9. "template": "options",
  10. "fullBlank": false,
  11. "options": [
  12. {
  13. "id": "d6c1e4e93ad8446f9a1e2e597b00ffdd",
  14. "representation": "100003",
  15. "attribute": "9b9434cd5d5e43bab2b9e064aa0d12e0"
  16. },
  17. {
  18. "id": "8bb64eaef5d34da7b142e94eaf93b31f",
  19. "representation": "100019",
  20. "attribute": "cf2a9da6b424478fa5e535b0174c5e26"
  21. }
  22. ],
  23. "attributes": [
  24. {
  25. "id": "26d0d77f147c4620b9264977feb868f7",
  26. "alias": "dd-nb",
  27. "correctness": true,
  28. "related": []
  29. },
  30. {
  31. "id": "9b9434cd5d5e43bab2b9e064aa0d12e0",
  32. "alias": "dd-nb1",
  33. "correctness": false,
  34. "related": [
  35. "26d0d77f147c4620b9264977feb868f7"
  36. ]
  37. },
  38. {
  39. "id": "cf2a9da6b424478fa5e535b0174c5e26",
  40. "alias": "dd-nb2",
  41. "correctness": false,
  42. "related": [
  43. "26d0d77f147c4620b9264977feb868f7"
  44. ]
  45. },
  46. {
  47. "id": "000",
  48. "alias": "Question is blank",
  49. "correctness": false,
  50. "related": [
  51. "26d0d77f147c4620b9264977feb868f7"
  52. ]
  53. }
  54. ],
  55. "questions": [
  56. {
  57. "id": "05c48fc43fe04da79486ba76b5c1663f",
  58. "max": 1,
  59. "min": 1,
  60. "cumul": 1,
  61. "writeIn": "false",
  62. "fusions": [],
  63. "blankAttribute": "000",
  64. "attribute": "26d0d77f147c4620b9264977feb868f7"
  65. }
  66. ],
  67. "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;}",
  68. "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;}"
  69. }