Skip to content

Commit

Permalink
Merge branch 'MDL-29808' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	question/type/upgrade.txt

There were already one just added upgrade.txt file so this ended
conflicting. Reviewed the contents, I've deleted the less detailed
note about pluginname, leaving the longer description added by Tim.

Ciao :-)
  • Loading branch information
stronk7 committed Nov 10, 2011
2 parents 47c6991 + 226b312 commit d59df65
Show file tree
Hide file tree
Showing 80 changed files with 1,046 additions and 289 deletions.
23 changes: 11 additions & 12 deletions admin/qbehaviours.php
Expand Up @@ -28,6 +28,7 @@
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');

// Check permissions.
Expand All @@ -39,6 +40,7 @@
$thispageurl = new moodle_url('/admin/qbehaviours.php');

$behaviours = get_plugin_list('qbehaviour');
$pluginmanager = plugin_manager::instance();

// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql_menu("
Expand All @@ -50,15 +52,11 @@
if (!array_key_exists($behaviour, $counts)) {
$counts[$behaviour] = 0;
}
$needed[$behaviour] = $counts[$behaviour] > 0;
$needed[$behaviour] = ($counts[$behaviour] > 0) &&
$pluginmanager->other_plugins_that_require('qbehaviour_' . $behaviour);
$archetypal[$behaviour] = question_engine::is_behaviour_archetypal($behaviour);
}

