From f331e91eb04dd7f3390e63204ed482ea304dbee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Fri, 1 Nov 2024 11:45:03 +0100 Subject: [PATCH 1/2] No reviews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Pinson --- instruqt/play.go | 6 ++++-- instruqt/track.go | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/instruqt/play.go b/instruqt/play.go index c985bda..cbaa671 100644 --- a/instruqt/play.go +++ b/instruqt/play.go @@ -51,8 +51,8 @@ type PlayReports struct { // PlayReport represents the data structure for a single play report on Instruqt. type PlayReport struct { - Id string // The unique identifier for the play report. - Track SandboxTrack // The track played. + Id string // The unique identifier for the play report. + Track SandboxTrackNoReviews // The track played. TrackInvite TrackInvite // The optional Track invite associated to the play. @@ -143,6 +143,8 @@ func (c *Client) GetPlays(from time.Time, to time.Time, take int, skip int, opts userIds[i] = graphql.String(id) } + c.InfoLogger.Printf("teamslug: %s", c.TeamSlug) + // Prepare the variables map for the GraphQL query variables := map[string]interface{}{ "teamSlug": graphql.String(c.TeamSlug), diff --git a/instruqt/track.go b/instruqt/track.go index 081623f..e95daab 100644 --- a/instruqt/track.go +++ b/instruqt/track.go @@ -100,6 +100,32 @@ type SandboxTrack struct { } } +// SandboxTrackNoReviews represents a track in a sandbox environment, including its details +// and associated challenges, without reviews. +type SandboxTrackNoReviews struct { + Id string // The unique identifier for the sandbox track. + Slug string // The slug identifier for the sandbox track. + Icon string // The icon associated with the sandbox track. + Title string // The title of the sandbox track. + Description string // The description of the sandbox track. + Teaser string // A teaser or short description of the sandbox track. + Level string // The difficulty level of the sandbox track. + Embed_Token string // The token used for embedding the sandbox track. + Statistics struct { // Statistics about the sandbox track. + Average_review_score float32 // The average review score of the sandbox track. + } + TrackTags []struct { // A list of tags associated with the sandbox track. + Value string + } + Challenges []Challenge // A list of challenges associated with the sandbox track. + Status string // The current status of the sandbox track. + Started time.Time // The timestamp when the sandbox track was started. + Completed time.Time // The timestamp when the sandbox track was completed. + Participant struct { // Information about the participant of the sandbox track. + Id string + } +} + // GetTrackById retrieves a track from Instruqt using its unique track ID. // // Parameters: From f95ef70937d4d69d96919d962e28b332ca0b6b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Fri, 1 Nov 2024 14:42:27 +0100 Subject: [PATCH 2/2] no track MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Pinson --- instruqt/challenge.go | 9 +++++++++ instruqt/track.go | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/instruqt/challenge.go b/instruqt/challenge.go index b0668e5..4d60d98 100644 --- a/instruqt/challenge.go +++ b/instruqt/challenge.go @@ -42,6 +42,15 @@ type Challenge struct { } `json:"-"` } +// ChallengeNoTrack represents the data structure for an Instruqt challenge. +type ChallengeNoTrack struct { + Id string `json:"id"` // The unique identifier for the challenge. + Slug string `json:"slug"` // The slug for the challenge, which is a human-readable identifier. + Title string `json:"title"` // The title of the challenge. + Index int `json:"index"` // The index of the challenge in the track. + Status string `json:"status"` // The status of the challenge (e.g., "unlocked", "completed"). +} + // GetChallenge retrieves a challenge from Instruqt using its unique challenge ID. // // Parameters: diff --git a/instruqt/track.go b/instruqt/track.go index e95daab..934bb6f 100644 --- a/instruqt/track.go +++ b/instruqt/track.go @@ -91,11 +91,11 @@ type SandboxTrack struct { TotalCount int Nodes []Review } - Challenges []Challenge // A list of challenges associated with the sandbox track. - Status string // The current status of the sandbox track. - Started time.Time // The timestamp when the sandbox track was started. - Completed time.Time // The timestamp when the sandbox track was completed. - Participant struct { // Information about the participant of the sandbox track. + Challenges []ChallengeNoTrack // A list of challenges associated with the sandbox track. + Status string // The current status of the sandbox track. + Started time.Time // The timestamp when the sandbox track was started. + Completed time.Time // The timestamp when the sandbox track was completed. + Participant struct { // Information about the participant of the sandbox track. Id string } } @@ -117,11 +117,11 @@ type SandboxTrackNoReviews struct { TrackTags []struct { // A list of tags associated with the sandbox track. Value string } - Challenges []Challenge // A list of challenges associated with the sandbox track. - Status string // The current status of the sandbox track. - Started time.Time // The timestamp when the sandbox track was started. - Completed time.Time // The timestamp when the sandbox track was completed. - Participant struct { // Information about the participant of the sandbox track. + Challenges []ChallengeNoTrack // A list of challenges associated with the sandbox track. + Status string // The current status of the sandbox track. + Started time.Time // The timestamp when the sandbox track was started. + Completed time.Time // The timestamp when the sandbox track was completed. + Participant struct { // Information about the participant of the sandbox track. Id string } } @@ -216,7 +216,7 @@ func (c *Client) GetTrackBySlug(trackSlug string) (t Track, err error) { // Returns: // - Challenge: The first unlocked challenge found. // - error: Any error encountered while retrieving the challenge. -func (c *Client) GetTrackUnlockedChallenge(userId string, trackId string) (challenge Challenge, err error) { +func (c *Client) GetTrackUnlockedChallenge(userId string, trackId string) (challenge ChallengeNoTrack, err error) { track, err := c.GetUserTrackById(userId, trackId) if err != nil { return challenge, fmt.Errorf("[instruqt.GetTrackUnlockedChallenge] failed to get user track: %v", err)