Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 5bf4566

Browse files
committed
🎉 (epitech) added old epitech plugin version
0 parents  commit 5bf4566

39 files changed

+7786
-0
lines changed

.github/workflows/ci.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Moodle plugin CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: 'ubuntu-latest'
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- php: '8.0'
12+
moodle-branch: 'master'
13+
database: 'pgsql'
14+
- php: '8.0'
15+
moodle-branch: 'MOODLE_401_STABLE'
16+
database: 'mariadb'
17+
- php: '7.4'
18+
moodle-branch: 'MOODLE_400_STABLE'
19+
database: 'pgsql'
20+
- php: '7.3'
21+
moodle-branch: 'MOODLE_311_STABLE'
22+
database: 'mariadb'
23+
24+
services:
25+
postgres:
26+
image: postgres:13
27+
env:
28+
POSTGRES_USER: 'postgres'
29+
POSTGRES_HOST_AUTH_METHOD: 'trust'
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 3
35+
ports:
36+
- 5432:5432
37+
38+
mariadb:
39+
image: mariadb:10
40+
env:
41+
MYSQL_USER: 'root'
42+
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
43+
ports:
44+
- 3306:3306
45+
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
46+
47+
steps:
48+
- name: Check out out repository code
49+
uses: actions/checkout@v2
50+
with:
51+
path: plugin
52+
53+
- name: Setup PHP ${{ matrix.php }}
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: ${{ matrix.php }}
57+
extensions: ${{ matrix.extensions }}
58+
ini-values: max_input_vars=5000
59+
coverage: none
60+
61+
- name: Initialise moodle-plugin-ci
62+
run: |
63+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
64+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
65+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
66+
sudo locale-gen en_AU.UTF-8
67+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
68+
69+
- name: Install Moodle
70+
run: |
71+
moodle-plugin-ci add-plugin --branch main moodleou/moodle-editor_ousupsub
72+
moodle-plugin-ci add-plugin --branch main moodleou/moodle-qtype_oumultiresponse
73+
moodle-plugin-ci add-plugin --branch main moodleou/moodle-qtype_pmatch
74+
moodle-plugin-ci add-plugin --branch main moodleou/moodle-qtype_varnumericset
75+
moodle-plugin-ci add-plugin --branch main moodleou/moodle-qtype_varnumeric
76+
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
77+
env:
78+
DB: ${{ matrix.database }}
79+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
80+
81+
- name: PHP Lint
82+
if: ${{ always() }}
83+
run: moodle-plugin-ci phplint
84+
85+
- name: PHP Copy/Paste Detector
86+
continue-on-error: true # This step will show errors but will not fail.
87+
if: ${{ always() }}
88+
run: moodle-plugin-ci phpcpd
89+
90+
- name: PHP Mess Detector
91+
if: ${{ always() }}
92+
run: moodle-plugin-ci phpmd
93+
94+
- name: Moodle Code Checker
95+
if: ${{ always() }}
96+
run: moodle-plugin-ci codechecker --max-warnings 0
97+
98+
- name: Moodle PHPDoc Checker
99+
continue-on-error: true # This step will show errors but will not fail.
100+
if: ${{ always() }}
101+
run: moodle-plugin-ci phpdoc
102+
103+
- name: Validating
104+
if: ${{ always() }}
105+
run: moodle-plugin-ci validate
106+
107+
- name: Check upgrade savepoints
108+
if: ${{ always() }}
109+
run: moodle-plugin-ci savepoints
110+
111+
- name: Mustache Lint
112+
if: ${{ always() }}
113+
run: moodle-plugin-ci mustache
114+
115+
- name: Grunt
116+
if: ${{ matrix.moodle-branch == 'MOODLE_400_STABLE' }}
117+
run: moodle-plugin-ci grunt --max-lint-warnings 0
118+
119+
- name: PHPUnit tests
120+
if: ${{ always() }}
121+
run: moodle-plugin-ci phpunit --fail-on-warning
122+
123+
- name: Behat features
124+
if: ${{ always() }}
125+
run: moodle-plugin-ci behat --profile chrome

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Combined question type [![Build Status](https://travis-ci.com/moodleou/moodle-qtype_combined.svg?branch=master)](https://travis-ci.com/moodleou/moodle-qtype_combined)
2+
3+
A combined question type which allows the embedding of the response fields for
4+
various available sub-questions in the question text.
5+
6+
So the student can enter a numeric or short text answer or choose an answer or
7+
answer(s) from using a select box, check boxes or radio boxes.
8+
9+
10+
## Requirements
11+
12+
You will need to install at least one question type that can be used as a sub-question, you can use any of the latest versions of
13+
these question types as sub-questions:
14+
15+
* Select missing words - which is now part of the standard Moodle release.
16+
* [Pattern match](https://moodle.org/plugins/qtype_pmatch)
17+
* [OU multiple response](https://moodle.org/plugins/qtype_oumultiresponse) - multiple choice with checkboxes.
18+
* Standard Moodle multiple-choice with one right choice - multiple choice with radio buttos.
19+
* [Variable numeric](https://moodle.org/plugins/qtype_varnumericset)
20+
21+
22+
## Acknowledgements
23+
24+
This question type was written by Jamie Pratt (http://jamiep.org/) for the
25+
Open University (http://www.open.ac.uk/). Subsequent enhancement have been
26+
made by OU staff.
27+
28+
29+
## Installation
30+
31+
### Installation Using from the Moodle plugins directory
32+
33+
Works as usual starting here
34+
* https://moodle.org/plugins/qtype_combined
35+
36+
### Installation Using Git
37+
38+
To install using git type these commands in the root of your Moodle install:
39+
40+
git clone https://github.com/moodleou/moodle-qtype_combined.git question/type/combined
41+
echo '/question/type/combined/' >> .git/info/exclude
42+
43+
Then run the moodle update process
44+
Site administration > Notifications
45+
46+
47+
## Making other question types combinable
48+
49+
You can make other question types work with this combined question type by
50+
adding the directory combinable/ to your question type. See examples of the
51+
files which are required in the combinable directory in the question types above.
52+
Or for a built in question type or where you don't want to change the code in
53+
the other question type plug ins directory you can put the required
54+
files in question/type/combined/combinable/{questiontypename}/
55+
56+
See question/type/combined/combinable/README.md for more information.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package qtype_combined
19+
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
22+
23+
24+
defined('MOODLE_INTERNAL') || die();
25+
26+
27+
/**
28+
* Provides the information to backup combined questions.
29+
*
30+
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
31+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32+
*/
33+
class backup_qtype_combined_plugin extends backup_qtype_plugin {
34+
35+
/**
36+
* Returns the qtype information to attach to question element.
37+
*/
38+
protected function define_question_plugin_structure() {
39+
40+
// Define the virtual plugin element with the condition to fulfill.
41+
$plugin = $this->get_plugin_element(null, '../../qtype', 'combined');
42+
43+
// Create one standard named plugin element (the visible container).
44+
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
45+
46+
// Connect the visible container ASAP.
47+
$plugin->add_child($pluginwrapper);
48+
49+
// Now create the qtype own structures.
50+
$combined = new backup_nested_element('combined', array('id'), array(
51+
'correctfeedback', 'correctfeedbackformat',
52+
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
53+
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));
54+
55+
// Now the own qtype tree.
56+
$pluginwrapper->add_child($combined);
57+
58+
// Set source to populate the data.
59+
$combined->set_source_table('qtype_combined', array('questionid' => backup::VAR_PARENTID));
60+
61+
// Don't need to annotate ids nor files.
62+
63+
return $plugin;
64+
}
65+
66+
/**
67+
* Returns one array with filearea => mappingname elements for the qtype.
68+
*
69+
* Used by {@link get_components_and_fileareas} to know about all the qtype
70+
* files to be processed both in backup and restore.
71+
*/
72+
public static function get_qtype_fileareas() {
73+
return array(
74+
'correctfeedback' => 'question_created',
75+
'partiallycorrectfeedback' => 'question_created',
76+
'incorrectfeedback' => 'question_created');
77+
}
78+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* @package qtype_combined
19+
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
20+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21+
*/
22+
23+
24+
defined('MOODLE_INTERNAL') || die();
25+
26+
require_once($CFG->dirroot.'/question/type/combined/combiner/restore.php');
27+
28+
/**
29+
* restore plugin class that provides the necessary information
30+
* needed to restore one combined qtype plugin.
31+
*
32+
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
33+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34+
*/
35+
class restore_qtype_combined_plugin extends restore_qtype_plugin {
36+
37+
/**
38+
* Returns the paths to be handled by the plugin at question level.
39+
*/
40+
protected function define_question_plugin_structure() {
41+
42+
$paths = array();
43+
44+
// Add own qtype stuff.
45+
$elename = 'combined';
46+
// We used get_recommended_name() so this works.
47+
$elepath = $this->get_pathfor('/combined');
48+
$paths[] = new restore_path_element($elename, $elepath);
49+
50+
return $paths; // And we return the interesting paths.
51+
}
52+
53+
/**
54+
* Process the qtype/combined element.
55+
*/
56+
public function process_combined($data) {
57+
global $DB;
58+
59+
$data = (object)$data;
60+
$oldid = $data->id;
61+
62+
// Detect if the question is created or mapped.
63+
$oldquestionid = $this->get_old_parentid('question');
64+
$newquestionid = $this->get_new_parentid('question');
65+
$questioncreated = (bool) $this->get_mappingid('question_created', $oldquestionid);
66+
67+
// If the question has been created by restore, we need to create its
68+
// qtype_combined too.
69+
if ($questioncreated) {
70+
// Adjust some columns.
71+
$data->questionid = $newquestionid;
72+
// Insert record.
73+
$newitemid = $DB->insert_record('qtype_combined', $data);
74+
// Create mapping (needed for decoding links).
75+
$this->set_mapping('qtype_combined', $oldid, $newitemid);
76+
}
77+
}
78+
79+
/**
80+
* Return the contents of this qtype to be processed by the links decoder.
81+
*/
82+
public static function define_decode_contents() {
83+
84+
$contents = array();
85+
86+
$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
87+
$contents[] = new restore_decode_content('qtype_combined', $fields, 'qtype_combined');
88+
89+
return $contents;
90+
}
91+
92+
public function recode_response($questionid, $sequencenumber, array $response) {
93+
$combiner = new qtype_combined_combiner_for_restore();
94+
95+
$combiner->load_subq_data_from_db($questionid);
96+
97+
$recodedresponses = array();
98+
$subqresponses = $combiner->get_subq_responses($response);
99+
foreach ($subqresponses as $subqno => $subqresponse) {
100+
$subqtype = $combiner->get_subq_type($subqno);
101+
$subqid = $combiner->get_subq_id($subqno);
102+
$recodedresponses[$subqno] =
103+
$this->step->questions_recode_response_data($subqtype, $subqid, $sequencenumber, $subqresponse);
104+
}
105+
$subqresponsesrecoded = $combiner->aggregate_response_arrays($recodedresponses);
106+
107+
// Remove responses recoded by sub-questions to leave just
108+
// parts of response array for the main question e.g. '-finish' => 1.
109+
// I don't want to assume that the response recoding will not change the keys,
110+
// just in case.
111+
$subqresponseswithprefixes = $combiner->aggregate_response_arrays($subqresponses);
112+
foreach (array_keys($subqresponseswithprefixes) as $recodedkey) {
113+
unset($response[$recodedkey]);
114+
}
115+
116+
return $subqresponsesrecoded + $response;
117+
}
118+
}

0 commit comments

Comments
 (0)