render_for_frontend();
} catch ( Throwable $e ) {
LP_Debug::error_log( $e );
}
}
/**
* Render curriculum AI popup template for frontend contexts (e.g. Course Builder).
*
* @return string
* @since 4.3.0
*/
public function render_for_frontend(): string {
try {
$this->config = Config::instance()->get( 'open-ai-modal', 'settings' );
$components = [
'wrap-script-template' => '',
];
return Template::combine_components( $components );
} catch ( Throwable $e ) {
LP_Debug::error_log( $e );
}
return '';
}
public function html_step_header(): string {
$components = [
'wrap' => '
',
];
return Template::combine_components( $components );
}
public function html_step_1(): string {
$options = $this->config;
$components = [
'step' => '',
'title' => sprintf(
'
%s
',
esc_html__( 'Step 1 — Curriculum Goal', 'learnpress' ),
),
'description' => sprintf(
'
%s
',
esc_html__( 'Provide the main goal for the curriculum so the system can generate aligned sections and lessons.', 'learnpress' )
),
'post-title' => sprintf(
'
',
esc_html__( 'Title refer', 'learnpress' ),
esc_html__( 'You can edit the course title to better suit the curriculum generation.', 'learnpress' ),
esc_html__( 'The course title is automatically imported from the previous step. It will guide the AI to build a structured curriculum.', 'learnpress' ),
),
'post-content' => sprintf(
'
',
esc_html__( 'Description refer', 'learnpress' ),
esc_html__( 'You can edit the course description to better suit the curriculum generation.', 'learnpress' ),
esc_html__( 'The course description is automatically imported from the previous step. It will guide the AI to build a structured curriculum.', 'learnpress' )
),
'goal' => sprintf(
'
%s
',
esc_html__( 'Goal', 'learnpress' ),
esc_html__( 'Defines the main objective of your curriculum. This helps the AI generate course sections and lessons that align with the intended learning outcomes.', 'learnpress' )
),
'form-grid' => '
',
'step_close' => '
',
];
return Template::combine_components( $components );
}
public function html_step_2(): string {
$options = $this->config;
$components = [
'step' => '',
'title' => sprintf(
'
%s
',
esc_html__( 'Step 2 — AI Settings', 'learnpress' ),
),
'description' => sprintf(
'
%s
',
esc_html__( 'Configure content quality controls for ChatGPT output.', 'learnpress' )
),
'form-grid' => '
',
'audience' => sprintf(
'
',
esc_html__( 'Target Audience', 'learnpress' ),
AdminTemplate::html_tom_select(
[
'name' => 'target_audience',
'class_name' => '',
'options' => $options['audience'] ?? [],
'default_value' => 'Students',
'multiple' => true,
]
),
esc_html__( 'Identifies who will take the course so the content matches their background and skill level.', 'learnpress' )
),
'tone' => sprintf(
'
',
esc_html__( 'Tone', 'learnpress' ),
AdminTemplate::html_tom_select(
[
'name' => 'tone',
'options' => $options['tone'] ?? [],
'multiple' => true,
'default_value' => [ 'Analytical' ],
]
),
esc_html__( 'Controls the writing style (e.g., friendly, formal, story-telling) so the content matches your brand and audience.', 'learnpress' )
),
'language' => sprintf(
'
',
esc_html__( 'Language', 'learnpress' ),
AdminTemplate::html_tom_select(
[
'name' => 'language',
'options' => $options['language'] ?? [],
]
),
esc_html__( 'Sets the output language for all generated course content.', 'learnpress' )
),
'form-grid-end' => '
',
'step_close' => '
',
];
return Template::combine_components( $components );
}
public function html_step_3(): string {
$options = $this->config;
$components = [
'step' => '',
'title' => sprintf(
'
%s
',
esc_html__( 'Step 3 — Prompt Generated', 'learnpress' ),
),
'prompt' => sprintf(
'
%s %s
%s
',
esc_html__( 'Generated Prompt', 'learnpress' ),
'
',
__( 'Shows the auto-generated AI prompt, allowing further adjustments before submission.', 'learnpress' )
),
'step_close' => '
',
];
return Template::combine_components( $components );
}
public function html_step_4(): string {
$options = $this->config;
$components = [
'step' => '',
'title' => sprintf(
'
%s
',
esc_html__( 'Step 4 — Result', 'learnpress' ),
),
'results' => '
',
'step_close' => '
',
];
return Template::combine_components( $components );
}
/**
* HTML preview with data received from OpenAI
*
* @param array $data_received
*
* @return string
*/
public static function html_preview_with_data( array $data_received ): string {
$sections = $data_received['sections'] ?? [];
$html_section = '';
foreach ( $sections as $section ) {
$section_title = $section['section_title'] ?? '';
$section_des = $section['section_description'] ?? '';
$lessons = $section['lessons'] ?? [];
$quizzes = $section['quizzes'] ?? [];
$html_lessons = '';
foreach ( $lessons as $lesson ) {
$lesson_title = $lesson['lesson_title'] ?? '';
$lesson_des = $lesson['lesson_description'] ?? '';
$arr_lesson_components = [
'wrap' => '