From a0197cc4a690c3fa5c13bb5ccdf9581ccbb3b6c7 Mon Sep 17 00:00:00 2001 From: Damir Perisic Date: Mon, 29 Jul 2019 12:58:15 +0200 Subject: [PATCH 1/4] Sign preview elements --- server/activity/activity.controller.js | 2 +- server/shared/publishing/helpers.js | 32 ++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/server/activity/activity.controller.js b/server/activity/activity.controller.js index 44f305f9b..bdd026fdd 100644 --- a/server/activity/activity.controller.js +++ b/server/activity/activity.controller.js @@ -63,7 +63,7 @@ function clone({ activity, body }, res) { } function getPreviewUrl({ course, activity }, res) { - return fetchActivityContent(course, activity) + return fetchActivityContent(course, activity, true) .then(content => { const body = { uid: activity.uid, ...content }; return request.post(previewUrl, body); diff --git a/server/shared/publishing/helpers.js b/server/shared/publishing/helpers.js index ed5ff41eb..362a15acc 100644 --- a/server/shared/publishing/helpers.js +++ b/server/shared/publishing/helpers.js @@ -1,11 +1,10 @@ 'use strict'; -const { getLevelRelationships } = require('../../../config/shared/activities'); -const { TeachingElement } = require('../database'); const filter = require('lodash/filter'); const find = require('lodash/find'); const findIndex = require('lodash/findIndex'); const get = require('lodash/get'); +const { getLevelRelationships } = require('../../../config/shared/activities'); const hash = require('hash-obj'); const keys = require('lodash/keys'); const map = require('lodash/map'); @@ -13,7 +12,9 @@ const omit = require('lodash/omit'); const pick = require('lodash/pick'); const Promise = require('bluebird'); const reduce = require('lodash/reduce'); +const { resolveStatics } = require('../storage/helpers'); const storage = require('../storage'); +const { TeachingElement } = require('../database'); const without = require('lodash/without'); const { FLAT_REPO_STRUCTURE } = process.env; @@ -100,12 +101,17 @@ function getPublishedStructure(repository) { }); } -function fetchActivityContent(repository, activity) { - return Promise.all([ +async function fetchActivityContent(repository, activity, signed = false) { + const res = await Promise.all([ fetchContainers(repository, activity), fetchAssessments(activity), fetchExams(activity) ]).spread((containers, assessments, exams) => ({ containers, assessments, exams })); + if (!signed) return res; + res.containers = await Promise.map(res.containers, resolveContainer); + res.assessments = await resolveAssessments(res.assessments); + res.exams = await Promise.map(res.exams, resolveExam); + return res; } function publishContent(repository, activity) { @@ -185,6 +191,24 @@ async function fetchQuestionGroups(exam) { }; } +async function resolveContainer(container) { + container.elements = await Promise.map(container.elements, resolveStatics); + return container; +} + +function resolveAssessments(assessments) { + return Promise.map(assessments, resolveStatics); +} + +async function resolveExam(exam) { + exam.groups = await Promise.map(exam.groups, async group => { + group.intro = await Promise.map(group.intro, resolveStatics); + group.assessments = await Promise.map(group.assessments, resolveStatics); + return group; + }); + return exam; +} + function saveFile(parent, key, data) { const buffer = Buffer.from(JSON.stringify(data), 'utf8'); const baseUrl = getBaseUrl(parent.courseId, parent.id); From bc5e38f24d668fb2f3cf4645598eff9ade2984b5 Mon Sep 17 00:00:00 2001 From: Toma Zelic Date: Tue, 30 Jul 2019 10:13:16 +0200 Subject: [PATCH 2/4] Remove unused vue-directive-tooltip --- client/main.js | 3 --- package-lock.json | 53 +++++++++++------------------------------------ package.json | 1 - 3 files changed, 12 insertions(+), 45 deletions(-) diff --git a/client/main.js b/client/main.js index 841b6d45b..05ccc741e 100644 --- a/client/main.js +++ b/client/main.js @@ -4,7 +4,6 @@ import 'dom-shims/shim/Element.classList'; import 'dom-shims/shim/Element.mutation'; import 'event-source-polyfill'; import 'bootstrap-sass/assets/javascripts/bootstrap'; -import 'vue-directive-tooltip/css/index.css'; import assetsApi from '@/api/asset'; import colors from 'vuetify/es5/util/colors'; @@ -14,7 +13,6 @@ import FileFilter from '@/directives/file-filter'; import QuestionContainer from 'tce-core/QuestionContainer'; import { sync } from 'vuex-router-sync'; import Timeago from 'vue-timeago'; -import Tooltip from 'vue-directive-tooltip'; import VeeValidate from './utils/validation'; import Vue from 'vue'; import VueHotkey from 'v-hotkey'; @@ -42,7 +40,6 @@ Vue.use(Vuetify, { } }); Vue.use(VuetifySnackbar); -Vue.use(Tooltip, { delay: 50 }); Vue.use(VeeValidate, { delay: 700, fieldsBagName: 'vFields', diff --git a/package-lock.json b/package-lock.json index 634041aac..e08497418 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10671,7 +10671,6 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.4.tgz", "integrity": "sha512-mlouk1OHlaUE8Odt1drMtG1bAJA4ZA6B/ehysgV0LUIrDHdKgo1KorZq3pK0b/7Z7LJIQ12MNM6aC+Tn6lUZ5w==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -10681,8 +10680,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, - "optional": true + "dev": true } } }, @@ -18711,14 +18709,6 @@ "resolved": "https://registry.npmjs.org/vue-datetime/-/vue-datetime-1.0.0-beta.10.tgz", "integrity": "sha512-/wJkj95JSzWqH0Ja4JpXX6I+fXo2A34GCtsx00vR5RjNxk3++93rg7G4ZlI3MFo807zH9bIxXfIohbAZgnAWbQ==" }, - "vue-directive-tooltip": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/vue-directive-tooltip/-/vue-directive-tooltip-1.5.1.tgz", - "integrity": "sha512-2v16flWOSM2gp/pNLje29lJXmWq4ib0NjoAn4wY5R1pYzy0S9a/q3dhQ7dgoqQ1ePXYOj3EpZxMVO8AQ1Zod/A==", - "requires": { - "popper.js": "1.12.5" - } - }, "vue-eslint-parser": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-2.0.3.tgz", @@ -19317,8 +19307,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -19339,14 +19328,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -19361,20 +19348,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -19491,8 +19475,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -19504,7 +19487,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -19519,7 +19501,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -19527,14 +19508,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -19553,7 +19532,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -19634,8 +19612,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -19647,7 +19624,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -19733,8 +19709,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -19770,7 +19745,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -19790,7 +19764,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -19834,14 +19807,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/package.json b/package.json index 6718880f9..47ef02a3a 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,6 @@ "vue-avatar": "^2.1.1", "vue-color": "^2.7.0", "vue-datetime": "^1.0.0-beta.3", - "vue-directive-tooltip": "^1.4.2", "vue-focus": "^2.1.0", "vue-infinite-loading": "^2.4.4", "vue-infinite-scroll": "^2.0.0", From bb822523bf2a1824610adced89efa71b24377cde Mon Sep 17 00:00:00 2001 From: Damir Perisic Date: Wed, 31 Jul 2019 01:23:53 +0200 Subject: [PATCH 3/4] Expose additional activity data for preview --- server/activity/activity.controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/activity/activity.controller.js b/server/activity/activity.controller.js index bdd026fdd..80c4d0215 100644 --- a/server/activity/activity.controller.js +++ b/server/activity/activity.controller.js @@ -65,7 +65,11 @@ function clone({ activity, body }, res) { function getPreviewUrl({ course, activity }, res) { return fetchActivityContent(course, activity, true) .then(content => { - const body = { uid: activity.uid, ...content }; + const body = { + ...pick(activity, ['id', 'uid', 'type']), + meta: activity.data, + ...content + }; return request.post(previewUrl, body); }) .then(({ data: { url } }) => { From a43a8efd7f41274816e78aa790ae0c26832408d8 Mon Sep 17 00:00:00 2001 From: Damir Perisic Date: Mon, 12 Aug 2019 17:31:36 +0200 Subject: [PATCH 4/4] Bump version --- package-lock.json | 49 +++++++++++++++++++++++++++++++++-------------- package.json | 2 +- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e08497418..fc7242ac8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tailor", - "version": "3.2.0", + "version": "3.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -10671,6 +10671,7 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.4.tgz", "integrity": "sha512-mlouk1OHlaUE8Odt1drMtG1bAJA4ZA6B/ehysgV0LUIrDHdKgo1KorZq3pK0b/7Z7LJIQ12MNM6aC+Tn6lUZ5w==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -10680,7 +10681,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true + "dev": true, + "optional": true } } }, @@ -18831,7 +18833,7 @@ "vue-video-player": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/vue-video-player/-/vue-video-player-3.1.4.tgz", - "integrity": "sha1-cAmwbc7EObPqZFGDIX0xTL8NN/0=", + "integrity": "sha512-CqVvhy2QSDRxXfaHn029Cpz+mbV2gubIcdZE5Uu1e7f0ZfpdqpuqnSYyE50nUXzM3zfa7TaYOARpLsY3FdLtOQ==", "requires": { "video.js": "^5.11.7" } @@ -19307,7 +19309,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -19328,12 +19331,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -19348,17 +19353,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -19475,7 +19483,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -19487,6 +19496,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -19501,6 +19511,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -19508,12 +19519,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -19532,6 +19545,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -19612,7 +19626,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -19624,6 +19639,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -19709,7 +19725,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -19745,6 +19762,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -19764,6 +19782,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -19807,12 +19826,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package.json b/package.json index 47ef02a3a..805e5c17c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tailor", - "version": "3.2.0", + "version": "3.2.1", "codename": "silk", "description": "Content authoring platform", "author": "ExtensionEngine ",