Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Creating mobile question types

From MoodleDocs
Revision as of 22:18, 31 December 2018 by Marcus Green (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

An empty template for creating quiz question types is available from here

https://github.com/marcusgreen/moodle-qtype_TEMPLATE

and it incorporates the skeleton code for supporting the App.

The files that need to be modified/added are

  • db/mobile.php
  • classes/output/mobile.php
  • mobile/mobile.js
  • mobile/addon-qtype-YOURQTYPENAME.html
  • styles_app.css

db/mobile.php

defined('MOODLE_INTERNAL') || die();

$addons = [

   "qtype_YOURQTYPENAME" => [
       "handlers" => [ // Different places where the add-on will display content.
           'YOURQTYPENAME' => [ // Handler unique name (can be anything).
               'displaydata' => [
                   'title' => 'YOURQTYPENAME question',
                   'icon' => '/question/type/YOURQTYPENAME/pix/icon.gif',
                   'class' => ,
               ],
               'delegate' => 'CoreQuestionDelegate', // Delegate (where to display the link to the add-on).
               'method' => 'mobile_get_YOURQTYPENAME',
               'offlinefunctions' => [
                   'mobile_get_YOURQTYPENAME' => [],// function in classes/output/mobile.php
               ], // Function needs caching for offline.
               'styles' => [
                   'url' => '/question/type/YOURQTYPENAME/mobile/styles_app.css',
                   'version' => '1.00'
               ]
           ]
       ],
       'lang' => [
                   ['pluginname', 'qtype_YOURQTYPENAME'], // matching value in  lang/en/qtype_YOURQTYPENAME
       ],
   ]

];