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

Add missing futures #2

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a4aa358
Rename vimeoactivity/LICENSE.txt to LICENSE.txt
fmido88 Mar 5, 2023
64695ae
Rename vimeoactivity/view.php to view.php
fmido88 Mar 5, 2023
dd31deb
Rename vimeoactivity/version.php to version.php
fmido88 Mar 5, 2023
152e6b4
Rename vimeoactivity/style.css to style.css
fmido88 Mar 5, 2023
4ed0402
Rename vimeoactivity/script.js to script.js
fmido88 Mar 5, 2023
24c2c96
Rename vimeoactivity/ping.php to ping.php
fmido88 Mar 5, 2023
7684b52
Rename vimeoactivity/mod_form.php to mod_form.php
fmido88 Mar 5, 2023
5316bcf
Rename vimeoactivity/locallib.php to locallib.php
fmido88 Mar 5, 2023
8dc3646
Rename vimeoactivity/lib.php to lib.php
fmido88 Mar 5, 2023
65752ce
Rename vimeoactivity/index.php to index.php
fmido88 Mar 5, 2023
df5c3bc
Delete icon.png
fmido88 Mar 5, 2023
1f0d13a
Rename vimeoactivity/pix/icon.svg to pix/icon.svg
fmido88 Mar 5, 2023
c406399
Rename vimeoactivity/lang/en/vimeoactivity.php to lang/en/vimeoactivi…
fmido88 Mar 5, 2023
87745b8
Rename vimeoactivity/db/access.php to db/access.php
fmido88 Mar 5, 2023
1d844d6
Rename vimeoactivity/db/install.php to db/install.php
fmido88 Mar 5, 2023
dc79f30
Rename vimeoactivity/db/upgrade.php to db/upgrade.php
fmido88 Mar 5, 2023
7cf1bfb
Rename vimeoactivity/db/uninstall.php to db/uninstall.php
fmido88 Mar 5, 2023
6845ae5
Rename vimeoactivity/db/install.xml to db/install.xml
fmido88 Mar 5, 2023
b88688d
Add files via upload
fmido88 Mar 5, 2023
162e88b
Add files via upload
fmido88 Mar 5, 2023
e35df26
Rename workflows/ci.yml to .github/workflows/ci.yml
fmido88 Mar 5, 2023
358969b
Update vimeoactivity.php
fmido88 Mar 5, 2023
4c49dbc
Add files via upload
fmido88 Mar 5, 2023
da8c942
Delete backup_vimeoactivity_settingslib.php
fmido88 Mar 5, 2023
5d56ae7
Add files via upload
fmido88 Mar 5, 2023
a192a86
Add files via upload
fmido88 Mar 5, 2023
a81d516
Update vimeoactivity.php
fmido88 Mar 5, 2023
c8be710
Update watchprog.php
fmido88 Mar 5, 2023
c5f299a
Update social_breadth.php
fmido88 Mar 5, 2023
4cff3db
Update cognitive_depth.php
fmido88 Mar 5, 2023
4feda76
Update course_module_instance_list_viewed.php
fmido88 Mar 5, 2023
0812c5b
Update index.php
fmido88 Mar 5, 2023
e32bd49
Update mod_form.php
fmido88 Mar 5, 2023
d6553d7
Update and rename ci.yml to moodle-ci.yml
fmido88 Mar 5, 2023
a3c0a02
Update restore_vimeoactivity_activity_task.class.php
fmido88 Mar 6, 2023
d5c91d1
Add files via upload
fmido88 Mar 6, 2023
20979d8
Add files via upload
fmido88 Mar 6, 2023
90878b9
Add files via upload
fmido88 Mar 6, 2023
9c78401
Update moodle-ci.yml
fmido88 Mar 6, 2023
2e11139
Update moodle-ci.yml
fmido88 Mar 6, 2023
c3a8504
Create release.yml
fmido88 Mar 6, 2023
220a48f
Update view.php
fmido88 Mar 6, 2023
a5fce9f
Update release.yml
fmido88 Mar 6, 2023
13b10c4
Update release.yml
fmido88 Mar 6, 2023
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
111 changes: 111 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Moodle Plugin CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:13
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"

ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3

strategy:
fail-fast: false
matrix:
php: ['7.3', '7.4', '8.0']
moodle-branch: ['master', 'MOODLE_401_STABLE', 'MOODLE_400_STABLE','MOODLE_311_STABLE', 'MOODLE_310_STABLE', 'MOODLE_39_STABLE']
database: [pgsql, mariadb]

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

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
coverage: none

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker --max-warnings 0

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

