@learnpack/learnpack 5.0.269 → 5.0.272

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,7 +10,7 @@
10
10
  />
11
11
 
12
12
  <title>Learnpack Creator: Craft tutorials in seconds!</title>
13
- <script type="module" crossorigin src="/creator/assets/index-CQXTTbaZ.js"></script>
13
+ <script type="module" crossorigin src="/creator/assets/index-C1pv1wUb.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/creator/assets/index-B4khtb0r.css">
15
15
  </head>
16
16
  <body>
@@ -31,4 +31,5 @@ export type FormState = {
31
31
  export type Syllabus = {
32
32
  lessons: Lesson[];
33
33
  courseInfo: FormState;
34
+ feedback?: string;
34
35
  };
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.269",
4
+ "version": "5.0.272",
5
5
  "author": "Alejandro Sanchez @alesanchezr",
6
6
  "contributors": [
7
7
  {
@@ -558,8 +558,6 @@ export default class ServeCommand extends SessionCommand {
558
558
  return res.json({ status: "ERROR" })
559
559
  }
560
560
 
561
- fs.writeFileSync(`image-${imageId}.json`, JSON.stringify(body, null, 2))
562
-
563
561
  const imageUrl = body.image_url
564
562
  const format = body.format
565
563
  const imagePath = `courses/${courseSlug}/.learn/assets/${imageId}`
@@ -663,6 +661,24 @@ export default class ServeCommand extends SessionCommand {
663
661
  "\n\nThe user provided the following feedback related to the content of the course so far: \n\n" +
664
662
  feedback
665
663
  )
664
+
665
+ syllabusJson.lessons[parseInt(position)].status = "GENERATING"
666
+ if (
667
+ syllabusJson.feedback &&
668
+ typeof syllabusJson.feedback === "string"
669
+ ) {
670
+ syllabusJson.feedback += "\n\n" + feedback
671
+ } else {
672
+ syllabusJson.feedback = feedback
673
+ }
674
+
675
+ await uploadFileToBucket(
676
+ bucket,
677
+ JSON.stringify(syllabusJson),
678
+ `courses/${courseSlug}/.learn/initialSyllabus.json`
679
+ )
680
+
681
+ res.json({ status: "SUCCESS" })
666
682
  }
667
683
  )
668
684
 
@@ -762,6 +778,11 @@ export default class ServeCommand extends SessionCommand {
762
778
  nextExercise &&
763
779
  (exerciseIndex === 0 || !(exerciseIndex % 3 === 0))
764
780
  ) {
781
+ let feedback = ""
782
+ if (syllabusJson.feedback) {
783
+ feedback = `\n\nThe user added the following feedback with relation to the previous generations: ${syllabusJson.feedback}`
784
+ }
785
+
765
786
  startExerciseGeneration(
766
787
  bucket,
767
788
  rigoToken,
@@ -771,7 +792,7 @@ export default class ServeCommand extends SessionCommand {
771
792
  `courses/${courseSlug}`,
772
793
  courseSlug,
773
794
  syllabusJson.courseInfo.purpose,
774
- readme.parsed.content
795
+ readme.parsed.content + "\n\n" + feedback
775
796
  )
776
797
  nextStarted = true
777
798
  } else {
@@ -801,12 +822,12 @@ export default class ServeCommand extends SessionCommand {
801
822
 
802
823
  const newSyllabus = {
803
824
  ...syllabusJson,
804
- lessons: syllabusJson.lessons.map(lesson => {
805
- if (lesson.id === exercise.id) {
825
+ lessons: syllabusJson.lessons.map((lesson, index) => {
826
+ if (index === exerciseIndex) {
806
827
  return { ...lesson, generated: true, status: "DONE" }
807
828
  }
808
829
 
809
- if (nextExercise && nextExercise.id === lesson.id && !nextStarted) {
830
+ if (nextExercise && nextExercise.id === lesson.id && nextStarted) {
810
831
  return { ...lesson, generated: false, status: "GENERATING" }
811
832
  }
812
833
 
@@ -44,6 +44,7 @@ const SyllabusEditor: React.FC = () => {
44
44
  messages,
45
45
  setMessages,
46
46
  technologies,
47
+ mode,
47
48
  } = useStore(
48
49
  useShallow((state) => ({
49
50
  history: state.history,
@@ -55,6 +56,7 @@ const SyllabusEditor: React.FC = () => {
55
56
  // formState: state.formState,
56
57
  setMessages: state.setMessages,
57
58
  technologies: state.technologies,
59
+ mode: state.mode,
58
60
  }))
59
61
  )
60
62
 
@@ -233,7 +235,7 @@ const SyllabusEditor: React.FC = () => {
233
235
 
234
236
  const timeout = setTimeout(() => {
235
237
  cleanAll()
236
- window.location.href = `/preview/${syllabus.courseInfo.slug}?token=${auth.bcToken}&language=${syllabus.courseInfo.language}`
238
+ window.location.href = `/preview/${syllabus.courseInfo.slug}?token=${auth.bcToken}&language=${syllabus.courseInfo.language}&mode=${mode}`
237
239
  }, 8000)
238
240
  try {
239
241
  await createCourse(syllabus, tokenToUse, auth.bcToken)