MOBILE-2858 grades: Improve course grades preformat

main
Pau Ferrer Ocaña 2019-02-01 11:23:31 +01:00
parent 92419e2799
commit 442c184ac0
1 changed files with 15 additions and 7 deletions

View File

@ -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, '<br>');
@ -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('<i ') > -1) {
const src = text.match(/class="fa-([^ ]*)"/);
row['icon'] = src[1];
}
}
return row;