From 442c184ac03aa803df2b58ec380af7dd90d160d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 1 Feb 2019 11:23:31 +0100 Subject: [PATCH 1/2] MOBILE-2858 grades: Improve course grades preformat --- src/core/grades/providers/helper.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/core/grades/providers/helper.ts b/src/core/grades/providers/helper.ts index 764d6ee7f..958c187e6 100644 --- a/src/core/grades/providers/helper.ts +++ b/src/core/grades/providers/helper.ts @@ -85,6 +85,10 @@ export class CoreGradesHelperProvider { let content = String(tableRow[name].content); if (name == 'itemname') { + row['id'] = parseInt(tableRow[name].id.split('_')[1], 10); + row['colspan'] = tableRow[name].colspan; + row['rowspan'] = (tableRow['leader'] && tableRow['leader'].rowspan) || 1; + this.setRowIcon(row, content); row['rowclass'] = tableRow[name].class.indexOf('leveleven') < 0 ? 'odd' : 'even'; row['rowclass'] += tableRow[name].class.indexOf('hidden') >= 0 ? ' hidden' : ''; @@ -92,10 +96,6 @@ export class CoreGradesHelperProvider { content = content.replace(/<\/span>/gi, '\n'); content = this.textUtils.cleanTags(content); - - row['id'] = parseInt(tableRow[name].id.split('_')[1], 10); - row['colspan'] = tableRow[name].colspan; - row['rowspan'] = (tableRow['leader'] && tableRow['leader'].rowspan) || 1; name = 'gradeitem'; } else { content = this.textUtils.replaceNewLines(content, '
'); @@ -439,9 +439,17 @@ export class CoreGradesHelperProvider { row['image'] = this.courseProvider.getModuleIconSrc(module[1], this.domUtils.convertToElement(text).querySelector('img').getAttribute('src')); } - } else if (text.indexOf('src=') > -1) { - const src = text.match(/src="([^"]*)"/); - row['image'] = src[1]; + } else { + if (row['rowspan']) { + row['itemtype'] = 'category'; + row['icon'] = 'fa-folder'; + } else if (text.indexOf('src=') > -1) { + const src = text.match(/src="([^"]*)"/); + row['image'] = src[1]; + } else if (text.indexOf(' -1) { + const src = text.match(/class="fa-([^ ]*)"/); + row['icon'] = src[1]; + } } return row; From e891fcb1a11ddf2a6ff76346dd425ee7c960b5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 1 Feb 2019 11:51:36 +0100 Subject: [PATCH 2/2] MOBILE-2858 courses: Do not check course options on empty list --- src/core/courses/providers/courses.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/courses/providers/courses.ts b/src/core/courses/providers/courses.ts index 548069d07..d4e492aa8 100644 --- a/src/core/courses/providers/courses.ts +++ b/src/core/courses/providers/courses.ts @@ -555,6 +555,10 @@ export class CoreCoursesProvider { * @return {Promise} Promise resolved with administration options for each course. */ getUserAdministrationOptions(courseIds: number[], siteId?: string): Promise { + if (!courseIds || courseIds.length == 0) { + return Promise.resolve({}); + } + return this.sitesProvider.getSite(siteId).then((site) => { const params = { courseids: courseIds @@ -597,6 +601,10 @@ export class CoreCoursesProvider { * @return {Promise} Promise resolved with navigation options for each course. */ getUserNavigationOptions(courseIds: number[], siteId?: string): Promise { + if (!courseIds || courseIds.length == 0) { + return Promise.resolve({}); + } + return this.sitesProvider.getSite(siteId).then((site) => { const params = { courseids: courseIds