Skip to content

Commit

Permalink
The start of support for the mobile app
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed May 26, 2024
1 parent f875a5b commit ff93785
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
56 changes: 56 additions & 0 deletions classes/output/mobile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Mobile output class for qtype_aitext
*
* @package qtype_aitext
* @copyright 2018 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace qtype_aitext\output;

/**
* Mobile output class for aitext question type
*
* @package qtype_aitext
* @copyright 2018 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mobile {

/**
* Returns the aite question type for the quiz in the mobile app.
* @param array $args
* @return array
*/
public static function mobile_get_aitext($args) {
global $CFG;
$args = (object) $args;
$folder = $args->appversioncode >= 3950 ? 'latest' : 'ionic3';
$templatepath = $CFG->dirroot."/question/type/aitext/mobile/$folder/addon-qtype-aitext.html";
return [
'templates' => [
[
'id' => 'main',
'html' => file_get_contents($templatepath)
]
],
'javascript' => file_get_contents($CFG->dirroot . '/question/type/aitext/mobile/mobile.js')
];
}
}
53 changes: 53 additions & 0 deletions db/mobile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Mobile app areas for AI Text
*
* Documentation: {@link https://moodledev.io/general/app/development/plugins-development-guide}
*
* @package qtype_aitext
* @copyright 2024 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

$addons = [
"qtype_aitext" => [
"handlers" => [ // Different places where the add-on will display content.
'aitext' => [ // Handler unique name (can be anything).
'displaydata' => [
'title' => 'AIText question',
'icon' => '/question/type/aitext/pix/icon.gif',
'class' => '',
],
'delegate' => 'CoreQuestionDelegate', // Delegate (where to display the link to the add-on).
'method' => 'mobile_get_aitext',
'offlinefunctions' => [
'mobile_get_aitext' => [], // Function in classes/output/mobile.php.
], // Function needs caching for offline.
'styles' => [
'url' => $CFG->wwwroot.'/question/type/aitext/mobile/styles_app.css',
'version' => '0.1'
]
]
],
'lang' => [
['pluginname', 'qtype_aitext'], // Matching value in lang/en/qtype_gapfill.
],
]
];
14 changes: 14 additions & 0 deletions mobile/qtype_aitext.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<section class="list qtype-aitext-container qtype_aitext" ion-list *ngIf="question.text || question.text === ''">
<ion-item><p>
<core-format-text [component]="component" [componentId]="componentId"
[text]="question.text"></core-format-text>
</p></ion-item>
<ion-item>
<core-format-text [component]="component" [componentId]="componentId"
[text]="question.textarea"></core-format-text>
</ion-item>
<ion-item>
<core-format-text [component]="component" [componentId]="componentId"
[text]="question.itemcount" (afterRender)="questionRendered()"></core-format-text>
</ion-item>
</section>
9 changes: 9 additions & 0 deletions mobile/qtype_aitext_app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.qtype-aitext .countwords {
margin-top: 0.5rem; /* mt-2 */
margin-bottom: 0;
}
.qtype-aitext .minwords,
.qtype-aitext .minwords {
margin-top: 0;
margin-bottom: 0;
}

0 comments on commit ff93785

Please sign in to comment.