Skip to content

Commit d3691fd

Browse files
authored
feat: edit exercise button (#290)
* feat: add exercise guide and update ActionBar (#290) * Introduced a new guide for adding and editing exercises in Starklings. * Enhanced ActionBar with an "Add Exercise" button that opens the guide in a new tab. * Updated Workspace component to handle the new button functionality. * feat: enhance exercise editing capabilities in Starklings * Added quick edit buttons for exercises and hints in the ActionBar, visible when connected to GitHub. * Implemented functionality to open the corresponding files directly in the user's GitHub fork for easy editing. * Updated the add_exercises.md guide to include new editing workflows and benefits of the quick edit system. * Improved Workspace component to support new edit actions and detect GitHub connection status. * feat: unify exercise editing options in Starklings * Replaced multiple edit buttons with a single "Edit Options" button in the ActionBar for a streamlined user experience. * Introduced a dialog that provides clear editing options and requirements when editing exercises and hints. * Updated the add_exercises.md guide to reflect the new editing workflow and benefits of the unified editing system. * Enhanced the Workspace component to support the new edit dialog and display the current exercise name. * refactor: replace add_exercises.md with CONTRIBUTION_GUIDE.md * Deleted the outdated add_exercises.md file and replaced it with a new CONTRIBUTION_GUIDE.md that consolidates instructions for adding and editing exercises in Starklings. * Updated ActionBar and Workspace components to reflect the new guide and ensure users are directed to the correct documentation for exercise contributions. * Translated relevant text in the ActionBar from Spanish to English for consistency and improved accessibility. * refactor: update ActionBar edit button for improved clarity * Replaced the "Edit options" tooltip with a simplified "Edit" tooltip for the edit button in the ActionBar. * Adjusted the layout to enhance user experience and maintain consistency in the interface. * docs: add EXERCISE_CONTRIBUTION_GUIDE.md for exercise management * Introduced a comprehensive guide detailing the process for adding and editing exercises in the Starklings project. * Updated the ActionBar to remove the outdated edit options dialog reference. * Modified the Workspace component to link to the new exercise contribution guide, ensuring users have access to the latest instructions for exercise contributions. * refactor: simplify handleEditExerciseClick in Workspace component * Removed unnecessary conditional check in handleEditExerciseClick, allowing direct opening of the GitHub edit link for exercises. * Streamlined the code for improved readability and efficiency. * fix: add conditional check in handleEditExerciseClick for GitHub link * Implemented a conditional check to ensure data.path is defined before attempting to open the GitHub edit link in handleEditExerciseClick. * This change prevents potential errors when the path is not available, enhancing the robustness of the Workspace component. * resolve comments * resolve comments * update GitHub username * remove new line * add new line
1 parent ca1d287 commit d3691fd

2 files changed

Lines changed: 361 additions & 4 deletions

File tree

EXERCISE_CONTRIBUTION_GUIDE.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Guide to Adding or Editing Starklings Exercises
2+
3+
This guide will help you add new exercises or edit existing ones in the Starklings project, an interactive platform to learn Cairo and Starknet.
4+
5+
## 📁 Project Structure
6+
7+
Starklings exercises are organized as follows:
8+
9+
```
10+
starklings/
11+
├── exercises/ # 📂 Main exercises directory
12+
│ ├── arrays/ # 📂 Array exercises
13+
│ ├── variables/ # 📂 Variable exercises
14+
│ ├── functions/ # 📂 Function exercises
15+
│ ├── starknet/ # 📂 Starknet-specific exercises
16+
│ └── ... # 📂 Other categories
17+
├── info.toml # ⚙️ Exercises and hints configuration
18+
```
19+
20+
## 🔧 Exercise Components
21+
22+
Each exercise in Starklings has **3 main components**:
23+
24+
### 1. 📄 Exercise File (`.cairo`)
25+
- **Location**: `exercises/<category>/<exercise_name>.cairo`
26+
- **Contains**: Cairo code with descriptive comments and the marker `// I AM NOT DONE`
27+
28+
### 2. 📝 Configuration in `info.toml`
29+
- **Location**: `info.toml` (project root)
30+
- **Contains**: Exercise metadata, execution mode, and hints
31+
32+
📋 **Prerequisites:**
33+
• You must have the project forked in your GitHub account
34+
• Your fork must be synced with the main repository
35+
36+
## ✏️ Editing an Existing Exercise
37+
38+
### Edit the Exercise Description
39+
40+
To change the description of an exercise (for example, `arrays1.cairo`):
41+
42+
1. **Open the exercise file:**
43+
```bash
44+
exercises/arrays/arrays1.cairo
45+
```
46+
47+
2. **Edit the comments at the top of the file:**
48+
```cairo
49+
// Your new exercise description here
50+
// Explain what the student should do
51+
// You can use multiple comment lines
52+
53+
// I AM NOT DONE ← This marker must stay
54+
55+
fn create_array() -> Array<felt252> {
56+
// ... exercise code
57+
}
58+
```
59+
60+
**⚠️ Important:**
61+
- Only edit the comments at the top of the file
62+
- **Do NOT remove** the `// I AM NOT DONE` line (it's needed for the system)
63+
- Use `//` for all descriptions
64+
65+
### Edit the Exercise Hint
66+
67+
To change the hint shown to students:
68+
69+
1. **Open the configuration file:**
70+
```bash
71+
info.toml
72+
```
73+
74+
2. **Find the exercise section:**
75+
```toml
76+
[[exercises]]
77+
name = "arrays1"
78+
path = "exercises/arrays/arrays1.cairo"
79+
mode = "test"
80+
hint = """
81+
Your new hint here.
82+
You can use multiple lines.
83+
Give key concepts or subtle tips.
84+
"""
85+
```
86+
87+
## ➕ Adding a New Exercise
88+
89+
### Step 1: Create the Exercise File
90+
91+
1. **Go to the right category** (or create a new one):
92+
```bash
93+
cd exercises/<category>/
94+
```
95+
96+
2. **Create the `.cairo` file:**
97+
```cairo
98+
// Clear and concise exercise description
99+
// Explain what concept it teaches
100+
// Give specific instructions
101+
102+
// I AM NOT DONE
103+
104+
fn example_exercise() {
105+
// Starter code with blanks or errors
106+
// for the student to complete
107+
}
108+
109+
// Test or verification code
110+
#[test]
111+
fn test_example() {
112+
// Tests to validate the solution
113+
}
114+
```
115+
116+
### Step 2: Configure in `info.toml`
117+
118+
1. **Open `info.toml`** and find your category section
119+
120+
2. **Add the exercise configuration:**
121+
```toml
122+
[[exercises]]
123+
name = "new_exercise" # Unique exercise name
124+
path = "exercises/category/new_exercise.cairo" # Path to the file
125+
mode = "test" # "test", "run", or "build"
126+
hint = """
127+
Helpful hint for the student.
128+
Can include:
129+
- Links to docs: https://book.cairo-lang.org/...
130+
- Key concepts to remember
131+
- Tips about the solution (not the full answer)
132+
"""
133+
```
134+
135+
## 🔄 Exercise Modes
136+
137+
In `info.toml`, each exercise has a `mode` field that determines how it runs:
138+
139+
- **`"test"`**: Runs the exercise tests
140+
- **`"run"`**: Runs the main program
141+
142+
## ✅ Best Practices
143+
144+
### For Exercise Descriptions:
145+
- 📝 Be clear and concise
146+
- 🎯 Focus on one concept per exercise
147+
- 📚 Mention previous concepts if needed
148+
- 🔍 Give enough context without revealing the solution
149+
150+
### For Hints:
151+
- 💡 Give tips, not full solutions
152+
- 🔗 Include links to relevant docs
153+
- 📖 Explain key concepts if needed
154+
- 🎯 Be specific about what to look for
155+
156+
### For Code:
157+
- 🏗️ Include useful starter code
158+
- ✅ Add tests to validate the solution
159+
- 🚫 Keep the `// I AM NOT DONE` marker
160+
- 📦 Import needed dependencies
161+
162+
With this guide and the quick edit buttons, you can now easily add and edit Starklings exercises! 🚀

0 commit comments

Comments
 (0)