}
    // Store things that gradeSubmit.php will need into the session
    session_start();
    $_SESSION['lis_outcome_service_url'] = $_REQUEST['lis_outcome_service_url'];
    $_SESSION['lis_result_sourcedid'] = $_REQUEST['lis_result_sourcedid'];
    $_SESSION['lis_person_name_given'] = $_REQUEST['lis_person_name_given'];
    $_SESSION['oauth_consumer_key'] = $_REQUEST['oauth_consumer_key'];
    $_SESSION['oauth_consumer_secret'] = $oauth_consumer_secret;
    session_write_close();
    /*
     *   READ BACK OUR GRADE
     *   If it exists, show the grade and disable the submit button.
     */
    $endpoint = $_REQUEST['lis_outcome_service_url'];
    $sourcedid = $_REQUEST['lis_result_sourcedid'];
    $postBody = str_replace(array('SOURCEDID', 'OPERATION', 'MESSAGE'), array($sourcedid, 'readResultRequest', uniqid()), getPOXRequest());
    $response = parseResponse(sendOAuthBodyPOST('POST', $endpoint, $oauth_consumer_key, $oauth_consumer_secret, 'application/xml', $postBody));
    if ($response['imsx_codeMajor'] == 'success' && $response['textString'] != '') {
        $grade = $response['textString'];
        $showGrade = true;
        $disabled = 'disabled';
    }
}
/*
 *   CUSTOM LTI LAUNCH PARAMETERS
 *   The "posted date" is the date that the quiz is posted. It is either set
 *   in the "Edit Link" page of "External Learning Tools" in your LMS, or set
 *   when the link is created with the Valence REST API.
 *   This example parameter is NOT automatically set by the LMS!
 */
if (isset($_SESSION['custom_timecreated'])) {
Esempio n. 2
0
    redirect($homeurl);
}
echo $OUTPUT->header();
if (!empty($sourcedid) and !empty($outcomeurl)) {
    if ($formdata = $mform->get_data()) {
        if (isset($formdata->replaceResultRequest)) {
            $operation = 'replaceResultRequest';
            $postBody = str_replace(array('SOURCEDID', 'GRADE', 'OPERATION', 'MESSAGE'), array($sourcedid, $_REQUEST['grade'], $operation, uniqid()), getPOXGradeRequest());
        } else {
            if (isset($formdata->readResultRequest)) {
                $operation = 'readResultRequest';
                $postBody = str_replace(array('SOURCEDID', 'OPERATION', 'MESSAGE'), array($sourcedid, $operation, uniqid()), getPOXRequest());
            } else {
                if (isset($formdata->deleteResultRequest)) {
                    $operation = 'deleteResultRequest';
                    $postBody = str_replace(array('SOURCEDID', 'OPERATION', 'MESSAGE'), array($sourcedid, $operation, uniqid()), getPOXRequest());
                }
            }
        }
        $response = sendOAuthBodyPOST('POST', $outcomeurl, $postBody);
        echo html_writer::link($graderurl, "Check in grade report");
        try {
            $retval = parseResponse($response);
        } catch (Exception $e) {
            $retval = $e->getMessage();
        }
        echo $OUTPUT->heading('Grading Results', 5);
        echo html_writer::start_tag('pre');
        print_r($retval);
        echo html_writer::end_tag('pre');
        echo $OUTPUT->heading('RAW Response', 5);