vote: RCV should never allow more rankings than options

This commit is contained in:
David Ernst
2024-01-25 14:09:44 -08:00
parent d617065960
commit c4fdcf4b62
5 changed files with 7 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
import { Fragment, useEffect, useState } from 'react'
import { CipherStrings } from 'src/crypto/stringify-shuffle'
import { EncryptedVote } from 'src/protocol/EncryptedVote'
import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem'
import { defaultRankingsAllowed } from 'src/vote/Ballot'
import { Item } from '../vote/storeElectionInfo'
import { TotalVotesCast } from './TotalVotesCast'

View File

@@ -1,6 +1,6 @@
import { orderBy } from 'lodash-es'
import { flatten } from 'lodash-es'
import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem'
import { defaultRankingsAllowed } from 'src/vote/Ballot'
import { unTruncateSelection } from './un-truncate-selection'
import { useDecryptedVotes } from './use-decrypted-votes'

View File

@@ -11,6 +11,7 @@ import { State } from './vote-state'
// Calculate maximum write-in string length
const verification_num_length = 15
export const max_string_length = maxLength - verification_num_length
export const defaultRankingsAllowed = 3
export const Ballot = ({
dispatch,
@@ -64,6 +65,7 @@ export const Ballot = ({
{...{
...item,
dispatch,
rankings_allowed: Math.min(defaultRankingsAllowed, max_options),
state,
}}
key={index}

View File

@@ -6,21 +6,19 @@ import { Label, TitleDescriptionQuestion } from './Item'
import { Item as ItemType } from './storeElectionInfo'
import { State } from './vote-state'
export const defaultRankingsAllowed = 3
export const RankedChoiceItem = ({
description,
dispatch,
id = 'vote',
options,
question,
rankings_allowed = defaultRankingsAllowed,
rankings_allowed,
state,
title,
}: ItemType & {
dispatch: Dispatch<Record<string, string>>
election_id?: string
rankings_allowed?: number
rankings_allowed: number
state: State
}): JSX.Element => {
// console.log(state.plaintext)

View File

@@ -3,7 +3,7 @@ import { flatten } from 'lodash-es'
import Link from 'next/link'
import { useEffect } from 'react'
import { defaultRankingsAllowed } from '../RankedChoiceItem'
import { defaultRankingsAllowed } from '../Ballot'
import { State } from '../vote-state'
import { DetailedEncryptionReceipt } from './DetailedEncryptionReceipt'
import { EncryptedVote } from './EncryptedVote'