<?php
include("../../db.php");
header('Content-Type: application/json');

$jsondata = $_POST['json'];

$status = 0;
$msg = '';
$array = array();

$decode = json_decode($jsondata, true);

$key_terms = $decode['key_terms'];
$mind_map = $decode['mind_map'];
$key_notes = $decode['key_notes'];
$practical_projects = $decode['practical_projects'];

$session = $decode['session'];
$dataAry = $decode['alldata'];

$assignment_id = $decode['assignment_id'];

foreach ($dataAry as $data) {

    $fileArray = array(
        "assignment_id" => $assignment_id,
        "name" => "$data[name]",
        "description" => "$data[description]",
        "type" => "$data[type]",
        "session" => "$session"
    );

    $db->insertAry("assignment_files", $fileArray);

}

$status = 1;
$msg = 'Assignment successfully saved.';


$array['status'] = $status;
$array['msg'] = $msg;

echo json_encode($array);
