dossinstitute / sidequest

Apache License 2.0
0 stars 0 forks source link

Event Manager Functional Requirement #19

Closed wvwatson closed 1 week ago

wvwatson commented 1 week ago

Event Manager Functional Requirement Ticket

Title: Development of a Decentralized Event Management System with Integrated Quest Management

Description: Develop a decentralized platform for managing events, where each event hosts various activities or "quests." The system should allow organizers to create and manage events, assign quests to these events, and track participant engagement. The QuestManager contract, previously provided, will handle the creation and management of quests, while the EventManager contract will focus on event lifecycle management.

Acceptance Criteria:

Event Management

  1. Event Creation:
    • Organizers must be able to create new events via a createEvent function.
    • The function must accept parameters for event ID, start time, end time, and a description of the event.
    • The contract must enforce that events cannot overlap in time.
  2. Event Update:
    • Organizers must be able to update the details of an existing event via an updateEvent function.
    • The function must accept parameters for event ID and updated details (start time, end time, description).
  3. Event Deletion:
    • Organizers must be able to delete an event via a deleteEvent function.
    • The function must accept the event ID as a parameter.
  4. Event Listing:
    • The contract must provide a function to list all active events, including their details.

Quest Assignment to Events

  1. Assign Quests to Events:
    • Organizers must be able to assign quests to events via an assignQuestToEvent function.
    • The function must accept parameters for event ID, quest ID, and the start time and end time of the quest within the event.
    • The contract must enforce that quests cannot overlap in time with other quests assigned to the same event.
  2. List Assigned Quests for an Event:
    • The contract must provide a function to list all quests assigned to a specific event, including their details.

Participant Engagement

  1. Participant Registration for Quests:
    • Participants must be able to register for quests they intend to complete during an event.
    • The contract must track which participants have registered for which quests.
  2. Quest Completion and Reward Distribution:
    • Participants must be able to mark quests as completed once they have finished them.
    • The contract must support the distribution of rewards to participants who successfully complete quests.
    • Rewards can be either tokens or NFTs, depending on the configuration set by the organizer for each event.
    • The contract must ensure that rewards are distributed securely and transparently.

Access Control

  1. Access Control:
    • Only the organizer of an event should be able to create, update, or delete events, assign quests to events, and distribute rewards.
    • Participants should be able to register for quests and mark them as completed.

Data Integrity and Security

  1. Data Integrity and Security:
    • The contract must ensure that event and quest data are stored securely and accurately.
    • The contract must prevent unauthorized access or manipulation of event and quest data.

Testing

  1. Testing:
    • Comprehensive unit tests must be developed to verify the functionality of the contract, including edge cases such as overlapping events or quests, and access control violations.

Solidity Contract Example

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.23;

import "./QuestManager.sol"; // Import the QuestManager contract

contract EventManager {

    address public admin;

    QuestManager private questManager;

    enum EventStatus { Active, Completed }

    struct Event {

        uint256 id;

        uint256 startTime;

        uint256 endTime;

        string description;

        EventStatus status;

        mapping(uint256 => QuestInfo) quests;

    }

    struct QuestInfo {

        uint256 questId;

        uint256 startTime;

        uint256 endTime;

    }

    mapping(uint256 => Event) public events;

    constructor(address _questManagerAddress) {

        admin = msg.sender;

        questManager = QuestManager(_questManagerAddress);

    }

    modifier onlyAdmin() {

        require(msg.sender == admin, "Only admin can perform this action");

        _;

    }

    function createEvent(

        uint256 _id,

        uint256 _startTime,

        uint256 _endTime,

        string memory _description

    ) public onlyAdmin {

        events[_id] = Event(_id, _startTime, _endTime, _description, EventStatus.Active);

    }

    function updateEvent(

        uint256 _id,

        uint256 _newStartTime,

        uint256 _newEndTime,

        string memory _newDescription

    ) public onlyAdmin {

        events[_id].startTime = _newStartTime;

        events[_id].endTime = _newEndTime;

        events[_id].description = _newDescription;

    }

    function deleteEvent(uint256 _id) public onlyAdmin {

        delete events[_id];

    }

    function assignQuestToEvent(

        uint256 _eventId,

        uint256 _questId,

        uint256 _questStartTime,

        uint256 _questEndTime

    ) public onlyAdmin {

        // Assuming QuestManager has a function to check if a quest exists

        require(questManager.getQuest(_questId).questId!= 0, "Quest does not exist");

        events[_eventId].quests[_questId] = QuestInfo(_questId, _questStartTime, _questEndTime);

    }

    function listEvents() public view returns (uint256[] memory ids) {

        uint256[] memory ids = new uint256[](events.length);

        for (uint256 i = 0; i < events.length; i++) {

            ids[i] = i;

        }

        return ids;

    }

    // Additional functions for participant registration, quest completion, and reward distribution

    // would go here, utilizing the QuestManager contract for quest-related operations.

}

Deliverables:

noireconnect2024 commented 4 days ago

image

Bit perplexing trying to see how to submit after filling out the form...whether or not it was completed or added

noireconnect2024 commented 4 days ago

After I selected completed and went back in I didn't see my event listed under the other ones someone submitted previously:

image

noireconnect2024 commented 4 days ago

image

Was able to go in create and update a new event and make edits. Workflow was simple and seamless