foreach ($behaviours as $behaviour => $notused) {
foreach (question_engine::get_behaviour_required_behaviours($behaviour) as $reqbehaviour) {
$needed[$reqbehaviour] = true;
}
}
foreach ($counts as $behaviour => $count) {
if (!array_key_exists($behaviour, $behaviours)) {
$counts['missingtype'] += $count;
Expand Down Expand Up @@ -238,13 +236,14 @@
}

// Other question types required by this one.
$requiredbehaviours = question_engine::get_behaviour_required_behaviours($behaviour);
if (!empty($requiredbehaviours)) {
$strrequiredbehaviours = array();
foreach ($requiredbehaviours as $required) {
$strrequiredbehaviours[] = $sortedbehaviours[$required];
$plugin = $pluginmanager->get_plugin_info('qbehaviour_' . $behaviour);
$required = $plugin->get_other_required_plugins();
if (!empty($required)) {
$strrequired = array();
foreach ($required as $component => $notused) {
$strrequired[] = $pluginmanager->plugin_name($component);
}
$row[] = implode(', ', $strrequiredbehaviours);
$row[] = implode(', ', $strrequired);
} else {
$row[] = '';
}
Expand Down
17 changes: 8 additions & 9 deletions admin/qtypes.php
Expand Up @@ -28,6 +28,7 @@
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/pluginlib.php');
require_once($CFG->libdir . '/tablelib.php');

// Check permissions.
Expand All @@ -40,6 +41,7 @@
$thispageurl = new moodle_url('/admin/qtypes.php');

$qtypes = question_bank::get_all_qtypes();
$pluginmanager = plugin_manager::instance();

// Get some data we will need - question counts and which types are needed.
$counts = $DB->get_records_sql("
Expand All @@ -52,15 +54,11 @@
$counts[$qtypename]->numquestions = 0;
$counts[$qtypename]->numhidden = 0;
}
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0;
$needed[$qtypename] = $counts[$qtypename]->numquestions > 0 &&
$pluginmanager->other_plugins_that_require($qtype->plugin_name());
$counts[$qtypename]->numquestions -= $counts[$qtypename]->numhidden;
}
$needed['missingtype'] = true; // The system needs the missing question type.
foreach ($qtypes as $qtypename => $qtype) {
foreach ($qtype->requires_qtypes() as $reqtype) {
$needed[$reqtype] = true;
}
}
foreach ($counts as $qtypename => $count) {
if (!isset($qtypes[$qtypename])) {
$counts['missingtype']->numquestions += $count->numquestions - $count->numhidden;
Expand Down Expand Up @@ -237,11 +235,12 @@
}

// Other question types required by this one.
$requiredtypes = $qtype->requires_qtypes();
$plugin = $pluginmanager->get_plugin_info($qtype->plugin_name());
$requiredtypes = $plugin->get_other_required_plugins();
$strtypes = array();
if (!empty($requiredtypes)) {
foreach ($requiredtypes as $required) {
$strtypes[] = $qtypes[$required]->local_name();
foreach ($requiredtypes as $required => $notused) {
$strtypes[] = $pluginmanager->plugin_name($required);
}
$row[] = implode(', ', $strtypes);
} else {
Expand Down
65 changes: 3 additions & 62 deletions lib/pluginlib.php
Expand Up @@ -1383,25 +1383,9 @@ protected static function get_modules_info($disablecache=false) {
* Class for question behaviours.
*/
class plugintype_qbehaviour extends plugintype_base implements plugin_information {

/**
* @see plugintype_base::load_other_required_plugins().
* @see plugin_information::get_uninstall_url()
*/
protected function load_other_required_plugins() {
parent::load_other_required_plugins();
if (!empty($this->dependencies)) {
return;
}

// Standard mechanism did not find anything, so try the legacy way.
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
$required = question_engine::get_behaviour_required_behaviours($this->name);
foreach ($required as $other) {
$this->dependencies['qbehaviour_' . $other] = ANY_VERSION;
}
}

public function get_uninstall_url() {
return new moodle_url('/admin/qbehaviours.php',
array('delete' => $this->name, 'sesskey' => sesskey()));
Expand All @@ -1413,58 +1397,15 @@ public function get_uninstall_url() {
* Class for question types
*/
class plugintype_qtype extends plugintype_base implements plugin_information {

/**
* @see plugin_information::init_display_name()
*/
public function init_display_name() {
if (get_string_manager()->string_exists('pluginname', $this->component)) {
$this->displayname = get_string('pluginname', $this->component);
} else {
$this->displayname = get_string($this->name, $this->component);
}
}

/**
* @see plugintype_base::load_other_required_plugins().
*/
protected function load_other_required_plugins() {
parent::load_other_required_plugins();
if (!empty($this->dependencies)) {
return;
}

// Standard mechanism did not find anything, so try the legacy way.
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
$required = question_bank::get_qtype($this->name)->requires_qtypes();
foreach ($required as $other) {
$this->dependencies['qtype_' . $other] = ANY_VERSION;
}
}

* @see plugin_information::get_uninstall_url()
*/
public function get_uninstall_url() {
return new moodle_url('/admin/qtypes.php',
array('delete' => $this->name, 'sesskey' => sesskey()));
}
}

/**
* Class for question formats
*/
class plugintype_qformat extends plugintype_base implements plugin_information {

/**
* @see plugin_information::init_display_name()
*/
public function init_display_name() {
if (get_string_manager()->string_exists('pluginname', $this->component)) {
$this->displayname = get_string('pluginname', $this->component);
} else {
$this->displayname = get_string($this->name, $this->component);
}
}
}

/**
* Class for authentication plugins
Expand Down
6 changes: 1 addition & 5 deletions lib/questionlib.php
Expand Up @@ -1207,11 +1207,7 @@ function get_import_export_formats($type) {

if ($provided) {
list($notused, $fileformat) = explode('_', $component, 2);
if (get_string_manager()->string_exists('pluginname', $component)) {
$fileformatnames[$fileformat] = get_string('pluginname', $component);
} else {
$fileformatnames[$fileformat] = get_string($fileformat, $component);
}
$fileformatnames[$fileformat] = get_string('pluginname', $component);
}
}

Expand Down
3 changes: 1 addition & 2 deletions mod/lesson/lib.php
Expand Up @@ -876,8 +876,7 @@ function lesson_get_import_export_formats($type) {
$provided = $format_class->provide_export();
}
if ($provided) {
$formatname = get_string($fileformat, 'qformat_'.$fileformat);
$fileformatnames[$fileformat] = $formatname;
$fileformatnames[$fileformat] = get_string('pluginname', 'qformat_'.$fileformat);
}
}
natcasesort($fileformatnames);
Expand Down
33 changes: 33 additions & 0 deletions question/behaviour/adaptive/version.php
@@ -0,0 +1,33 @@
<?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 qbehaviour
* @subpackage adaptive
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->component = 'qbehaviour_adaptive';
$plugin->version = 2011102700;

$plugin->requires = 2011102700;

$plugin->maturity = MATURITY_STABLE;
4 changes: 0 additions & 4 deletions question/behaviour/adaptivenopenalty/behaviour.php
Expand Up @@ -40,10 +40,6 @@
class qbehaviour_adaptivenopenalty extends qbehaviour_adaptive {
const IS_ARCHETYPAL = true;

public static function get_required_behaviours() {
return array('adaptive');
}

protected function adjusted_fraction($fraction, $prevtries) {
return $fraction;
}
Expand Down
36 changes: 36 additions & 0 deletions question/behaviour/adaptivenopenalty/version.php
@@ -0,0 +1,36 @@
<?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 qbehaviour
* @subpackage adaptivenopenalty
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->component = 'qbehaviour_adaptivenopenalty';
$plugin->version = 2011102700;

$plugin->requires = 2011102700;
$plugin->dependencies = array(
'qbehaviour_adaptive' => 2011102700
);

$plugin->maturity = MATURITY_STABLE;
4 changes: 0 additions & 4 deletions question/behaviour/behaviourbase.php
Expand Up @@ -77,10 +77,6 @@ public function __construct(question_attempt $qa, $preferredbehaviour) {
}
}

public static function get_required_behaviours() {
return array();
}

/**
* Most behaviours can only work with {@link question_definition}s
* of a particular subtype, or that implement a particular interface.
Expand Down
4 changes: 0 additions & 4 deletions question/behaviour/deferredcbm/behaviour.php
Expand Up @@ -45,10 +45,6 @@
class qbehaviour_deferredcbm extends qbehaviour_deferredfeedback {
const IS_ARCHETYPAL = true;

public static function get_required_behaviours() {
return array('deferredfeedback');
}

public static function get_unused_display_options() {
return array('correctness', 'marks', 'specificfeedback', 'generalfeedback',
'rightanswer');
Expand Down
36 changes: 36 additions & 0 deletions question/behaviour/deferredcbm/version.php
@@ -0,0 +1,36 @@
<?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 qbehaviour
* @subpackage deferredcbm
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->component = 'qbehaviour_deferredcbm';
$plugin->version = 2011102700;

$plugin->requires = 2011102700;
$plugin->dependencies = array(
'qbehaviour_deferredfeedback' => 2011102700
);

$plugin->maturity = MATURITY_STABLE;
33 changes: 33 additions & 0 deletions question/behaviour/deferredfeedback/version.php
@@ -0,0 +1,33 @@
<?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 qbehaviour
* @subpackage deferredfeedback
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->component = 'qbehaviour_deferredfeedback';
$plugin->version = 2011102700;

$plugin->requires = 2011102700;

$plugin->maturity = MATURITY_STABLE;

0 comments on commit d59df65

Please sign in to comment.