mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-20636 converstion of questionlib.php and base questiontype.php, plus other cheanges required to get the question editing page to display.
This commit is contained in:
parent
06f8ed54fd
commit
f29aeb5afd
13 changed files with 3165 additions and 2639 deletions
|
@ -63,8 +63,9 @@ abstract class question_bank {
|
|||
if (isset(self::$questiontypes[$qtypename])) {
|
||||
return self::$questiontypes[$qtypename];
|
||||
}
|
||||
$file = $CFG->dirroot . '/question/type/' . $qtypename . '/questiontype.php';
|
||||
$file = get_plugin_directory('qtype', $qtypename) . '/questiontype.php';
|
||||
if (!is_readable($file)) {
|
||||
echo 'problem';
|
||||
if ($mustexist || $qtypename == 'missingtype') {
|
||||
throw new Exception('Unknown question type ' . $qtypename);
|
||||
} else {
|
||||
|
@ -73,6 +74,9 @@ abstract class question_bank {
|
|||
}
|
||||
include_once($file);
|
||||
$class = 'qtype_' . $qtypename;
|
||||
if (!class_exists($class)) {
|
||||
throw new coding_exception("Class $class must be defined in $file");
|
||||
}
|
||||
self::$questiontypes[$qtypename] = new $class();
|
||||
return self::$questiontypes[$qtypename];
|
||||
}
|
||||
|
@ -82,7 +86,7 @@ abstract class question_bank {
|
|||
* @return boolean whether users are allowed to create questions of this type.
|
||||
*/
|
||||
public static function qtype_enabled($qtypename) {
|
||||
;
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,9 +102,12 @@ abstract class question_bank {
|
|||
*/
|
||||
public static function get_all_qtypes() {
|
||||
$qtypes = array();
|
||||
$plugins = get_list_of_plugins('question/type', 'datasetdependent');
|
||||
foreach ($plugins as $plugin) {
|
||||
$qtypes[$plugin] = self::get_qtype($plugin);
|
||||
foreach (get_plugin_list('qtype') as $plugin => $notused) {
|
||||
try {
|
||||
$qtypes[$plugin] = self::get_qtype($plugin);
|
||||
} catch (Exception $e) {
|
||||
// TODO ingore, but reivew this later.
|
||||
}
|
||||
}
|
||||
return $qtypes;
|
||||
}
|
||||
|
|
|
@ -551,21 +551,32 @@ abstract class question_flags {
|
|||
}
|
||||
|
||||
public static function initialise_js() {
|
||||
global $CFG;
|
||||
|
||||
require_js(array('yui_yahoo','yui_dom','yui_event','yui_connection'));
|
||||
require_js($CFG->wwwroot . '/question/qengine.js');
|
||||
|
||||
$config = array(
|
||||
'actionurl' => $CFG->wwwroot . '/question/toggleflag.php',
|
||||
'flagicon' => $CFG->pixpath . '/i/flagged.png',
|
||||
'unflagicon' => $CFG->pixpath . '/i/unflagged.png',
|
||||
'flagtooltip' => get_string('clicktoflag', 'question'),
|
||||
'unflagtooltip' => get_string('clicktounflag', 'question'),
|
||||
'flaggedalt' => get_string('flagged', 'question'),
|
||||
'unflaggedalt' => get_string('notflagged', 'question'),
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
static $done = false;
|
||||
if ($done) {
|
||||
return;
|
||||
}
|
||||
$module = array(
|
||||
'name' => 'core_question_flags',
|
||||
'fullpath' => '/question/flags.js',
|
||||
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
|
||||
);
|
||||
return print_js_config($config, 'qengine_config', true);
|
||||
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
|
||||
$flagattributes = array(
|
||||
0 => array(
|
||||
'src' => $OUTPUT->pix_url('i/unflagged') . '',
|
||||
'title' => get_string('clicktoflag', 'question'),
|
||||
'alt' => get_string('notflagged', 'question'),
|
||||
),
|
||||
1 => array(
|
||||
'src' => $OUTPUT->pix_url('i/flagged') . '',
|
||||
'title' => get_string('clicktounflag', 'question'),
|
||||
'alt' => get_string('flagged', 'question'),
|
||||
),
|
||||
);
|
||||
$PAGE->requires->js_init_call('M.core_question_flags.init',
|
||||
array($actionurl, $flagattributes), false, $module);
|
||||
$done = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class core_question_renderer extends renderer_base {
|
|||
'<input type="checkbox" id="' . $id . 'checkbox" name="' . $id . '" value="1" ' . $checked . ' />' .
|
||||
'<input type="hidden" value="' . s($postdata) . '" class="questionflagpostdata" />' .
|
||||
'<label id="' . $id . 'label" for="' . $id . '">' . $this->get_flag_html(
|
||||
$qa->is_flagged(), $id . 'img') . '</label>' . "\n" .
|
||||
$qa->is_flagged(), $id . 'img') . '</label>' . "\n";
|
||||
break;
|
||||
default:
|
||||
$flagcontent = '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue