Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
75a31c90
Commit
75a31c90
authored
Nov 02, 2011
by
Tim Hunt
Browse files
MDL-29808 qbehaviours: update to use ->dependencies in version.php
parent
828788f0
Changes
20
Hide whitespace changes
Inline
Side-by-side
admin/qbehaviours.php
View file @
75a31c90
...
...
@@ -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.
...
...
@@ -39,6 +40,7 @@ admin_externalpage_setup('manageqbehaviours');
$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
(
"
...
...
@@ -50,15 +52,11 @@ foreach ($behaviours as $behaviour => $notused) {
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
;
...
...
@@ -238,13 +236,14 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
}
// 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
(
', '
,
$strrequired
behaviours
);
$row
[]
=
implode
(
', '
,
$strrequired
);
}
else
{
$row
[]
=
''
;
}
...
...
lib/pluginlib.php
View file @
75a31c90
...
...
@@ -1382,25 +1382,9 @@ class plugintype_mod extends plugintype_base implements plugin_information {
* Class for question behaviours.
*/
class
plugintype_qbehaviour
extends
plugintype_base
implements
plugin_information
{
/**
* @see plugin
type_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
()));
...
...
question/behaviour/adaptive/version.php
0 → 100644
View file @
75a31c90
<?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
;
question/behaviour/adaptivenopenalty/behaviour.php
View file @
75a31c90
...
...
@@ -40,10 +40,6 @@ require_once(dirname(__FILE__) . '/../adaptive/behaviour.php');
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
;
}
...
...
question/behaviour/adaptivenopenalty/version.php
0 → 100644
View file @
75a31c90
<?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
;
question/behaviour/behaviourbase.php
View file @
75a31c90
...
...
@@ -77,10 +77,6 @@ abstract class question_behaviour {
}
}
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.
...
...
question/behaviour/deferredcbm/behaviour.php
View file @
75a31c90
...
...
@@ -45,10 +45,6 @@ require_once(dirname(__FILE__) . '/../deferredfeedback/behaviour.php');
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'
);
...
...
question/behaviour/deferredcbm/version.php
0 → 100644
View file @
75a31c90
<?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
;
question/behaviour/deferredfeedback/version.php
0 → 100644
View file @
75a31c90
<?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
;
question/behaviour/immediatecbm/behaviour.php
View file @
75a31c90
...
...
@@ -45,10 +45,6 @@ require_once(dirname(__FILE__) . '/../immediatefeedback/behaviour.php');
class
qbehaviour_immediatecbm
extends
qbehaviour_immediatefeedback
{
const
IS_ARCHETYPAL
=
true
;
public
static
function
get_required_behaviours
()
{
return
array
(
'immediatefeedback'
,
'deferredcbm'
);
}
public
function
get_min_fraction
()
{
return
question_cbm
::
adjust_fraction
(
parent
::
get_min_fraction
(),
question_cbm
::
HIGH
);
}
...
...
question/behaviour/immediatecbm/version.php
0 → 100644
View file @
75a31c90
<?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 immediatecbm
* @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_immediatecbm'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
dependencies
=
array
(
'qbehaviour_immediatefeedback'
=>
2011102700
,
'qbehaviour_deferredcbm'
=>
2011102700
);
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/immediatefeedback/version.php
0 → 100644
View file @
75a31c90
<?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 immediatefeedback
* @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_immediatefeedback'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/informationitem/version.php
0 → 100644
View file @
75a31c90
<?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 informationitem
* @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_informationitem'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/interactive/version.php
0 → 100644
View file @
75a31c90
<?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 interactive
* @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_interactive'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/interactivecountback/behaviour.php
View file @
75a31c90
...
...
@@ -64,10 +64,6 @@ require_once(dirname(__FILE__) . '/../interactive/behaviour.php');
class
qbehaviour_interactivecountback
extends
qbehaviour_interactive
{
const
IS_ARCHETYPAL
=
false
;
public
static
function
get_required_behaviours
()
{
return
array
(
'interactive'
);
}
public
function
required_question_definition_type
()
{
return
'question_automatically_gradable_with_countback'
;
}
...
...
question/behaviour/interactivecountback/version.php
0 → 100644
View file @
75a31c90
<?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 interactivecountback
* @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_interactivecountback'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
dependencies
=
array
(
'qbehaviour_interactive'
=>
2011102700
);
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/manualgraded/version.php
0 → 100644
View file @
75a31c90
<?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 manualgraded
* @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_manualgraded'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/missing/version.php
0 → 100644
View file @
75a31c90
<?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 missing
* @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_missing'
;
$plugin
->
version
=
2011102700
;
$plugin
->
requires
=
2011102700
;
$plugin
->
maturity
=
MATURITY_STABLE
;
question/behaviour/upgrade.txt
0 → 100644
View file @
75a31c90
This files describes API changes for question behaviour plugins.
=== 2.2 ===
* The old
public static function get_required_behaviours()
method is no more. Instead use the ->dependencies facility in version.php. E.g.
$plugin->dependencies = array(
'qbehaviour_immediatefeedback' => 2011102700,
'qbehaviour_deferredcbm' => 2011102700
);
question/engine/lib.php
View file @
75a31c90
...
...
@@ -328,17 +328,6 @@ abstract class question_engine {
return
get_string
(
'pluginname'
,
'qbehaviour_'
.
$behaviour
);
}
/**
* Get the translated name of an behaviour, for display in the UI.
* @param string $behaviour the internal name of the model.
* @return string name from the current language pack.
*/
public
static
function
get_behaviour_required_behaviours
(
$behaviour
)
{
self
::
load_behaviour_class
(
$behaviour
);
$class
=
'qbehaviour_'
.
$behaviour
;
return
$class
::
get_required_behaviours
();
}
/**
* @return array all the file area names that may contain response files.
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment