Skip to content
Snippets Groups Projects
Commit 2049591f authored by Lehtinen Teemu's avatar Lehtinen Teemu
Browse files

Add initial version

parents
No related branches found
No related tags found
No related merge requests found
*.log
npm-debug.log*
node_modules
.DS_Store
\ No newline at end of file
LICENSE 0 → 100644
The MIT License (MIT)
Copyright (c) 2016 acos-server
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# acos-webdev-iwdap
Content package for Acos-servers that adds web development exercises
designed for *Introduction to Web Development and Programming*.
## Installation
For the time being, this package requires that `acos-webdev` package has been installed manually.
## Testing
Tests are written with WebDriverIO, refer to the `acos-server` documentation on testing.
{
"hidden_button": {
"html": "<div class=\"acos-webdev-poi\"><button class=\"green\" style=\"display:none\">Click me</button></div>",
"selector": ".exercise button",
"events": "click",
"instructions": "The blue area on left has a hidden button in the document object model. Your task is to use the web browser inspector to first display that button and then click it to receive your points.",
"maxPoints": 10,
"title": "Hidden button",
"description": "Find and display hidden button in browser inspector",
"concepts": ["Inspector", "DOM", "CSS"],
"order": 0
},
"delete_element": {
"html": "<ul><li class=\"acos-webdev-poi\">😀</li><li class=\"acos-webdev-poi angry-face\">😠</li><li class=\"acos-webdev-poi\">😀</li></ul>",
"selector": ".angry-face",
"events": "DOMNodeRemoved",
"instructions": "There are two happy and one angry face on left. Your task is to use the web browser inspector to delete the angry face from the document object model and keep the two happy faces.",
"maxPoints": 10,
"title": "Delete element",
"description": "Find and delete element in browser inspector",
"concepts": ["Inspector", "DOM"],
"order": 1
}
}
index.js 0 → 100644
/* global module, require, __dirname, console */
/* jshint globalstrict: true */
'use strict';
var nj = require('nunjucks');
var fs = require('fs');
var WEBDEVIwdap = function () {};
var baseDir = __dirname;
var content = JSON.parse(fs.readFileSync(baseDir + '/content/inspector.json', 'utf8'));
WEBDEVIwdap.initialize = function (req, params, handlers, cb) {
var templateDir = baseDir + '/templates/';
nj.configure(templateDir, { autoescape: false });
var config = content[params.name];
config.abFlag = params.abFlag;
if (config.template) {
config.html = nj.render(config.template, config);
}
var templateParam = {
id: 'acos-webdev-iwdap-' + params.name,
config: JSON.stringify(config),
acceptTest: config.acceptTest,
pointsCalculator: config.pointsCalculator
};
params.headContent += nj.render('head.html', templateParam);
params.bodyContent += nj.render('body.html', templateParam);
cb();
};
WEBDEVIwdap.register = function (handlers, app, conf) {
handlers.contentPackages['webdev-iwdap'] = WEBDEVIwdap;
handlers.contentTypes.webdev.installedContentPackages.push(WEBDEVIwdap);
};
WEBDEVIwdap.namespace = 'webdev-iwdap';
WEBDEVIwdap.contentTypeNamespace = 'webdev';
WEBDEVIwdap.packageType = 'content';
WEBDEVIwdap.meta = {
'name': 'webdev-iwdap',
'shortDescription': 'Exercise package for web development.',
'description': '',
'author': 'Lassi Haaranen & Teemu Lehtinen',
'license': 'MIT',
'version': '0.1.0',
'url': '',
'teaserContent': ['hidden_button', 'delete_element'],
'contents': content
};
module.exports = WEBDEVIwdap;
{
"name": "acos-webdev-iwdap",
"version": "0.1.0",
"description": "Webdev content package for introduction to web",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": {
"name": "Teemu Lehtinen"
},
"dependencies": {
"acos-webdev": "^0.1.0",
"nunjucks": "^3.1.3"
},
"license": "MIT"
}
<div id="{{ id }}" class="acos-webdev-exercise acos-webdev-inspector">
<div class="guide-column">
<p class="instructions"></p>
<div class="state">
<div class="points"></div>
</div>
<div class="toolbar">
<button class="reset-button">Reset</button>
</div>
</div>
<div class="exercise"></div>
</div>
<script>
$(document).ready(function () {
new ACOSWebdev(
$('#{{ id }}'),
{{ config }},
{% if acceptTest %}{{ acceptTest }}{% else %}undefined{% endif %},
{% if pointsCalculator %}{{ pointsCalculator }}{% else %}undefined{% endif %}
);
});
</script>
describe('acos-webdev-iwdap', function () {
it('should be displayed on the frontpage', function () {
return browser
.url('http://localhost:3000')
.getText('.container').then(function (text) {
text.should.contain('webdev-iwdap');
});
});
it('hidden_button and delete_element should show up on the frontpage', function () {
return browser
.url('http://localhost:3000')
.getText('.container').then(function (text) {
text.should.contain('hidden_button');
text.should.contain('delete_element');
});
});
it('hidden_button should grade correct attempts', function () {
return browser
.url('/html/webdev/webdev-iwdap/hidden_button')
.isVisible('#acos-webdev-iwdap-hidden_button .exercise button').then(function (vis) {
vis.should.be.equal(false);
})
.getText('#acos-webdev-iwdap-hidden_button .points').then(function (text) {
text.should.contain('0 / 10')
})
.click('#acos-webdev-iwdap-hidden_button .exercise button')
.getText('#acos-webdev-iwdap-hidden_button .points').then(function (text) {
text.should.contain('10 / 10')
})
.getAttribute('#acos-webdev-iwdap-hidden_button', 'class').then(function (classes) {
classes.should.contain('green');
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment