@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.
@@ -356,7 +356,6 @@ class ServeCommand extends SessionCommand_1.default {
356
356
  });
357
357
  return res.json({ status: "ERROR" });
358
358
  }
359
- fs.writeFileSync(`image-${imageId}.json`, JSON.stringify(body, null, 2));
360
359
  const imageUrl = body.image_url;
361
360
  const format = body.format;
362
361
  const imagePath = `courses/${courseSlug}/.learn/assets/${imageId}`;
@@ -437,6 +436,16 @@ class ServeCommand extends SessionCommand_1.default {
437
436
  await startExerciseGeneration(bucket, rigoToken, syllabusJson.lessons, syllabusJson.courseInfo, exercise, `courses/${courseSlug}`, courseSlug, syllabusJson.courseInfo.purpose, previousReadme +
438
437
  "\n\nThe user provided the following feedback related to the content of the course so far: \n\n" +
439
438
  feedback);
439
+ syllabusJson.lessons[parseInt(position)].status = "GENERATING";
440
+ if (syllabusJson.feedback &&
441
+ typeof syllabusJson.feedback === "string") {
442
+ syllabusJson.feedback += "\n\n" + feedback;
443
+ }
444
+ else {
445
+ syllabusJson.feedback = feedback;
446
+ }
447
+ await uploadFileToBucket(bucket, JSON.stringify(syllabusJson), `courses/${courseSlug}/.learn/initialSyllabus.json`);
448
+ res.json({ status: "SUCCESS" });
440
449
  });
441
450
  app.post("/webhooks/:courseSlug/exercise-processor/:lessonID/:rigoToken", async (req, res) => {
442
451
  // console.log("Receiving a webhook to exercise processor")
@@ -493,7 +502,11 @@ class ServeCommand extends SessionCommand_1.default {
493
502
  let nextStarted = false;
494
503
  if (nextExercise &&
495
504
  (exerciseIndex === 0 || !(exerciseIndex % 3 === 0))) {
496
- startExerciseGeneration(bucket, rigoToken, syllabusJson.lessons, syllabusJson.courseInfo, nextExercise, `courses/${courseSlug}`, courseSlug, syllabusJson.courseInfo.purpose, readme.parsed.content);
505
+ let feedback = "";
506
+ if (syllabusJson.feedback) {
507
+ feedback = `\n\nThe user added the following feedback with relation to the previous generations: ${syllabusJson.feedback}`;
508
+ }
509
+ startExerciseGeneration(bucket, rigoToken, syllabusJson.lessons, syllabusJson.courseInfo, nextExercise, `courses/${courseSlug}`, courseSlug, syllabusJson.courseInfo.purpose, readme.parsed.content + "\n\n" + feedback);
497
510
  nextStarted = true;
498
511
  }
499
512
  else {
@@ -511,11 +524,11 @@ class ServeCommand extends SessionCommand_1.default {
511
524
  await (0, exports.processImage)(image.url, image.alt, rigoToken, courseSlug);
512
525
  }
513
526
  }
514
- const newSyllabus = Object.assign(Object.assign({}, syllabusJson), { lessons: syllabusJson.lessons.map(lesson => {
515
- if (lesson.id === exercise.id) {
527
+ const newSyllabus = Object.assign(Object.assign({}, syllabusJson), { lessons: syllabusJson.lessons.map((lesson, index) => {
528
+ if (index === exerciseIndex) {
516
529
  return Object.assign(Object.assign({}, lesson), { generated: true, status: "DONE" });
517
530
  }
518
- if (nextExercise && nextExercise.id === lesson.id && !nextStarted) {
531
+ if (nextExercise && nextExercise.id === lesson.id && nextStarted) {
519
532
  return Object.assign(Object.assign({}, lesson), { generated: false, status: "GENERATING" });
520
533
  }
521
534
  return Object.assign({}, lesson);