H5P Content to Question Conversion
Sorry, this activity is currently hidden
Whoops \ Exception \ ErrorException
(E_WARNING)
Stack frames (9)
8
Whoops\Exception\ErrorException
…/blocks/deft/classes/socket.php136
7
file_get_contents
…/blocks/deft/classes/socket.php136
6
block_deft\socket
execute
…/blocks/deft/classes/socket.php170
5
block_deft\socket
get_token
…/course/format/popups/classes/output/courseformat/content.php57
4
format_popups\output\courseformat\content
export_for_template
…/lib/classes/output/plugin_renderer_base.php87
3
core\output\plugin_renderer_base
render
…/course/format/classes/output/section_renderer.php88
2
core_courseformat\output\section_renderer
render
…/course/format/topics/format.php60
1
require
…/course/format/popups/format.php27
0
require
…/course/view.php351
/opt/moodle/blocks/deft/classes/socket.php
return null;
}
$this->validate();
$requestparams = [
'contextid' => $this->context->id,
'component' => self::COMPONENT,
'area' => self::AREA,
] + $requestparams;
$clientid = $DB->get_field_select('lti_types', 'clientid', "tooldomain = 'deftly.us'");
$jwt = lti_sign_jwt($requestparams, self::ENDPOINT, $clientid);
$requestparams = array_merge($requestparams, $jwt);
$query = html_entity_decode(http_build_query($requestparams), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401);
return json_decode(file_get_contents(
self::ENDPOINT . '?' . $query
));
}
/**
* Supply the token receievd to authenticate connection
*/
public function get_token() {
if (!get_config('block_deft', 'enableupdating')) {
return;
}
if ($this->room) {
return $this->room->get_jwt();
}
$this->validate();
$cache = cache::make('block_deft', 'tokens');
$cached = $cache->get($this->context->id);
More info
https://docs.moodle.org/405/en_us/error/moodle/generalexceptionmessage
/opt/moodle/blocks/deft/classes/socket.php
return null;
}
$this->validate();
$requestparams = [
'contextid' => $this->context->id,
'component' => self::COMPONENT,
'area' => self::AREA,
] + $requestparams;
$clientid = $DB->get_field_select('lti_types', 'clientid', "tooldomain = 'deftly.us'");
$jwt = lti_sign_jwt($requestparams, self::ENDPOINT, $clientid);
$requestparams = array_merge($requestparams, $jwt);
$query = html_entity_decode(http_build_query($requestparams), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401);
return json_decode(file_get_contents(
self::ENDPOINT . '?' . $query
));
}
/**
* Supply the token receievd to authenticate connection
*/
public function get_token() {
if (!get_config('block_deft', 'enableupdating')) {
return;
}
if ($this->room) {
return $this->room->get_jwt();
}
$this->validate();
$cache = cache::make('block_deft', 'tokens');
$cached = $cache->get($this->context->id);
/opt/moodle/blocks/deft/classes/socket.php
$this->validate();
$cache = cache::make('block_deft', 'tokens');
$cached = $cache->get($this->context->id);
if (!empty($cached) && $cached->expiry > time()) {
$this->iceservers = $cached->iceservers ?? '';
return $cached->token;
}
// Prevent other clients requesting token for a bit.
$cache->set($this->context->id, (object) [
'token' => '',
'expiry' => time() + 5,
'iceservers' => $cached->iceservers ?? '',
]);
$response = $this->execute([
'action' => 'token',
'contextid' => $this->context->id,
]);
if (empty($response)) {
return null;
}
$this->iceservers = $response->iceservers;
$cache->set($this->context->id, $response);
return $response->token;
}
/**
* Return ICE servers
*
* @return array Server information
*/
public function ice_servers() {
/opt/moodle/course/format/popups/classes/output/courseformat/content.php
*/
class content extends \format_topics\output\courseformat\content {
/**
* Export this data so it can be used as the context for a mustache template (core/inplace_editable).
*
* @param renderer_base $output typically, the renderer that's calling this function
* @return stdClass data context for a mustache template
*/
public function export_for_template(renderer_base $output) {
global $PAGE;
$course = $this->format->get_course();
$context = context_course::instance($course->id);
$displaysection = $this->format->get_sectionid();
if (
get_config('format_popups', 'enabledeftresponse')
&& get_config('block_deft', 'enableupdating') == 1
) {
$socket = new socket($context);
$token = $socket->get_token();
$PAGE->requires->js_call_amd('format_popups/deft', 'init', [
$context->id, $course->id, $displaysection, $token, get_config('block_deft', 'throttle'),
]);
} else {
$PAGE->requires->js_call_amd('format_popups/popups', 'init', [
$context->id, $course->id, $displaysection,
]);
}
return parent::export_for_template($output);
}
}
/opt/moodle/lib/classes/output/plugin_renderer_base.php
// Keep a copy at this point, we may need to look for a deprecated method.
$deprecatedmethod = "render_{$classname}";
// Remove _renderable suffixes.
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = "render_{$classname}";
if (method_exists($this, $rendermethod)) {
// Call the render_[widget_name] function.
// Note: This has a higher priority than the named_templatable to allow the theme to override the template.
return $this->$rendermethod($widget);
}
if ($widget instanceof named_templatable) {
// This is a named templatable.
// Fetch the template name from the get_template_name function instead.
// Note: This has higher priority than the deprecated method which is not overridable by themes anyway.
return $this->render_from_template(
$widget->get_template_name($this),
$widget->export_for_template($this)
);
}
if ($rendermethod !== $deprecatedmethod && method_exists($this, $deprecatedmethod)) {
// This is exactly where we don't want to be.
// If you have arrived here you have a renderable component within your plugin that has the name
// blah_renderable, and you have a render method render_blah_renderable on your plugin.
// In 2.8 we revamped output, as part of this change we changed slightly how renderables got rendered
// and the _renderable suffix now gets removed when looking for a render method.
// You need to change your renderers render_blah_renderable to render_blah.
// Until you do this it will not be possible for a theme to override the renderer to override your method.
// Please do it ASAP.
static $debugged = [];
if (!isset($debugged[$deprecatedmethod])) {
debugging(sprintf(
'Deprecated call. Please rename your renderables render method from %s to %s.',
$deprecatedmethod,
$rendermethod
), DEBUG_DEVELOPER);
$debugged[$deprecatedmethod] = true;
/opt/moodle/course/format/classes/output/section_renderer.php
*
* @param renderable $widget instance with renderable interface
* @return string the widget HTML
*/
public function render(renderable $widget) {
global $CFG;
$fullpath = str_replace('\\', '/', get_class($widget));
$classparts = explode('/', $fullpath);
// Strip namespaces.
$classname = array_pop($classparts);
// Remove _renderable suffixes.
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = 'render_' . $classname;
if (method_exists($this, $rendermethod)) {
return $this->$rendermethod($widget);
}
// If nothing works, let the parent class decide.
return parent::render($widget);
}
/**
* Generate the section title, wraps it in a link to the section page if page is to be displayed on a separate page
*
* @param stdClass $section The course_section entry from DB
* @param stdClass $course The course entry from DB
* @return string HTML to output.
*/
public function section_title($section, $course) {
$title = get_section_name($course, $section);
$url = course_get_url($course, $section->section, array('navigation' => true));
if ($url) {
$title = html_writer::link($url, $title);
}
return $title;
}
/**
* Generate the section title to be displayed on the section page, without a link
/opt/moodle/course/format/topics/format.php
$format = course_get_format($course);
$course = $format->get_course();
$context = context_course::instance($course->id);
if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
$course->marker = $marker;
course_set_marker($course->id, $marker);
}
// Make sure section 0 is created.
course_create_sections_if_missing($course, 0);
$renderer = $PAGE->get_renderer('format_topics');
if (!is_null($displaysection)) {
$format->set_sectionnum($displaysection);
}
$outputclass = $format->get_output_classname('content');
$widget = new $outputclass($format);
echo $renderer->render($widget);
/opt/moodle/course/format/popups/format.php
//
// 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 <https://www.gnu.org/licenses/>.
/**
* Popup activities course format
*
* @package format_popups
* @copyright 2021 Daniel Thies <dethies@gmail.com>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require($CFG->dirroot . '/course/format/topics/format.php');
// The additional javascript added for this format is now included by the
// section content renderer. To add this functionality to another format
// you should extend format_popups\output\courseformat\content class in
// the new format and add a dependency in version.php to this format.
/opt/moodle/course/view.php
// Get information about course modules and existing module types.
// format.php in course formats may rely on presence of these variables.
$modinfo = get_fast_modinfo($course);
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
$modnamesused = $modinfo->get_used_module_names();
$mods = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
// CAUTION, hacky fundamental variable defintion to follow!
// Note that because of the way course fromats are constructed though
// inclusion we pass parameters around this way.
$displaysection = $section;
// Include course AJAX.
include_course_ajax($course, $modnamesused);
// Include the actual course format.
require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');
// Content wrapper end.
echo html_writer::end_tag('div');
// Trigger course viewed event.
// We don't trust $context here. Course format inclusion above executes in the global space. We can't assume
// anything after that point.
course_view(context_course::instance($course->id), $section);
// If available, include the JS to prepare the download course content modal.
if ($candownloadcourse) {
$PAGE->requires->js_call_amd('core_course/downloadcontent', 'init');
}
// Load the view JS module if completion tracking is enabled for this course.
$completion = new completion_info($course);
if ($completion->is_enabled()) {
$PAGE->requires->js_call_amd('core_course/view', 'init');
}
Environment & details:
| Key | Value |
| id | 52 |
empty
empty
| Key | Value |
| MoodleSession | kausb6fst3jsvvqub3kapdlae5 |
| Key | Value |
| USER | stdClass Object ( [id] => 1 [auth] => manual [confirmed] => 1 [policyagreed] => 0 [deleted] => 0 [suspended] => 0 [mnethostid] => 1 [username] => guest [idnumber] => [firstname] => Guest user [lastname] => [email] => root@localhost [emailstop] => 0 [phone1] => [phone2] => [institution] => [department] => [address] => [city] => [country] => [lang] => en_us [calendartype] => gregorian [theme] => [timezone] => 99 [firstaccess] => 0 [lastaccess] => 0 [lastlogin] => 0 [currentlogin] => 0 [lastip] => [secret] => [picture] => 0 [descriptionformat] => 1 [mailformat] => 1 [maildigest] => 0 [maildisplay] => 2 [autosubscribe] => 1 [trackforums] => 0 [timecreated] => 0 [timemodified] => 1566869212 [trustbitmask] => 0 [imagealt] => [lastnamephonetic] => [firstnamephonetic] => [middlename] => [alternatename] => [moodlenetprofile] => [lastcourseaccess] => Array ( ) [currentcourseaccess] => Array ( ) [profile] => Array ( ) [sesskey] => v9UjWHgcM5 [preference] => Array ( ) [autologinguest] => 1 [access] => Array ( [ra] => Array ( [/1] => Array ( [6] => 6 ) [/1/483/492] => Array ( [6] => 6 ) ) [time] => 1763743254 [rsw] => Array ( ) ) [enrol] => Array ( [enrolled] => Array ( ) [tempguest] => Array ( [52] => 2147483647 ) ) [editing] => 0 ) |
| SESSION | stdClass Object ( [isnewsessioncookie] => 1 [lang] => en_us [fromdiscussion] => https://moodle.openlearner.org/course/view.php?id=52 [cachestore_session] => Array ( [default_session-core/navigation_cache] => Array ( [__lastaccess__u1_kausb6fst3jsvvqub3kapdlae5] => Array ( [0] => 1763743255 [1] => 1763743255 ) ) [default_session-core/coursecat] => Array ( [__lastaccess__u1_kausb6fst3jsvvqub3kapdlae5] => Array ( [0] => 1763743255 [1] => 1763743255 ) [u1_kausb6fst3jsvvqub3kapdlae5_ddc4bc4754192dc4e0b41497b22ffd5dd660bcf6] => Array ( [0] => 1763743255.1053-6920961719b286.51763876 [1] => 1763743255 ) [u1_kausb6fst3jsvvqub3kapdlae5_a432eb3ace283db7eeab490890072df5526386cd] => Array ( [0] => Array ( [0] => 1 [1] => 2 ) [1] => 1763743255 ) [u1_kausb6fst3jsvvqub3kapdlae5_f0ce9beeda1b212e5bdf3402a555b5c93aafce2f] => Array ( [0] => Array ( [0] => 6 [1] => 3 ) [1] => 1763743255 ) ) [default_session-core/courseeditorstate] => Array ( [__lastaccess__u1_kausb6fst3jsvvqub3kapdlae5] => Array ( [0] => 1763743255 [1] => 0 ) [u1_kausb6fst3jsvvqub3kapdlae5_lastinvalidation-9c2da51ccf478beee423a2ff95f19327] => Array ( [0] => 1763743255.1053-6920961719b286.51763876 [1] => 0 ) [u1_kausb6fst3jsvvqub3kapdlae5_52-9c2da51ccf478beee423a2ff95f19327] => Array ( [0] => 1762277756_1763743255 [1] => 0 ) ) ) ) |
| Key | Value |
| USER | www-data |
| HOME | /var/www |
| HTTP_HOST | moodle.openlearner.org |
| HTTP_COOKIE | MoodleSession=kausb6fst3jsvvqub3kapdlae5 |
| HTTP_REFERER | https://moodle.openlearner.org/mod/forum/view.php?id=304&lang=pl |
| HTTP_ACCEPT_ENCODING | gzip, br, zstd, deflate |
| HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
| HTTP_ACCEPT | */* |
| SCRIPT_FILENAME | /opt/moodle/course/view.php |
| PATH_INFO | |
| REDIRECT_STATUS | 200 |
| SERVER_NAME | moodle.openlearner.org |
| SERVER_PORT | 443 |
| SERVER_ADDR | 204.48.16.209 |
| REMOTE_USER | |
| REMOTE_PORT | 11771 |
| REMOTE_ADDR | 216.73.216.175 |
| SERVER_SOFTWARE | nginx/1.26.3 |
| GATEWAY_INTERFACE | CGI/1.1 |
| HTTPS | on |
| REQUEST_SCHEME | https |
| SERVER_PROTOCOL | HTTP/1.1 |
| DOCUMENT_ROOT | /opt/moodle |
| DOCUMENT_URI | /course/view.php |
| REQUEST_URI | /course/view.php?id=52 |
| SCRIPT_NAME | /course/view.php |
| CONTENT_LENGTH | |
| CONTENT_TYPE | |
| REQUEST_METHOD | GET |
| QUERY_STRING | id=52 |
| FCGI_ROLE | RESPONDER |
| PHP_SELF | /course/view.php |
| REQUEST_TIME_FLOAT | 1763743254.8037 |
| REQUEST_TIME | 1763743254 |
empty
0. Whoops\Handler\PrettyPageHandler
1. Whoops\Handler\CallbackHandler