diff --git a/src/app/courses/add-courses/courses-add.component.html b/src/app/courses/add-courses/courses-add.component.html index 3a4aa9c6d9..e53410414b 100644 --- a/src/app/courses/add-courses/courses-add.component.html +++ b/src/app/courses/add-courses/courses-add.component.html @@ -42,11 +42,15 @@
tags
+ const codeBlockStart = /```/g;
+ const codeBlockEnd = /```/g;
+ const textWithCodeBlocks = textWithLineBreaks
+ .replace(codeBlockStart, '')
+ .replace(codeBlockEnd, '
');
+
+ return textWithCodeBlocks;
+ }
+
}
diff --git a/src/app/courses/add-courses/courses-step.component.html b/src/app/courses/add-courses/courses-step.component.html
index a5e1111b91..a99cd01d6b 100644
--- a/src/app/courses/add-courses/courses-step.component.html
+++ b/src/app/courses/add-courses/courses-step.component.html
@@ -29,6 +29,10 @@
+
+
+
+
{{activeStep?.exam ? 'Update' : 'Add' }} Test
diff --git a/src/app/courses/add-courses/courses-step.component.ts b/src/app/courses/add-courses/courses-step.component.ts
index c57e43def1..dc9d88c2c6 100644
--- a/src/app/courses/add-courses/courses-step.component.ts
+++ b/src/app/courses/add-courses/courses-step.component.ts
@@ -7,6 +7,7 @@ import { takeUntil } from 'rxjs/operators';
import { CoursesService } from '../courses.service';
import { DialogsAddResourcesComponent } from '../../shared/dialogs/dialogs-add-resources.component';
import { DialogsLoadingService } from '../../shared/dialogs/dialogs-loading.service';
+import { ChatService } from '../../shared/chat.service';
@Component({
selector: 'planet-courses-step',
@@ -24,6 +25,7 @@ export class CoursesStepComponent implements OnDestroy {
dialogRef: MatDialogRef;
activeStep: any;
activeStepIndex = -1;
+ rating: Text;
private onDestroy$ = new Subject();
constructor(
@@ -31,7 +33,8 @@ export class CoursesStepComponent implements OnDestroy {
private fb: FormBuilder,
private dialog: MatDialog,
private coursesService: CoursesService,
- private dialogsLoadingService: DialogsLoadingService
+ private dialogsLoadingService: DialogsLoadingService,
+ private chatService: ChatService
) {
this.stepForm = this.fb.group({
id: '',
@@ -100,4 +103,32 @@ export class CoursesStepComponent implements OnDestroy {
this.addStepEvent.emit();
}
+ rateStep() {
+ const content = `In 3 clear blobs, 1. provide a rating for this course step(granular rating out of 100%), 2. Explain why you gave the rating 3. Explain how to improve the course step
+ ${this.stepForm.get('stepTitle').value} - ${this.stepForm.get('description').value.text}`;
+
+ this.chatService.getPrompt(content).subscribe(
+ (completion: any) => {
+ this.rating = this.sanitizeText(completion?.chat);
+ },
+ (error: any) => {
+ console.log(error);
+ }
+ );
+ }
+
+ sanitizeText(text: any): any {
+ // Replace newline characters with
tags
+ const textWithLineBreaks = text.replace(/\n/g, '
');
+
+ // Replace code block markers with tags
+ const codeBlockStart = /```/g;
+ const codeBlockEnd = /```/g;
+ const textWithCodeBlocks = textWithLineBreaks
+ .replace(codeBlockStart, '')
+ .replace(codeBlockEnd, '
');
+
+ return textWithCodeBlocks;
+ }
+
}