From ce64a72eabd5a899836fb88bfe34124a7b4c4149 Mon Sep 17 00:00:00 2001 From: Robert Russo Date: Thu, 22 Feb 2024 19:22:53 +0000 Subject: [PATCH] Add a working token counter --- local/d1/classes/d1.php | 3 ++- local/d1/lib.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/local/d1/classes/d1.php b/local/d1/classes/d1.php index 4f12ef3818e46..715e857021a6e 100644 --- a/local/d1/classes/d1.php +++ b/local/d1/classes/d1.php @@ -577,10 +577,11 @@ public static function course_grade_postings($postings) { } // Merge the returner into the array with the approriate count. - $pgs[$counter] = $returner; + $pgs[$eounter] = $returner; // Increment the couneter. $counter++; + $counter2++; } // Return the array of postings and statuses. diff --git a/local/d1/lib.php b/local/d1/lib.php index 69d90efdb836b..19e304757c2ef 100644 --- a/local/d1/lib.php +++ b/local/d1/lib.php @@ -82,6 +82,9 @@ public function run_post_odl() { // Get a token. $token = lsupgd1::get_token(); + // Instantiate the token counter and set its count to 0; + $tokencounter = 0; + // Get the list of courses to be posted. $odlcourses = lsupgd1::get_odl_dgps(true); @@ -109,6 +112,13 @@ public function run_post_odl() { // Increment the counter. $count++; + $tokencounter++; + + // Get a new token every 100 rows. + if ($tokencounter % 100 == 0) { + $token = self::get_token(); + mtrace("Got new token: $token."); + } // Set the cs objectId to the PD Grade object. $odlgrade->csobjectid = $csobjectid; @@ -149,6 +159,8 @@ public function run_post_pd() { // Get a token. $token = lsupgd1::get_token(); + $tokencounter = 0; + // Get the list of courses to be posted. $pdcourses = lsupgd1::get_pd_dgps(true); @@ -176,6 +188,13 @@ public function run_post_pd() { // Increment the counter. $count++; + $tokencounter++; + + // Get a new token every 100 rows. + if ($tokencounter % 100 == 0) { + $token = self::get_token(); + mtrace("Got new token: $token."); + } // Set the cs objectId to the PD Grade object. $pdgrade->csobjectid = $csobjectid;