@learnpack/learnpack 5.0.118 → 5.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,8 +10,8 @@
10
10
  />
11
11
 
12
12
  <title>Learnpack Creator: Craft tutorials in seconds!</title>
13
- <script type="module" crossorigin src="/creator/assets/index-BmLJLoHH.js"></script>
14
- <link rel="stylesheet" crossorigin href="/creator/assets/index-D5mdIXUX.css">
13
+ <script type="module" crossorigin src="/creator/assets/index-oNPF5WK9.js"></script>
14
+ <link rel="stylesheet" crossorigin href="/creator/assets/index-1sKQbOKY.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -1 +1 @@
1
- {"version":"5.0.118","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
1
+ {"version":"5.0.122","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false}},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"strict":{"name":"strict","type":"boolean","char":"s","description":"strict mode","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"serve":{"id":"serve","description":"Runs a small server to build tutorials","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learnpack/learnpack",
3
3
  "description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
4
- "version": "5.0.118",
4
+ "version": "5.0.122",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -14,7 +14,7 @@ import { ValidationError } from "../utils/errors"
14
14
 
15
15
  import * as path from "path"
16
16
  import {
17
- hasCreatorPermission,
17
+ // hasCreatorPermission,
18
18
  generateImage,
19
19
  downloadImage,
20
20
  interactiveCreation,
@@ -10,11 +10,8 @@ import { interactiveCreation } from "./utils/rigo"
10
10
  import { checkParams, loginWithToken, parseLesson } from "./utils/lib"
11
11
 
12
12
  import { Uploader } from "./components/Uploader"
13
-
14
- // const exampleContentIndex = `-Introduction to AI: Explain what is AI and its applications
15
- // -Introduction to Machine Learning: Explain What is machine learning and its aplications
16
- // -What is an AI Model: Explain what is an AI model an its applications`
17
-
13
+ import toast from "react-hot-toast"
14
+ import { ParamsChecker } from "./components/ParamsChecker"
18
15
  function App() {
19
16
  const navigate = useNavigate()
20
17
 
@@ -101,12 +98,12 @@ function App() {
101
98
  const buildSteps = () => {
102
99
  const steps = [
103
100
  {
104
- title: "Provide a description for your tutorial",
101
+ title: "Provide a description for your course",
105
102
  slug: "description",
106
103
  isCompleted: false,
107
104
  content: (
108
105
  <textarea
109
- placeholder="Describe your tutorial"
106
+ placeholder="Describe what you want to learn"
110
107
  className="w-full h-24 border-2 border-gray-300 rounded-md p-2 bg-white"
111
108
  value={formState.description}
112
109
  onChange={(e) => {
@@ -161,7 +158,7 @@ function App() {
161
158
  ),
162
159
  },
163
160
  {
164
- title: "Do you have a content index for this tutorial?",
161
+ title: "Any materials to get this course started?",
165
162
  slug: "hasContentIndex",
166
163
  isCompleted: false,
167
164
  content: (
@@ -181,6 +178,15 @@ function App() {
181
178
  <SelectableCard
182
179
  title="No, help me create one"
183
180
  onClick={() => {
181
+ if (!formState.contentIndex && !formState.description) {
182
+ toast.error(
183
+ "Please provide at least a description for your course!"
184
+ )
185
+ setFormState({
186
+ currentStep: "description",
187
+ })
188
+ return
189
+ }
184
190
  setFormState({
185
191
  hasContentIndex: false,
186
192
  isCompleted: true,
@@ -218,6 +224,7 @@ function App() {
218
224
  }
219
225
  return (
220
226
  <>
227
+ <ParamsChecker />
221
228
  {formState.isCompleted ? (
222
229
  <Loader
223
230
  text="Learnpack is setting up your tutorial. It may take a moment..."
@@ -1,6 +1,11 @@
1
1
  // import { useState, useRef } from "react"
2
2
  // import { SVGS } from "../assets/svgs"
3
3
 
4
+ import { useState } from "react"
5
+ import { useRef } from "react"
6
+ import { SVGS } from "../assets/svgs"
7
+ import useStore from "../utils/store"
8
+
4
9
  export interface Lesson {
5
10
  id: string
6
11
  uid: string
@@ -28,12 +33,13 @@ interface LessonItemProps {
28
33
 
29
34
  export const LessonItem: React.FC<LessonItemProps> = ({
30
35
  lesson,
31
- // onChange,
32
- // onRemove,
36
+ onChange,
37
+ onRemove,
33
38
  isNew,
34
39
  }) => {
35
- // const inputRef = useRef<HTMLInputElement>(null)
36
- // const [isEditing, setIsEditing] = useState(false)
40
+ const mode = useStore((state) => state.mode)
41
+ const inputRef = useRef<HTMLInputElement>(null)
42
+ const [isEditing, setIsEditing] = useState(false)
37
43
 
38
44
  return (
39
45
  <div
@@ -43,11 +49,13 @@ export const LessonItem: React.FC<LessonItemProps> = ({
43
49
  >
44
50
  {isNew && <span className="red-ball"></span>}
45
51
  {/* <span className="index-circle">{cleanFloatString(lesson.id)}</span> */}
46
- {/* <span className="text-gray-500 text-sm">
47
- {lesson.type[0] + lesson.type.slice(1).toLowerCase()} ●
48
- </span> */}
52
+ {mode === "teacher" && (
53
+ <span className="text-gray-500 text-sm">
54
+ {lesson.type[0] + lesson.type.slice(1).toLowerCase()}
55
+ </span>
56
+ )}
49
57
 
50
- {/* {isEditing ? (
58
+ {isEditing ? (
51
59
  <input
52
60
  defaultValue={lesson.title}
53
61
  ref={inputRef}
@@ -61,30 +69,33 @@ export const LessonItem: React.FC<LessonItemProps> = ({
61
69
  />
62
70
  ) : (
63
71
  <span className="flex-1 text-sm text-gray-800">{lesson.title}</span>
64
- )} */}
65
- <span className="flex-1 text-sm text-gray-800">{lesson.title}</span>
72
+ )}
66
73
 
67
74
  <span className="text-sm text-gray-600 bg-blue-100 px-2 py-1 rounded-full">
68
75
  {lesson.duration} min
69
76
  </span>
70
77
 
71
- {/* <button
72
- onClick={() => {
73
- setIsEditing(!isEditing)
74
- if (inputRef.current) {
75
- onChange(lesson.uid, inputRef.current.value)
76
- }
77
- }}
78
- className="text-gray-500 hover:text-blue-500 cursor-pointer "
79
- >
80
- {SVGS.pen}
81
- </button>
82
- <button
83
- onClick={() => onRemove()}
84
- className="text-red-500 hover:text-red-700 cursor-pointer"
85
- >
86
- {SVGS.trash}
87
- </button> */}
78
+ {mode === "teacher" && (
79
+ <>
80
+ <button
81
+ onClick={() => {
82
+ setIsEditing(!isEditing)
83
+ if (inputRef.current) {
84
+ onChange(lesson.uid, inputRef.current.value)
85
+ }
86
+ }}
87
+ className="text-gray-500 hover:text-blue-500 cursor-pointer "
88
+ >
89
+ {SVGS.pen}
90
+ </button>
91
+ <button
92
+ onClick={() => onRemove()}
93
+ className="text-red-500 hover:text-red-700 cursor-pointer"
94
+ >
95
+ {SVGS.trash}
96
+ </button>
97
+ </>
98
+ )}
88
99
  </div>
89
100
  )
90
101
  }
@@ -31,7 +31,7 @@ const LinkUploader: React.FC<LinkUploaderProps> = ({ onResult }) => {
31
31
 
32
32
  try {
33
33
  const key = toBase64Url(raw)
34
- const resp = await fetch(`actions/fetch/${key}`)
34
+ const resp = await fetch(`/actions/fetch/${key}`)
35
35
  if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
36
36
  const data = (await resp.json()) as ParsedLink
37
37
 
@@ -0,0 +1,17 @@
1
+ import { useEffect } from "react"
2
+ import useStore from "../utils/store"
3
+
4
+ export const ParamsChecker = () => {
5
+ const setMode = useStore((state) => state.setMode)
6
+
7
+ useEffect(() => {
8
+ const params = new URLSearchParams(window.location.search)
9
+ const mode = params.get("mode")
10
+ if (mode && ["teacher", "student"].includes(mode.toLowerCase())) {
11
+ console.log("Setting mode to ", mode.toLowerCase())
12
+ setMode(mode.toLowerCase() as "teacher" | "student")
13
+ }
14
+ }, [])
15
+
16
+ return <></>
17
+ }
@@ -7,6 +7,7 @@ import Loader from "../Loader"
7
7
  import { motion, AnimatePresence } from "framer-motion"
8
8
  // import { randomUUID } from "../../utils/creatorUtils"
9
9
  import toast from "react-hot-toast"
10
+ import { randomUUID } from "../../utils/creatorUtils"
10
11
 
11
12
  const ContentIndexHeader = ({
12
13
  messages,
@@ -104,6 +105,7 @@ export const ContentIndex = ({
104
105
  }) => {
105
106
  const history = useStore((state) => state.history)
106
107
  const push = useStore((state) => state.push)
108
+ const mode = useStore((state) => state.mode)
107
109
  const containerRef = useRef<HTMLDivElement>(null)
108
110
  const [showScrollHint, setShowScrollHint] = useState(false)
109
111
 
@@ -127,22 +129,22 @@ export const ContentIndex = ({
127
129
  })
128
130
  }
129
131
 
130
- // const addLessonAfter = (index: number, id: string) => {
131
- // const newLesson: Lesson = {
132
- // id: (parseFloat(id) + 0.1).toFixed(1),
133
- // title: "Hello World",
134
- // uid: randomUUID(),
135
- // type: "READ",
136
- // duration: 2,
137
- // description: "Hello World",
138
- // }
139
- // const updated = [...syllabus.lessons]
140
- // updated.splice(index + 1, 0, newLesson)
141
- // push({
142
- // ...syllabus,
143
- // lessons: updated,
144
- // })
145
- // }
132
+ const addLessonAfter = (index: number, id: string) => {
133
+ const newLesson: Lesson = {
134
+ id: (parseFloat(id) + 0.1).toFixed(1),
135
+ title: "Hello World",
136
+ uid: randomUUID(),
137
+ type: "READ",
138
+ duration: 2,
139
+ description: "Hello World",
140
+ }
141
+ const updated = [...syllabus.lessons]
142
+ updated.splice(index + 1, 0, newLesson)
143
+ push({
144
+ ...syllabus,
145
+ lessons: updated,
146
+ })
147
+ }
146
148
 
147
149
  useEffect(() => {
148
150
  const container = containerRef.current
@@ -205,16 +207,18 @@ export const ContentIndex = ({
205
207
  )
206
208
  )}
207
209
  />
208
- {/* <div className="relative h-6">
209
- <div className="absolute left-1/2 -translate-x-1/2 -top-3">
210
- <button
211
- onClick={() => addLessonAfter(index, lesson.id)}
212
- className="w-6 h-6 flex items-center justify-center bg-blue-100 text-blue-600 rounded hover:bg-blue-200 shadow-sm text-sm font-semibold cursor-pointer"
213
- >
214
- +
215
- </button>
210
+ {mode === "teacher" && (
211
+ <div className="relative h-6">
212
+ <div className="absolute left-1/2 -translate-x-1/2 -top-3">
213
+ <button
214
+ onClick={() => addLessonAfter(index, lesson.id)}
215
+ className="w-6 h-6 flex items-center justify-center bg-blue-100 text-blue-600 rounded hover:bg-blue-200 shadow-sm text-sm font-semibold cursor-pointer"
216
+ >
217
+ +
218
+ </button>
219
+ </div>
216
220
  </div>
217
- </div> */}
221
+ )}
218
222
  </div>
219
223
  ))}
220
224
  {syllabus.lessons.length > 0 && (
@@ -43,15 +43,15 @@ export const Sidebar = ({
43
43
  <div className="fixed bottom-5 left-2 z-50 lg:hidden">
44
44
  {showBubble && (
45
45
  <div
46
- className={`flex flex-col gap-2 cloudy bg-white rounded-md p-2 shadow-md bg-gray-blue duration-500 `}
46
+ className={`flex flex-row gap-3 cloudy bg-white rounded-md p-2 shadow-md bg-learnpack-blue duration-500 border-2 border-blue-600`}
47
47
  >
48
+ <span>Chat with me to update the course content</span>
48
49
  <button
49
- className="absolute top-1 right-1 text-red-500 cursor-pointer"
50
+ className=" text-red-500 cursor-pointer bg-learnpack-blue p-2 rounded-md"
50
51
  onClick={() => setShowBubble(false)}
51
52
  >
52
53
  {SVGS.redClose}
53
54
  </button>
54
- Chat with me to update the course content
55
55
  </div>
56
56
  )}
57
57
  <button
@@ -29,6 +29,7 @@ import Login from "../Login"
29
29
  import { eventBus } from "../../utils/eventBus"
30
30
  import { useNavigate } from "react-router"
31
31
  import PreviewGenerator from "../PreviewGenerator"
32
+ import { ParamsChecker } from "../ParamsChecker"
32
33
 
33
34
  const SyllabusEditor: React.FC = () => {
34
35
  const navigate = useNavigate()
@@ -219,6 +220,7 @@ It may take a moment..."
219
220
  </>
220
221
  ) : (
221
222
  <div className="flex w-full bg-white rounded-md shadow-md overflow-hidden h-screen ">
223
+ <ParamsChecker />
222
224
  {showLoginModal && (
223
225
  <Login
224
226
  onFinish={() => {
@@ -6,7 +6,12 @@ import {
6
6
  uploadFileToBucket,
7
7
  uploadImageToBucket,
8
8
  } from "./lib"
9
- import { makeReadmeReadable, readmeCreator, checkReadability } from "./rigo"
9
+ import {
10
+ makeReadmeReadable,
11
+ readmeCreator,
12
+ checkReadability,
13
+ createCodeFile,
14
+ } from "./rigo"
10
15
  import { FormState } from "./store"
11
16
 
12
17
  export const slugify = (text: string) => {
@@ -117,28 +122,29 @@ export async function processExercise(
117
122
  }, 500)
118
123
 
119
124
  const readmeFilename = "README.md"
125
+
126
+ const targetDir = `${exercisesDir}/${slugify(
127
+ exercise.id + "-" + exercise.title
128
+ )}`
120
129
  await uploadFileToBucket(
121
130
  readability.newMarkdown,
122
- `${exercisesDir}/${slugify(
123
- exercise.id + "-" + exercise.title
124
- )}/${readmeFilename}`
131
+ `${targetDir}/${readmeFilename}`
125
132
  )
126
133
 
127
134
  if (exercise.type.toLowerCase() === "code") {
128
- // const codeFile = await createCodeFile(rigoToken, {
129
- // readme: readability.newMarkdown,
130
- // tutorial_info: packageContext,
131
- // })
132
- // fs.writeFileSync(
133
- // path.join(
134
- // exerciseDir,
135
- // `app.${codeFile.parsed.extension.replace(".", "")}`
136
- // ),
137
- // codeFile.parsed.content
138
- // )
135
+ eventBus.emit("course-generation", {
136
+ message: `🔍 Creating code file for ${exercise.title}`,
137
+ })
138
+ const codeFile = await createCodeFile(rigoToken, {
139
+ readme: readability.newMarkdown,
140
+ tutorial_info: packageContext,
141
+ })
142
+ await uploadFileToBucket(
143
+ codeFile.parsed.content,
144
+ `${targetDir}/index.${codeFile.parsed.extension.replace(".", "")}`
145
+ )
139
146
  }
140
147
 
141
- // toast.success("Lesson generated successfully", { id: tid })
142
148
  return readability.newMarkdown
143
149
  }
144
150
 
@@ -389,3 +389,30 @@ export async function makeReadmeReadable(
389
389
  return null
390
390
  }
391
391
  }
392
+
393
+ type TCreateCodeFileInputs = {
394
+ readme: string
395
+ tutorial_info: string
396
+ }
397
+
398
+ export const createCodeFile = async (
399
+ token: string,
400
+ inputs: TCreateCodeFileInputs
401
+ ) => {
402
+ const response = await axios.post(
403
+ `${RIGOBOT_HOST}/v1/prompting/completion/456/`,
404
+ {
405
+ inputs: inputs,
406
+ include_purpose_objective: false,
407
+ execute_async: false,
408
+ },
409
+ {
410
+ headers: {
411
+ "Content-Type": "application/json",
412
+ Authorization: "Token " + token,
413
+ },
414
+ }
415
+ )
416
+
417
+ return response.data
418
+ }
@@ -52,6 +52,8 @@ type Store = {
52
52
  setFormState: (formState: Partial<FormState>) => void
53
53
  consumables: Consumables
54
54
  setConsumables: (consumables: Partial<Consumables>) => void
55
+ mode: "student" | "teacher"
56
+ setMode: (mode: "student" | "teacher") => void
55
57
  }
56
58
 
57
59
  const useStore = create<Store>()(
@@ -119,6 +121,8 @@ const useStore = create<Store>()(
119
121
  }),
120
122
 
121
123
  setAuth: (auth: Auth) => set({ auth }),
124
+ mode: "student",
125
+ setMode: (mode: "student" | "teacher") => set({ mode }),
122
126
  }),
123
127
  {
124
128
  name: "syllabus-storage",
@@ -390,15 +390,9 @@
390
390
  .top-0 {
391
391
  top: calc(var(--spacing) * 0);
392
392
  }
393
- .top-1 {
394
- top: calc(var(--spacing) * 1);
395
- }
396
393
  .top-2 {
397
394
  top: calc(var(--spacing) * 2);
398
395
  }
399
- .right-1 {
400
- right: calc(var(--spacing) * 1);
401
- }
402
396
  .right-2 {
403
397
  right: calc(var(--spacing) * 2);
404
398
  }
@@ -704,6 +698,9 @@
704
698
  .gap-2 {
705
699
  gap: calc(var(--spacing) * 2);
706
700
  }
701
+ .gap-3 {
702
+ gap: calc(var(--spacing) * 3);
703
+ }
707
704
  :where(.space-y-2 > :not(:last-child)) {
708
705
  --tw-space-y-reverse: 0;
709
706
  margin-block-start: calc(
@@ -790,6 +787,9 @@
790
787
  .border-blue-500 {
791
788
  border-color: var(--color-blue-500);
792
789
  }
790
+ .border-blue-600 {
791
+ border-color: var(--color-blue-600);
792
+ }
793
793
  .border-gray-200 {
794
794
  border-color: var(--color-gray-200);
795
795
  }