<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

include('../../../config/config.php');


 $studentIDnew = $_POST["studentIDnew"];

 $ekenecampus = $_POST["ekenecampus"];

 $assignmentid = $_POST["assignmentid"];

 $publishdata = explode(',',$_POST["publishdata"]);

$studentIDnew = explode(',', $studentIDnew);
// $ObjectAnswer = explode(',', $ObjectAnswer);


   $publishstatus = 0;
   $unpublishstatus = 0;

    foreach($studentIDnew as $key => $student)
    {
        $status = $publishdata[$key];

     
       if ($status == 1)
        {


            $resetassignment = mysqli_query($link, "UPDATE `assignmentanswer` SET`publishstatus`= 0 WHERE `CampusID`= '$ekenecampus' AND `AssignmentSettingsID` = '$assignmentid' AND `StudentID` = '$student'");


            $publishstatus+=+1;

        }else
        {
            $resetassignment = mysqli_query($link, "UPDATE `assignmentanswer` SET`publishstatus`= 1 WHERE `CampusID`= '$ekenecampus' AND `AssignmentSettingsID` = '$assignmentid' AND `StudentID` = '$student'");

            $unpublishstatus+=+1;
        }
       
    
    }
    
    if($publishstatus > $unpublishstatus)
    {
        echo '1';
    
    }else if($publishstatus <  $unpublishstatus)
    {
        echo '8';
    }else{
        echo 'failed';
    }
    
  


?>
