src/Core/Result.php
public function gradeSendDueDate($gradetosend, $oldgrade=false, $dueDate=false) {
        if ( $gradetosend == 1.0 ) {
            $scorestr = "Your answer is correct, score saved.";
        } else {
            $scorestr = "Your score of ".($gradetosend*100.0)."% has been saved.";
        }
        if ( $dueDate && $dueDate->penalty > 0 ) {
            $gradetosend = $gradetosend * (1.0 - $dueDate->penalty);
            $scorestr = "Effective Score = ".($gradetosend*100.0)."% after ".$dueDate->penalty*100.0." percent late penalty";
        }
        if ( $oldgrade && $oldgrade > $gradetosend ) {
            $scorestr = "New score of ".($gradetosend*100.0)."% is < than previous grade of ".($oldgrade*100.0)."%, previous grade kept";
            $gradetosend = $oldgrade;
        }

        // Use LTIX to store the grade in out database send the grade back to the LMS.
        $debug_log = array();
        $retval = $this->gradeSend($gradetosend, false, $debug_log);
        $this->session_put('debug_log', $debug_log);

        if ( $retval === true ) {
            $this->session_put('success', $scorestr);
        } else if ( $retval === false ) { // Stored locally
            $this->session_put('success', $scorestr);
        } else if ( is_string($retval) ) {
            $this->session_put('error', "Grade not sent: ".$retval);
        } else {
            $svd = Output::safe_var_dump($retval);
            error_log("Grade sending error:".$svd);
            $this->session_put('error', "Grade sending error: ".substr($svd,0,100));
        }
    }
public function gradeSendDueDate($gradetosend, $oldgrade=false, $dueDate=false) {
        if ( $gradetosend == 1.0 ) {
            $scorestr = "Your answer is correct, score saved.";
        } else {
            $scorestr = "Your score of ".($gradetosend*100.0)."% has been saved.";
        }
        if ( $dueDate && $dueDate->penalty > 0 ) {
            $gradetosend = $gradetosend * (1.0 - $dueDate->penalty);
            $scorestr = "Effective Score = ".($gradetosend*100.0)."% after ".$dueDate->penalty*100.0." percent late penalty";
        }
        if ( $oldgrade && $oldgrade > $gradetosend ) {
            $scorestr = "New score of ".($gradetosend*100.0)."% is < than previous grade of ".($oldgrade*100.0)."%, previous grade kept";
            $gradetosend = $oldgrade;
        }

        // Use LTIX to store the grade in out database send the grade back to the LMS.
        $debug_log = array();
        $retval = $this->gradeSend($gradetosend, false, $debug_log);
        $this->session_put('debug_log', $debug_log);

        if ( $retval === true ) {
            $this->session_put('success', $scorestr);
        } else if ( $retval === false ) { // Stored locally
            $this->session_put('success', $scorestr);
        } else if ( is_string($retval) ) {
            $this->session_put('error', "Grade not sent: ".$retval);
        } else {
            $svd = Output::safe_var_dump($retval);
            error_log("Grade sending error:".$svd);
            $this->session_put('error', "Grade sending error: ".substr($svd,0,100));
        }
    }
public function gradeSendDueDate ( $ gradetosend , $ oldgrade = false , $ dueDate = false ) { if ( $ gradetosend == 1.0 ) { $ scorestr = "Your answer is correct, score saved." ; } else { $ scorestr = "Your score of " . ( $ gradetosend * 100.0 ) . "% has been saved." ; } if ( $ dueDate && $ dueDate -> penalty > 0 ) { $ gradetosend = $ gradetosend * ( 1.0 - $ dueDate -> penalty ) ; $ scorestr = "Effective Score = " . ( $ gradetosend * 100.0 ) . "% after " . $ dueDate -> penalty * 100.0 . " percent late penalty" ; } if ( $ oldgrade && $ oldgrade > $ gradetosend ) { $ scorestr = "New score of " . ( $ gradetosend * 100.0 ) . "% is < than previous grade of " . ( $ oldgrade * 100.0 ) . "%, previous grade kept" ; $ gradetosend = $ oldgrade ; } // Use LTIX to store the grade in out database send the grade back to the LMS. $ debug_log = array ( ) ; $ retval = $ this -> gradeSend ( $ gradetosend , false , $ debug_log ) ; $ this -> session_put ( 'debug_log' , $ debug_log ) ; if ( $ retval === true ) { $ this -> session_put ( 'success' , $ scorestr ) ; } else if ( $ retval === false ) { // Stored locally $ this -> session_put ( 'success' , $ scorestr ) ; } else if ( is_string ( $ retval ) ) { $ this -> session_put ( 'error' , "Grade not sent: " . $ retval ) ; } else { $ svd = Output :: safe_var_dump ( $ retval ) ; error_log ( "Grade sending error:" . $ svd ) ; $ this -> session_put ( 'error' , "Grade sending error: " . substr ( $ svd , 0 , 100 ) ) ; } }
Send a grade applying the due date logic and only increasing grades

Puts messages in the session for a redirect.

@param $gradetosend - The grade in the range 0.0 .. 1.0
@param $oldgrade - The previous grade in the range 0.0 .. 1.0 (optional)
@param $dueDate - The due date for this assignment
Send a grade applying the due date logic and only increasing grades