<?php
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET, POST' );
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
include '../../../config/index.php';
// var_dump( $_POST );

$data = file_get_contents( 'php://input' );
$obj = json_decode( $data, true );

$db_description = 'descriptions/'.time();
$dv_file = '/home/sendusco/app/descriptions/'.time();

$file = fopen( $dv_file, 'w' ) or die( 'Unable to open file!' );

fwrite( $file, $_POST[ 'Notes' ] );

fclose( $file );

$sql = "UPDATE course_lesson_structure SET
            teachers_notes='".$db_description."'
        WHERE course_lesson_structure_id='".$_GET["course_lesson_structure_id"]."'";

if ( mysqli_query( $conn, $sql ) ) {

    
    $curl_post_data = array(
        'Success' => 'true',
        'Reason' => 'You Have Succesfully added a Teachers Notes',
        'course_tags_id' => $course_tags_id ,
    );
    echo json_encode( $curl_post_data );

} else {

    $curl_post_data = array(
        'Success' => 'false',
        'Reason' => 'Unable to Succesfully Add a Teachers Notes, Kindly contact Admin for help?',
        'course_tags_id' => '',
    );
    echo json_encode( $curl_post_data );

}

?>