Page MenuHomePhabricator

Provide available and current participant questions via the API
Closed, ResolvedPublic

Description

Acceptance criteria

  • As a user
    • Given I have registered
    • And I have answered participant questions
    • I can use a GET API endpoint to see my current answers and visibility
  • As a user
    • Given I want to register for an event
    • I can use a GET API endpoint to see a list of available questions for an event
  • As a user
    • Given I want to register for an event
    • And I know what questions are enabled for that event
    • I can use a GET API endpoint to see the descriptions and possible answers to those questions

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptJun 29 2023, 11:57 AM

Change 934326 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Add participant questions support to API: get event questions, get your answers

https://gerrit.wikimedia.org/r/934326

Change 934388 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Add participant questions support to API: get possible answers

https://gerrit.wikimedia.org/r/934388

Change 934326 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add participant questions support to API: get event questions, get your answers

https://gerrit.wikimedia.org/r/934326

Change 934388 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add participant questions support to API: get possible answers

https://gerrit.wikimedia.org/r/934388

Change 935055 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Update format of participant answers returned by the API

https://gerrit.wikimedia.org/r/935055

Change 935055 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Update format of participant answers returned by the API

https://gerrit.wikimedia.org/r/935055

@Daimona can we edit these bits of AC? Given I want to register via the API [note, this isn't possible yet] to Given I have registered as in the first example in the AC, since API registration is not possible yet? Or just move this ticket out of QA until it is ready?

@Daimona can we edit these bits of AC? Given I want to register via the API [note, this isn't possible yet] to Given I have registered as in the first example in the AC, since API registration is not possible yet? Or just move this ticket out of QA until it is ready?

Thanks, I've updated them. Registering via the API wasn't indeed a requirement.

As a user
Given I have registered
And I have answered participant questions
โœ… I can use a GET API endpoint to see my current answers and visibility
/campaignevents/v0/event_registration/3/participants/self

Public:

Screenshot 2023-07-10 at 12.31.05 PM.png (1ร—1 px, 233 KB)

Private:
Screenshot 2023-07-10 at 12.34.32 PM.png (1ร—1 px, 190 KB)

Error messages are correctly displaying:

400 - You need a central user account in order to register for events.

Screenshot 2023-07-10 at 1.25.18 PM.png (1ร—1 px, 192 KB)

404 - There is no event with this id:

Screenshot 2023-07-10 at 12.46.06 PM.png (1ร—1 px, 190 KB)

404 -You are not participating in this event:

Screenshot 2023-07-10 at 12.47.41 PM.png (1ร—1 px, 199 KB)


As a user
Given I want to register for an event
โœ… I can use a GET API endpoint to see a list of available questions for an event
/campaignevents/v0/event_registration/3

Screenshot 2023-07-10 at 12.14.44 PM.png (1ร—1 px, 278 KB)


As a user
Given I want to register for an event
And I know what questions are enabled for that event
โœ… I can use a GET API endpoint to see the descriptions and possible answers to those questions
/campaignevents/v0/participant_questions

Screen Recording 2023-07-10 at 1.17.27 PM.gif (1ร—1 px, 3 MB)

and using the query param /campaignevents/v0/participant_questions?question_ids=5:

Screenshot 2023-07-10 at 1.13.02 PM.png (1ร—1 px, 252 KB)

and for multiple questions /campaignevents/v0/participant_questions?question_ids[]=2&question_ids[]=1 (using postman)

Screenshot 2023-07-10 at 1.50.24 PM.png (1ร—1 px, 307 KB)


โœ… The endpoints must be documented https://www.mediawiki.org/wiki/Extension:CampaignEvents/Api

@Daimona this all looks good except one thing is that we might want to be documented - a 400 error can be thrown in /campaignevents/v0/participant_questions if passing in anything besides an integer. It correctly returns an error, but should that 400 be reflected in the doc here? Right now a 200 is the only expected response in the doc

Screenshot 2023-07-10 at 1.52.21 PM.png (1ร—1 px, 231 KB)

@Daimona this all looks good except one thing is that we might want to be documented - a 400 error can be thrown in /campaignevents/v0/participant_questions if passing in anything besides an integer. It correctly returns an error, but should that 400 be reflected in the doc here? Right now a 200 is the only expected response in the doc

Even for the other endpoints, we do not document errors arising from bad parameter types -- otherwise there'd be a lot to document :) For each parameter, the documentation says what type is expected, and that should be sufficient. The exception being when there are "special" requirements, like passing an empty array as user_ids to the "Remove participants from an event" endpoint.

@Daimona this all looks good except one thing is that we might want to be documented - a 400 error can be thrown in /campaignevents/v0/participant_questions if passing in anything besides an integer. It correctly returns an error, but should that 400 be reflected in the doc here? Right now a 200 is the only expected response in the doc

Even for the other endpoints, we do not document errors arising from bad parameter types -- otherwise there'd be a lot to document :) For each parameter, the documentation says what type is expected, and that should be sufficient. The exception being when there are "special" requirements, like passing an empty array as user_ids to the "Remove participants from an event" endpoint.

Okay thx, sounds good!

ifried subscribed.

This looks good, as per QA notes. I'm marking this as Done.