Skip to content

Commit 44a5ed2

Browse files
authored
Merge branch 'dev' into async-pages-from-lms
2 parents c8f46ae + c6a6a7e commit 44a5ed2

14 files changed

Lines changed: 229 additions & 285 deletions

File tree

.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ ACCESSIBILITY_CHECKER="equalaccess_local"
6565
MESSENGER_TRANSPORT_DSN=doctrine://default
6666
###< symfony/messenger ###
6767

68+
###> equalaccess ###
69+
EQUALACCESS_EXCLUDED_RULES="
70+
html_lang_exists,
71+
html_skipnav_exists,
72+
page_title_exists,
73+
skip_main_exists,
74+
style_highcontrast_visible,
75+
style_viewport_resizable,
76+
aria_accessiblename_exists,
77+
aria_content_in_landmark,
78+
aria_landmark_name_unique,
79+
a_target_warning,
80+
text_quoted_correctly
81+
"
82+
###> equalaccess ###
83+
6884
###> phpally ###
6985
# Rule exclusion list as a comma-separated list of rule IDs.
7086
PHPALLY_EXCLUDED_RULES="

assets/js/Components/FixIssuesPage.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export default function FixIssuesPage({
119119

120120
// PHPAlly returns a contentItemId that we can use to get the content type
121121
let tempContentItem = getContentById(issue.contentItemId)
122+
let parentLmsId = null
122123
if(tempContentItem) {
123124
let tempContentType = tempContentItem.contentType
124125

@@ -130,6 +131,7 @@ export default function FixIssuesPage({
130131
'discussion_forum': FILTER.DISCUSSION_FORUM,
131132
'file': FILTER.FILE,
132133
'quiz': FILTER.QUIZ,
134+
'quiz_question': FILTER.QUIZ,
133135
'syllabus': FILTER.SYLLABUS,
134136
'module': FILTER.MODULE,
135137
}
@@ -148,6 +150,11 @@ export default function FixIssuesPage({
148150
if(tempContentItem.published === false) {
149151
published = false
150152
}
153+
154+
if(tempContentItem.metadata) {
155+
let metadataObj = JSON.parse(tempContentItem.metadata)
156+
parentLmsId = metadataObj.parentLmsId || null
157+
}
151158
}
152159

153160
let issueResolution = FILTER.ACTIVE
@@ -171,7 +178,7 @@ export default function FixIssuesPage({
171178
let formLabel = t(`form.${formName}.title`)
172179

173180
return {
174-
issueData: Object.assign({}, issue, { contentUrl: tempContentItem?.url || '' }),
181+
issueData: Object.assign({}, issue, { contentUrl: tempContentItem?.url || '' }, { parentLmsId: parentLmsId }),
175182
id: issue.id,
176183
severity: issueSeverity,
177184
status: issueResolution,
@@ -186,7 +193,7 @@ export default function FixIssuesPage({
186193
contentType: issueContentType,
187194
contentTitle: tempContentItem.title,
188195
contentUrl: tempContentItem.url,
189-
currentState: currentState,
196+
currentState: currentState,
190197
}
191198
}
192199

assets/js/Components/Icons/ContentTypeIcon.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function ContentTypeIcon(props) {
2929
case('FILE_OBJECT'):
3030
return <ContentFileIcon {...props} />
3131
case('QUIZ'):
32+
case('QUIZ_QUESTION'):
3233
return <ContentQuizIcon {...props} />
3334
case('SYLLABUS'):
3435
return <ContentSyllabusIcon {...props} />

assets/js/Services/Report.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,18 @@ export function analyzeReport(report, ISSUE_STATE) {
239239
let specificError = 'udoit-ignore-' + issue.scanRuleId.replaceAll("_", "-")
240240
let classesArray = elementClasses.split(' ')
241241
if(classesArray.includes('phpally-ignore') || classesArray.includes(specificError)) {
242+
// If the scanner found it, but it has an 'ignore' class, don't include it.
242243
issueIgnored = true
243244
}
244245
}
245246

246-
// For the text_block_heading rule, we need to check if the element is inside a table cell.
247247
if(runCustomChecks(issue, element)) {
248+
// If there are custom checks that indicate we should ignore this issue, do so.
248249
issueIgnored = true
249250
}
250251
}
251252
else {
253+
// If we can't find the element in the content item body, we have to ignore the issue.
252254
issueIgnored = true
253255
}
254256
}

src/Controller/IssuesController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ public function saveIssue(
126126
$apiResponse->addMessage($e->getMessage(), 'error');
127127
}
128128

129+
$contentItem = $issue->getContentItem();
130+
if ($contentItem->getContentType() == "quiz_question") {
131+
$apiResponse->addMessage('msg.sync.quiz_question', 'alert');
132+
}
133+
129134
return new JsonResponse($apiResponse);
130135
}
131136

src/Controller/SyncController.php

Lines changed: 24 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,27 @@ class SyncController extends ApiController
3030
/** @var UtilityService $util */
3131
protected $util;
3232

33+
private function isCurrentVersion(Course $course): bool {
34+
$previousReport = $course->getLatestReport();
35+
if($previousReport) {
36+
$data = json_decode($previousReport->getData());
37+
$currentVersionNumber = !empty($_ENV['VERSION_NUMBER']) ? $_ENV['VERSION_NUMBER'] : '';
38+
if(isset($data->versionNumber) && $data->versionNumber === $currentVersionNumber) {
39+
return true;
40+
}
41+
}
42+
return false;
43+
}
44+
3345
private ManagerRegistry $doctrine;
3446

3547
public function __construct(ManagerRegistry $doctrine)
3648
{
3749
$this->doctrine = $doctrine;
3850
}
39-
40-
#[Route('/api/sync/{course}', name: 'request_sync')]
41-
public function requestSync(Course $course,
42-
LmsFetchService $lmsFetch,
43-
UserRepository $userRepo,
44-
CourseUserRepository $courseUserRepo,
45-
EntityManagerInterface $em,
46-
LmsApiService $lmsApi
47-
)
48-
{
51+
52+
private function executeScan(Course $course, LmsFetchService $lmsFetch, bool $force) {
53+
4954
$response = new ApiResponse();
5055
$user = $this->getUser();
5156
$reportArr = false;
@@ -62,18 +67,6 @@ public function requestSync(Course $course,
6267
throw new \Exception('msg.sync.course_inactive');
6368
}
6469

65-
// Check to see if the CODE (based on version number) has been updated since the last scan.
66-
// If so (or if we can't tell), force a full rescan.
67-
$force = true;
68-
$previousReport = $course->getLatestReport();
69-
if($previousReport) {
70-
$data = json_decode($previousReport->getData());
71-
$currentVersionNumber = !empty($_ENV['VERSION_NUMBER']) ? $_ENV['VERSION_NUMBER'] : '';
72-
if(isset($data->versionNumber) && $data->versionNumber === $currentVersionNumber) {
73-
$force = false;
74-
}
75-
}
76-
7770
$lmsFetch->refreshLmsContent($course, $user, $force);
7871

7972
$report = $course->getLatestReport();
@@ -116,56 +109,17 @@ public function requestSync(Course $course,
116109
return new JsonResponse($response);
117110
}
118111

112+
#[Route('/api/sync/{course}', name: 'request_sync')]
113+
public function requestSync(Course $course, LmsFetchService $lmsFetch)
114+
{
115+
$force = ! $this->isCurrentVersion($course);
116+
117+
return $this->executeScan($course, $lmsFetch, $force);
118+
}
119+
119120
#[Route('/api/sync/rescan/{course}', name: 'full_rescan')]
120121
public function fullCourseRescan(Course $course, LmsFetchService $lmsFetch) {
121-
$response = new ApiResponse();
122-
$user = $this->getUser();
123-
$reportArr = false;
124-
125-
try {
126-
if (!$this->userHasCourseAccess($course)) {
127-
throw new \Exception('msg.no_permissions');
128-
}
129-
if ($course->isDirty()) {
130-
throw new \Exception('msg.course_scanning');
131-
}
132-
if (!$course->isActive()) {
133-
$response->setData(0);
134-
throw new \Exception('msg.sync.course_inactive');
135-
}
136-
137-
$lmsFetch->refreshLmsContent($course, $user, true);
138-
139-
$report = $course->getLatestReport();
140-
141-
if (!$report) {
142-
throw new \Exception('msg.no_report_created');
143-
}
144-
145-
$reportArr = $report->toArray();
146-
$reportArr['files'] = $course->getFileItems();
147-
$reportArr['issues'] = $course->getAllIssues();
148-
$reportArr['contentItems'] = $course->getContentItems();
149-
$reportArr['contentSections'] = $lmsFetch->getCourseSections($course, $user);
150-
151-
$response->setData($reportArr);
152-
153-
$reportData = json_decode($report->getData());
154-
if(isset($reportData->itemsScanned) && $reportData->itemsScanned > 0) {
155-
$response->addMessage('msg.new_content', 'success', 5000);
156-
} else {
157-
$response->addMessage('msg.no_new_content', 'success', 5000);
158-
}
159-
160-
} catch (\Exception $e) {
161-
if ('msg.course_scanning' === $e->getMessage()) {
162-
$response->addMessage($e->getMessage(), 'info', 0, false);
163-
} else {
164-
$response->addMessage($e->getMessage(), 'error', 0);
165-
}
166-
}
167-
168-
return new JsonResponse($response);
122+
return $this->executeScan($course, $lmsFetch, true);
169123
}
170124

171125
#[Route('/api/sync/content/{contentItem}', name: 'content_sync', methods: ['GET'])]

src/Entity/ContentItem.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,27 @@ public function setMetadata(?string $metadata): self
153153
return $this;
154154
}
155155

156+
public function getParentLmsId(): ?string
157+
{
158+
$metadata = json_decode($this->getMetadata(), true);
159+
if (isset($metadata['parentLmsId'])) {
160+
return $metadata['parentLmsId'];
161+
}
162+
return null;
163+
}
164+
165+
public function setParentLmsId(?string $parentLmsId): self
166+
{
167+
$metadata = json_decode($this->getMetadata(), true);
168+
if (!is_array($metadata)) {
169+
$metadata = [];
170+
}
171+
$metadata['parentLmsId'] = $parentLmsId;
172+
$this->setMetadata(json_encode($metadata));
173+
174+
return $this;
175+
}
176+
156177
public function getBody(): ?string
157178
{
158179
return $this->body;
@@ -233,7 +254,6 @@ public function setTitle(string $title): self
233254

234255
public function update($lmsContent): self
235256
{
236-
// try {
237257
$updatedDate = new \DateTime($lmsContent['updated'], UtilityService::$timezone);
238258

239259
$this->setUpdated($updatedDate);
@@ -243,10 +263,9 @@ public function update($lmsContent): self
243263
$this->setBody($lmsContent['body']);
244264
$this->setUrl($lmsContent['url']);
245265

246-
// }
247-
// catch (\Exception $e) {
248-
249-
// }
266+
if(isset($lmsContent['parentLmsId'])) {
267+
$this->setParentLmsId($lmsContent['parentLmsId']);
268+
}
250269

251270
return $this;
252271
}

0 commit comments

Comments
 (0)