libdir.'/datalib.php'); include_once('lib.php'); global $DB; $hs = required_param('hs', PARAM_ALPHANUM); $ts = required_param('ts', PARAM_RAW); $un = required_param('un', PARAM_ALPHANUM); $lsid = required_param('lsId', PARAM_INT); if(!isset($CFG->lamslesson_serverid)||!isset($CFG->lamslesson_serverkey)) { header('HTTP/1.1 401 Unauthenticated'); exit(1); } $plaintext = trim($ts).trim($un).trim($CFG->lamslesson_serverid).trim($CFG->lamslesson_serverkey); $hash = sha1(strtolower($plaintext)); if($hash != $hs){ header('HTTP/1.1 401 Unauthenticated'); exit(1); } //OK, the caller is authenticated. Now let's fulfill its request. // and make Moodle get the latest marks for this user in this lesson $user = $DB->get_record('user', array('username'=>$un)); if(!$user){ header('HTTP/1.1 401 Unauthenticated'); exit(1); } $lamslesson = $DB->get_record('lamslesson', array('lesson_id' => $lsid), '*', MUST_EXIST); $gradebookmark = lamslesson_get_lams_outputs($user->username,$lamslesson,$user->username); // let LAMS know that mark retrieval process has finished successfully echo 'OK'; ?>