Skip to content

Commit

Permalink
Release Parent 3.12.0 52
Browse files Browse the repository at this point in the history
  • Loading branch information
domonkosadam authored Oct 10, 2024
2 parents 4e0c1fa + e692350 commit 6e9184f
Show file tree
Hide file tree
Showing 584 changed files with 31,459 additions and 2,184 deletions.
2 changes: 1 addition & 1 deletion android-vault
4 changes: 2 additions & 2 deletions apps/flutter_parent/assets/html/html_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
margin-bottom: 12px;
height: 38px;
width: 100%;
border: 0.5px solid #C7CDD1;
border: 0.5px solid #9EA6AD;
border-radius: 4px;
background-color: #F5F5F5;
background-color: #FFFFFF;
text-align: center;
vertical-align: middle;
line-height: 38px;
Expand Down
8 changes: 4 additions & 4 deletions apps/flutter_parent/lib/models/help_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ abstract class HelpLink implements Built<HelpLink, HelpLinkBuilder> {

factory HelpLink([void Function(HelpLinkBuilder) updates]) = _$HelpLink;

String get id;
String? get id;

String get type;

@BuiltValueField(wireName: 'available_to')
BuiltList<AvailableTo> get availableTo;

String get url;
String? get url;

String get text;
String? get text;

String get subtext;
String? get subtext;
}

