Skip to content

Commit

Permalink
version update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Mar 12, 2024
1 parent 70aaa42 commit ea4dca1
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 68 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
fail-fast: false
matrix:
php: ['8.1']
moodle-branch: ['MOODLE_402_STABLE']
moodle-branch: ['MOODLE_402_STABLE', 'MOODLE_403_STABLE']
database: ['mariadb', 'pgsql']
include:
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
moodle-branch: 'main'
database: 'pgsql'

name: ${{ matrix.moodle-branch }} php ${{ matrix.php }} ${{ matrix.database }}
Expand All @@ -58,14 +58,6 @@ jobs:
repository: catalyst/moodle-local_aws
path: extras/local_aws

- name: npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: node-${{ matrix.php }}-${{ matrix.moodle-branch }}-${{ matrix.database }}-cache
restore-keys: |
node-${{ matrix.php }}-${{ matrix.moodle-branch }}-${{ matrix.database }}-cache
- name: composer
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci
Expand All @@ -87,10 +79,6 @@ jobs:
if: ${{ !cancelled() }}
run: moodle-plugin-ci --ansi phplint

- name: phpcpd
if: ${{ !cancelled() }}
run: moodle-plugin-ci --ansi phpcpd

- name: phpmd
if: ${{ !cancelled() }}
run: moodle-plugin-ci --ansi phpmd
Expand Down
48 changes: 23 additions & 25 deletions classes/engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function translate_section($sectionid): string {
* @return string
*/
public function translate_module($moduleid): string {
global $CFG, $DB;
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
$modinfo = get_fast_modinfo($this->course->id, -1);
$cm = $modinfo->cms[$moduleid];
Expand Down Expand Up @@ -218,31 +218,29 @@ public function translate_module($moduleid): string {
case 'quiz':
$s .= $this->add_records('quiz_sections', 'quizid', $cm->instance, ['heading']);
$s .= $this->add_records('quiz_feedback', 'quizid', $cm->instance);
$slots = $CFG->version < 2022020300 ? $DB->get_records('quiz_slots', ['quizid' => $cm->instance]) :
\mod_quiz\question\bank\qbank_helper::get_question_structure($cm->instance, $context);
foreach ($slots as $slot) {
$sid = $slot->questionid;
if (!is_integer($sid)) {
continue;
$questions = \mod_quiz\question\bank\qbank_helper::get_question_structure($cm->instance, $context);
foreach ($questions as $question) {
if ($question->questionid) {
$sid = $question->questionid;
$s .= $this->add_records('question', 'id', $sid);
$s .= $this->add_records('question_answers', 'question', $sid);
$s .= $this->add_records('question_hints', 'questionid', $sid);
$s .= $this->add_records('question_order', 'question', $sid);
$s .= $this->add_records('question_order_sub', 'question', $sid);
$q = \question_bank::load_question($sid);
$qt = get_class($q->qtype);
// Brute force collect feedback.
$s .= $this->add_records($qt, 'questionid', $sid);
$s .= $this->add_records($qt . '_options' , 'questionid', $sid);
$s .= $this->add_records($qt . '_answers' , 'questionid', $sid);
$s .= $this->add_records($qt . '_subquestions' , 'questionid', $sid);
$qt = str_ireplace('qtype', 'question', $qt);
$s .= $this->add_records($qt, 'questionid', $sid);
$s .= $this->add_records($qt, 'question', $sid);
$s .= $this->add_records($qt . '_options' , 'questionid', $sid);
$s .= $this->add_records($qt . '_answers' , 'questionid', $sid);
$s .= $this->add_records($qt . '_subquestions' , 'questionid', $sid);
}
$s .= $this->add_records('question', 'id', $sid);
$s .= $this->add_records('question_answers', 'question', $sid);
$s .= $this->add_records('question_hints', 'questionid', $sid);
$s .= $this->add_records('question_order', 'question', $sid);
$s .= $this->add_records('question_order_sub', 'question', $sid);
$q = \question_bank::load_question($sid);
$qt = get_class($q->qtype);
// Brute force collect feedback.
$s .= $this->add_records($qt, 'questionid', $sid);
$s .= $this->add_records($qt . '_options' , 'questionid', $sid);
$s .= $this->add_records($qt . '_answers' , 'questionid', $sid);
$s .= $this->add_records($qt . '_subquestions' , 'questionid', $sid);
$qt = str_ireplace('qtype', 'question', $qt);
$s .= $this->add_records($qt, 'questionid', $sid);
$s .= $this->add_records($qt, 'question', $sid);
$s .= $this->add_records($qt . '_options' , 'questionid', $sid);
$s .= $this->add_records($qt . '_answers' , 'questionid', $sid);
$s .= $this->add_records($qt . '_subquestions' , 'questionid', $sid);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/aws/tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class other_test extends \advanced_testcase {
final class other_test extends \advanced_testcase {

/** @var \stdClass course */
private $course;
Expand Down
2 changes: 1 addition & 1 deletion engine/aws/tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class privacy_test extends provider_testcase {
final class privacy_test extends provider_testcase {

/**
* Test returning metadata.
Expand Down
8 changes: 4 additions & 4 deletions engine/aws/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
defined('MOODLE_INTERNAL') || die;

$plugin->component = 'translateengine_aws';
$plugin->requires = 2022112800;
$plugin->supported = [401, 403];
$plugin->requires = 2023042400;
$plugin->version = 2024031000;
$plugin->supported = [402, 403];
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v4.0.2';
$plugin->version = 2024010200;
$plugin->release = 'v4.2.1';
$plugin->dependencies = ['tool_translate' => ANY_VERSION];
2 changes: 1 addition & 1 deletion engine/deepl/tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class other_test extends \advanced_testcase {
final class other_test extends \advanced_testcase {

/** @var \stdClass course */
private $course;
Expand Down
2 changes: 1 addition & 1 deletion engine/deepl/tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class privacy_test extends provider_testcase {
final class privacy_test extends provider_testcase {

/**
* Test returning metadata.
Expand Down
8 changes: 4 additions & 4 deletions engine/deepl/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

$plugin->component = 'translateengine_deepl';
$plugin->dependencies = ['tool_translate' => ANY_VERSION];
$plugin->requires = 2022112800;
$plugin->supported = [401, 403];
$plugin->requires = 2023042400;
$plugin->version = 2024031000;
$plugin->supported = [402, 403];
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v4.0.2';
$plugin->version = 2024010200;
$plugin->release = 'v4.2.1';
2 changes: 1 addition & 1 deletion engine/google/tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class other_test extends \advanced_testcase {
final class other_test extends \advanced_testcase {

/** @var \stdClass course */
private $course;
Expand Down
2 changes: 1 addition & 1 deletion engine/google/tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class privacy_test extends provider_testcase {
final class privacy_test extends provider_testcase {

/**
* Test returning metadata.
Expand Down
8 changes: 4 additions & 4 deletions engine/google/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

$plugin->component = 'translateengine_google';
$plugin->dependencies = ['tool_translate' => ANY_VERSION];
$plugin->requires = 2022112800;
$plugin->supported = [401, 403];
$plugin->requires = 2023042400;
$plugin->version = 2024031000;
$plugin->supported = [402, 403];
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v4.0.2';
$plugin->version = 2024010200;
$plugin->release = 'v4.2.1';
1 change: 1 addition & 0 deletions lang/en/tool_translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
$string['translate'] = 'Translate';
$string['translate:translate'] = 'Translate a course';
$string['words'] = 'Words';
$string['subplugintype_translateengine'] = 'Translate engine';
2 changes: 1 addition & 1 deletion tests/event/event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class event_test extends advanced_testcase {
final class event_test extends advanced_testcase {

/**
* Test the tool viewed event.
Expand Down
2 changes: 1 addition & 1 deletion tests/include_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class include_test extends \advanced_testcase {
final class include_test extends \advanced_testcase {

/**
* Test the adminmanageplugins.
Expand Down
2 changes: 1 addition & 1 deletion tests/library_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class library_test extends advanced_testcase {
final class library_test extends advanced_testcase {

/**
* Test the library.
Expand Down
4 changes: 2 additions & 2 deletions tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class other_test extends advanced_testcase {
final class other_test extends advanced_testcase {

/** @var \stdClass course */
private $course;
Expand Down Expand Up @@ -190,7 +190,7 @@ public function test_engine(): void {
$engine->sourcelang = 'en';
$engine->targetlang = 'fr';
$this->assertStringContainsString('Course with id', $engine->translate_other());
$this->assertEquals('Topic with id 1 translated', $engine->translate_section(1));
$this->assertStringContainsString('with id 1 translated', $engine->translate_section(1));
$this->assertStringContainsString('Module with id', $engine->translate_module($book->cmid));
$this->assertStringContainsString('Module with id', $engine->translate_module($lesson->cmid));
$this->assertStringContainsString('Module with id', $engine->translate_module($page->cmid));
Expand Down
3 changes: 2 additions & 1 deletion tests/output/table_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \tool_translate\translation_table
*/
class table_test extends advanced_testcase {
final class table_test extends advanced_testcase {

/**
* Setup testcase.
Expand Down Expand Up @@ -73,6 +73,7 @@ public function test_table(): void {
$glossarygenerator->create_content($glossary, ['concept' => 'Custom concept']);
$gen->create_module('choice', ['course' => $course->id]);
$gen->create_module('forum', ['course' => $course->id]);
$gen->create_module('resource', ['course' => $course->id]);

ob_start();
$table = new translation_table($course);
Expand Down
2 changes: 1 addition & 1 deletion tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Renaat Debleu <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class privacy_test extends provider_testcase {
final class privacy_test extends provider_testcase {

/**
* Test returning metadata.
Expand Down
8 changes: 4 additions & 4 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
defined('MOODLE_INTERNAL') || die;

$plugin->component = 'tool_translate';
$plugin->requires = 2022112800;
$plugin->supported = [401, 403];
$plugin->requires = 2023042400;
$plugin->supported = [402, 403];
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v4.0.2';
$plugin->version = 2024010200;
$plugin->release = 'v4.2.1';
$plugin->version = 2024031000;
$plugin->dependencies = ['local_aws' => ANY_VERSION];

0 comments on commit ea4dca1

Please sign in to comment.