Skip to content

ECO-S14 Force Advance as Optional #70

@eshabansiya

Description

@eshabansiya

Make force advance optional - so participants can play games without waiting for other participants to finish

So rn, participants must wait for the facilitator to “Force advace” to move to the next phase

But, lets make it so that there is an option for games to not have this, and participants can just play through

If a session is asynchornou (is_asycn = TRUE), then lets make it so they can play through

File: app/facilitator/session-view/page.tsx

        <Button onClick={advancePhase} disabled={isAdvancing}>
          {isAdvancing ? "Advancing..." : "Force Advance"}
        </Button>

This is where we do that

so we only want advacePhase on the facilitator side if it is not async

and advance_phase is connected to an rpc

Resources on the rpc we made:

Participant File: app/participants/components/ParticipantNextButton.tsx

app/participants/session-flow/page.tsx

  • Here the participant waits to be moved to the next phase (if advance_rpc has been caled)
  • It is moved to the next phase when in participant_session, the phase_index is moved
  • So, either make a new rpc or query that moved that individual to the next phase (for that specific participant_session where session_id and user_id match, increase the index and make is_finished false)

The RPC for refrence:

DECLARE
  v_template_id uuid;
  v_next_phase_number integer;
BEGIN
  v_next_phase_number := p_current_phase_num + 1;

  SELECT template_id
  INTO v_template_id
  FROM session
  WHERE session_id = p_session_id;

  IF NOT EXISTS (
    SELECT 1
    FROM phase
    WHERE template_id = v_template_id
      AND phase_number = v_next_phase_number
  ) THEN
    RETURN NULL;
  END IF;

  UPDATE participant_session
  SET phase_index = v_next_phase_number,
      is_finished = FALSE
  WHERE session_id = p_session_id;

  RETURN v_next_phase_number;
END;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions