2008-12-17 16:37:35 +00:00
|
|
|
<?php
|
2009-11-01 11:31:16 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
2009-05-22 08:41:00 +00:00
|
|
|
// 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.
|
2009-11-01 11:31:16 +00:00
|
|
|
//
|
2009-05-22 08:41:00 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Used to be used for tracking conditions that apply before activities are
|
|
|
|
* displayed to students ('conditional availability').
|
2009-11-01 11:31:16 +00:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Now replaced by the availability API. This library is a stub; some functions
|
|
|
|
* still work while others throw exceptions. New code should not rely on the
|
|
|
|
* classes, functions, or constants defined here.
|
|
|
|
*
|
|
|
|
* @package core_availability
|
|
|
|
* @copyright 2014 The Open University
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated Since Moodle 2.7
|
2009-05-22 08:41:00 +00:00
|
|
|
*/
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2010-07-25 13:35:05 +00:00
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
|
2012-03-07 02:19:59 +01:00
|
|
|
/**
|
|
|
|
* CONDITION_STUDENTVIEW_HIDE - The activity is not displayed to students at all when conditions aren't met.
|
2012-01-09 07:06:57 +05:30
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
define('CONDITION_STUDENTVIEW_HIDE', 0);
|
2012-03-07 02:19:59 +01:00
|
|
|
/**
|
|
|
|
* CONDITION_STUDENTVIEW_SHOW - The activity is displayed to students as a greyed-out name, with
|
|
|
|
* informational text that explains the conditions under which it will be available.
|
2012-01-09 07:06:57 +05:30
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
define('CONDITION_STUDENTVIEW_SHOW', 1);
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2012-03-07 02:19:59 +01:00
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* CONDITION_MISSING_NOTHING - The $item variable is expected to contain all completion-related data
|
2012-01-09 07:06:57 +05:30
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
define('CONDITION_MISSING_NOTHING', 0);
|
2012-03-07 02:19:59 +01:00
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* CONDITION_MISSING_EXTRATABLE - The $item variable is expected to contain the fields from
|
|
|
|
* the relevant table (course_modules or course_sections) but not the _availability data
|
2012-01-09 07:06:57 +05:30
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
define('CONDITION_MISSING_EXTRATABLE', 1);
|
2012-03-07 02:19:59 +01:00
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* CONDITION_MISSING_EVERYTHING - The $item variable is expected to contain nothing except the ID
|
2012-01-09 07:06:57 +05:30
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
define('CONDITION_MISSING_EVERYTHING', 2);
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_CONTAINS - comparison operator that determines whether a specified user field contains
|
|
|
|
* a provided variable
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_CONTAINS', 'contains');
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_DOES_NOT_CONTAIN - comparison operator that determines whether a specified user field does not
|
|
|
|
* contain a provided variable
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_DOES_NOT_CONTAIN', 'doesnotcontain');
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_IS_EQUAL_TO - comparison operator that determines whether a specified user field is equal to
|
|
|
|
* a provided variable
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_IS_EQUAL_TO', 'isequalto');
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_STARTS_WITH - comparison operator that determines whether a specified user field starts with
|
|
|
|
* a provided variable
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_STARTS_WITH', 'startswith');
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_ENDS_WITH - comparison operator that determines whether a specified user field ends with
|
|
|
|
* a provided variable
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_ENDS_WITH', 'endswith');
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
|
|
|
* OP_IS_EMPTY - comparison operator that determines whether a specified user field is empty
|
|
|
|
*/
|
2012-05-09 23:56:14 +08:00
|
|
|
define('OP_IS_EMPTY', 'isempty');
|
MDL-34285 condition: Added is not empty option for user profile conditions and moved strings.
As part of this change I added a new condition for user fields: is not equal.
I also copied the strings being used from the filters lang file to the condition
lang file and changed the uses in code.
AMOS BEGIN
CPY [contains,filters],[contains,condition]
CPY [doesnotcontain,filters],[doesnotcontain,condition]
CPY [isequalto,filters],[isequalto,condition]
CPY [startswith,filters],[startswith,condition]
CPY [endswith,filters],[endswith,condition]
CPY [isempty,filters],[isempty,condition]
AMOS END
2012-07-13 14:28:23 +12:00
|
|
|
/**
|
|
|
|
* OP_IS_NOT_EMPTY - comparison operator that determines whether a specified user field is not empty
|
|
|
|
*/
|
|
|
|
define('OP_IS_NOT_EMPTY', 'isnotempty');
|
2012-05-09 01:32:45 +08:00
|
|
|
|
2010-11-17 06:23:56 +00:00
|
|
|
require_once($CFG->libdir.'/completionlib.php');
|
|
|
|
|
2009-05-22 08:41:00 +00:00
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Core class to handle conditional activities.
|
2012-03-07 02:19:59 +01:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* This class is now deprecated and partially functional. Public functions either
|
|
|
|
* work and output deprecated messages or (in the case of the more obscure ones
|
|
|
|
* which weren't really for public use, or those which can't be implemented in
|
|
|
|
* the new API) throw exceptions.
|
|
|
|
*
|
|
|
|
* @copyright 2014 The Open University
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated Since Moodle 2.7
|
2009-05-22 08:41:00 +00:00
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
class condition_info extends condition_info_base {
|
2008-12-17 16:37:35 +00:00
|
|
|
/**
|
|
|
|
* Constructs with course-module details.
|
|
|
|
*
|
2012-01-09 07:06:57 +05:30
|
|
|
* @global moodle_database $DB
|
2009-05-22 08:41:00 +00:00
|
|
|
* @uses CONDITION_MISSING_NOTHING
|
2014-03-11 16:42:59 +00:00
|
|
|
* @param object $cm Moodle course-module object. Required ->id, ->course
|
|
|
|
* will save time, using a full cm_info will save more time
|
2008-12-17 16:37:35 +00:00
|
|
|
* @param int $expectingmissing Used to control whether or not a developer
|
2009-11-01 11:31:16 +00:00
|
|
|
* debugging message (performance warning) will be displayed if some of
|
|
|
|
* the above data is missing and needs to be retrieved; a
|
2008-12-17 16:37:35 +00:00
|
|
|
* CONDITION_MISSING_xx constant
|
|
|
|
* @param bool $loaddata If you need a 'write-only' object, set this value
|
|
|
|
* to false to prevent database access from constructor
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public function __construct($cm, $expectingmissing = CONDITION_MISSING_NOTHING,
|
2014-03-11 16:42:59 +00:00
|
|
|
$loaddata=true) {
|
|
|
|
global $DB;
|
|
|
|
debugging('The condition_info class is deprecated; change to \core_availability\info_module',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
|
|
|
|
// Check ID as otherwise we can't do the other queries.
|
|
|
|
if (empty($cm->id)) {
|
|
|
|
throw new coding_exception('Invalid parameters; item ID not included');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load cm_info object.
|
|
|
|
if (!($cm instanceof cm_info)) {
|
|
|
|
// Get modinfo.
|
|
|
|
if (empty($cm->course)) {
|
|
|
|
$modinfo = get_fast_modinfo(
|
|
|
|
$DB->get_field('course_modules', 'course', array('id' => $cm->id), MUST_EXIST));
|
|
|
|
} else {
|
|
|
|
$modinfo = get_fast_modinfo($cm->course);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get $cm object.
|
|
|
|
$cm = $modinfo->get_cm($cm->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->item = $cm;
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the extra availability conditions (if any) into the given
|
|
|
|
* course-module (or section) object.
|
|
|
|
*
|
|
|
|
* This function may be called statically (for the editing form) or
|
|
|
|
* dynamically.
|
|
|
|
*
|
|
|
|
* @param object $cm Moodle course-module data object
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (does nothing)
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public static function fill_availability_conditions($cm) {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('Calls to condition_info::fill_availability_conditions should be removed',
|
|
|
|
DEBUG_DEVELOPER);
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the course-module object with full necessary data to determine availability.
|
2014-03-11 16:42:59 +00:00
|
|
|
*
|
2012-04-02 12:16:13 +01:00
|
|
|
* @return object Course-module object with full data
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2012-05-17 00:51:50 +02:00
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
public function get_full_course_module() {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('Calls to condition_info::get_full_course_module should be removed',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
return $this->item;
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Used to update a table (which no longer exists) based on form data
|
|
|
|
* (which is no longer used).
|
|
|
|
*
|
|
|
|
* Should only have been called from core code. Now removed (throws exception).
|
2012-04-02 12:16:13 +01:00
|
|
|
*
|
|
|
|
* @param object $cm Course-module with as much data as necessary, min id
|
|
|
|
* @param object $fromform Data from form
|
|
|
|
* @param bool $wipefirst If true, wipes existing conditions
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public static function update_cm_from_form($cm, $fromform, $wipefirst=true) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
2012-05-17 00:51:50 +02:00
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Used to be used in course/lib.php because we needed to disable the
|
|
|
|
* completion JS if a completion value affects a conditional activity.
|
|
|
|
*
|
|
|
|
* Should only have been called from core code. Now removed (throws exception).
|
2012-04-02 12:16:13 +01:00
|
|
|
*
|
|
|
|
* @global stdClass $CONDITIONLIB_PRIVATE
|
|
|
|
* @param object $course Moodle course object
|
|
|
|
* @param object $item Moodle course-module
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public static function completion_value_used_as_condition($course, $cm) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2013-03-20 14:05:36 +00:00
|
|
|
}
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles conditional access to sections.
|
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* This class is now deprecated and partially functional. Public functions either
|
|
|
|
* work and output deprecated messages or (in the case of the more obscure ones
|
|
|
|
* which weren't really for public use, or those which can't be implemented in
|
|
|
|
* the new API) throw exceptions.
|
|
|
|
*
|
|
|
|
* @copyright 2014 The Open University
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated Since Moodle 2.7
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
class condition_info_section extends condition_info_base {
|
|
|
|
/**
|
|
|
|
* Constructs with course-module details.
|
|
|
|
*
|
|
|
|
* @global moodle_database $DB
|
|
|
|
* @uses CONDITION_MISSING_NOTHING
|
2014-03-11 16:42:59 +00:00
|
|
|
* @param object $section Moodle section object. Required ->id, ->course
|
|
|
|
* will save time, using a full section_info will save more time
|
2012-04-02 12:16:13 +01:00
|
|
|
* @param int $expectingmissing Used to control whether or not a developer
|
|
|
|
* debugging message (performance warning) will be displayed if some of
|
|
|
|
* the above data is missing and needs to be retrieved; a
|
|
|
|
* CONDITION_MISSING_xx constant
|
|
|
|
* @param bool $loaddata If you need a 'write-only' object, set this value
|
|
|
|
* to false to prevent database access from constructor
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public function __construct($section, $expectingmissing = CONDITION_MISSING_NOTHING,
|
2014-03-11 16:42:59 +00:00
|
|
|
$loaddata=true) {
|
|
|
|
global $DB;
|
|
|
|
debugging('The condition_info_section class is deprecated; change to \core_availability\info_section',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
|
|
|
|
// Check ID as otherwise we can't do the other queries.
|
|
|
|
if (empty($section->id)) {
|
|
|
|
throw new coding_exception('Invalid parameters; item ID not included');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load cm_info object.
|
|
|
|
if (!($section instanceof section_info)) {
|
|
|
|
// Get modinfo.
|
|
|
|
if (empty($section->course)) {
|
|
|
|
$modinfo = get_fast_modinfo(
|
|
|
|
$DB->get_field('course_sections', 'course', array('id' => $section->id), MUST_EXIST));
|
|
|
|
} else {
|
|
|
|
$modinfo = get_fast_modinfo($section->course);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get $cm object.
|
|
|
|
foreach ($modinfo->get_section_info_all() as $possible) {
|
|
|
|
if ($possible->id === $section->id) {
|
|
|
|
$section = $possible;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->item = $section;
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the extra availability conditions (if any) into the given
|
|
|
|
* course-module (or section) object.
|
|
|
|
*
|
|
|
|
* This function may be called statically (for the editing form) or
|
|
|
|
* dynamically.
|
|
|
|
*
|
|
|
|
* @param object $section Moodle section data object
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (does nothing)
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
public static function fill_availability_conditions($section) {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('Calls to condition_info_section::fill_availability_conditions should be removed',
|
|
|
|
DEBUG_DEVELOPER);
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the section object with full necessary data to determine availability.
|
2014-03-11 16:42:59 +00:00
|
|
|
*
|
|
|
|
* @return section_info Section object with full data
|
|
|
|
* @deprecated Since Moodle 2.7
|
2012-05-17 00:51:50 +02:00
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
public function get_full_section() {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('Calls to condition_info_section::get_full_section should be removed',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
return $this->item;
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Utility function that used to be called by modedit.php; updated a
|
|
|
|
* table (that no longer exists) based on the module form data.
|
2012-04-02 12:16:13 +01:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Should only have been called from core code. Now removed (throws exception).
|
2012-05-17 00:51:50 +02:00
|
|
|
*
|
|
|
|
* @param object $section Section object, must at minimum contain id
|
|
|
|
* @param object $fromform Data from form
|
|
|
|
* @param bool $wipefirst If true, wipes existing conditions
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2012-05-17 00:51:50 +02:00
|
|
|
*/
|
2012-04-02 12:16:13 +01:00
|
|
|
public static function update_section_from_form($section, $fromform, $wipefirst=true) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2013-03-20 14:05:36 +00:00
|
|
|
}
|
2012-04-02 12:16:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Base class to handle conditional items (course_modules or sections).
|
|
|
|
*
|
|
|
|
* This class is now deprecated and partially functional. Public functions either
|
|
|
|
* work and output deprecated messages or (in the case of the more obscure ones
|
|
|
|
* which weren't really for public use, or those which can't be implemented in
|
|
|
|
* the new API) throw exceptions.
|
2012-04-02 12:16:13 +01:00
|
|
|
*
|
|
|
|
* @copyright 2012 The Open University
|
2014-03-11 16:42:59 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated Since Moodle 2.7
|
2012-04-02 12:16:13 +01:00
|
|
|
*/
|
|
|
|
abstract class condition_info_base {
|
2014-03-11 16:42:59 +00:00
|
|
|
/** @var cm_info|section_info Item with availability data */
|
2012-07-09 11:45:44 +12:00
|
|
|
protected $item;
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2011-09-26 21:20:17 +08:00
|
|
|
/**
|
|
|
|
* The operators that provide the relationship
|
|
|
|
* between a field and a value.
|
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2011-09-26 21:20:17 +08:00
|
|
|
*/
|
2012-05-09 01:32:45 +08:00
|
|
|
public static function get_condition_user_field_operators() {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2011-09-26 21:20:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-02-19 13:33:58 +00:00
|
|
|
* Returns list of user fields that can be compared.
|
2011-09-26 21:20:17 +08:00
|
|
|
*
|
2013-02-19 13:33:58 +00:00
|
|
|
* If you specify $formatoptions, then format_string will be called on the
|
|
|
|
* custom field names. This is necessary for multilang support to work so
|
|
|
|
* you should include this parameter unless you are going to format the
|
|
|
|
* text later.
|
|
|
|
*
|
|
|
|
* @param array $formatoptions Passed to format_string if provided
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2011-09-26 21:20:17 +08:00
|
|
|
*/
|
2013-02-19 13:33:58 +00:00
|
|
|
public static function get_condition_user_fields($formatoptions = null) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2011-09-26 21:20:17 +08:00
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/**
|
|
|
|
* Adds to the database a condition based on completion of another module.
|
2009-05-22 08:41:00 +00:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Should only have been called from core and test code. Now removed
|
|
|
|
* (throws exception).
|
|
|
|
*
|
2012-01-09 07:06:57 +05:30
|
|
|
* @global moodle_database $DB
|
2008-12-17 16:37:35 +00:00
|
|
|
* @param int $cmid ID of other module
|
|
|
|
* @param int $requiredcompletion COMPLETION_xx constant
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
2009-04-17 14:32:50 +00:00
|
|
|
public function add_completion_condition($cmid, $requiredcompletion) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
|
2011-09-26 21:20:17 +08:00
|
|
|
/**
|
|
|
|
* Adds user fields condition
|
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Should only have been called from core and test code. Now removed
|
|
|
|
* (throws exception).
|
|
|
|
*
|
2011-09-26 21:20:17 +08:00
|
|
|
* @param mixed $field numeric if it is a user profile field, character
|
|
|
|
* if it is a column in the user table
|
|
|
|
* @param int $operator specifies the relationship between field and value
|
|
|
|
* @param char $value the value of the field
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2011-09-26 21:20:17 +08:00
|
|
|
*/
|
|
|
|
public function add_user_field_condition($field, $operator, $value) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2011-09-26 21:20:17 +08:00
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/**
|
|
|
|
* Adds to the database a condition based on the value of a grade item.
|
2009-05-22 08:41:00 +00:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Should only have been called from core and test code. Now removed
|
|
|
|
* (throws exception).
|
|
|
|
*
|
2012-01-09 07:06:57 +05:30
|
|
|
* @global moodle_database $DB
|
2008-12-17 16:37:35 +00:00
|
|
|
* @param int $gradeitemid ID of grade item
|
|
|
|
* @param float $min Minimum grade (>=), up to 5 decimal points, or null if none
|
|
|
|
* @param float $max Maximum grade (<), up to 5 decimal points, or null if none
|
|
|
|
* @param bool $updateinmemory If true, updates data in memory; otherwise,
|
|
|
|
* memory version may be out of date (this has performance consequences,
|
|
|
|
* so don't do it unless it really needs updating)
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
2009-04-17 14:32:50 +00:00
|
|
|
public function add_grade_condition($gradeitemid, $min, $max, $updateinmemory=false) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
|
2014-03-11 16:42:59 +00:00
|
|
|
/**
|
2008-12-17 16:37:35 +00:00
|
|
|
* Erases from the database all conditions for this activity.
|
2009-05-22 08:41:00 +00:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* Should only have been called from core and test code. Now removed
|
|
|
|
* (throws exception).
|
|
|
|
*
|
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
|
|
|
public function wipe_conditions() {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
|
|
|
}
|
2008-12-17 16:37:35 +00:00
|
|
|
|
2014-03-11 16:42:59 +00:00
|
|
|
/**
|
|
|
|
* Integration point with new API; obtains the new class for this item.
|
|
|
|
*
|
|
|
|
* @return \core_availability\info Availability info for item
|
|
|
|
*/
|
|
|
|
protected function get_availability_info() {
|
|
|
|
if ($this->item instanceof section_info) {
|
|
|
|
return new \core_availability\info_section($this->item);
|
|
|
|
} else {
|
|
|
|
return new \core_availability\info_module($this->item);
|
|
|
|
}
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtains a string describing all availability restrictions (even if
|
|
|
|
* they do not apply any more).
|
2009-05-22 08:41:00 +00:00
|
|
|
*
|
2013-08-01 14:10:23 +10:00
|
|
|
* @param course_modinfo|null $modinfo Usually leave as null for default. Specify when
|
|
|
|
* calling recursively from inside get_fast_modinfo()
|
2009-11-01 11:31:16 +00:00
|
|
|
* @return string Information string (for admin) about all restrictions on
|
2008-12-17 16:37:35 +00:00
|
|
|
* this item
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
|
|
|
public function get_full_information($modinfo=null) {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('condition_info*::get_full_information() is deprecated, replace ' .
|
|
|
|
'with new \core_availability\info_module($cm)->get_full_information()',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
return $this->get_availability_info()->get_full_information($modinfo);
|
2011-10-11 14:50:01 +01:00
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* Determines whether this particular item is currently available
|
2009-11-01 11:31:16 +00:00
|
|
|
* according to these criteria.
|
|
|
|
*
|
|
|
|
* - This does not include the 'visible' setting (i.e. this might return
|
2008-12-17 16:37:35 +00:00
|
|
|
* true even if visible is false); visible is handled independently.
|
|
|
|
* - This does not take account of the viewhiddenactivities capability.
|
|
|
|
* That should apply later.
|
|
|
|
*
|
2009-05-22 08:41:00 +00:00
|
|
|
* @uses COMPLETION_COMPLETE
|
|
|
|
* @uses COMPLETION_COMPLETE_FAIL
|
|
|
|
* @uses COMPLETION_COMPLETE_PASS
|
|
|
|
* @param string $information If the item has availability restrictions,
|
2009-11-01 11:31:16 +00:00
|
|
|
* a string that describes the conditions will be stored in this variable;
|
2008-12-17 16:37:35 +00:00
|
|
|
* if this variable is set blank, that means don't display anything
|
2009-11-01 11:31:16 +00:00
|
|
|
* @param bool $grabthelot Performance hint: if true, caches information
|
2008-12-17 16:37:35 +00:00
|
|
|
* required for all course-modules, to make the front page and similar
|
|
|
|
* pages work more quickly (works only for current user)
|
|
|
|
* @param int $userid If set, specifies a different user ID to check availability for
|
2013-08-01 14:10:23 +10:00
|
|
|
* @param course_modinfo|null $modinfo Usually leave as null for default. Specify when
|
|
|
|
* calling recursively from inside get_fast_modinfo()
|
2008-12-17 16:37:35 +00:00
|
|
|
* @return bool True if this item is available to the user, false otherwise
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
2009-04-17 14:32:50 +00:00
|
|
|
public function is_available(&$information, $grabthelot=false, $userid=0, $modinfo=null) {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('condition_info*::is_available() is deprecated, replace ' .
|
|
|
|
'with new \core_availability\info_module($cm)->is_available()',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
return $this->get_availability_info()->is_available(
|
|
|
|
$information, $grabthelot, $userid, $modinfo);
|
2009-04-17 16:06:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 16:37:35 +00:00
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* Checks whether availability information should be shown to normal users.
|
2012-01-09 07:06:57 +05:30
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* This information no longer makes sense with the new system because there
|
|
|
|
* are multiple show options. (I doubt anyone much used this function anyhow!)
|
|
|
|
*
|
2008-12-17 16:37:35 +00:00
|
|
|
* @return bool True if information about availability should be shown to
|
|
|
|
* normal users
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
|
|
|
public function show_availability() {
|
2014-03-11 16:42:59 +00:00
|
|
|
debugging('condition_info*::show_availability() is deprecated and there ' .
|
|
|
|
'is no direct replacement (this is no longer a boolean value), ' .
|
|
|
|
'please refactor code',
|
|
|
|
DEBUG_DEVELOPER);
|
|
|
|
return false;
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 11:33:21 +11:00
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Used to be called by grade code to inform the completion system when a
|
|
|
|
* grade was changed.
|
2013-10-29 11:33:21 +11:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* This function should not have ever been used outside the grade API, so
|
|
|
|
* it now just throws an exception.
|
2013-10-29 11:33:21 +11:00
|
|
|
*
|
|
|
|
* @param grade_grade $grade
|
|
|
|
* @param bool $deleted
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7 (not available)
|
|
|
|
* @throws Always throws a coding_exception
|
2013-10-29 11:33:21 +11:00
|
|
|
*/
|
|
|
|
public static function inform_grade_changed($grade, $deleted) {
|
2014-03-11 16:42:59 +00:00
|
|
|
throw new coding_exception('Function no longer available');
|
2013-10-29 11:33:21 +11:00
|
|
|
}
|
|
|
|
|
2012-05-09 01:32:45 +08:00
|
|
|
/**
|
2014-03-11 16:42:59 +00:00
|
|
|
* Used to be used for testing.
|
2012-05-09 01:32:45 +08:00
|
|
|
*
|
2013-10-29 12:22:59 +11:00
|
|
|
* @deprecated since 2.6
|
2009-05-22 08:41:00 +00:00
|
|
|
*/
|
2014-03-11 16:42:59 +00:00
|
|
|
public static function wipe_session_cache() {
|
|
|
|
debugging('Calls to completion_info::wipe_session_cache should be removed', DEBUG_DEVELOPER);
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-04-02 12:16:13 +01:00
|
|
|
* Initialises the global cache
|
2008-12-17 16:37:35 +00:00
|
|
|
*
|
2014-03-11 16:42:59 +00:00
|
|
|
* @deprecated Since Moodle 2.7
|
2008-12-17 16:37:35 +00:00
|
|
|
*/
|
2014-03-11 16:42:59 +00:00
|
|
|
public static function init_global_cache() {
|
|
|
|
debugging('Calls to completion_info::init_globa_cache should be removed', DEBUG_DEVELOPER);
|
2008-12-17 16:37:35 +00:00
|
|
|
}
|
|
|
|
}
|