Skip to content

Commit 35ccb76

Browse files
committed
feat/fix: Scan fail counts + removing the ability to scan .html files
1 parent 17c6f2a commit 35ccb76

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

src/Lms/Canvas/CanvasLms.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ private function saveOrUpdateContentItem($canvasApi, Course $course, $contentTyp
214214
}
215215
}
216216

217-
/* get HTML file content */
218-
if (('file' === $contentType) && ('html' === $content['mime_class'])) {
219-
$lmsContent['body'] = file_get_contents($content['url']);
220-
}
221-
222217
if (!$contentItem) {
223218
$contentItem = new ContentItem();
224219
$metadata = $parentLmsId ? array('parentLmsId' => $parentLmsId) : array();
@@ -390,18 +385,15 @@ public function updateCourseContent(Course $course, User $user, $force = false):
390385
$apiToken = $this->getApiToken($user);
391386

392387
$canvasApi = new CanvasApi($apiDomain, $apiToken);
388+
$scanFails = 0;
393389

394-
// Batch page pulling maintaince
395-
$pageUrls = [];
396-
$asyncFetch = true;
397-
398-
$start_time = microtime(true);
399390
foreach ($urls as $contentType => $url) {
400391
$response = $canvasApi->apiGet($url);
392+
$statusCode = $response->getStatusCode();
401393

402-
if ($response->getErrors()) {
403-
$this->util->createMessage('Error retrieving content. Failed API Call: ' . $url, 'error', $course, $user);
404-
throw new \Exception('msg.sync.error.api');
394+
if(!$statusCode || $statusCode != 200 || $response->getErrors()){
395+
$scanFails += 1;
396+
continue; // Continue to onto next content item if we failed to get a status code
405397
}
406398
else {
407399
if ('syllabus' === $contentType) {
@@ -430,6 +422,9 @@ public function updateCourseContent(Course $course, User $user, $force = false):
430422
$this->saveOrUpdateContentItem($canvasApi, $course, $contentType, $content, $force);
431423
}
432424
}
425+
}
426+
if($scanFails > 0){
427+
$this->util->createMessage('Failed to fetch {$scanFails} from LMS. Please try to rescan the course to account for all issues.', 'error', $course, $user);
433428
}
434429
// push any updates made to content items to DB
435430
$this->entityManager->flush();

0 commit comments

Comments
 (0)