Exercises returns the user's exercises within the workspace. This doesn't find legacy exercises where the metadata is missing.
()
| 78 | // Exercises returns the user's exercises within the workspace. |
| 79 | // This doesn't find legacy exercises where the metadata is missing. |
| 80 | func (ws Workspace) Exercises() ([]Exercise, error) { |
| 81 | candidates, err := ws.PotentialExercises() |
| 82 | if err != nil { |
| 83 | return nil, err |
| 84 | } |
| 85 | |
| 86 | exercises := make([]Exercise, 0, len(candidates)) |
| 87 | for _, candidate := range candidates { |
| 88 | ok, err := candidate.HasMetadata() |
| 89 | if err != nil { |
| 90 | return nil, err |
| 91 | } |
| 92 | if ok { |
| 93 | exercises = append(exercises, candidate) |
| 94 | } |
| 95 | } |
| 96 | return exercises, nil |
| 97 | } |
| 98 | |
| 99 | // ExerciseDir determines the root directory of an exercise. |
| 100 | // This is the directory that contains the exercise metadata file. |