Skip to content

Commit

Permalink
Merge branch 'master' into feature/completiontracking
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe authored Jul 4, 2024
2 parents 002625d + 6828664 commit 8f3e6d1
Show file tree
Hide file tree
Showing 78 changed files with 1,978 additions and 995 deletions.
87 changes: 32 additions & 55 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:

strategy:
matrix:
php: ['8.2']
moodle-branch: ['MOODLE_403_STABLE']
php: ['8.3']
moodle-branch: ['MOODLE_404_STABLE']
database: ['pgsql']

steps:
- name: Start PostgreSQL
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -28,29 +28,9 @@ jobs:
ini-values: max_input_vars=5000
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Composer cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand All @@ -67,11 +47,6 @@ jobs:
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
if: ${{ always() }}
run: moodle-plugin-ci phpcpd
continue-on-error: true

- name: PHP Mess Detector
if: ${{ always() }}
run: moodle-plugin-ci phpmd
Expand Down Expand Up @@ -108,19 +83,27 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
php: ['8.0', '8.1', '8.2', '8.3']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE']
database: ['mariadb', 'pgsql']
exclude:
- php: '8.0'
moodle-branch: 'MOODLE_404_STABLE'
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_401_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_402_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_403_STABLE'
include:
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'

steps:
- name: Start MariaDB
Expand All @@ -132,7 +115,7 @@ jobs:
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -143,24 +126,6 @@ jobs:
ini-values: max_input_vars=5000
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Composer cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
Expand All @@ -183,3 +148,15 @@ jobs:
- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome --auto-rerun 0

# This step allows to upload Behat faildump (screenshots) as workflow artifact,
# so it can be downloaded and inspected. You do not need this step if you
# are not running Behat test. Artifact will be retained for 7 days.
- name: Upload Behat Faildump
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ join(matrix.*, ', ') }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
if-no-files-found: ignore
13 changes: 7 additions & 6 deletions backup/moodle2/backup_ratingallocate_activity_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ protected function define_structure() {

// Define sources.
$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');
[this_db\ratingallocate::ID => backup::VAR_ACTIVITYID], this_db\ratingallocate_choices::ID . ' ASC');
$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::RATINGALLOCATEID => backup::VAR_PARENTID],
this_db\ratingallocate_choices::ID . ' ASC');
$groupchoice->set_source_table(get_tablename_for_tableClass($groupchoiceclass), ['choiceid' => backup::VAR_PARENTID]);
$ratingallocatechoicegroup->set_source_table(
Expand All @@ -106,13 +106,14 @@ protected function define_structure() {
if ($userinfo) {
$ratingallocaterating->set_source_table(get_tablename_for_tableClass(
'mod_ratingallocate\db\ratingallocate_ratings'),
array(this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID),
[this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID],
this_db\ratingallocate_ratings::ID . ' ASC');
$ratingallocateallocation->set_source_table(
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),
[
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID,
],
this_db\ratingallocate_allocations::ID . ' ASC'
);
}
Expand Down
31 changes: 27 additions & 4 deletions backup/moodle2/backup_restore_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,55 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package moodlecore
* Backup restore helper.
*
* @package mod_ratingallocate
* @subpackage backup-moodle2
* @copyright 2014 C. Usener
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Get fields for tableclass
*
* @param $class
* @return array
* @throws ReflectionException
*/
function get_fields_for_tableclass($class) {
$class = new ReflectionClass($class);
$constants = $class->getConstants();
$keystoremove = array('ID', 'TABLE');
$keystoremove = ['ID', 'TABLE'];
foreach ($constants as $key => $value) {
if (count(array_intersect(array($key), $keystoremove)) > 0) {
if (count(array_intersect([$key], $keystoremove)) > 0) {
unset($constants[$key]);
}
}
return array_values($constants);
}

/**
* Get tablename for tableclass.
*
* @param $class
* @return mixed
* @throws ReflectionException
*/
function get_tablename_for_tableclass($class) {
$class = new ReflectionClass($class);
$constants = $class->getConstants();
return $constants['TABLE'];
}

/**
* Get id for tableclass.
*
* @param $class
* @return array
* @throws ReflectionException
*/
function get_id_for_tableclass($class) {
$class = new ReflectionClass($class);
$constants = $class->getConstants();
return array($constants['ID']);
return [$constants['ID']];
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
*
* @package moodlecore
* @package mod_ratingallocate
* @subpackage backup-moodle2
* @copyright 2014 C. Usener
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down
15 changes: 11 additions & 4 deletions backup/moodle2/restore_ratingallocate_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
*/
require_once($CFG->dirroot . '/mod/ratingallocate/backup/moodle2/restore_ratingallocate_activity_stepslib.php');

/**
* Restore ratingallocate activity class
*
* @package mod_ratingallocate
* @copyright 214 C. Usener
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_ratingallocate_activity_task extends restore_activity_task {

/**
Expand All @@ -49,7 +56,7 @@ protected function define_my_steps() {
* processed by the link decoder
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

return $contents;
}
Expand All @@ -59,7 +66,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

return $rules;
}
Expand All @@ -72,7 +79,7 @@ public static function define_decode_rules() {
* of {@link restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

return $rules;
}
Expand All @@ -89,7 +96,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];
return $rules;
}
}
20 changes: 16 additions & 4 deletions classes/algorithm_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@
* @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.
/**
* Algorithm did not finish correctly.
*/
const FAILURE = -1;
/**
* Default status for new instances.
*/
const NOTSTARTED = 0;
/**
* Algorithm is currently running.
*/
const RUNNING = 1;
/**
* Algorithm finished correctly.
*/
const FINISHED = 2;
}
13 changes: 9 additions & 4 deletions classes/allocations_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
require_once($CFG->libdir . '/tablelib.php');
require_once($CFG->dirroot . '/user/lib.php');

/**
* Allocations table.
*
* @package mod_ratingallocate
*/
class allocations_table extends \table_sql {

/**
Expand All @@ -44,7 +49,7 @@ public function __construct($ratingallocate) {
parent::__construct('mod_ratingallocate_allocation_table');
global $PAGE;
$url = $PAGE->url;
$url->params(array("action" => ACTION_SHOW_ALLOCATION_TABLE));
$url->params(["action" => ACTION_SHOW_ALLOCATION_TABLE]);
$PAGE->set_url($url);
$this->ratingallocate = $ratingallocate;
if (has_capability('mod/ratingallocate:export_ratings', $ratingallocate->get_context())) {
Expand Down Expand Up @@ -203,10 +208,10 @@ private function get_user_link($user) {
$name = fullname($user);

if ($COURSE->id == SITEID) {
$profileurl = new \moodle_url('/user/profile.php', array('id' => $user->id));
$profileurl = new \moodle_url('/user/profile.php', ['id' => $user->id]);
} else {
$profileurl = new \moodle_url('/user/view.php',
array('id' => $user->id, 'course' => $COURSE->id));
['id' => $user->id, 'course' => $COURSE->id]);
}
return \html_writer::link($profileurl, $name);
}
Expand All @@ -229,7 +234,7 @@ public function init_sql() {

$where = "c.ratingallocateid = :ratingallocateid";

$params = array();
$params = [];
$params['ratingallocateid'] = $this->ratingallocate->ratingallocate->id;

$this->set_sql($fields, $from, $where, $params);
Expand Down
Loading

0 comments on commit 8f3e6d1

Please sign in to comment.