optionsWithBlank.json 6.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {
  2. "id": "e133300f6a124ca8aea3fd7c935b18e0",
  3. "defaultTitle": "dd-ab",
  4. "defaultDescription": "dd-ab",
  5. "alias": "dd-ab",
  6. "electionEvent": {
  7. "id": "6eb1403ab44d4fedb86a6f73adcf17fc"
  8. },
  9. "template": "options",
  10. "fullBlank": "false",
  11. "options": [
  12. {
  13. "id": "c6897cc6f7f04df393a4ec9bf388970c",
  14. "representation": "100103",
  15. "attribute": "95331a0df37e44299a28d64d9ca6ba2e"
  16. },
  17. {
  18. "id": "491280b4d21a45c2bc35445d8803ff58",
  19. "representation": "10009",
  20. "attribute": "b4f8afb4d56b449cbcd1ae28b94300ee"
  21. }
  22. ],
  23. "attributes": [
  24. {
  25. "id": "f9f3b581f27a43789f42f4841002d319",
  26. "alias": "dd-ab",
  27. "correctness": true,
  28. "related": []
  29. },
  30. {
  31. "id": "95331a0df37e44299a28d64d9ca6ba2e",
  32. "alias": "dd-ab1",
  33. "correctness": false,
  34. "related": [
  35. "f9f3b581f27a43789f42f4841002d319"
  36. ]
  37. },
  38. {
  39. "id": "b4f8afb4d56b449cbcd1ae28b94300ee",
  40. "alias": "Blank",
  41. "correctness": false,
  42. "related": [
  43. "2ad28ae479a645e39936aa14aac81372",
  44. "f9f3b581f27a43789f42f4841002d319"
  45. ]
  46. }
  47. ],
  48. "questions": [
  49. {
  50. "id": "50e2e005c2c0413a96cd6b36e659fae0",
  51. "max": "1",
  52. "min": "0",
  53. "cumul": "1",
  54. "writeIn": "false",
  55. "fusions": [],
  56. "blankAttribute": "b4f8afb4d56b449cbcd1ae28b94300ee",
  57. "attribute": "f9f3b581f27a43789f42f4841002d319"
  58. }
  59. ],
  60. "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 = 'e133300f6a124ca8aea3fd7c935b18e0';var attributeName = 'f9f3b581f27a43789f42f4841002d319';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;}",
  61. "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 = '50e2e005c2c0413a96cd6b36e659fae0';var votingOptions = ['c6897cc6f7f04df393a4ec9bf388970c', '491280b4d21a45c2bc35445d8803ff58'];var selectionRelevantVotingOptions = CorrectnessFunctions.getRelevantVotingOptions(votingOptions, subSelection);partialResult = partialResult && CorrectnessFunctions.isMinMatch(selectionRelevantVotingOptions, 0, selectionName, callbackFunction);partialResult = partialResult && CorrectnessFunctions.isMaxMatch(selectionRelevantVotingOptions, 1, selectionName, callbackFunction);return partialResult;}(encodedSelection, callbackFunction) && result;;var globalVotingOptions = ['c6897cc6f7f04df393a4ec9bf388970c', '491280b4d21a45c2bc35445d8803ff58'];result = CorrectnessFunctions.areAllSelectionsValid(globalVotingOptions, encodedSelection, callbackFunction) && result;result = CorrectnessFunctions.areAllSelectionsUnique(encodedSelection, callbackFunction) && result;return result;}"
  62. }