candidatesWithWriteIns.json 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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": "222a4ad2f1f846ad85b13ec6e894a71e",
  24. "representation": "5",
  25. "attribute": "5cabbcddeb814f9b95e84b76d3fc023b"
  26. },
  27. {
  28. "id": "e10518b168214f779736bef5d5a7ab9d",
  29. "representation": "100613",
  30. "attribute": "b09d8da03cbb49b785207080e66e338b"
  31. },
  32. {
  33. "id": "3449e8e4a0ca4904bf9e05b248c73301",
  34. "representation": "100559",
  35. "attribute": "85bb39c30ba14d29999bd272da0412dd"
  36. },
  37. {
  38. "id": "8ffd9fc3c1544e4cbb80b2bb265eaf11",
  39. "representation": "100549",
  40. "attribute": "6d735c50a81e4b24b9fc721c6b18f82c"
  41. }
  42. ],
  43. "attributes": [
  44. {
  45. "id": "3e4cd5337e204f5591808887fa2cea02",
  46. "alias": "candidates",
  47. "correctness": true,
  48. "related": []
  49. },
  50. {
  51. "id": "7defa20679bc4582a1efcc7b33aed45a",
  52. "alias": "Blank Candidate",
  53. "correctness": false,
  54. "related": [
  55. "3e4cd5337e204f5591808887fa2cea02"
  56. ]
  57. },
  58. {
  59. "id": "9053f1203ecf4281b220b9c385c3c18e",
  60. "alias": "PR_AB1",
  61. "correctness": false,
  62. "related": []
  63. },
  64. {
  65. "id": "e009fda34d674273bfd187b43c409a44",
  66. "alias": "PR_AB11id",
  67. "correctness": false,
  68. "related": [
  69. "9053f1203ecf4281b220b9c385c3c18e",
  70. "3e4cd5337e204f5591808887fa2cea02"
  71. ]
  72. },
  73. {
  74. "id": "b09d8da03cbb49b785207080e66e338b",
  75. "alias": "PR_AB12id",
  76. "correctness": false,
  77. "related": [
  78. "9053f1203ecf4281b220b9c385c3c18e",
  79. "3e4cd5337e204f5591808887fa2cea02"
  80. ]
  81. },
  82. {
  83. "id": "980cd86438a048e78737405f34687c05",
  84. "alias": "PR_AB2",
  85. "correctness": false,
  86. "related": []
  87. },
  88. {
  89. "id": "85bb39c30ba14d29999bd272da0412dd",
  90. "alias": "PR_AB21id",
  91. "correctness": false,
  92. "related": [
  93. "980cd86438a048e78737405f34687c05",
  94. "3e4cd5337e204f5591808887fa2cea02"
  95. ]
  96. },
  97. {
  98. "id": "6d735c50a81e4b24b9fc721c6b18f82c",
  99. "alias": "PR_AB22id",
  100. "correctness": false,
  101. "related": [
  102. "980cd86438a048e78737405f34687c05",
  103. "3e4cd5337e204f5591808887fa2cea02"
  104. ]
  105. },
  106. {
  107. "id": "5cabbcddeb814f9b95e84b76d3fc023b",
  108. "alias": "WRITE_IN_7af8f6e43e134556a8935d53404b89b2",
  109. "correctness": "false",
  110. "related": [
  111. "3e4cd5337e204f5591808887fa2cea02"
  112. ]
  113. }
  114. ],
  115. "questions": [
  116. {
  117. "id": "5178a35e29cc4874ab817d2653f5a732",
  118. "max": "1",
  119. "min": "0",
  120. "cumul": "1",
  121. "writeIn": "true",
  122. "fusions": [],
  123. "blankAttribute": "7defa20679bc4582a1efcc7b33aed45a",
  124. "writeInAttribute": "5cabbcddeb814f9b95e84b76d3fc023b",
  125. "attribute": "3e4cd5337e204f5591808887fa2cea02"
  126. }
  127. ],
  128. "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;}",
  129. "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;}"
  130. }