class AvailableTo extends EnumClass {
Expand Down
73 changes: 41 additions & 32 deletions apps/flutter_parent/lib/models/help_link.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apps/flutter_parent/lib/network/api/course_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ class CourseApi {
var dio = canvasDio(forceRefresh: forceRefresh);
return fetch(dio.get('courses/$courseId/permissions'));
}

Future<List<String>?> getEnabledCourseFeatures(String courseId, {bool forceRefresh = false}) async {
var dio = canvasDio(forceRefresh: forceRefresh);
return fetchList(dio.get('courses/$courseId/features/enabled'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ import 'package:flutter_parent/utils/notification_util.dart';
import 'package:flutter_parent/utils/service_locator.dart';

class AssignmentDetailsInteractor {
final String _ASSIGNMENT_ENHANCEMENT_KEY = "assignments_2_student";

Future<AssignmentDetails?> loadAssignmentDetails(
bool forceRefresh,
String courseId,
String assignmentId,
String? studentId,
) async {
final course = locator<CourseApi>().getCourse(courseId, forceRefresh: forceRefresh);
final enabledCourseFeatures = locator<CourseApi>().getEnabledCourseFeatures(courseId, forceRefresh: forceRefresh);
final assignment = locator<AssignmentApi>().getAssignment(courseId, assignmentId, forceRefresh: forceRefresh);

return AssignmentDetails(
assignment: (await assignment),
course: (await course),
);
assignment: (await assignment),
course: (await course),
assignmentEnhancementEnabled: (await enabledCourseFeatures)?.contains(_ASSIGNMENT_ENHANCEMENT_KEY));
}

Future<AssignmentDetails> loadQuizDetails(
Expand All @@ -45,12 +48,13 @@ class AssignmentDetailsInteractor {
String studentId,
) async {
final course = locator<CourseApi>().getCourse(courseId, forceRefresh: forceRefresh);
final enabledCourseFeatures = locator<CourseApi>().getEnabledCourseFeatures(courseId, forceRefresh: forceRefresh);
final quiz = locator<AssignmentApi>().getAssignment(courseId, assignmentId, forceRefresh: forceRefresh);

return AssignmentDetails(
assignment: (await quiz),
course: (await course),
);
assignment: (await quiz),
course: (await course),
assignmentEnhancementEnabled: (await enabledCourseFeatures)?.contains(_ASSIGNMENT_ENHANCEMENT_KEY));
}

Future<Reminder?> loadReminder(String assignmentId) async {
Expand Down Expand Up @@ -100,7 +104,6 @@ class AssignmentDetailsInteractor {
reminder = insertedReminder;
await locator<NotificationUtil>().scheduleReminder(l10n, title, body, reminder);
}

}

Future<void> deleteReminder(Reminder? reminder) async {
Expand All @@ -113,6 +116,7 @@ class AssignmentDetailsInteractor {
class AssignmentDetails {
final Course? course;
final Assignment? assignment;
final bool? assignmentEnhancementEnabled;

AssignmentDetails({this.course, this.assignment});
AssignmentDetails({this.course, this.assignment, this.assignmentEnhancementEnabled});
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class _AssignmentDetailsScreenState extends State<AssignmentDetailsScreen> {
final course = snapshot.data?.course;
final restrictQuantitativeData = course?.settings?.restrictQuantitativeData ?? false;
final assignment = snapshot.data!.assignment!;
final assignmentEnhancementEnabled = snapshot.data?.assignmentEnhancementEnabled ?? false;
final submission = assignment.submission(_currentStudent?.id);
final fullyLocked = assignment.isFullyLocked;
final missing = submission?.missing == true;
Expand Down Expand Up @@ -191,7 +192,11 @@ class _AssignmentDetailsScreenState extends State<AssignmentDetailsScreen> {
padding: const EdgeInsets.only(top: 16.0, bottom: 16.0),
child: OutlinedButton(
onPressed: () {
_onSubmissionAndRubricClicked(assignment.htmlUrl, l10n.submission);
_onSubmissionAndRubricClicked(
assignment.htmlUrl,
assignmentEnhancementEnabled,
l10n.submission,
);
},
child: Align(
alignment: Alignment.center,
Expand Down Expand Up @@ -400,12 +405,13 @@ class _AssignmentDetailsScreenState extends State<AssignmentDetailsScreen> {
}
}

_onSubmissionAndRubricClicked(String? assignmentUrl, String title) async {
_onSubmissionAndRubricClicked(String? assignmentUrl, bool assignmentEnhancementEnabled, String title) async {
if (assignmentUrl == null) return;
final parentId = ApiPrefs.getUser()?.id ?? 0;
final currentStudentId = _currentStudent?.id ?? 0;
final url = assignmentEnhancementEnabled ? assignmentUrl : assignmentUrl + "/submissions/$currentStudentId";
locator<QuickNav>().pushRoute(context, PandaRouter.submissionWebViewRoute(
await locator<WebContentInteractor>().getAuthUrl(assignmentUrl),
await locator<WebContentInteractor>().getAuthUrl(url),
title,
{"k5_observed_user_for_$parentId": "$currentStudentId"},
false
Expand Down
24 changes: 12 additions & 12 deletions apps/flutter_parent/lib/screens/help/help_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class _HelpScreenState extends State<HelpScreen> {
List<Widget> _generateLinks(List<HelpLink>? links) {
List<Widget> helpLinks = List.from(links?.map(
(l) => ListTile(
title: Text(l.text, style: Theme.of(context).textTheme.titleMedium),
subtitle: Text(l.subtext, style: Theme.of(context).textTheme.bodySmall),
title: Text(l.text ?? '', style: Theme.of(context).textTheme.titleMedium),
subtitle: Text(l.subtext ?? '', style: Theme.of(context).textTheme.bodySmall),
onTap: () => _linkClick(l),
),
) ?? []);
Expand All @@ -84,7 +84,7 @@ class _HelpScreenState extends State<HelpScreen> {
}

void _linkClick(HelpLink link) {
String url = link.url;
String url = link.url ?? '';
if (url[0] == '#') {
// Internal link
if (url.contains('#create_ticket')) {
Expand All @@ -93,24 +93,24 @@ class _HelpScreenState extends State<HelpScreen> {
// Custom for Android
_showShareLove();
}
} else if (link.id.contains('submit_feature_idea')) {
} else if (link.id?.contains('submit_feature_idea') == true) {
_showRequestFeature();
} else if (link.url.startsWith('tel:+')) {
} else if (url.startsWith('tel:+')) {
// Support phone links: https://community.canvaslms.com/docs/DOC-12664-4214610054
locator<AndroidIntentVeneer>().launchPhone(link.url);
} else if (link.url.startsWith('mailto:')) {
locator<AndroidIntentVeneer>().launchPhone(url);
} else if (url.startsWith('mailto:')) {
// Support mailto links: https://community.canvaslms.com/docs/DOC-12664-4214610054
locator<AndroidIntentVeneer>().launchEmail(link.url);
} else if (link.url.contains('cases.canvaslms.com/liveagentchat')) {
locator<AndroidIntentVeneer>().launchEmail(url);
} else if (url.contains('cases.canvaslms.com/liveagentchat')) {
// Chat with Canvas Support - Doesn't seem work properly with WebViews, so we kick it out
// to the external browser
locator<UrlLauncher>().launch(link.url);
} else if (link.id.contains('search_the_canvas_guides')) {
locator<UrlLauncher>().launch(url);
} else if (link.id?.contains('search_the_canvas_guides') == true) {
// Send them to the mobile Canvas guides
_showSearch();
} else {
// External url
locator<UrlLauncher>().launch(link.url);
locator<UrlLauncher>().launch(url);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HelpScreenInteractor {
link.availableTo.contains(AvailableTo.user));

List<HelpLink> filterObserverLinks(BuiltList<HelpLink> list) => list
.where((link) => link.url != null && link.text != null)
.where((link) =>
link.availableTo.contains(AvailableTo.observer) ||
link.availableTo.contains(AvailableTo.user))
Expand Down
2 changes: 1 addition & 1 deletion apps/flutter_parent/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ description: Canvas Parent
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.11.0+51
version: 3.12.0+52

module:
androidX: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,21 @@ void main() {

expect(details?.assignment, assignment);
});

test('returns assignmentEnhancementEnabled as false if response does not contain key', () async {
final features = ["feature1", "feature2"];
when(courseApi.getEnabledCourseFeatures(courseId)).thenAnswer((_) async => features);
final details = await AssignmentDetailsInteractor().loadAssignmentDetails(false, courseId, assignmentId, studentId);

expect(details?.assignmentEnhancementEnabled, false);
});

test('returns assignmentEnhancementEnabled as true if response contains key', () async {
final features = ["feature1", "assignments_2_student", "feature3"];
when(courseApi.getEnabledCourseFeatures(courseId)).thenAnswer((_) async => features);
final details = await AssignmentDetailsInteractor().loadAssignmentDetails(false, courseId, assignmentId, studentId);

expect(details?.assignmentEnhancementEnabled, true);
});
});
}
Loading

0 comments on commit 6e9184f

Please sign in to comment.