first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,46 @@
<?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/>.
/**
* Privacy Subsystem implementation for qformat_xhtml.
*
* @package qformat_xhtml
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace qformat_xhtml\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for qformat_xhtml implementing null_provider.
*
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+195
View File
@@ -0,0 +1,195 @@
<?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/>.
/**
* XHTML question exporter.
*
* @package qformat_xhtml
* @copyright 2005 Howard Miller
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* XHTML question exporter.
*
* Exports questions as static HTML.
*
* @copyright 2005 Howard Miller
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qformat_xhtml extends qformat_default {
public function provide_export() {
return true;
}
protected function repchar($text) {
return $text;
}
protected function writequestion($question) {
global $OUTPUT;
// Turns question into string.
// Question reflects database fields for general question and specific to type.
// If a category switch, just ignore.
if ($question->qtype=='category') {
return '';
}
// Initial string.
$expout = "";
$id = $question->id;
// Add comment and div tags.
$expout .= "<!-- question: {$id} name: {$question->name} -->\n";
$expout .= "<div class=\"question\">\n";
// Add header.
$expout .= "<h3>{$question->name}</h3>\n";
// Format and add the question text.
$text = question_rewrite_question_preview_urls($question->questiontext, $question->id,
$question->contextid, 'question', 'questiontext', $question->id,
$question->contextid, 'qformat_xhtml');
$expout .= '<p class="questiontext">' . format_text($text,
$question->questiontextformat, array('noclean' => true)) . "</p>\n";
// Selection depends on question type.
switch($question->qtype) {
case 'truefalse':
$sttrue = get_string('true', 'qtype_truefalse');
$stfalse = get_string('false', 'qtype_truefalse');
$expout .= "<ul class=\"truefalse\">\n";
$expout .= " <li><input name=\"quest_{$id}\" type=\"radio\" value=\"{$sttrue}\" />{$sttrue}</li>\n";
$expout .= " <li><input name=\"quest_{$id}\" type=\"radio\" value=\"{$stfalse}\" />{$stfalse}</li>\n";
$expout .= "</ul>\n";
break;
case 'multichoice':
$expout .= "<ul class=\"multichoice\">\n";
foreach ($question->options->answers as $answer) {
$answertext = $this->repchar( $answer->answer );
if ($question->options->single) {
$expout .= " <li><input name=\"quest_{$id}\" type=\"radio\" value=\""
. s($answertext) . "\" />{$answertext}</li>\n";
} else {
$expout .= " <li><input name=\"quest_{$id}\" type=\"checkbox\" value=\""
. s($answertext) . "\" />{$answertext}</li>\n";
}
}
$expout .= "</ul>\n";
break;
case 'shortanswer':
$expout .= html_writer::start_tag('ul', array('class' => 'shortanswer'));
$expout .= html_writer::start_tag('li');
$expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
$expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text'));
$expout .= html_writer::end_tag('li');
$expout .= html_writer::end_tag('ul');
break;
case 'numerical':
$expout .= html_writer::start_tag('ul', array('class' => 'numerical'));
$expout .= html_writer::start_tag('li');
$expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
$expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text'));
$expout .= html_writer::end_tag('li');
$expout .= html_writer::end_tag('ul');
break;
case 'match':
$expout .= html_writer::start_tag('ul', array('class' => 'match'));
// Build answer list.
$answerlist = array();
foreach ($question->options->subquestions as $subquestion) {
$answerlist[] = $this->repchar( $subquestion->answertext );
}
shuffle( $answerlist ); // Random display order.
// Build select options.
$selectoptions = array();
foreach ($answerlist as $ans) {
$selectoptions[s($ans)] = s($ans);
}
// Display.
$option = 0;
foreach ($question->options->subquestions as $subquestion) {
// Build drop down for answers.
$questiontext = $this->repchar( $subquestion->questiontext );
if ($questiontext != '') {
$dropdown = html_writer::label(get_string('answer', 'qtype_match', $option+1), 'quest_'.$id.'_'.$option,
false, array('class' => 'accesshide'));
$dropdown .= html_writer::select($selectoptions, "quest_{$id}_{$option}", '', false,
array('id' => "quest_{$id}_{$option}"));
$expout .= html_writer::tag('li', $questiontext);
$expout .= $dropdown;
$option++;
}
}
$expout .= html_writer::end_tag('ul');
break;
case 'description':
break;
case 'multianswer':
default:
$expout .= "<!-- export of {$question->qtype} type is not supported -->\n";
}
// Close off div.
$expout .= "</div>\n\n\n";
return $expout;
}
protected function presave_process($content) {
// Override method to allow us to add xhtml headers and footers.
global $CFG;
// Get css bit.
$csslines = file( "{$CFG->dirroot}/question/format/xhtml/xhtml.css" );
$css = implode( ' ', $csslines );
$xp = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
$xp .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
$xp .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
$xp .= "<head>\n";
$xp .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />\n";
$xp .= "<title>Moodle Quiz XHTML Export</title>\n";
$xp .= "<style type=\"text/css\">\n";
$xp .= $css;
$xp .= "</style>\n";
$xp .= "</head>\n";
$xp .= "<body>\n";
$xp .= "<form action=\"...REPLACE ME...\" method=\"post\">\n\n";
$xp .= $content;
$xp .= "<p class=\"submit\">\n";
$xp .= " <input type=\"submit\" />\n";
$xp .= "</p>\n";
$xp .= "</form>\n";
$xp .= "</body>\n";
$xp .= "</html>\n";
return $xp;
}
public function export_file_extension() {
return '.html';
}
}
@@ -0,0 +1,28 @@
<?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/>.
/**
* Strings for component 'qformat_xhtml', language 'en', branch 'MOODLE_20_STABLE'
*
* @package qformat_xhtml
* @copyright 2010 Helen Foster
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'XHTML format';
$string['pluginname_help'] = 'XHTML format enables all questions in the category to be exported to a single page of strict XHTML for possible use in another application.';
$string['pluginname_link'] = 'qformat/xhtml';
$string['privacy:metadata'] = 'The XHTML question format plugin does not store any personal data.';
+58
View File
@@ -0,0 +1,58 @@
<?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/>.
/**
* Standard plugin entry points of the HTML question export format.
*
* @package qformat_xhtml
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Serve question files when they are displayed in this export format.
*
* @param context $previewcontext the quiz context
* @param int $questionid the question id.
* @param context $filecontext the file (question) context
* @param string $filecomponent the component the file belongs to.
* @param string $filearea the file area.
* @param array $args remaining file args.
* @param bool $forcedownload.
* @param array $options additional options affecting the file serving.
*/
function qformat_xhtml_question_preview_pluginfile($previewcontext, $questionid,
$filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array()) {
global $CFG;
list($context, $course, $cm) = get_context_info_array($previewcontext->id);
require_login($course, false, $cm);
question_require_capability_on($questionid, 'view');
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}
+32
View File
@@ -0,0 +1,32 @@
<?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/>.
/**
* Version information for the calculated question type.
*
* @package qformat_xhtml
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'qformat_xhtml';
$plugin->version = 2024042200;
$plugin->requires = 2024041600;
$plugin->maturity = MATURITY_STABLE;
+20
View File
@@ -0,0 +1,20 @@
body {
font-family: verdana, helvetica, sans-serif;
background-color: #fff;
color: #000;
}
.question {
border: 1px solid #ddd;
margin: 5px;
padding: 3px;
}
.question h3 {
font-weight: normal;
font-size: 125%;
}
.question ul {
list-style-type: none;
}