Skip to content

JoeAucoin/GIBS.Module.QuickPoll

Repository files navigation

GIBS.Module.QuickPoll

A comprehensive polling module for Oqtane that enables site administrators and content managers to create, manage, and publish polls with scheduled start/end times, vote tracking, and real-time result visualization.

Features

  • Poll Management: Create, edit, and delete polls with an intuitive admin interface
  • Scheduled Polls: Set start and end dates/times to control when voting is available
  • Multiple Options: Add unlimited voting options with custom ordering
  • Vote Tracking: Track user votes using browser fingerprinting to prevent duplicate voting
  • Results Display: View real-time poll results with visual progress bars and vote percentages
  • Security: Role-based access control integrated with Oqtane's security model
  • Responsive Design: Mobile-friendly UI built with Bootstrap

Requirements

  • Oqtane: 6.2.1 or later
  • .NET: .NET 9 or later
  • Database: Compatible with any database supported by Oqtane

Installation

Via Package Manager

  1. Download the latest release from the Releases page
  2. Extract the module files to your Oqtane modules directory
  3. Build and run the application (database migrations will be applied automatically)

Via NuGet

dotnet add package GIBS.Module.QuickPoll

Usage

Creating a Poll

  1. Navigate to the QuickPoll module
  2. Click "Add QuickPoll" button
  3. Fill in the poll details:
    • Question: The poll question text
    • Start Date/Time: When voting should begin (optional)
    • End Date/Time: When voting should end (optional)
    • Options: Add voting options with custom display order
  4. Click "Add" to create the poll

Managing Polls

  • Edit: Click the "Edit Poll" button on any poll card
  • Delete: Click the "Delete" button and confirm the action
  • View Results: Results are automatically displayed when:
    • The poll has ended (past the End Date/Time)
    • The current user has already voted
    • Poll is no longer active

Voting

Users can vote on active polls by:

  1. Selecting a voting option via radio button
  2. Clicking the "Vote" button
  3. Poll results are immediately displayed after voting

Poll States

  • Not Started: Shows message with scheduled start time
  • Active: User can vote if they haven't already
  • Ended: Results are displayed; no new votes accepted
  • Results: Displays vote counts and percentages with progress bars

Configuration

Security Levels

The module respects Oqtane's security model:

  • Edit Access: Required to create, edit, and delete polls
  • View Access: Required to view and vote on polls

Module Parameters

Configure the module through Oqtane's module settings interface.

Architecture

Client-Side (Blazor)

  • Index.razor: Main poll listing and voting interface
  • Edit.razor: Poll creation and editing form
  • QuickPollService: Client-side API communication

Server-Side

  • QuickPollService: Business logic and vote validation
  • QuickPollRepository: Data access layer
  • QuickPollManager: Poll lifecycle management
  • QuickPollController: API endpoints

Data Models

  • QuickPoll: Main poll entity with question, dates, and status
  • PollOption: Voting options with vote counts and display order
  • PollVote: Individual vote records with user fingerprints

Database

Entity Framework Core is used with automatic migrations:

  • QuickPoll: Stores poll questions and metadata
  • PollOption: Stores voting options
  • PollVote: Tracks individual votes

Vote Tracking

The module uses browser fingerprinting to uniquely identify voters and prevent duplicate voting:

  • Fingerprints are generated via JavaScript on the client
  • Votes are validated server-side to ensure a user votes only once per poll
  • Server-side validation includes user ID and IP address tracking

Development

Prerequisites

  • Visual Studio 2022 or later
  • .NET 9 SDK
  • Git

Building

dotnet build

Running

  1. Start the Oqtane development server
  2. Navigate to the QuickPoll module
  3. Create a test poll and verify functionality

Project Structure

GIBS.Module.QuickPoll/
├── Client/
│   ├── Modules/GIBS.Module.QuickPoll/
│   │   ├── Index.razor          # Main module view
│   │   ├── Edit.razor           # Poll editor
│   │   ├── ModuleInfo.cs        # Module metadata
│   │   └── Services/
│   │       └── QuickPollService.cs
│   └── ...
├── Server/
│   ├── Services/QuickPollService.cs
│   ├── Controllers/QuickPollController.cs
│   ├── Repository/QuickPollRepository.cs
│   ├── Manager/QuickPollManager.cs
│   ├── Migrations/
│   │   ├── 01000100_AddStartTime_EndTime.cs
│   │   └── EntityBuilders/
│   └── ...
├── Shared/
│   └── Models/
│       ├── QuickPoll.cs
│       ├── PollOption.cs
│       └── PollVote.cs
└── ...

API Endpoints

Get Polls

GET /api/QuickPoll/GetQuickPolls/{moduleId}

Get Poll Results

GET /api/QuickPoll/GetResults/{pollId}/{moduleId}

Cast Vote

POST /api/QuickPoll/AddVote
Content-Type: application/json

{
  "optionId": 1,
  "fingerprint": "unique-device-id"
}

Check If User Voted

GET /api/QuickPoll/HasUserVoted/{pollId}/{moduleId}/{fingerprint}

Localization

The module supports localization through Oqtane's IStringLocalizer<T> interface. Resource strings are maintained in the module's resource files.

Known Limitations

  • Vote deduplication relies on browser fingerprinting, which is not 100% foolproof
  • Browser fingerprints may change if user clears local storage or browser data
  • For highly sensitive voting scenarios, consider additional server-side validation

Troubleshooting

Polls Not Loading

  • Verify the user has appropriate module view permissions
  • Check server logs for database connection issues
  • Ensure database migrations have been applied

Votes Not Recording

  • Check browser console for JavaScript errors
  • Verify the fingerprint is being generated correctly
  • Ensure the database has write permissions

Results Not Showing

  • Confirm the poll's end date/time has passed, or you've already voted
  • Refresh the page to reload poll data
  • Check that poll options exist in the database

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This module is provided as part of the GIBS solution suite. See LICENSE file for details.

Support

For issues, questions, or feature requests, please use the Issues section of this repository.

Changelog

Version 1.0.5

  • Initial release
  • Core polling functionality
  • Vote tracking and result visualization
  • Scheduled poll support
  • Oqtane integration

Built for: Oqtane 5.0+ | .NET: 9.0+ | C#: 13.0+

About

Oqtane Quick Poll Module

Resources

License

Stars

Watchers

Forks

Packages

No packages published