Authored-by: Christian <christianbeeznest@users.noreply.github.com>pull/3952/head
							parent
							
								
									47915cfb17
								
							
						
					
					
						commit
						7101db8d2d
					
				@ -0,0 +1,67 @@ | 
				
			||||
<?php | 
				
			||||
/* For license terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
require_once __DIR__.'/../../../../main/inc/global.inc.php'; | 
				
			||||
require_once __DIR__.'/../../src/LtiProvider.php'; | 
				
			||||
 | 
				
			||||
$launch = LtiProvider::create()->launch(true, $_REQUEST['launch_id']); | 
				
			||||
 | 
				
			||||
if (!$launch->hasAgs()) { | 
				
			||||
    throw new Exception("Don't have grades!"); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
if (!isset($_REQUEST['exeId'])) { | 
				
			||||
    throw new Exception("Any Exercise result"); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$launchData = $launch->getLaunchData(); | 
				
			||||
 | 
				
			||||
$label = 'Score'; | 
				
			||||
$courseClient = $launchData['https://purl.imsglobal.org/spec/lti/claim/resource_link']['title']; | 
				
			||||
if (!empty($courseClient)) { | 
				
			||||
    $label = $courseClient; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$exeId = (int) $_REQUEST['exeId']; | 
				
			||||
$trackInfo = Exercise::get_stat_track_exercise_info_by_exe_id($exeId); | 
				
			||||
$score = $trackInfo['exe_result']; | 
				
			||||
$weight = $trackInfo['exe_weighting']; | 
				
			||||
$duration = $trackInfo['duration']; | 
				
			||||
$timestamp = date(DateTime::ISO8601); | 
				
			||||
 | 
				
			||||
$grades = $launch->getAgs(); | 
				
			||||
$score = Packback\Lti1p3\LtiGrade::new() | 
				
			||||
    ->setScoreGiven($score) | 
				
			||||
    ->setScoreMaximum($weight) | 
				
			||||
    ->setTimestamp($timestamp) | 
				
			||||
    ->setActivityProgress('Completed') | 
				
			||||
    ->setGradingProgress('FullyGraded') | 
				
			||||
    ->setUserId($launch->getLaunchData()['sub']); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
$scoreLineitem = Packback\Lti1p3\LtiLineitem::new() | 
				
			||||
    ->setTag('score') | 
				
			||||
    ->setScoreMaximum($weight) | 
				
			||||
    ->setLabel($label) | 
				
			||||
    ->setResourceId($launch->getLaunchData()['https://purl.imsglobal.org/spec/lti/claim/resource_link']['id']); | 
				
			||||
 | 
				
			||||
$grades->putGrade($score, $scoreLineitem); | 
				
			||||
 | 
				
			||||
 | 
				
			||||
$time = Packback\Lti1p3\LtiGrade::new() | 
				
			||||
    ->setScoreGiven($duration) | 
				
			||||
    ->setScoreMaximum(999) | 
				
			||||
    ->setTimestamp($timestamp) | 
				
			||||
    ->setActivityProgress('Completed') | 
				
			||||
    ->setGradingProgress('FullyGraded') | 
				
			||||
    ->setUserId($launch->getLaunchData()['sub']); | 
				
			||||
 | 
				
			||||
$timeLineitem = Packback\Lti1p3\LtiLineitem::new() | 
				
			||||
    ->setTag('time') | 
				
			||||
    ->setScoreMaximum(999) | 
				
			||||
    ->setLabel('Time Taken') | 
				
			||||
    ->setResourceId('time'.$launch->getLaunchData()['https://purl.imsglobal.org/spec/lti/claim/resource_link']['id']); | 
				
			||||
 | 
				
			||||
$grades->putGrade($time, $timeLineitem); | 
				
			||||
 | 
				
			||||
echo '{"success" : true}'; | 
				
			||||
@ -0,0 +1,8 @@ | 
				
			||||
<?php | 
				
			||||
/* For license terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
require_once __DIR__.'/../../../main/inc/global.inc.php'; | 
				
			||||
require_once __DIR__.'/../src/LtiProvider.php'; | 
				
			||||
use Packback\Lti1p3; | 
				
			||||
 | 
				
			||||
LtiProvider::create()->login($_REQUEST); | 
				
			||||
@ -0,0 +1,26 @@ | 
				
			||||
<?php | 
				
			||||
/* For license terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
require_once __DIR__.'/../../../main/inc/global.inc.php'; | 
				
			||||
require_once __DIR__.'/../src/LtiProvider.php'; | 
				
			||||
require_once __DIR__.'/../LtiProviderPlugin.php'; | 
				
			||||
 | 
				
			||||
use Packback\Lti1p3; | 
				
			||||
 | 
				
			||||
$launch = LtiProvider::create()->launch(); | 
				
			||||
if (!$launch->hasNrps()) { | 
				
			||||
    throw new Exception("Don't have names and roles!"); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
$launchData = $launch->getLaunchData(); | 
				
			||||
 | 
				
			||||
$plugin = LtiProviderPlugin::create(); | 
				
			||||
$toolVars = $plugin->getToolProviderVars($launchData['iss']); | 
				
			||||
 | 
				
			||||
$login = LtiProvider::create()->validateUser($launchData, $toolVars['courseCode']); | 
				
			||||
$cidReq = 'cidReq='.$toolVars['courseCode'].'&id_session=0&gidReq=0&gradebook=0'; | 
				
			||||
 | 
				
			||||
$launchUrl = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.$cidReq.'&origin=embeddable&exerciseId='.$toolVars['toolId'].'<i_launch_id='.$launch->getLaunchId(); | 
				
			||||
header('Location: '.$launchUrl); | 
				
			||||
exit; | 
				
			||||
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue