<?php 

require __DIR__ . '/config.php';

$portal = cbt::getClientPortal( $_SESSION['portal'], uss::$global['user']['id'] );

$scores = cbt::getScores( $portal['id'], $portal['userid'] );

$prefix = DB_TABLE_PREFIX;

if( empty($portal['complete']) ) {
	$SQL = sQuery::update( "{$prefix}_portals", array(
		"complete" => 1
	), "id = '{$portal['id']}'" );
	uss::$global['mysqli']->query( $SQL );
};

echo json_encode( $scores );