Skip to content

Commit

Permalink
Merge pull request #264 from learnweb/fix/codechecker_cleanup
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
Laur0r committed Jun 20, 2023
2 parents 6248a3b + 9977182 commit e7a9d36
Show file tree
Hide file tree
Showing 58 changed files with 518 additions and 543 deletions.
3 changes: 2 additions & 1 deletion backup/moodle2/backup_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ protected function define_structure() {
'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'),
$ratingallocateallocation->set_source_table(
get_tablename_for_tableClass('ratingallocate\db\ratingallocate_allocations'),
array(
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID),
Expand Down
3 changes: 0 additions & 3 deletions backup/moodle2/restore_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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

use ratingallocate\db as this_db;

/**
Expand Down Expand Up @@ -163,6 +161,5 @@ protected function process_ratingallocate_groupings($data) {
protected function after_execute() {
// Add ratingallocate related files.
$this->add_related_files('mod_' . RATINGALLOCATE_MOD_NAME, 'intro', null);
// $this->add_related_files('mod_' . RATINGALLOCATE_MOD_NAME, ratingallocate_FILEAREA_NAME, RATINGALLOCATE_MOD_NAME);
}
}
18 changes: 0 additions & 18 deletions backup/moodle2/restore_ratingallocate_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ protected function define_my_steps() {
public static function define_decode_contents() {
$contents = array();

// $contents[] = new restore_decode_content('ratingallocate', array('intro'), 'ratingallocate');

return $contents;
}

Expand All @@ -63,9 +61,6 @@ public static function define_decode_contents() {
public static function define_decode_rules() {
$rules = array();

// $rules[] = new restore_decode_rule('RATINGALLOCATEVIEWBYID', '/mod/ratingallocate/view.php?id=$1', 'course_module');
// $rules[] = new restore_decode_rule('RATINGALLOCATEINDEX', '/mod/ratingallocate/index.php?id=$1', 'course');

return $rules;
}

Expand All @@ -79,13 +74,6 @@ public static function define_decode_rules() {
public static function define_restore_log_rules() {
$rules = array();

// $rules[] = new restore_log_rule('raitingallocate', 'add', 'view.php?id={course_module}', '{raitingallocate}');
// $rules[] = new restore_log_rule('raitingallocate', 'update', 'view.php?id={course_module}', '{raitingallocate}');
// $rules[] = new restore_log_rule('raitingallocate', 'view', 'view.php?id={course_module}', '{raitingallocate}');
// $rules[] = new restore_log_rule('raitingallocate', 'choose', 'view.php?id={course_module}', '{raitingallocate}');
// $rules[] = new restore_log_rule('raitingallocate', 'choose again', 'view.php?id={course_module}', '{raitingallocate}');
// $rules[] = new restore_log_rule('raitingallocate', 'report', 'report.php?id={course_module}', '{raitingallocate}');

return $rules;
}

Expand All @@ -102,12 +90,6 @@ public static function define_restore_log_rules() {
*/
public static function define_restore_log_rules_for_course() {
$rules = array();

// Fix old wrong uses (missing extension)
// $rules[] = new restore_log_rule('raitingallocate', 'view all', 'index?id={course}', null,
// null, null, 'index.php?id={course}');
// $rules[] = new restore_log_rule('raitingallocate', 'view all', 'index.php?id={course}', null);

return $rules;
}
}
8 changes: 4 additions & 4 deletions classes/algorithm_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class algorithm_status {
const FAILURE = -1; // Algorithm did not finish correctly
const NOTSTARTED = 0; // Default status for new instances
const RUNNING = 1; // Algorithm is currently running
const FINISHED = 2; // Algorithm finished correctly
const FAILURE = -1; // Algorithm did not finish correctly.
const NOTSTARTED = 0; // Default status for new instances.
const RUNNING = 1; // Algorithm is currently running.
const FINISHED = 2; // Algorithm finished correctly.
}
2 changes: 1 addition & 1 deletion classes/event/all_ratings_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate rating_deleted event class.
*
Expand Down
1 change: 0 additions & 1 deletion classes/event/allocation_published.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate allocation_published event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/allocation_statistics_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate allocation_statistics_viewed event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/allocation_table_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate allocation_table_viewed event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/distribution_triggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate distribution_triggered event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/index_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate index_viewed event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/manual_allocation_saved.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate manual_allocation_saved event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/rating_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate rating_deleted event class.
Expand Down
6 changes: 3 additions & 3 deletions classes/event/rating_saved.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate rating_saved event class.
Expand All @@ -41,8 +40,9 @@
class rating_saved extends \core\event\base {

public static function create_simple($modulecontext, $ratingallocateid, $rating) {
// the values of other need to be encoded since the base checks for equality of a decoded encoded other instance with the original.
// this is not given for nested arrays
// The values of other need to be encoded since the base checks for equality
// of a decoded encoded other instance with the original
// this is not given for nested arrays.
$ratingjsonvalid = json_decode(json_encode($rating), true);
return self::create(array('context' => $modulecontext, 'objectid' => $ratingallocateid,
'other' => array('ratings' => $ratingjsonvalid)));
Expand Down
1 change: 0 additions & 1 deletion classes/event/rating_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate rating_viewed event class.
Expand Down
1 change: 0 additions & 1 deletion classes/event/ratingallocate_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();

/**
* The mod_ratingallocate ratingallocate_viewed event class.
Expand Down
2 changes: 1 addition & 1 deletion classes/event/ratings_and_allocation_table_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

namespace mod_ratingallocate\event;
defined('MOODLE_INTERNAL') || die();


/**
* The mod_ratingallocate ratings_and_allocation_table_viewed event class.
Expand Down
5 changes: 2 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
use core_privacy\local\request\userlist;
use core_privacy\local\request\approved_userlist;

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

/**
* Implementation of the privacy subsystem plugin provider for the ratingallocate activity module.
*
Expand Down Expand Up @@ -288,7 +286,8 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
// Delete Choices.
$DB->delete_records_select(
'ratingallocate_ratings',
"choiceid IN (SELECT id FROM {ratingallocate_choices} WHERE ratingallocateid = :instanceid) AND userid = :userid",
"choiceid IN (SELECT id FROM {ratingallocate_choices}
WHERE ratingallocateid = :instanceid) AND userid = :userid",
[
'instanceid' => $instanceid,
'userid' => $userid
Expand Down
2 changes: 0 additions & 2 deletions classes/ratingallocate_observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
use coding_exception;
use dml_exception;

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

class ratingallocate_observer {

/**
Expand Down
4 changes: 3 additions & 1 deletion classes/ratings_and_allocations_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public function __construct(\mod_ratingallocate_renderer $renderer, $titles, $ra
}, $allgroupsofchoices);
if ($downloadable && has_capability('mod/ratingallocate:export_ratings', $ratingallocate->get_context())) {
$download = optional_param('download', '', PARAM_ALPHA);
$this->is_downloading($download, $ratingallocate->ratingallocate->name . '-ratings_and_allocations', 'ratings_and_allocations');
$this->is_downloading($download,
$ratingallocate->ratingallocate->name . '-ratings_and_allocations',
'ratings_and_allocations');
}

$this->shownames = true;
Expand Down
4 changes: 2 additions & 2 deletions classes/task/cron_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public function execute() {
$course = null;
foreach ($records as $record) {
$cm = get_coursemodule_from_instance(this_db\ratingallocate::TABLE, $record->{this_db\ratingallocate::ID});
// Fetch the data for the course, if is has changed
// Fetch the data for the course, if is has changed.
if (!$course || $course->id != $record->{this_db\ratingallocate::COURSE}) {
$course = $DB->get_record('course', array('id' => $record->{this_db\ratingallocate::COURSE}), '*', MUST_EXIST);
}
// Create ratingallocate instance from record
// Create ratingallocate instance from record.
$ratingallocate = new \ratingallocate($record, $course, $cm, \context_module::instance($cm->id));
$currenttime = time();
$timetoterminate = $CFG->ratingallocate_algorithm_timeout + $ratingallocate->ratingallocate->algorithmstarttime;
Expand Down
8 changes: 4 additions & 4 deletions classes/task/send_distribution_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
use 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
// command it to notify users
// Gets executed by the task runner. Will lookup the ratingallocation object and
// command it to notify users.
public function execute() {
global $CFG, $DB;

require_once($CFG->dirroot . '/mod/ratingallocate/locallib.php');

$site = get_site();
// parse customdata passed
// Parse customdata passed.
$customdata = $this->get_custom_data();
$ratingallocateid = $customdata->ratingallocateid;

// get instance of ratingallocate
// Get instance of ratingallocate.
$ratingallocate =
$DB->get_record(this_db\ratingallocate::TABLE, array(this_db\ratingallocate::ID => $ratingallocateid), '*',
MUST_EXIST);
Expand Down
2 changes: 1 addition & 1 deletion db/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();

$messageproviders = array(
// Notify student about published allocation
// Notify student about published allocation.
'allocation' => array(
'capability' => 'mod/ratingallocate:give_rating'
)
Expand Down
4 changes: 1 addition & 3 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

/**
* Execute newmodule upgrade from the given old version
*
Expand All @@ -39,7 +37,7 @@
*/
function xmldb_ratingallocate_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.

if ($oldversion < 2014103000) {
try {
Expand Down
4 changes: 2 additions & 2 deletions form_manual_allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function definition_after_data() {

$ratingdata = $this->ratingallocate->get_ratings_for_rateable_choices();
$differentratings = array();
// Add actual rating data to userdata
// Add actual rating data to userdata.
foreach ($ratingdata as $rating) {
if ($rating->rating != null) {
$differentratings[$rating->rating] = $rating->rating;
Expand Down Expand Up @@ -155,7 +155,7 @@ public function add_special_action_buttons() {

$mform = $this->_form;

// elements in a row need a group
// Elements in a row need a group.
$buttonarray = array();

$buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
Expand Down
10 changes: 6 additions & 4 deletions grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
* @copyright based on code by M Schulze copyright (C) 2014 M Schulze
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(__DIR__ . "/../../config.php");
require_login();

$id = required_param('id', PARAM_INT); // Course module ID
$id = required_param('id', PARAM_INT); // Course module ID.
$itemnumber = optional_param('itemnumber', 0,
PARAM_INT); // Item number, may be != 0 for activities that allow more than one grade per user
$userid = optional_param('userid', 0, PARAM_INT); // Graded user ID (optional)
PARAM_INT); // Item number, may be != 0 for activities that allow more than one grade per user.
$userid = optional_param('userid', 0, PARAM_INT); // Graded user ID (optional).

// in the simplest case just redirect to the view page
// In the simplest case just redirect to the view page.
redirect('view.php?id=' . $id);
14 changes: 7 additions & 7 deletions lang/en/ratingallocate.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@
$string['strategy_yesmaybeno_rating_maybe'] = 'Neutral';
$string['strategy_yesmaybeno_rating_yes'] = 'Accept';

// Specific to Strategy03, Likert
// Specific to Strategy03, Likert.
$string['strategy_lickert_name'] = 'Likert Scale';
$string['strategy_lickert_setting_maxno'] = 'Maximum number of choices the user can rate with 0';
$string['strategy_lickert_max_no'] = 'You may only assign 0 points to at most {$a} choice(s).';
$string['strategy_lickert_setting_maxlickert'] = 'Highest number on the likert scale (3, 5 or 7 are common values)';
$string['strategy_lickert_rating_biggestwish'] = '{$a} - Highly appreciated';
$string['strategy_lickert_rating_exclude'] = '{$a} - Exclude';

// Specific to Strategy04, Points
// Specific to Strategy04, Points.
$string['strategy_points_name'] = 'Give Points';
$string['strategy_points_setting_maxzero'] = 'Maximum number of choices to which the user can give 0 points';
$string['strategy_points_explain_distribute_points'] =
Expand All @@ -357,7 +357,7 @@
$string['strategy_points_max_count_zero'] = 'You may give 0 points to at most {$a} choice(s).';
$string['strategy_points_illegal_entry'] = 'The points that you assign to a choice must be between 0 and {$a}.';

// Specific to Strategy05, Order
// Specific to Strategy05, Order.
$string['strategy_order_name'] = 'Rank Choices';
$string['strategy_order_no_choice'] = '{$a}. Choice';
$string['strategy_order_use_only_once'] = 'Choices cannot be selected twice and must be unique.';
Expand All @@ -368,23 +368,23 @@
$string['strategy_order_header_description'] = 'Available Choices';
$string['strategy_order_choice_none'] = 'Please select a choice';

// Specific to Strategy06, tickyes
// Specific to Strategy06, tickyes.
$string['strategy_tickyes_name'] = 'Tick Accept';
$string['strategy_tickyes_accept'] = 'Accept';
$string['strategy_tickyes_not_accept'] = '-';
$string['strategy_tickyes_setting_mintickyes'] = 'Minimum number of choices to accept';
$string['strategy_tickyes_error_mintickyes'] = 'You have to tick at least {$a} boxes.';
$string['strategy_tickyes_explain_mintickyes'] = 'You have to tick a minimum of {$a} boxes.';

// As message provider, for the notification after allocation
// As message provider, for the notification after allocation.
$string['messageprovider:notifyalloc'] = 'Notification of option allocation';
$string['allocation_notification_message_subject'] = 'Allocation published for {$a}';
$string['allocation_notification_message'] =
'Concerning the "{$a->ratingallocate}", you have been assigned to the choice "{$a->choice} ({$a->explanation})".';
$string['no_allocation_notification_message'] = 'Concerning the "{$a->ratingallocate}", you could not be assigned to any choice.';
$string['messageprovider:allocation'] = 'Notification about published allocation';

// Logging
// Logging.
$string['log_rating_saved'] = 'User rating saved';
$string['log_rating_saved_description'] =
'The user with id "{$a->userid}" saved his rating for the Fair Allocation with id "{$a->ratingallocateid}".';
Expand Down Expand Up @@ -433,7 +433,7 @@

$string['no_id_or_m_error'] = 'You must specify a course_module ID or an instance ID';

// Language strings for Privacy API
// Language strings for Privacy API.
$string['privacy:metadata:ratingallocate_ratings'] = 'Information about the user\'s ratings for given choices.';
$string['privacy:metadata:ratingallocate_ratings:choiceid'] = 'The ID of the choice the user has rated';
$string['privacy:metadata:ratingallocate_ratings:userid'] = 'The ID of the user rating this choice';
Expand Down
Loading

0 comments on commit e7a9d36

Please sign in to comment.