Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/namespace discrepancy #296

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions backup/moodle2/backup_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

require_once(dirname(__FILE__) . '/backup_restore_helper.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* Define the complete ratingallocate structure for backup, with [file and] id annotations
Expand All @@ -35,38 +35,38 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');

// Define each element separated.
$class = 'ratingallocate\db\ratingallocate';
$class = 'mod_ratingallocate\db\ratingallocate';
$ratingallocate = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
get_fields_for_tableClass($class));

$class = 'ratingallocate\db\ratingallocate_choices';
$class = 'mod_ratingallocate\db\ratingallocate_choices';
$ratingallocatechoices = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
$ratingallocatechoice = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
get_fields_for_tableClass($class));

$class = 'ratingallocate\db\ratingallocate_ratings';
$class = 'mod_ratingallocate\db\ratingallocate_ratings';
$ratingallocateratings = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
$ratingallocaterating = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
get_fields_for_tableClass($class));

$class = 'ratingallocate\db\ratingallocate_allocations';
$class = 'mod_ratingallocate\db\ratingallocate_allocations';
$ratingallocateallocations = new backup_nested_element(get_tablename_for_tableClass($class) . 's');
$ratingallocateallocation = new backup_nested_element(get_tablename_for_tableClass($class), get_id_for_tableClass($class),
get_fields_for_tableClass($class));

$groupchoiceclass = 'ratingallocate\db\ratingallocate_group_choices';
$groupchoiceclass = 'mod_ratingallocate\db\ratingallocate_group_choices';
$groupchoices = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass) . 's');
$groupchoice = new backup_nested_element(get_tablename_for_tableClass($groupchoiceclass),
get_id_for_tableClass($groupchoiceclass),
get_fields_for_tableClass($groupchoiceclass));

$choicegroupclass = 'ratingallocate\db\ratingallocate_ch_gengroups';
$choicegroupclass = 'mod_ratingallocate\db\ratingallocate_ch_gengroups';
$ratingallocatechoicegroups = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass) . 's');
$ratingallocatechoicegroup = new backup_nested_element(get_tablename_for_tableClass($choicegroupclass),
get_id_for_tableClass($choicegroupclass),
get_fields_for_tableClass($choicegroupclass));

