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

$jsondata = $_POST['json'];

$status = 0;
$msg = 'Failed to update marks';
$array = array();

if($jsondata != null && $jsondata != ''){

    $decode = json_decode($jsondata, true);

    $session = $decode['session'];
    $addedBy = $decode['added_by'];
    $studentId = $decode['uid'];

    $markList = $decode['marks'];
    foreach ($markList as $item){
        $qid = $item['qid'];
        $markObt = $item['mark'];
        $db->updateAry("assignment_attempt_question", array("mark_obtained" => $markObt, "mark_given_by" => $addedBy), " where qid='$qid' and uid='$studentId'");
    }

    $status = 1;
    $msg = 'Marked updated successfully';

}

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

echo json_encode($array);
