Skip to content

metaversecloud-com/sdk-poll

Repository files navigation

Poll

Introduction / Summary

The In World Poll App allows admins to create a poll by configuring a question and up to 5 answer options. Users can then vote for their preferred option and view the poll results once they've cast their vote. Results are displayed based on a configuration that shows either the percentage or the total number of votes for each answer.

Key Features

Canvas elements & interactions

  • Key Asset: When clicked, this asset opens the app in the drawer and allows both admins and users to interact with the poll.

Drawer content

  • User View:

    • Main page with a placeholder text if no poll is configured.
    • Displays the poll title, question, and available answers.
    • Allows users to cast a single vote and view poll results (either as percentages or vote counts based on admin configuration).
  • Admin View:

    • Accessible via a settings icon on the main page.
    • Contains poll configuration options and admin-specific interactions (see below).

Admin features

  • Access:
    • When the admin clicks on the key asset, the app opens in the drawer.
    • A settings icon on the main page leads to the admin page.
  • Poll Configuration:
    • Question Entry: Admin can enter the poll question.
    • Answer Options:
      • Admin can provide between 2 to 5 answer options.
      • Five text fields are provided; only fields with input values are dynamically rendered for users.
    • Display Mode:
      • Admin selects whether poll results are displayed as a percentage or as a number of votes via radio buttons
      • Options:
        • Percentage
        • Number of Votes
    • Save Button:
      • Clicking on the Save button updates the app with the current poll filled out in the admin form page and deletes any existing data in the assets data object
    • Reset Button:
      • Clicking on the Reset button clears the current poll and all the saved data in the assets data object

Data objects

  • Key Asset: the data object attached to the dropped key asset will store information related to this specific implementation of the app and would be deleted if the key asset is removed from world. Example data:
    • question: string;
    • answers: string[];
    • displayMode: "percentage" | "count";
    • options?: { [key: string]: { votes: number } };
    • results?: { [profileId: string]: { answer: number } };

Environment Variables

Create a .env file in the root directory. See .env-example for a template.

Variable Description Required
NODE_ENV Node environment No
SKIP_PREFLIGHT_CHECK Skip CRA preflight check No
INSTANCE_DOMAIN Topia API domain (api.topia.io for production, api-stage.topia.io for staging) Yes
INTERACTIVE_KEY Topia interactive app key Yes
INTERACTIVE_SECRET Topia interactive app secret Yes

Developers

Built With

Client

React Vite TypeScript Tailwind CSS

Server

Node.js Express

Getting Started

  • Clone this repository
  • Run npm i in server
  • cd client
  • Run npm i in client
  • cd .. back to server

Add your .env environmental variables

See Environment Variables above.

Where to find INTERACTIVE_KEY and INTERACTIVE_SECRET

Topia Dev Account Dashboard

Topia Production Account Dashboard

Helpful links

  • SDK Developer docs
  • To see an example of an on canvas turn based game check out TicTacToe:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •