User Tools

Site Tools


auto_scoring

Retrieving scoring results (automation)

For data wrangling purposes, it is useful to automate the retrieve of a training session's scoring result.

The formal syntax is:

https://server/pma.control/Training/UserScoreReportExcel/{TRAINING_SESSION_ID}/type={REPORT_TYPE}&sessionID={PMA_CORE_SESSION_ID}

For convenient parsing, we recommend setting REPORT_TYPE to 2 (CSV, computer-readable, de-normalized).

Note that the above URL cannot be invoked automatically from within any programming environment. PHP's file_get_contents() method e.g. does not work.

The call requires cookie to authenticate properly, because it is a view controller. The php function file_get_contents() does not use cookies as the server requests so the call fails. It only works if you have cookies set correctly in the browser via another tab or previous login to the pma.control.

For this to work properly via php you have to use cUrl with cookies enabled:

<?php
function file_get_contents_curl($url) {
    $ckfile = tempnam ("/tmp", "CURLCOOKIE");
 
    $ch = curl_init();
 
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 3);     
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       
 
    $data = curl_exec($ch);
    curl_close($ch);
 
    return $data;
}
 
// assume $sessionID already exists and contains a valid PMA.core SessionID
// build URL
 
$trainingsession = 66
$url = "https://server/pma.control/Training/UserScoreReportExcel/".$trainingsession."?type=2&delimiter=%2C&decimalSeperator=.&sessionId=".$sessionID;
 
// retrieve data
$tsData = file_get_contents_curl($url);
}
?>
auto_scoring.txt · Last modified: 2022/01/25 14:52 by yves