Election Config Schema

From Electowiki
Jump to: navigation, search

{

 "type": "map",
 "desc": "An election configuration is a mapping with a series of parameters, as defined below:",
 "mapping": {
     "version": {
         "type": "str",
         "enum": ["0.1"],
         "desc": "Version of the election configuration format being used.",
         "required": true,
         "desc_enum": {
             "0.1": "Format version number for all versions of Electowidget as of this writing (October, 2005)"
         }
       },
     "allow_voting": {
         "type": "bool",
         "desc": "'true' if a link should be displayed to allow logged-in users to edit their vote.",
     },
     "ballot_type": {
         "type": "str",
         "enum": ["barscale", "radioarray", "singlecheckbox", "singleradio", "stars"],
         "desc": "Controls the appearance and behavior of the voting user interface.",
         "desc_enum": {
             "barscale": "Bar chart with adjustable bars.  Requires JavaScript for optimal use, though essential functionality is accessible without JavaScript by entering a rating in the provided text entry field.  Specify minimum and maximum ratings using min_rating and max_rating parameters, and control the size of the sliding scale using barscale_tickpx",
             "radioarray": "Series of descrete ratings selectable by simple radio button control.  Specify minimum and maximum ratings using min_rating and max_rating parameters, and set the labels for each rating using radioarray_labels.",
             "singlecheckbox": "Allow users to check (set rating to 1) or uncheck (set rating to 0) for each candidate.  Ignores min_rating and max_rating parameters.  Useful for conducting a pure Approval election.",
             "singleradio": "Allow users to select (set rating to 1) a single candidate, deselecting all other candidates (setting ratings to 0).  Ignores min_rating and max_rating parameters.  Useful for conducting a traditional plurality election.",
             "stars": "Graphical bar chart with stars representing the ratings.  Requires JavaScript for optimal use, though essential functionality is accessible without JavaScript by selecting a rating from the provided drop-down selection box.  Specify maximum rating using max_rating parameter.   Ignores min_rating parameter.",
         }
     },
     "barscale_tickpx": {
         "type": "int",
         "desc": "Used when ballot_type is set to 'barscale' to specify the number of pixels per rating.  For example, if min_rating is set to 0, and max_rating is set to 10, setting barscale_tickpx to 2 will cause adjustable portion of the barscale to be 20 pixels wide."
     },
     "candidates": {
         "type": "map",
         "desc": "Key/value List of candidates in the election.  The key portion is an internal identifier for the candidate used by the program which sometimes shows up in the user interface (though this will hopefully be rare).  Set the key to something readable, but short.",
         "mapping": {
             "(candidate key)": {
                 "type": "map",
                 "mapping": {
                     "candidate_url": {
                       "type": "str",
                       "desc": "URL to a page describing the candidate"
                     },
                     "display_name": {
                       "type": "str",
                       "desc": "Name of the candidate as you would like it displayed in the ballots and results."
                     },
                     "(other fields)": {
                       "type": "str",
                       "desc": "Other fields may be defined by adding field definitions to the features mapping."
                     },
                   }
               }
           }
       },
     "count_subpage_ballots": {
       "type": "bool",
       "desc": "If true, count ballots cast by logged in users."
     },
     "description": {
       "type": "str",
       "desc": "Description of the election, which appears at the top of the initial election entry page."
     },
     "display_parameters": {
       "type": "bool",
       "desc": "If true, display the parameters for this election on the initial election entry page.  At the time of this writing, this is woefully incomplete, but will at least return the list of candidates."
     },
     "display_results": {
       "type": "bool",
       "desc": "If true, calculate and display the results of the election with ballots currently on hand."
     },
     "election_methods": {
         "type": "seq",
         "desc": "List of election methods to use in tallying the results.  Each item of the list is a mapping which has parameters specific to that particular method.",
         "sequence": [
           {
             "desc": "Key/value list of parameters for this particular method.",
             "type": "map",
             "mapping": {
               "type": {
                 "type": "str",
                 "enum": ['approval', 'chain', 'copeland', 'dmc', 'instant-runoff', 'minmax-margins', 'minmax-wv', 'plurality', 'range', 'schulze-margins', 'schulze-wv', 'schulze-wv-mod', 'smith'],
                 "desc": "The election tallying method.  schulze-wv is recommended by the author of this software.",
                 "desc_enum": {
                     'approval': "Approval voting",
                     'chain': "Chain multiple methods using this election type.  For example, one can define a chain such that the Smith method is used, and Minmax(wv) settles any ties should there be multiple Smith method winners.  Use the 'methods' parameter described below to provide an ordered list of methods.",
                     'copeland': "Copeland method", 
                     'dmc': "Definite Majority Choice method.  This particular implementation implements it as Minmax(Total Approval) as an implementation convenience. ",
                     'instant-runoff': "Instant runoff voting",
                     'minmax-margins': "Minmax(wv) - use 'margins' to measure victory strength.", 
                     'minmax-wv': "Minmax(wv) - use 'winning votes' to measure victory strength.", 
                     'plurality': "Plurality", 
                     'range': "Range Voting", 
                     'schulze-margins': "Schulze method - use 'margins' to measure victory strength.",
                     'schulze-wv': "Schulze method - use 'winning votes' to measure victory strength.", 
                     'schulze-wv-mod': "Schulze method - use 'winning votes' to measure victory strength, and use 'margins' to resolve ties.", 
                     'smith': "Choses the member(s) of the Smith set"
                 },
                 "required": "true"
               },
               "methods": {
                   "type": "seq",
                   "desc": "Used in conjunction with the chain method.  This defines an ordered sequence of methods to use in calculating the winner.",
                   "sequence": [
                           {
                             "type": "map",
                             "mapping": {
                               "type": {
                                 "type": "str",
                                 "desc": "Any valid election method type.  See documentation for 'type' parameter under 'election_methods' for more information."
                               }
                             }
                           }
                         ]
                 }
             }
           }
         ]
       },
     "features": {
         "type": "map",
         "desc": "List of important features/characteristics useful in comparing candidates.  'Political party' is an example of a candidate characteristic important while voting.  These features will be listed in a separate column from the candidates' names, and will be sortable.",
         "mapping": {
             "(feature identifier)": {
                 "type": "map",
                 "desc": "Parameters for a particular feature.",
                 "mapping": {
                     "display_name": {
                       "type": "str",
                       "desc": "The label for use in the column header."
                     },
                     "url_field": {
                       "type": "str",
                       "desc": "A field identifier for an optional URL associated with a particular feature.  The identifier defined here can be used in the (candidate key) mapping defined above."
                     }
                   }
               }
           }
       },
     "max_rating": {
       "desc": "Maximum rating that voters may assign to a candidate.  Not respected by all ballot types.",
       "type": "int"
     },
     "min_rating": {
       "desc": "Maximum rating that voters may assign to a candidate.  Not respected by all ballot types.",
       "type": "int"
     },
     "radioarray_labels": {
         "type": "map",
         "desc": 'Set of labels to use when the "radioarray" value for ballot_type is chosen.',
         "mapping": {
             "(rating value)": {
               "type": "str",
               "desc": "label associated with this particular numerical rating."
             }
           }
       }
   }

}