candidatesOnly.json 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. {
  2. "id": "dfb0059f3e45411d973951e122ddf1be",
  3. "defaultTitle": "PR_AB",
  4. "defaultDescription": "PR_AB",
  5. "alias": "PR_AB",
  6. "electionEvent": {
  7. "id": "6eb1403ab44d4fedb86a6f73adcf17fc"
  8. },
  9. "template": "listsAndCandidates",
  10. "fullBlank": "true",
  11. "options": [
  12. {
  13. "id": "84106a8b84104ef8a5bea3a9f748fd2c",
  14. "representation": "100673",
  15. "attribute": "7defa20679bc4582a1efcc7b33aed45a"
  16. },
  17. {
  18. "id": "670db19029274b99a8a6795fab43c476",
  19. "representation": "10069",
  20. "attribute": "e009fda34d674273bfd187b43c409a44"
  21. },
  22. {
  23. "id": "e10518b168214f779736bef5d5a7ab9d",
  24. "representation": "100613",
  25. "attribute": "b09d8da03cbb49b785207080e66e338b"
  26. },
  27. {
  28. "id": "3449e8e4a0ca4904bf9e05b248c73301",
  29. "representation": "100559",
  30. "attribute": "85bb39c30ba14d29999bd272da0412dd"
  31. },
  32. {
  33. "id": "8ffd9fc3c1544e4cbb80b2bb265eaf11",
  34. "representation": "100549",
  35. "attribute": "6d735c50a81e4b24b9fc721c6b18f82c"
  36. }
  37. ],
  38. "attributes": [
  39. {
  40. "id": "3e4cd5337e204f5591808887fa2cea02",
  41. "alias": "candidates",
  42. "correctness": true,
  43. "related": []
  44. },
  45. {
  46. "id": "7defa20679bc4582a1efcc7b33aed45a",
  47. "alias": "Blank Candidate",
  48. "correctness": false,
  49. "related": [
  50. "3e4cd5337e204f5591808887fa2cea02"
  51. ]
  52. },
  53. {
  54. "id": "9053f1203ecf4281b220b9c385c3c18e",
  55. "alias": "PR_AB1",
  56. "correctness": false,
  57. "related": []
  58. },
  59. {
  60. "id": "e009fda34d674273bfd187b43c409a44",
  61. "alias": "PR_AB11id",
  62. "correctness": false,
  63. "related": [
  64. "9053f1203ecf4281b220b9c385c3c18e",
  65. "3e4cd5337e204f5591808887fa2cea02"
  66. ]
  67. },
  68. {
  69. "id": "b09d8da03cbb49b785207080e66e338b",
  70. "alias": "PR_AB12id",
  71. "correctness": false,
  72. "related": [
  73. "9053f1203ecf4281b220b9c385c3c18e",
  74. "3e4cd5337e204f5591808887fa2cea02"
  75. ]
  76. },
  77. {
  78. "id": "980cd86438a048e78737405f34687c05",
  79. "alias": "PR_AB2",
  80. "correctness": false,
  81. "related": []
  82. },
  83. {
  84. "id": "85bb39c30ba14d29999bd272da0412dd",
  85. "alias": "PR_AB21id",
  86. "correctness": false,
  87. "related": [
  88. "980cd86438a048e78737405f34687c05",
  89. "3e4cd5337e204f5591808887fa2cea02"
  90. ]
  91. },
  92. {
  93. "id": "6d735c50a81e4b24b9fc721c6b18f82c",
  94. "alias": "PR_AB22id",
  95. "correctness": false,
  96. "related": [
  97. "980cd86438a048e78737405f34687c05",
  98. "3e4cd5337e204f5591808887fa2cea02"
  99. ]
  100. }
  101. ],
  102. "questions": [
  103. {
  104. "id": "5178a35e29cc4874ab817d2653f5a732",
  105. "max": "1",
  106. "min": "0",
  107. "cumul": "1",
  108. "writeIn": "false",
  109. "fusions": [],
  110. "blankAttribute": "7defa20679bc4582a1efcc7b33aed45a",
  111. "attribute": "3e4cd5337e204f5591808887fa2cea02"
  112. }
  113. ],
  114. "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 = 'dfb0059f3e45411d973951e122ddf1be';var attributeName = '3e4cd5337e204f5591808887fa2cea02';var min = 0;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;}",
  115. "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 = '7567ab251a51459794b69cd9f517fe17';var votingOptions = ['84106a8b84104ef8a5bea3a9f748fd2c', '670db19029274b99a8a6795fab43c476', 'e10518b168214f779736bef5d5a7ab9d', '3449e8e4a0ca4904bf9e05b248c73301', '8ffd9fc3c1544e4cbb80b2bb265eaf11'];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 = ['84106a8b84104ef8a5bea3a9f748fd2c', '670db19029274b99a8a6795fab43c476', 'e10518b168214f779736bef5d5a7ab9d', '3449e8e4a0ca4904bf9e05b248c73301', '8ffd9fc3c1544e4cbb80b2bb265eaf11'];result = CorrectnessFunctions.areAllSelectionsValid(globalVotingOptions, encodedSelection, callbackFunction) && result;result = CorrectnessFunctions.areAllSelectionsUnique(encodedSelection, callbackFunction) && result;return result;}"
  116. }