:microscope: Where students practice and receive automated and human feedback
:microscope: Where students practice and receive automated and human feedback
Code assement web application for the Mumuki Platform
Laboratory is a multitenant Rails webapp for solving exercises, organized in terms of chapters and guides.
First, we need to install some software: PostgreSQL database, RabbitMQ queue, and some common Ruby on Rails native dependencies
sudo apt-get install autoconf curl git build-essential libssl-dev autoconf bison libreadline6 libreadline6-dev zlib1g zlib1g-dev postgresql libpq-dev rabbitmq-serverrbenv is a ruby versions manager, similar to rvm, nvm, and so on.
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc # or .bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bashrc # or .bash_profileNow we have rbenv installed, we can install ruby and bundler
rbenv install 2.6.3
rbenv global 2.6.3
rbenv rehash
gem install bundlerBecause, err... we need to clone this repostory before developing it :stuck_out_tongue:
git clone https://github.com/mumuki/mumuki-laboratory
cd mumuki-laboratoryWe need to create a PostgreSQL role - AKA a user - who will be used by Laboratory to create and access the database
# create db user for linux users
sudo -u postgres psql {
// do stuff
});Mumuki provides several editor types: code editors, multiple choice, file upload, and so on. However, some runners will require custom editors in order to provide better ways of entering solutions.
The process to do so is not difficult, but tricky, since there are a few hooks you need to implement. Let's look at them:
If you need to provide a custom editor, chances are that you also need to provide assets to augment the layout, e.g. providing ways to render some custom components on descriptions or corollaries. That code will be included first.
In order to do that, add to your runner the layout html, css and js code. Layout code has no further requirements. It can customize any public selector previously.
Although it is not required, it is recommended that your layout code works with any of the mumuki layouts:
input_rightinput_bottominput_primaryinput_kindergarten:warning: Not all the selectors will be available to all layouts.
Then expose code in the MetadataHook:
class ... {
// ... write here your custom component content...
$('#mu-custom-editor-value').val(/* ... */);
});
// alternate method
// you can register many sources
mumuki.editors.addCustomSource({
getContent() {
return { name: "solution[content]", value: /* ... */ } ;
}
});Your solution will be automatically sent to the client and processed when the submit button is pressed.
However, if you need to trigger the whole submission process programmatically,
call mumuki.submission.processSolution:
mumuki.submission.processSolution({solution: {content: /* ... */}});Your solution will be automatically sent to the client when the submit button is pressed, as part of the
solution processing. However, if you just need to send your submission to the server programmatically,
call mumuki.submission.sendSolution:
mumuki.submission.sendSolution({solution: {content: /* ... */}});You can alternatively override the default submit button UI and behaviour, by replacing it with a custom component. In order to
do that, override the .mu-submit-button or the kids-specific .mu-kids-submit-button:
$(".mu-submit-button").html(/* ... */);However, doing this is tricky, since you will need to manually update the UI and connecting to the server. See:
mumuki.kids.showResultmumuki.bridge.Laboratory.runTestsmumuki.updateProgressBarAndShowModalKids layouts have some special areas:
If you want to support kids layouts, you need to register scalers that will be called when device is resized. Skip this step otherwise.
mumuki.kids.registerStateScaler(($state, fullMargin, preferredWidth, preferredHeight) => {
// ... resize your components ...
});
mumuki.kids.registerBlocksAreaScaler(($blocks) => {
// ... resize your components ...
});In order to remove loading spinners, you will need to call mumuki.assetsLoadedFor when your code is ready.
mumuki.assetsLoadedFor('editor');In order to be able to link content, laboratory exposes slug-based routes that will redirect to the actual content URL in the current organization transparently:
GET /topics//GET /guides//GET /exercises///Before using the API, you must create an ApiClient using rails c, which will generate a private JWT. Use it to authenticate API calls in any Platform application within a Authorizaion: Bearer .
Before using the API, take a look to the roles hierarchy:
.
Permissions are bound to a scope, that states in which context the operation can be performed. Scopes are simply two-level contexts, expressed as slugss /, without any explicit semantic. They exact meaning depends on the role:
organization/courseorganization/courseorganization/courseorganization/contentorganization/_organization/__/__/_This is a generic user creation request.
Minimal permission: janitor
POST /usersSample request body:
{
"first_name": "María",
"last_name": "Casas",
"email": "[email protected]",
"permissions": {
"student": "cpt/*:rte/*",
"teacher": "ppp/2016-2q"
}
}This is a way of updating user basic data. Permissions are ignored.
Minimal permission: janitor
PUT /users/:uidSample request body:
{
"first_name": "María",
"last_name": "Casas",
"email": "[email protected]",
"uid": "[email protected]"
}Creates the student if necessary, and updates her permissions.
Minimal permission: janitor
POST /courses/:organization/:course/students{
"first_name": "María",
"last_name": "Casas",
"email": "[email protected]",
"uid": "[email protected]"
}Response
{
"uid": "[email protected]",
"first_name": "María",
"last_name": "Casas",
"email": "[email protected]"
}Forbidden Response
{
"status": 403,
"error": "Exception"
}Remove student permissions from a course.
Minimal permission: janitor
POST /courses/:organization/:course/students/:uid/detachResponse: status code: 200
Not Found Response
{
"status": 404,
"error": "Couldn't find User"
}Add student permissions to a course.
Minimal permission: janitor
POST /courses/:organization/:course/students/:uid/attachResponse: status code: 200
Not Found Response
{
"status": 404,
"error": "Couldn't find User"
}Creates the teacher if necessary, and updates her permissions.
Minimal permission: headmaster, janitor
POST /course/:id/teachers{
"first_name": "Erica",
"last_name": "Gonzalez",
"email": "[email protected]",
"uid": "[email protected]"
}Creates every user if necesssary, an updates permissions.
Minimal permission: janitor
POST /course/:id/batches{
"students": [
{
"first_name": "Tupac",
"last_name": "Lincoln",
"email": "[email protected]",
"uid": "[email protected]"
}
],
"teachers": [
{
"first_name": "Erica",
"last_name": "Gonzalez",
"email": "[email protected]",
"uid": "[email protected]"
}
]
}Minimal permission: janitor
DELETE /course/:id/students/:uidMinimal permission: janitor
DELETE /course/:id/teachers/:uidMinimal permission: admin
DELETE /users/:uidMinimal permission: janitor
POST /organization/:id/courses/{
"name": "....",
}Minimal permission: janitor
DELETE /organization/:id/courses/:idMinimal permission: admin
DELETE /courses/:id{
"name": "academy",
"contact_email": "[email protected]",
"books": [
"MumukiProject/mumuki-libro-metaprogramacion"
],
"locale": "es-AR"
}{
"public": false,
"description": "...",
"login_methods": [
"facebook", "twitter", "google"
],
"logo_url": "http://mumuki.io/logo-alt-large.png",
"terms_of_service": "Al usar Mumuki aceptás que las soluciones de tus ejercicios sean registradas para ser corregidas por tu/s docente/s...",
"theme_stylesheet": ".theme { color: red }",
"extension_javascript": "doSomething = function() { }"
}null to public, login_methods, the values will be false and `["user_pass"].null to description, the value will be null.null to the others, it will be inherited from an organization called "base" every time you query the API.{
"theme_stylesheet_url": "stylesheets/academy-asjdf92j1jd8.css",
"extension_javascript_url": "javascripts/academy-jd912j8jdj19.js"
}get /organizationsSample response body:
{
"organizations": [
{ "name": "academy", "contact_email": "[email protected]", "locale": "es-AR", "login_methods": ["facebook"], "books": ["libro"], "public": true, "logo_url": "http://..." },
{ "name": "alcal", "contact_email": "[email protected]", "locale": "en-US", "login_methods": ["facebook", "github"], "books": ["book"], "public": false }
]
}Minimal permission: None for public organizations, janitor for user's private organizations.
get /organizations/:nameSample response body:
{ "name": "academy", "contact_email": "[email protected]", "locale": "es-AR", "login_methods": ["facebook"], "books": ["libro"], "public": true, "logo_url": "http://..." }Minimal permission: janitor of the organization.
post /organizations... with at least the required fields.
Minimal permission: admin of that organization
put /organizations/:name... with a partial update.
Minimal permission: admin of :name
No open issues yet, or sync has not completed.