0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.144.25.130


Current Path : /var/www/html/revaapi/src/
Upload File :
Current File : /var/www/html/revaapi/src/studentResults.php

<?php

function getStudRes($aobj_context)
{ 
	include("genToken.php");	
	include("const.php");
	$tokenArry = getToken(client_id,client_secret,username,password,grant_type);
	$tokendet = json_decode($tokenArry,true);
	//var_dump($tokendet);
	$token = $tokendet['access_token'];
	$iurl  = $tokendet['instance_url'];
	
	$username = username;
	$password = password;
	$hbody = 'Basic '.base64_encode((username.':'.password));
	

	$headers = array
		(
			"Authorization:Bearer $token",
			"Content-Type: application/json"
		);
			
	$query = "select distinct fregno from res_fee 
	where fregno in ('R22MK326')";
	$resreg = $aobj_context->mobj_db->getAll($query);		

	foreach($resreg as $v)	
	{
		$regno = $v['fregno'];

		$query = "select r.fregno,r.fexamno,dg.fexamdate,s.fesubcode,s.fsubname,s.fcsubcode,
		s.ftheory,s.fintass,s.fretain,
		case when s.ftheory = 'T' and s.fintass = 'T' then fmarks 
		when s.ftheory = 'F' and s.fintass = 'T' then  fmarks
		when s.ftheory = 'F' and s.fintass = 'F' then  fmarks else 'X' end as ia,
		case when s.ftheory = 'T' and s.fintass = 'F' then fmarks 
		when s.ftheory = 'F' and s.fintass = 'F' then  fmarks else 'X' end as exam,
		r.fthvv as FCREDITS,r.fthia as FGP,r.fthtot as  FCP,if(s.ftheory = 'T',r.FTHPASSMTH,r.FPRPASSMTH) as FGRADE,
		r.fpercent as FSGPA,r.fprevtot as  FCGPA,r.fclass,
		s.fesubid
		from resmarks r 
		inner join resmarksdet rd on r.fregno = rd.fregno 
		and r.fdegree=rd.fdegree
		and r.fexamno = rd.fexamno
		and r.fyear = rd.fyear
		and rd.fexamtype = r.fexamtype
		and r.fsubcode = left(rd.fsubcode,4)
		inner join degexam dg on r.fdegree = dg.fdegree 
		and r.fexamno = dg.fexamno 
		and r.fyear = dg.fyear
		and r.fexamtype = dg.fexamtype
		inner join subject s on r.fdegree = s.fdegree 
		and r.fexamno = s.fexamno
		and r.fsubcode = s.fsubcode
		and rd.fsubcode = s.fcsubcode
		left join resapi a on r.fregno = a.fregno and r.fexamno = a.fsem
		and s.fesubcode = a.fsubcode 
		#and ifnull(a.fmsg,'') = 'Successful'
		where  r.fregno = '{$regno}'
		and ifnull(s.fesubcode,'') <> ''
		group by r.fregno,rd.fsubcode";	
		
		$res1 = $aobj_context->mobj_db->getAll($query);	
		
		$finalarry = [];
		$subarry = [];
		$oldregno = '';
		$newregno = '';
		$oldsubcode = '';
		$newsubcode = '';
		$i = 0;
		foreach($res1 as $val)
		{	
			$newregno = $val['fregno'];
			$newsubcode = $val['fesubcode'];
			if($oldregno != $newregno)
			{
				$subarry = [];
				$oldregno = $newregno;
			}
			
			if($oldsubcode != $newsubcode)
			{
				if($i != 0)
					array_push($finalarry,$subarry);
				$oldsubcode = $newsubcode;
			}
			
			$sems = array("A"=>"1", "B"=>"2","C"=>"3","D"=>"4","E"=>"5","F"=>"6","G"=>"7","H"=>"8","I"=>"9","J"=>"10");

			$subarry['regno'] = $val['fregno'];
			$fexamno = $val['fexamno'];
			$subarry['sem'] = $sems[$fexamno];//$val['fexamno'];
			$subarry['ExaminationMonthYear'] = $val['fexamdate'];
			$subarry['subcode'] = $val['fesubcode'];
			$subarry['courseExternalId'] = $val['fesubid'];
			$subarry['subname'] = $val['fsubname'];
			if($val['ia'] != 'X')
				$subarry['securedIAMarks'] = $val['ia'];
			if($val['exam'] != 'X')
				$subarry['securedExternalMarks'] = $val['exam'];
			$subarry['credits'] = $val['FCREDITS'];
			$subarry['gradepoint'] = $val['FGP'];
			$subarry['creditpoint'] = $val['FCP'];
			$subarry['cgpa'] = $val['FCGPA'];
			$subarry['sgpa'] = $val['FSGPA'];
			$subarry['grade'] = $val['FGRADE'];
			$subarry['Result'] = $val['fclass'];
			$subarry['remarks'] = "Note : REVA University is not responsible for any inadvertent error that may have crept in the results being published on NET. The results published on net are for immediate information to the examinees. These cannot be treated as original mark sheets.";
			$i++;

		}

		array_push($finalarry,$subarry);
		// $resdata = $aobj_context->mobj_output->ToJSONEnvelope($finalarry,0,'success');
	
		//$req['MarksDetails'] = $studData; 
		
		$url = $iurl."/services/apexrest/studentresults";
		
		$ch = curl_init();
		curl_setopt( $ch,CURLOPT_URL, $url);            
		curl_setopt( $ch,CURLOPT_POST, true );
		curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
		curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
		curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
		curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $finalarry ) );
		$result2 = curl_exec($ch);
		echo $result2;

		curl_close( $ch );


		$resjuno = json_decode($result2,true);
		
		$resdata = $resjuno['data'];
		foreach($resdata as $val)
		{
			$regno = $val['regno'];
			$status = $val['status'];		
			$msg = $val['msg'];
			$sem = $val['sem'];
			$subcode = $val['subcode'];

			$semnta = array("1"=>"A", "2"=>"B","3"=>"C","4"=>"D","5"=>"E","6"=>"F","7"=>"G","8"=>"H","9"=>"I","10"=>"J");
			$fexamno = $semnta[$sem];
			$query = "INSERT INTO resapi (fregno, fsem, fsubcode, fstatus, fmsg, fdate)
			VALUES
			('{$regno}', '{$fexamno}', '{$subcode}', '{$status}', '{$msg}', now())";
			$upres = $aobj_context->mobj_db->Execute($query);

			echo "regno: ".$regno." Subcode: ".$subcode." Message: ".$msg." </br>";
		}

	}
}

?>