Differences Between: [Versions 400 and 403] [Versions 401 and 403]
1 <?php 2 3 namespace Packback\Lti1p3; 4 5 class LtiGrade 6 { 7 private $score_given; 8 private $score_maximum; 9 private $comment; 10 private $activity_progress; 11 private $grading_progress; 12 private $timestamp; 13 private $user_id; 14 private $submission_review; 15 private $canvas_extension; 16 17 public function __construct(array $grade = null) 18 { 19 $this->score_given = $grade['scoreGiven'] ?? null; 20 $this->score_maximum = $grade['scoreMaximum'] ?? null; 21 $this->comment = $grade['comment'] ?? null; 22 $this->activity_progress = $grade['activityProgress'] ?? null; 23 $this->grading_progress = $grade['gradingProgress'] ?? null; 24 $this->timestamp = $grade['timestamp'] ?? null; 25 $this->user_id = $grade['userId'] ?? null; 26 $this->submission_review = $grade['submissionReview'] ?? null; 27 $this->canvas_extension = $grade['https://canvas.instructure.com/lti/submission'] ?? null; 28 } 29 30 public function __toString() 31 { 32 // Additionally, includes the call back to filter out only NULL values 33 $request = array_filter([ 34 'scoreGiven' => $this->score_given, 35 'scoreMaximum' => $this->score_maximum, 36 'comment' => $this->comment, 37 'activityProgress' => $this->activity_progress, 38 'gradingProgress' => $this->grading_progress, 39 'timestamp' => $this->timestamp, 40 'userId' => $this->user_id, 41 'submissionReview' => $this->submission_review, 42 'https://canvas.instructure.com/lti/submission' => $this->canvas_extension, 43 ], '\Packback\Lti1p3\Helpers\Helpers::checkIfNullValue'); 44 45 return json_encode($request); 46 } 47 48 /** 49 * Static function to allow for method chaining without having to assign to a variable first. 50 */ 51 public static function new() 52 { 53 return new LtiGrade(); 54 } 55 56 public function getScoreGiven() 57 { 58 return $this->score_given; 59 } 60 61 public function setScoreGiven($value) 62 { 63 $this->score_given = $value; 64 65 return $this; 66 } 67 68 public function getScoreMaximum() 69 { 70 return $this->score_maximum; 71 } 72 73 public function setScoreMaximum($value) 74 { 75 $this->score_maximum = $value; 76 77 return $this; 78 } 79 80 public function getComment() 81 { 82 return $this->comment; 83 } 84 85 public function setComment($comment) 86 { 87 $this->comment = $comment; 88 89 return $this; 90 } 91 92 public function getActivityProgress() 93 { 94 return $this->activity_progress; 95 } 96 97 public function setActivityProgress($value) 98 { 99 $this->activity_progress = $value; 100 101 return $this; 102 } 103 104 public function getGradingProgress() 105 { 106 return $this->grading_progress; 107 } 108 109 public function setGradingProgress($value) 110 { 111 $this->grading_progress = $value; 112 113 return $this; 114 } 115 116 public function getTimestamp() 117 { 118 return $this->timestamp; 119 } 120 121 public function setTimestamp($value) 122 { 123 $this->timestamp = $value; 124 125 return $this; 126 } 127 128 public function getUserId() 129 { 130 return $this->user_id; 131 } 132 133 public function setUserId($value) 134 { 135 $this->user_id = $value; 136 137 return $this; 138 } 139 140 public function getSubmissionReview() 141 { 142 return $this->submission_review; 143 } 144 145 public function setSubmissionReview($value) 146 { 147 $this->submission_review = $value; 148 149 return $this; 150 } 151 152 public function getCanvasExtension() 153 { 154 return $this->canvas_extension; 155 } 156 157 // Custom Extension for Canvas. 158 // https://documentation.instructure.com/doc/api/score.html 159 public function setCanvasExtension($value) 160 { 161 $this->canvas_extension = $value; 162 163 return $this; 164 } 165 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body