This document describes the implementation of vote input method tracking in ShinyImageVoteR. This feature tracks whether users cast votes using keyboard hotkeys or mouse clicks to help analyze the relationship between input method and voting speed.
Analysis revealed that median vote times range from 2-15 seconds across users. We want to understand how much of this difference is explained by hotkey usage versus mouse clicking.
When a user presses a hotkey (1, 2, 3, 4 for radio buttons or a, s, d, f for checkboxes):
- The input element is marked with
dataset.inputMethod = "hotkey" Shiny.setInputValue("voting-last_input_method", "hotkey")sends this information to R
When a user clicks on a radio button or checkbox:
- The click is verified to be within the voting questions div (same validation as hotkeys)
- The input element is marked with
dataset.inputMethod = "mouse" Shiny.setInputValue("voting-last_input_method", "mouse")sends this information to R
Note: This validation prevents accidental tracking of clicks on other inputs with the same names elsewhere in the application.
When a user logs in, their user_info.json file is initialized with:
{
"user_id": "User1",
"voting_institute": "InstituteA",
"images_randomisation_seed": 12345,
"vote_input_methods": {
"hotkey_count": 0,
"mouse_count": 0,
"unknown_count": 0
}
}Note: The unknown_count field tracks cases where the input method couldn't be determined, which helps identify potential issues with the tracking mechanism.
When a user casts a new vote (not a vote change):
- The input method is read from
input$last_input_method - If not set, it's marked as "unknown" (with a warning logged)
- The
user_info.jsonfile is read - The appropriate counter (
hotkey_count,mouse_count, orunknown_count) is incremented - The updated info is written back to
user_info.json
Note:
- Vote changes are not tracked to avoid skewing the data. We only track initial votes.
- Using "unknown" instead of defaulting to "mouse" ensures accurate data and helps identify tracking issues.
After users complete their voting sessions, the user_info.json files can be analyzed to:
- Calculate the percentage of hotkey vs mouse usage per user
- Correlate this with average voting times (from
time_till_vote_casted_in_secondsin annotations) - Determine if hotkey users are significantly faster
For each user:
- Read
user_info.jsonto get hotkey/mouse counts - Read
user_annotations.tsvto get vote times - Calculate:
- Hotkey usage percentage:
hotkey_count / (hotkey_count + mouse_count) * 100 - Median vote time: median of
time_till_vote_casted_in_seconds
- Hotkey usage percentage:
- Plot correlation between hotkey usage and vote speed
- inst/shiny-app/www/js/hotkeys.js: Added input method detection and Shiny communication
- vignettes/www/hotkeys.js: Updated to match inst version
- R/main_server.R: Added
vote_input_methodsinitialization to user_info - R/mod_voting.R: Added tracking logic to update user_info.json after each vote
To test this implementation:
- Start the Shiny app
- Log in as a user
- Vote using hotkeys (press 1, 2, 3, or 4)
- Vote using mouse clicks
- Check the
user_info.jsonfile for the user - it should show updated counts
Example:
{
"user_id": "TestUser",
"voting_institute": "TestInstitute",
"images_randomisation_seed": 67890,
"vote_input_methods": {
"hotkey_count": 12,
"mouse_count": 5,
"unknown_count": 0
}
}Note: If unknown_count is greater than 0, it indicates potential issues with the tracking mechanism that should be investigated.
Potential improvements:
- Track vote changes separately to understand behavior patterns
- Add per-vote logs instead of just counts for more detailed analysis
- Add real-time dashboard showing hotkey vs mouse usage statistics
- Export aggregated statistics across all users