Skip to content

Instantly share code, notes, and snippets.

View mudrd8mz's full-sized avatar

David Mudrák mudrd8mz

View GitHub Profile
diff --git a/backup/util/loggers/file_logger.class.php b/backup/util/loggers/file_logger.class.php
index b183767..9b69932 100644
--- a/backup/util/loggers/file_logger.class.php
+++ b/backup/util/loggers/file_logger.class.php
@@ -69,7 +69,7 @@ class file_logger extends base_logger {
// Protected API starts here
protected function action($message, $level, $options = null) {
- $prefix = $this->get_prefix($level, $options);
+ $prefix = sprintf('%-38s', $this->get_prefix($level, $options));
@mudrd8mz
mudrd8mz / test.php
Created July 7, 2011 15:26
At attempt to reproduce MDL-28161
<?php
require('config.php');
$CFG->enablehtmlpurifier = 1;
$PAGE->set_context(get_system_context());
$PAGE->set_url('/test.php');
echo $OUTPUT->header();
diff --git a/mod/resource/backup/moodle1/lib.php b/mod/resource/backup/moodle1/lib.php
index b18172b..4dbb38a 100644
--- a/mod/resource/backup/moodle1/lib.php
+++ b/mod/resource/backup/moodle1/lib.php
@@ -248,7 +248,10 @@ class moodle1_mod_resource_handler extends moodle1_mod_handler {
break;
case 'file':
// if http:// https:// ftp:// OR starts with slash need to be converted to URL
- if (strpos($reference, '://') or strpos($reference, '/') === 0) {
+ if ((strpos($reference, '$@FILEPHP@$') !== false) or
line 51 of /lib/formslib.php: call to debugging()
line 31 of /mod/assignment/lib.php: call to require_once()
line 7365 of /lib/moodlelib.php: call to include_once()
line 906 of /lib/modinfolib.php: call to plugin_supports()
line 251 of /lib/modinfolib.php: call to cm_info->__construct()
line 1071 of /lib/modinfolib.php: call to course_modinfo->__construct()
line 2348 of /lib/moodlelib.php: call to get_fast_modinfo()
line 38 of /mod/workshop/submission.php: call to require_login()
@mudrd8mz
mudrd8mz / gist:1228554
Created September 20, 2011 07:20
dmlwriteexception thrown in moodle
Debug info: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
UPDATE mdl_quiz SET grade = ? WHERE id = ?
[array (
0 => 15,
1 => '2',
)]
Stack trace:
line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1056 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
@mudrd8mz
mudrd8mz / gist:1261665
Created October 4, 2011 13:39
Temporary solution of Moodle sending 304 header even when revision -1 is requested
diff --git a/theme/yui_combo.php b/theme/yui_combo.php
index 8d46a1d..2f631be 100644
--- a/theme/yui_combo.php
+++ b/theme/yui_combo.php
@@ -48,7 +48,7 @@ if (substr($parts, -3) === '.js') {
// if they are requesting a revision that's not -1, and they have supplied an
// If-Modified-Since header, we can send back a 304 Not Modified since the
// content never changes (the rev number is increased any time the content changes)
-if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+if (!empty($CFG->cachejs) && (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE']))) {
@mudrd8mz
mudrd8mz / gist:1263910
Created October 5, 2011 08:01
Advanced grading methods support in the Assignment module
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index d247b31..bded4ff 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -922,6 +922,7 @@ class assignment_base {
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/tablelib.php');
require_once("$CFG->dirroot/repository/lib.php");
+ require_once("$CFG->dirroot/grade/grading/lib.php");
if ($userid==-1) {
@mudrd8mz
mudrd8mz / gist:1287112
Created October 14, 2011 13:32
Extending the concept of renderable components so that the rendering methods can be organized into hierarchies
/**
* Tries to render the given widget or delegates the task to the parent renderer
*
* In order to be able to render the given widget, this renderer must implement
* a protected method called render_widgetname() where widgetname is the name of
* the widget's class or some of its parents. The rendering method is supposed
* to accept the single parameter - the renderable widget itself.
*
* @param renderable $widget some object implementing the renderable interface
* @return string HTML code representing the widget
@mudrd8mz
mudrd8mz / gist:1367058
Created November 15, 2011 13:18
Do not hide the list of loaded JS modules from the performance report in the footer
diff --git a/theme/base/style/core.css b/theme/base/style/core.css
index 4976044..ebf514f 100644
--- a/theme/base/style/core.css
+++ b/theme/base/style/core.css
@@ -139,7 +139,7 @@ a.skip:active {position: static;display: block;}
.arrow,
.arrow_button input {font-family: Arial,Helvetica,Courier,sans-serif;}
-#yui-module-debug {display:none;}
+#yui-module-debug {display:block;}

After clicking the continue in the previous (unfinished) attempt button, a user is getting:

Debug info: Stack trace when the theme was set up:

  • line 1295 of /lib/setuplib.php: call to moodle_page->initialise_theme_and_output()
  • line 118 of /question/type/truefalse/questiontype.php: call to bootstrap_renderer->__call()
  • line 118 of /question/type/truefalse/questiontype.php: call to bootstrap_renderer->notification()
  • line 787 of /lib/questionlib.php: call to qtype_truefalse->get_question_options()
  • line 815 of /lib/questionlib.php: call to _tidy_question()
  • line 261 of /question/engine/bank.php: call to get_question_options()