Skip to content

Instantly share code, notes, and snippets.

@dancgray
dancgray / assetApiModule.js
Created November 6, 2019 16:20
Assets AbstractApiModule test
const AbstractApiModule = require('adapt-authoring-api');
const AssetSchema = require('../schema/asset.schema.js');
/**
* Abstract module which handles course assets
* @extends {AbstractApiModule}
*/
class AssetApiModule extends AbstractApiModule {
/** @override */
static get def() {
return {
@dancgray
dancgray / scaffoldListView.js
Last active July 10, 2019 14:59
Overly complex version of scaffoldListView.js with courseassets cleaned up on item removal
define([
'core/origin',
'core/helpers',
'core/models/courseAssetModel',
'core/collections/contentCollection',
'backbone-forms',
'backbone-forms-lists'
], function(Origin, Helpers, CourseAssetModel, ContentCollection, BackboneForms) {
var ScaffoldListView = Backbone.Form.editors.List.extend({
@dancgray
dancgray / Error
Created May 8, 2019 10:08
Error when component name not present in zip components or installed components
To reproduce add content with a new component that is not included in the import zip.
(node:3626) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '_id' of undefined
at Promise (/source/deltanet/github/adapt_authoring/plugins/output/adapt/importsource.js:501:70)
at new Promise (<anonymous>)
at transformContent (/source/deltanet/github/adapt_authoring/plugins/output/adapt/importsource.js:488:12)
at transform (/source/deltanet/github/adapt_authoring/plugins/output/adapt/importsource.js:561:9)
at /source/deltanet/github/adapt_authoring/node_modules/async/dist/async.js:3880:24
at replenish (/source/deltanet/github/adapt_authoring/node_modules/async/dist/async.js:1011:17)
at /source/deltanet/github/adapt_authoring/node_modules/async/dist/async.js:1016:9
function updateStartIds(cb) {
app.contentmanager.getContentPlugin('course', function (err, coursePlugin) {
coursePlugin.retrieve({_id: courseId}, function(err, results) {
var start = { _start: results[0]._start };
if(!start._start || !start._start._startIds || start._start._startIds.length == 0) return cb();
var newStartIds = [];
start._start._startIds.forEach(function(item, index) {
var newStartId = _.clone(item);

Import

You can import course source code built using the adapt framework or exported from the adapt authoring tool. However there are limitations depending on the version of framework and plugins that are installed in the authoring tool you are importing into.

The import feature does not "update" existing courses, a new course will always be create.

Prerequisites

Import requires at least version 0.5.0 of the Adapt Authoring tool.

Importing the Course Source Code

In the authoring tool, import a course by going to the dashboard and clicking "Import source" on the side bar. This will open the course import page.

@dancgray
dancgray / nginx.conf
Created July 26, 2017 14:03 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@dancgray
dancgray / API.md
Created April 13, 2017 11:03 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

####What about extensions, menus, and themes

The attributes for extensions, menus, and themes can be placed in any of the course JSON files. Because of this the structure of the properties.schema file is different and has a pluginLocations element for each of the course JSON files. The extension, menu, and theme properties for each of these pluginLocations should be added as required by the plug-in.

An empty properties.shema file for an extension would be described like this:

{
  "type":"object",
  "$schema": "http://json-schema.org/draft-04/schema",
  "id": "http://jsonschema.net",
>> Local Npm module "grunt-casperjs" not found. Is it installed?
Running "build:dev" (build) task
Running "requirePlugins" task
Running "merge-json:en" (merge-json) task
File "routes/lang/en.json" created.
Running "copy:main" (copy) task
// possible schema for adapt-contrib-textinput generic answers
"_answers": {
"type":"array",
"required":false,
"title": "Generic Answers",
"items": {
"type":"array",
"required":false,
"items": {