- name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ always() }}
run: moodle-plugin-ci mustache

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --fail-on-warning

- name: Behat features
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Whenever a new tag starting with "v" is pushed, add the tagged version
# to the Moodle Plugins directory at https://moodle.org/plugins
#
# revision: 2021070201
#
name: Releasing in the Plugins directory

on:
push:
tags:
- V*

workflow_dispatch:
inputs:
tag:
description: 'Tag to be released'
required: true

defaults:
run:
shell: bash

jobs:
release-at-moodle-org:
runs-on: ubuntu-latest
env:
PLUGIN: mod_vimeoactivity
CURL: curl -s
ENDPOINT: https://moodle.org/webservice/rest/server.php
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
FUNCTION: local_plugins_add_version

steps:
- name: Call the service function
id: add-version
run: |
if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then
TAGNAME="${{ github.event.inputs.tag }}"
elif [[ $GITHUB_REF = refs/tags/* ]]; then
TAGNAME="${GITHUB_REF##*/}"
fi
if [[ -z "${TAGNAME}" ]]; then
echo "No tag name has been provided!"
exit 1
fi
ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}"
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
--data-urlencode "wsfunction=${FUNCTION}" \
--data-urlencode "moodlewsrestformat=json" \
--data-urlencode "frankenstyle=${PLUGIN}" \
--data-urlencode "zipurl=${ZIPURL}" \
--data-urlencode "vcssystem=git" \
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
--data-urlencode "vcstag=${TAGNAME}" \
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
--data-urlencode "altdownloadurl=${ZIPURL}")
echo "::set-output name=response::${RESPONSE}"

- name: Evaluate the response
id: evaluate-response
env:
RESPONSE: ${{ steps.add-version.outputs.response }}
run: |
jq <<< ${RESPONSE}
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null
File renamed without changes.
72 changes: 72 additions & 0 deletions backup/moodle2/backup_vimeoactivity_activity_task.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

/**
* The task that provides all the steps to perform a complete backup is defined here.
*
* @package mod_vimeoactivity
* @author Mohammad Farouk
* @copyright 2023 Mohammad Farouk <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @category backup
*/

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

// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}.
// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}.

require_once($CFG->dirroot.'//mod/vimeoactivity/backup/moodle2/backup_vimeoactivity_stepslib.php');

/**
* Provides all the settings and steps to perform a complete backup of mod_vimeoactivity.
*/
class backup_vimeoactivity_activity_task extends backup_activity_task {

/**
* Defines particular settings for the plugin.
*/
protected function define_my_settings() {
return;
}

/**
* Defines particular steps for the backup process.
*/
protected function define_my_steps() {
$this->add_step(new backup_vimeoactivity_activity_structure_step('vimeoactivity_structure', 'vimeoactivity.xml'));
}

/**
* Codes the transformations to perform in the activity in order to get transportable (encoded) links.
*
* @param string $content
* @return string
*/
public static function encode_content_links($content) {
global $CFG;

$base = preg_quote($CFG->wwwroot, '/');

$search = "/(".$base."\/mod\/vimeoactivity\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@vimeoactivityINDEX*$2@$', $content);

$search = "/(".$base."\/mod\/vimeoactivity\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@vimeoactivityVIEWBYID*$2@$', $content);

return $content;
}
}
66 changes: 66 additions & 0 deletions backup/moodle2/backup_vimeoactivity_stepslib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

/**
* Backup steps for mod_vimeoactivity are defined here.
*
* @package mod_vimeoactivity
* @author Mohammad Farouk
* @copyright 2023 Mohammad Farouk <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @category backup
*/

// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}.
// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}.

/**
* Define the complete structure for backup, with file and id annotations.
*/
class backup_vimeoactivity_activity_structure_step extends backup_activity_structure_step {

/**
* Defines the structure of the resulting xml file.
*
* @return backup_nested_element The structure wrapped by the common 'activity' element.
*/
protected function define_structure() {

// Build the tree with these elements with $root as the root of the backup tree.
$vimeoactivity = new backup_nested_element('vimeoactivity', ['id'], [
'course',
'name',
'intro',
'introformat',
'video',
'color',
'autoplay',
'autoloop',
'popupopen',
'popupwidth',
'popupheight',
'completionenable',
'visible',
'completionprogress',
'timecreated',
'timemodified']);

// Define the source tables for the elements.
$vimeoactivity->set_source_table('vimeoactivity', ['id' => backup::VAR_ACTIVITYID]);

return $this->prepare_activity_structure($vimeoactivity);
}
}
Loading