From 91a93759d54219397df8449acca5348f2ae00508 Mon Sep 17 00:00:00 2001 From: Sam McGrath Date: Fri, 7 Dec 2018 09:15:17 -0700 Subject: [PATCH 1/2] Adding new property for new child module --- Course.js | 218 +++++++++++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 108 deletions(-) diff --git a/Course.js b/Course.js index a16c5a0..d5c1abc 100644 --- a/Course.js +++ b/Course.js @@ -6,122 +6,124 @@ const Logger = require('logger'); var logger = new Logger('Conversion Report'); module.exports = class Course { - constructor(data) { - this.settings = { - 'domain': data.domain || 'byui', - 'platform': data.platform || 'online', - 'accountID': data.platform === 'online'? '42':'19', - 'cookies': data.cookies || [], - 'deleteCourse': data.cleanUpModules ? data.cleanUpModules.includes('delete-course') : false, - 'removeFiles': data.cleanUpModules ? !data.cleanUpModules.includes('remove-files') : true, - 'reorganizeFiles': false, - 'lessonFolders': false, - 'pinDiscussionBoards': false, - 'blockCourse': /block/i.test(data.name), - 'targetAttributes': false, - 'disableLogOutput': false, - 'blueprintLockItems': false, - 'moveUnusedIntoArchive': false, - 'renameFiles': false, - 'moveFiles': false, - 'moduleItemNamingConventions': false, - 'term': data.EnrollmentTerm || null - }; + constructor(data) { + this.settings = { + 'domain': data.domain || 'byui', + 'platform': data.platform || 'online', + 'accountID': data.platform === 'online' ? '42' : '19', + 'cookies': data.cookies || [], + 'deleteCourse': data.cleanUpModules ? data.cleanUpModules.includes('delete-course') : false, + 'removeFiles': data.cleanUpModules ? !data.cleanUpModules.includes('remove-files') : true, + 'reorganizeFiles': false, + 'lessonFolders': false, + 'pinDiscussionBoards': false, + 'blockCourse': /block/i.test(data.name), + 'targetAttributes': false, + 'disableLogOutput': false, + 'blueprintLockItems': false, + 'moveUnusedIntoArchive': false, + 'renameFiles': false, + 'moveFiles': false, + 'moduleItemNamingConventions': false, + 'term': data.EnrollmentTerm || null + }; - /* Identify the selected options and add them to settings */ - if (data.options) { - data.options.forEach(option => { - this.settings[option.name] = option.value; - }); - } + /* Identify the selected options and add them to settings */ + if (data.options) { + data.options.forEach(option => { + this.settings[option.name] = option.value; + }); + } - /* Add leading 20 to enrollment term year. This will break in 900+ years */ - if (this.settings.term) { - this.settings.term = this.settings.term.replace(/\d+/, '20$&'); - } + /* Add leading 20 to enrollment term year. This will break in 900+ years */ + if (this.settings.term) { + this.settings.term = this.settings.term.replace(/\d+/, '20$&'); + } - this.info = { - 'data': data, - 'username': data.username || data.author || 'Unspecified', - 'password': data.password || null, - 'instructorName': data.instructorName || '', - 'instructorEmail': data.instructorEmail || '', - 'D2LOU': data.D2LOU || '', - 'originalZipPath': data.name ? path.resolve('factory', 'originalZip', data.name) : 'Unspecified', - 'unzippedPath': path.resolve('factory', 'unzipped') || 'Unspecified', - 'processedPath': path.resolve('factory', 'processed') || 'Unspecified', - 'uploadZipPath': path.resolve('factory', 'uploadZip') || 'Unspecified', - 'fileName': data.name ? data.name.split(path.sep)[data.name.split(path.sep).length - 1].replace('\\', '-').replace('/', '-') : 'Unspecified', - 'childModules': data.preImportModules && data.postImportModules ? [...data.preImportModules, ...data.postImportModules] : [], - 'canvasOU': data.canvasOU || '', - 'checkStandards:': false, - 'linkCounter': 0, - 'canvasFolders': { - media: -1, - documents: -1, - template: -1, - archive: -1 - }, - get counter() { - this.linkCounter = this.linkCounter++; - return this.linkCounter; - } - }; + this.info = { + 'data': data, + 'username': data.username || data.author || 'Unspecified', + 'password': data.password || null, + 'instructorName': data.instructorName || '', + 'instructorEmail': data.instructorEmail || '', + 'D2LOU': data.D2LOU || '', + 'originalZipPath': data.name ? path.resolve('factory', 'originalZip', data.name) : 'Unspecified', + 'unzippedPath': path.resolve('factory', 'unzipped') || 'Unspecified', + 'processedPath': path.resolve('factory', 'processed') || 'Unspecified', + 'uploadZipPath': path.resolve('factory', 'uploadZip') || 'Unspecified', + 'fileName': data.name ? data.name.split(path.sep)[data.name.split(path.sep).length - 1].replace('\\', '-').replace('/', '-') : 'Unspecified', + 'childModules': data.preImportModules && data.postImportModules ? [...data.preImportModules, ...data.postImportModules] : [], + 'canvasOU': data.canvasOU || '', + 'bannerDashboardImagesType': '', + 'bannerDashboardImagesLocalFile': '', + 'checkStandards:': false, + 'linkCounter': 0, + 'canvasFolders': { + media: -1, + documents: -1, + template: -1, + archive: -1 + }, + get counter() { + this.linkCounter = this.linkCounter++; + return this.linkCounter; + } + }; - this.info.courseName = this.info.fileName.split('.zip')[0]; - this.info.courseCode = (this.info.fileName.split(' ')[0] + ' ' + this.info.fileName.split(' ')[1]).replace(':', ''); - this.info.courseCode = this.info.courseCode.replace('.zip', ''); - // console.log('COURSE NAME:', this.info.courseName); - // console.log('COURSE CODE:', this.info.courseCode); + this.info.courseName = this.info.fileName.split('.zip')[0]; + this.info.courseCode = (this.info.fileName.split(' ')[0] + ' ' + this.info.fileName.split(' ')[1]).replace(':', ''); + this.info.courseCode = this.info.courseCode.replace('.zip', ''); + // console.log('COURSE NAME:', this.info.courseName); + // console.log('COURSE CODE:', this.info.courseCode); - /* Set up the logger */ - this.logger = logger; - this.logs = logger.logs; - this.content = []; - this.log = logger.log; - this.warning = logger.warning; - this.error = logger.error; - this.fatalError = logger.fatalError; - this.message = logger.message; - this.getCallingModule = logger.getCallingModule; - this.console = logger.console; + /* Set up the logger */ + this.logger = logger; + this.logs = logger.logs; + this.content = []; + this.log = logger.log; + this.warning = logger.warning; + this.error = logger.error; + this.fatalError = logger.fatalError; + this.message = logger.message; + this.getCallingModule = logger.getCallingModule; + this.console = logger.console; - /* Disable output if set */ - if (this.settings.disableLogOutput === true) { - logger.disableOutput(true); - console.log('LOGGER OUTPUT DISABLED'); - } + /* Disable output if set */ + if (this.settings.disableLogOutput === true) { + logger.disableOutput(true); + console.log('LOGGER OUTPUT DISABLED'); + } - /* Removes new lines in the logs */ - logger.removeNewLines(true); - } + /* Removes new lines in the logs */ + logger.removeNewLines(true); + } - /* Adds new "junk drawer" item to info */ - newInfo(propertyName, value) { - if (this.info[propertyName]) { - // eslint-disable-next-line - console.log(`This item already exists on the course.info object. Cannot add: ${propertyName}`); - } else { - this.info[propertyName] = value; - } - } + /* Adds new "junk drawer" item to info */ + newInfo(propertyName, value) { + if (this.info[propertyName]) { + // eslint-disable-next-line + console.log(`This item already exists on the course.info object. Cannot add: ${propertyName}`); + } else { + this.info[propertyName] = value; + } + } - /* Retrieves the current count on linkCounter */ - getCount() { - this.info.linkCounter += 1; - return this.info.linkCounter; - } + /* Retrieves the current count on linkCounter */ + getCount() { + this.info.linkCounter += 1; + return this.info.linkCounter; + } - consoleReport() { - logger.consoleReport(); - } - jsonReport(path) { - logger.jsonReport(path); - } - htmlReport(location, title) { - logger.htmlReport(location, title); - } - setReportHeader(html) { - logger.setHtmlHeader(html); - } + consoleReport() { + logger.consoleReport(); + } + jsonReport(path) { + logger.jsonReport(path); + } + htmlReport(location, title) { + logger.htmlReport(location, title); + } + setReportHeader(html) { + logger.setHtmlHeader(html); + } }; \ No newline at end of file From 807802d089ef197890c9649f2247b72c56226188 Mon Sep 17 00:00:00 2001 From: Sam McGrath Date: Fri, 7 Dec 2018 10:18:31 -0700 Subject: [PATCH 2/2] Fixed misspelling --- Course.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Course.js b/Course.js index d5c1abc..7e636e3 100644 --- a/Course.js +++ b/Course.js @@ -55,7 +55,7 @@ module.exports = class Course { 'childModules': data.preImportModules && data.postImportModules ? [...data.preImportModules, ...data.postImportModules] : [], 'canvasOU': data.canvasOU || '', 'bannerDashboardImagesType': '', - 'bannerDashboardImagesLocalFile': '', + 'bannerDashboardImagesFileLocation': '', 'checkStandards:': false, 'linkCounter': 0, 'canvasFolders': {