forked from ngandrass/moodle-quiz_archiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
404 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/>. | ||
|
||
/** | ||
* Handles everything that is needed for coversheet creation. | ||
* | ||
* @package quiz_archiver | ||
* @copyright ISB Bayern, 2024 | ||
* @author Dr. Peter Mayer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace quiz_archiver\local\coversheet; | ||
|
||
use admin_setting_heading; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Handles everything that is needed for coversheet creation. | ||
* | ||
* @package quiz_archiver | ||
* @copyright ISB Bayern, 2024 | ||
* @author Dr. Peter Mayer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class create_coversheet { | ||
|
||
/** | ||
* Create the coversheet. Only this method should be called from outside. | ||
* @param int $attemptid | ||
* @return string | ||
*/ | ||
public static function get_coversheet(int $attemptid): string { | ||
|
||
$config = get_config('quiz_archiver'); | ||
|
||
if(empty($config->enable_pdf_coversheet)) { | ||
return ''; | ||
} | ||
|
||
return $config->dynamic_pdf_content; | ||
|
||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Admin config settings page | ||
* | ||
* @package quiz_archiver | ||
* @copyright ISB Bayern, 2024 | ||
* @author Dr. Peter Mayer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace quiz_archiver\local\setting\admin; | ||
|
||
use admin_setting_heading; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->libdir . '/moodlelib.php'); | ||
|
||
/** | ||
* Settings for label type admin setting. | ||
* | ||
* @package quiz_archiver | ||
* @copyright ISB Bayern, 2024 | ||
* @author Dr. Peter Mayer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class setting_button extends admin_setting_heading { | ||
/** @var string Button label */ | ||
protected $label; | ||
/** @var string Button href */ | ||
protected $href; | ||
/** @var string Button css */ | ||
protected $additionalcssclasses; | ||
|
||
/** | ||
* A button element | ||
* | ||
* @param string $name unique ascii name. | ||
* @param string $visiblename heading | ||
* @param string $description description of what the button does | ||
* @param string $label what is written on the button | ||
* @param string $href the URL directed to on click | ||
* @param string $additionalcssclasses additional css classes | ||
*/ | ||
public function __construct(string $name, string $visiblename, string $description, string $label, string $href, string $additionalcssclasses) { | ||
$this->nosave = true; | ||
$this->label = $label; | ||
$this->href = $href; | ||
$this->additionalcssclasses = $additionalcssclasses; | ||
parent::__construct($name, $visiblename, $description, ''); | ||
} | ||
|
||
/** | ||
* Returns an HTML string | ||
* @param mixed $data | ||
* @param string $query | ||
* @return string Returns an HTML string | ||
*/ | ||
public function output_html($data, $query = '') { | ||
global $OUTPUT; | ||
$context = (object)[ | ||
'label' => $this->label, | ||
'href' => $this->href, | ||
'additionalcssclasses' => $this->additionalcssclasses, | ||
'forceltr' => $this->get_force_ltr(), | ||
]; | ||
|
||
$element = $OUTPUT->render_from_template('quiz_archiver/setting_configbutton', $context); | ||
|
||
return format_admin_setting($this, $this->visiblename, $element, $this->description); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?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/>. | ||
|
||
/** | ||
* @package quiz_archiver | ||
* @copyright ISB Bayern, 2024 | ||
* @author Dr. Peter Mayer | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.php'); | ||
|
||
|
||
global $PAGE, $USER, $DB, $OUTPUT; | ||
|
||
// $courseid = required_param('courseid', PARAM_INT); | ||
|
||
$thisurl = new moodle_url('/mod/quiz/report/archiver/settings_coversheet.php'); | ||
$PAGE->set_url($thisurl); | ||
// $PAGE->set_pagelayout('incourse'); | ||
|
||
$action = optional_param('action', '', PARAM_RAW); | ||
|
||
if (!empty($action)) { | ||
switch ($action) { | ||
case 'storecoversheet': | ||
set_config('dynamic_pdf_content', required_param('dynamic_pdf_content', PARAM_RAW), 'quiz_archiver'); | ||
break; | ||
} | ||
} | ||
|
||
// $category = $DB->get_record('course_categories', array('id' => $ccatid), '*', MUST_EXIST); | ||
// $courseurl = new moodle_url('/course/view.php', array('id' => $courseid)); | ||
|
||
// require_login($courseid, false); | ||
// $coursecontext = context_course::instance($courseid); | ||
|
||
// $template = $DB->get_record('block_mbsteachshare_template', array('courseid' => $courseid), '*', MUST_EXIST); | ||
|
||
$PAGE->set_context(\context_system::instance()); | ||
$pagetitle = get_string('define_pdfcoversheet', 'quiz_archiver'); | ||
$PAGE->set_title($pagetitle); | ||
$PAGE->set_heading($pagetitle); | ||
|
||
// No secondary navigation. | ||
$PAGE->set_secondary_navigation(false); | ||
|
||
$templatecontext = []; | ||
|
||
// $helper = new quiz_archiver\helper(); | ||
// $plugininfo = new quiz_archiver\plugininfo\aitool(); | ||
// $enabledtools = $plugininfo->get_enabled_plugins(); | ||
|
||
// // $options = ['' => get_string('pleaseselect', 'quiz_archiver')]; | ||
// $options = []; | ||
// foreach ($enabledtools as $tool) { | ||
// $options[] = ['tool' => $tool, 'toolname' => get_string('pluginname', 'aitool_' . $tool), 'apikey' => "testkey"]; | ||
// } | ||
|
||
// $purposes = $helper->get_all_purposes(); | ||
// foreach ($purposes as $purpose) { | ||
|
||
// $templatecontext['matching']['purposes'][] = [ | ||
// 'purpose' => $purpose, | ||
// 'purposename' => get_string('purpose_' . $purpose, 'quiz_archiver'), | ||
// 'selectoptions' => $options, | ||
// ]; | ||
// } | ||
|
||
$templatecontext['storedhtml'] = '<html> | ||
<head> | ||
</head> | ||
<body> | ||
<h2>EXAMPLE</h2> | ||
<p>This is an example, and will not be present in the PDF. As far as you do not save this page :-).</p> | ||
</body> | ||
</html>'; | ||
if(!empty($dynamicpdfcontent = get_config('quiz_archiver', 'dynamic_pdf_content'))) { | ||
$templatecontext['storedhtml'] = get_config('quiz_archiver', 'dynamic_pdf_content'); | ||
} | ||
// print_r(get_config('quiz_archiver', 'dynamic_pdf_content'));die; | ||
echo $OUTPUT->header(); | ||
|
||
// $renderer = $PAGE->get_renderer('block_mbsteachshare'); | ||
// template::add_template_management_info($template); | ||
|
||
echo $OUTPUT->render_from_template('quiz_archiver/define_pdfcoversheet', $templatecontext); | ||
// $logdata = log::get_template_history($template->id); | ||
// echo $renderer->render_template_history($template, $logdata); | ||
|
||
echo $OUTPUT->footer(); |
Oops, something went wrong.