$groupingclass = 'ratingallocate\db\ratingallocate_groupings';
$groupingclass = 'mod_ratingallocate\db\ratingallocate_groupings';
$ratingallocategroupings = new backup_nested_element(get_tablename_for_tableClass($groupingclass) . 's');
$ratingallocategrouping = new backup_nested_element(get_tablename_for_tableClass($groupingclass),
get_id_for_tableClass($groupingclass),
Expand All @@ -92,9 +92,9 @@ protected function define_structure() {
$ratingallocatechoicegroups->add_child($ratingallocatechoicegroup);

// Define sources.
$ratingallocate->set_source_table(get_tablename_for_tableClass('ratingallocate\db\ratingallocate'),
$ratingallocate->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate'),
array(this_db\ratingallocate::ID => backup::VAR_ACTIVITYID), this_db\ratingallocate_choices::ID . ' ASC');
$ratingallocatechoice->set_source_table(get_tablename_for_tableClass('ratingallocate\db\ratingallocate_choices'),
$ratingallocatechoice->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_choices'),
array(this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID),
this_db\ratingallocate_choices::ID . ' ASC');
$groupchoice->set_source_table(get_tablename_for_tableClass($groupchoiceclass), ['choiceid' => backup::VAR_PARENTID]);
Expand All @@ -105,11 +105,11 @@ protected function define_structure() {

if ($userinfo) {
$ratingallocaterating->set_source_table(get_tablename_for_tableClass(
'ratingallocate\db\ratingallocate_ratings'),
'mod_ratingallocate\db\ratingallocate_ratings'),
array(this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID),
this_db\ratingallocate_ratings::ID . ' ASC');
$ratingallocateallocation->set_source_table(
get_tablename_for_tableClass('ratingallocate\db\ratingallocate_allocations'),
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_allocations'),
array(
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion classes/choice_importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_ratingallocate;
use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

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

Expand Down
2 changes: 1 addition & 1 deletion classes/task/cron_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace mod_ratingallocate\task;

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

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

Expand Down
2 changes: 1 addition & 1 deletion classes/task/send_distribution_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

require_once(dirname(__FILE__) . '/../../db/db_structure.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

class send_distribution_notification extends \core\task\adhoc_task {
// Gets executed by the task runner. Will lookup the ratingallocation object and
Expand Down
2 changes: 1 addition & 1 deletion db/db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace ratingallocate\db;
namespace mod_ratingallocate\db;

defined('MOODLE_INTERNAL') || die();
class ratingallocate {
Expand Down
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

require_once(dirname(__FILE__) . '/db/db_structure.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

// //////////////////////////////////////////////////////////////////////////////
// Moodle core API //
Expand Down
16 changes: 8 additions & 8 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

use core_availability\info_module;
use mod_ratingallocate\task\distribute_unallocated_task;
use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

global $CFG;

Expand Down Expand Up @@ -328,7 +328,7 @@ private function process_action_give_rating() {
// Rating is possible...

// Suche das richtige Formular nach Strategie.
$strategyform = 'ratingallocate\\' . $this->ratingallocate->strategy . '\\mod_ratingallocate_view_form';
$strategyform = 'mod_ratingallocate\\' . $this->ratingallocate->strategy . '\\mod_ratingallocate_view_form';

$mform = new $strategyform($PAGE->url->out(), $this);
$mform->add_action_buttons();
Expand Down Expand Up @@ -396,9 +396,9 @@ private function process_action_show_choices() {
// Notifications if no choices exist or too few in comparison to strategy settings.
$availablechoices = $this->get_rateable_choices();
$strategysettings = $this->get_strategy_class()->get_static_settingfields();
if (array_key_exists(ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) {
if (array_key_exists(mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) {
$necessarychoices =
$strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
$strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
} else {
$necessarychoices = 0;
}
Expand Down Expand Up @@ -1213,9 +1213,9 @@ public function handle_view() {
$choicestatus->availablechoices = $this->filter_choices_by_groups($choicestatus->availablechoices, $USER->id);

$strategysettings = $this->get_strategy_class()->get_static_settingfields();
if (array_key_exists(ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) {
if (array_key_exists(mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS, $strategysettings)) {
$choicestatus->necessarychoices =
$strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
$strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
} else {
$choicestatus->necessarychoices = 0;
}
Expand Down Expand Up @@ -2047,7 +2047,7 @@ public function get_options_titles(array $ratings) {
* Returns the strategy class for the ratingallocate
*/
private function get_strategy_class() {
$strategyclassp = 'ratingallocate\\' . $this->ratingallocate->strategy . '\\strategy';
$strategyclassp = 'mod_ratingallocate\\' . $this->ratingallocate->strategy . '\\strategy';
$allsettings = json_decode($this->ratingallocate->setting, true);
if (array_key_exists($this->ratingallocate->strategy, $allsettings)) {
return new $strategyclassp($allsettings[$this->ratingallocate->strategy]);
Expand Down Expand Up @@ -2197,7 +2197,7 @@ public function is_setup_ok() {
$choicecount = count($this->get_rateable_choices());
$strategyclass = $this->get_strategy_class();
$strategysettings = $strategyclass->get_static_settingfields();
$necessarychoices = $strategysettings[ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
$necessarychoices = $strategysettings[mod_ratingallocate\strategy_order\strategy::COUNTOPTIONS][2];
if ($choicecount < $necessarychoices) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function definition() {

foreach (\strategymanager::get_strategies() as $strategy) {
// Load strategy class.
$strategyclassp = 'ratingallocate\\' . $strategy . '\\strategy';
$strategyclassp = 'mod_ratingallocate\\' . $strategy . '\\strategy';
$strategyclass = new $strategyclassp();

// Add options fields.
Expand Down Expand Up @@ -218,7 +218,7 @@ public function definition_after_data() {
// Add dynamic settings fields.
foreach (\strategymanager::get_strategies() as $strategy) {
// Load strategy class.
$strategyclassp = 'ratingallocate\\' . $strategy . '\\strategy';
$strategyclassp = 'mod_ratingallocate\\' . $strategy . '\\strategy';
if (isset($allstrategyoptions) && array_key_exists($strategy, $allstrategyoptions)) {
$strategyclass = new $strategyclassp($allstrategyoptions[$strategy]);
} else {
Expand Down Expand Up @@ -276,7 +276,7 @@ public function validation($data, $files) {
// User has to select one strategy.
$errors['strategy'] = get_string('strategy_not_specified', self::MOD_NAME);
} else {
$strategyclassp = 'ratingallocate\\' . $data['strategy'] . '\\strategy';
$strategyclassp = 'mod_ratingallocate\\' . $data['strategy'] . '\\strategy';
if (array_key_exists($data['strategy'], $data['strategyopt'])) {
$strategyclass = new $strategyclassp($data['strategyopt'][$data['strategy']]);
$settingerrors = $strategyclass->validate_settings();
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;


defined('MOODLE_INTERNAL') || die();
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy01_yes_no.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace ratingallocate\strategy_yesno;
namespace mod_ratingallocate\strategy_yesno;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy02_yes_maybe_no.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

// Namespace is mandatory!
namespace ratingallocate\strategy_yesmaybeno;
namespace mod_ratingallocate\strategy_yesmaybeno;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy03_lickert.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

// Namespace is mandatory!
namespace ratingallocate\strategy_lickert;
namespace mod_ratingallocate\strategy_lickert;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy04_points.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

// Namespace is mandatory!
namespace ratingallocate\strategy_points;
namespace mod_ratingallocate\strategy_points;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy05_order.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Namespace is mandatory!
namespace ratingallocate\strategy_order;
namespace mod_ratingallocate\strategy_order;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion strategy/strategy06_tickyes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

// Namespace is mandatory!
namespace ratingallocate\strategy_tickyes;
namespace mod_ratingallocate\strategy_tickyes;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
Expand Down
2 changes: 1 addition & 1 deletion tests/backup_restore_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* mod_ratingallocate backup restore procedure test
Expand Down
2 changes: 1 addition & 1 deletion tests/cron_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require_once(__DIR__ . '/generator/lib.php');
require_once(__DIR__ . '/../locallib.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* mod_ratingallocate cron tests
Expand Down
2 changes: 1 addition & 1 deletion tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

require_once(dirname(__FILE__) . '/../../locallib.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* mod_ratinallocate generator tests
Expand Down
2 changes: 1 addition & 1 deletion tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require_once(dirname(__FILE__) . '/generator/lib.php');
require_once(dirname(__FILE__) . '/../locallib.php');

use ratingallocate\db as this_db;
use mod_ratingallocate\db as this_db;

/**
* mod_ratingallocate generator tests
Expand Down
Loading
Loading