Skip to content

Commit 5a9d750

Browse files
committed
rename assignment -> lesson
1 parent 2f2b645 commit 5a9d750

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

checks/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
)
99

1010
func CLICommand(
11-
assignment api.Assignment,
11+
lesson api.Lesson,
1212
optionalPositionalArgs []string,
1313
) []api.CLICommandResult {
14-
data := assignment.Assignment.AssignmentDataCLICommand.CLICommandData
14+
data := lesson.Lesson.LessonDataCLICommand.CLICommandData
1515
responses := make([]api.CLICommandResult, len(data.Commands))
1616
for i, command := range data.Commands {
1717
finalCommand := args.InterpolateCommand(command.Command, optionalPositionalArgs)

checks/http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ type HttpTestResult struct {
2424
}
2525

2626
func HttpTest(
27-
assignment api.Assignment,
27+
lesson api.Lesson,
2828
baseURL *string,
2929
) (
3030
responses []HttpTestResult,
3131
finalBaseURL string,
3232
) {
33-
data := assignment.Assignment.AssignmentDataHTTPTests
33+
data := lesson.Lesson.LessonDataHTTPTests
3434
client := &http.Client{}
3535
variables := make(map[string]string)
3636
responses = make([]HttpTestResult, len(data.HttpTests.Requests))

client/assignments.go renamed to client/lessons.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type HTTPTestHeader struct {
3838
Value string
3939
}
4040

41-
type AssignmentDataHTTPTests struct {
41+
type LessonDataHTTPTests struct {
4242
HttpTests struct {
4343
BaseURL *string
4444
ContainsCompleteDir bool
@@ -70,7 +70,7 @@ type CLICommandTestCase struct {
7070
StdoutLinesGt *int
7171
}
7272

73-
type AssignmentDataCLICommand struct {
73+
type LessonDataCLICommand struct {
7474
CLICommandData struct {
7575
Commands []struct {
7676
Command string
@@ -79,21 +79,21 @@ type AssignmentDataCLICommand struct {
7979
}
8080
}
8181

82-
type Assignment struct {
83-
Assignment struct {
82+
type Lesson struct {
83+
Lesson struct {
8484
Type string
85-
AssignmentDataHTTPTests *AssignmentDataHTTPTests
86-
AssignmentDataCLICommand *AssignmentDataCLICommand
85+
LessonDataHTTPTests *LessonDataHTTPTests
86+
LessonDataCLICommand *LessonDataCLICommand
8787
}
8888
}
8989

90-
func FetchAssignment(uuid string) (*Assignment, error) {
91-
resp, err := fetchWithAuth("GET", "/v1/assignments/"+uuid)
90+
func FetchLesson(uuid string) (*Lesson, error) {
91+
resp, err := fetchWithAuth("GET", "/v1/lessons/"+uuid)
9292
if err != nil {
9393
return nil, err
9494
}
9595

96-
var data Assignment
96+
var data Lesson
9797
err = json.Unmarshal(resp, &data)
9898
if err != nil {
9999
return nil, err
@@ -111,12 +111,12 @@ type submitHTTPTestRequest struct {
111111
ActualHTTPRequests any `json:"actualHTTPRequests"`
112112
}
113113

114-
func SubmitHTTPTestAssignment(uuid string, results any) error {
114+
func SubmitHTTPTestLesson(uuid string, results any) error {
115115
bytes, err := json.Marshal(submitHTTPTestRequest{ActualHTTPRequests: results})
116116
if err != nil {
117117
return err
118118
}
119-
resp, code, err := fetchWithAuthAndPayload("POST", "/v1/assignments/"+uuid+"/http_tests", bytes)
119+
resp, code, err := fetchWithAuthAndPayload("POST", "/v1/lessons/"+uuid+"/http_tests", bytes)
120120
if err != nil {
121121
return err
122122
}
@@ -141,12 +141,12 @@ type CLICommandResult struct {
141141
Stdout string
142142
}
143143

144-
func SubmitCLICommandAssignment(uuid string, results []CLICommandResult) (*StructuredErrCLICommand, error) {
144+
func SubmitCLICommandLesson(uuid string, results []CLICommandResult) (*StructuredErrCLICommand, error) {
145145
bytes, err := json.Marshal(submitCLICommandRequest{CLICommandResults: results})
146146
if err != nil {
147147
return nil, err
148148
}
149-
resp, code, err := fetchWithAuthAndPayload("POST", "/v1/assignments/"+uuid+"/cli_command", bytes)
149+
resp, code, err := fetchWithAuthAndPayload("POST", "/v1/lessons/"+uuid+"/cli_command", bytes)
150150
if err != nil {
151151
return nil, err
152152
}

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func init() {
1313
var runCmd = &cobra.Command{
1414
Use: "run UUID",
1515
Args: cobra.MatchAll(cobra.RangeArgs(1, 10)),
16-
Short: "Run an assignment without submitting",
16+
Short: "Run an lesson without submitting",
1717
PreRun: compose(requireUpdated, requireAuth),
1818
RunE: submissionHandler,
1919
}

cmd/submit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,40 @@ func init() {
2121
var submitCmd = &cobra.Command{
2222
Use: "submit UUID",
2323
Args: cobra.MatchAll(cobra.RangeArgs(1, 10)),
24-
Short: "Submit an assignment",
24+
Short: "Submit an lesson",
2525
PreRun: compose(requireUpdated, requireAuth),
2626
RunE: submissionHandler,
2727
}
2828

2929
func submissionHandler(cmd *cobra.Command, args []string) error {
3030
cmd.SilenceUsage = true
3131
isSubmit := cmd.Name() == "submit"
32-
assignmentUUID := args[0]
32+
lessonUUID := args[0]
3333
optionalPositionalArgs := []string{}
3434
if len(args) > 1 {
3535
optionalPositionalArgs = args[1:]
3636
}
3737

38-
assignment, err := api.FetchAssignment(assignmentUUID)
38+
lesson, err := api.FetchLesson(lessonUUID)
3939
if err != nil {
4040
return err
4141
}
42-
switch assignment.Assignment.Type {
42+
switch lesson.Lesson.Type {
4343
case "type_http_tests":
44-
results, finalBaseURL := checks.HttpTest(*assignment, &submitBaseURL)
45-
render.PrintHTTPResults(results, assignment, finalBaseURL)
44+
results, finalBaseURL := checks.HttpTest(*lesson, &submitBaseURL)
45+
render.PrintHTTPResults(results, lesson, finalBaseURL)
4646
if isSubmit {
47-
err := api.SubmitHTTPTestAssignment(assignmentUUID, results)
47+
err := api.SubmitHTTPTestLesson(lessonUUID, results)
4848
if err != nil {
4949
return err
5050
}
5151
fmt.Println("\nSubmitted! Check the lesson on Boot.dev for results")
5252
}
5353
case "type_cli_command":
54-
results := checks.CLICommand(*assignment, optionalPositionalArgs)
55-
data := *assignment.Assignment.AssignmentDataCLICommand
54+
results := checks.CLICommand(*lesson, optionalPositionalArgs)
55+
data := *lesson.Lesson.LessonDataCLICommand
5656
if isSubmit {
57-
failure, err := api.SubmitCLICommandAssignment(assignmentUUID, results)
57+
failure, err := api.SubmitCLICommandLesson(lessonUUID, results)
5858
if err != nil {
5959
return err
6060
}
@@ -63,7 +63,7 @@ func submissionHandler(cmd *cobra.Command, args []string) error {
6363
render.CommandRun(data, results, optionalPositionalArgs)
6464
}
6565
default:
66-
return errors.New("unsupported assignment type")
66+
return errors.New("unsupported lesson type")
6767
}
6868
return nil
6969
}

render/command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ func pointerToBool(a bool) *bool {
213213
}
214214

215215
func CommandRun(
216-
data api.AssignmentDataCLICommand,
216+
data api.LessonDataCLICommand,
217217
results []api.CLICommandResult,
218218
optionalPositionalArgs []string,
219219
) {
220220
commandRenderer(data, results, nil, false, optionalPositionalArgs)
221221
}
222222

223223
func CommandSubmission(
224-
data api.AssignmentDataCLICommand,
224+
data api.LessonDataCLICommand,
225225
results []api.CLICommandResult,
226226
failure *api.StructuredErrCLICommand,
227227
optionalPositionalArgs []string,
@@ -230,7 +230,7 @@ func CommandSubmission(
230230
}
231231

232232
func commandRenderer(
233-
data api.AssignmentDataCLICommand,
233+
data api.LessonDataCLICommand,
234234
results []api.CLICommandResult,
235235
failure *api.StructuredErrCLICommand,
236236
isSubmit bool,

render/http.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import (
88
api "github.com/bootdotdev/bootdev/client"
99
)
1010

11-
func PrintHTTPResults(results []checks.HttpTestResult, assignment *api.Assignment, finalBaseURL string) {
11+
func PrintHTTPResults(results []checks.HttpTestResult, lesson *api.Lesson, finalBaseURL string) {
1212
fmt.Println("=====================================")
1313
defer fmt.Println("=====================================")
1414
fmt.Printf("Running requests against: %s\n", finalBaseURL)
1515
for i, result := range results {
16-
printHTTPResult(result, i, assignment)
16+
printHTTPResult(result, i, lesson)
1717
}
1818
}
1919

20-
func printHTTPResult(result checks.HttpTestResult, i int, assignment *api.Assignment) {
21-
req := assignment.Assignment.AssignmentDataHTTPTests.HttpTests.Requests[i]
20+
func printHTTPResult(result checks.HttpTestResult, i int, lesson *api.Lesson) {
21+
req := lesson.Lesson.LessonDataHTTPTests.HttpTests.Requests[i]
2222
fmt.Printf("%v. %v %v\n", i+1, req.Request.Method, req.Request.Path)
2323
if result.Err != "" {
2424
fmt.Printf(" Err: %v\n", result.Err)

0 commit comments

Comments
 (0)