diff --git a/.gitignore b/.gitignore index a26e73e25994deb8ca53008bdf30dd74635b2306..ea19bb97e3b74cec2fe30f0205ce3206824e03ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ .DS_STORE -*.sublime-project -*.sublime-workspace -vendor -classes/log/error_log.txt -composer.phar -.idea/ +/.idea +/*.sublime-project +/*.sublime-workspace +/classes/log/error_log.txt +/composer.phar +/node_modules +/package-lock.json +/vendor diff --git a/.travis.yml b/.travis.yml index d1aa3a456600edab6f682f42709bf75df94e1ea0..614ca656ceafe01585ecb1ad70b5c7f9de458383 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,47 +1,70 @@ language: php - sudo: false cache: - directories: - - $HOME/.composer/cache + directories: + - $HOME/.composer/cache php: - - 5.6 - - 7.0 - - 7.1 + - 5.6 + - 7.0 + - 7.1 env: - global: - - MOODLE_BRANCH=MOODLE_32_STABLE - matrix: - - DB=pgsql -# - DB=mysqli + global: + - MOODLE_BRANCH=MOODLE_32_STABLE + matrix: + - DB=pgsql +# - DB=mysqli before_install: - - composer install --no-interaction - - phpenv config-rm xdebug.ini - - nvm install node - - cd ../.. - - composer selfupdate - - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2 - - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" + - echo $TRAVIS_PHP_VERSION + - composer install --no-interaction + - phpenv config-rm xdebug.ini + - nvm install node + - cd ../.. + - composer selfupdate + - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2 + - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" install: - - moodle-plugin-ci install + - moodle-plugin-ci install script: -# - moodle-plugin-ci phplint -# - moodle-plugin-ci phpcpd -# - moodle-plugin-ci phpmd -# - moodle-plugin-ci codechecker - - moodle-plugin-ci validate - - moodle-plugin-ci savepoints -# - moodle-plugin-ci mustache -# - moodle-plugin-ci grunt - - moodle-plugin-ci phpunit -# - moodle-plugin-ci behat - - # run codechecker without the vendor/ directory - - rm -rf "$(find -type d -name xapi)/vendor" - - moodle-plugin-ci codechecker +# - moodle-plugin-ci phplint +# - moodle-plugin-ci phpcpd +# - moodle-plugin-ci phpmd +# - moodle-plugin-ci codechecker + - moodle-plugin-ci validate + - moodle-plugin-ci savepoints +# - moodle-plugin-ci mustache +# - moodle-plugin-ci grunt + - moodle-plugin-ci phpunit +# - moodle-plugin-ci behat + + # run codechecker without the vendor/ directory + - rm -rf "$(find -type d -name xapi)/vendor" + - moodle-plugin-ci codechecker + - cd $TRAVIS_BUILD_DIR + +after_success: + - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then + git fetch --tags; + npm i semantic-release; + npm i last-release-git; + ./node_modules/.bin/semantic-release pre; + ./node_modules/.bin/semantic-release post; + fi + +before_deploy: + - sh ./scripts/generateVersionFile.sh + - sh ./scripts/generateZipFile.sh + +deploy: + provider: releases + api_key: $GH_TOKEN + file: xapi.zip + skip_cleanup: true + on: + tags: true + php: 7.1 diff --git a/classes/log/store.php b/classes/log/store.php index 039b55cf49110336cae7c3484c690b91045693b8..7d2630cc8fce4d2d9ca93cb99c8b02ef7dc55660 100644 --- a/classes/log/store.php +++ b/classes/log/store.php @@ -65,10 +65,14 @@ class store extends php_obj implements log_writer { * @param log_manager $manager */ public function __construct(log_manager $manager) { + global $CFG; $this->helper_setup($manager); $this->logguests = $this->get_config('logguests', 1); $routes = $this->get_config('routes', ''); $this->routes = $routes === '' ? [] : explode(',', $routes); + if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) { + $this->loggingenabled = true; + } } /** diff --git a/package.json b/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4ab8460c6c5fd65f333c6eaebe1f8c0d1b4ee888 --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "moodle-logstore_xapi", + "repository": { + "type": "git", + "url": "https://github.com/xAPI-vle/moodle-logstore_xapi.git" + }, + "release": { + "getLastRelease": "last-release-git" + } +} diff --git a/scripts/generateVersionFile.sh b/scripts/generateVersionFile.sh new file mode 100644 index 0000000000000000000000000000000000000000..519e8d7b3a8ed62a1ff9137244f5b26098fd55eb --- /dev/null +++ b/scripts/generateVersionFile.sh @@ -0,0 +1,13 @@ +release=$(echo "${TRAVIS_TAG//v}") + +year=$(date +"%Y") + +today=$(date +"%Y-%m-%d") +todaysReleases=$(git log --tags --simplify-by-decoration --pretty="format:%ai %d" | sort -r | grep "$today" | wc -l | tr -d '[:space:]') + +versionPrefix=$(date +"%Y%m%d") +versionSuffix=$(printf %02d $todaysReleases) +version="$versionPrefix$versionSuffix" + +template=$(cat templateVersionFile) +eval "echo \"$template\"" > version.php diff --git a/build.sh b/scripts/generateZipFile.sh similarity index 78% rename from build.sh rename to scripts/generateZipFile.sh index 36e004155e108ab7a59b0075acc9343fb1b91a34..4024a3152a1871b76d7157ea6a61c682c7fdd036 100755 --- a/build.sh +++ b/scripts/generateZipFile.sh @@ -14,13 +14,11 @@ find ../moodle_logstore_build -type f -name '.gitignore' | xargs rm -rf find ../moodle_logstore_build -type f -name 'composer.*' | xargs rm -rf find ../moodle_logstore_build -type f -name 'phpunit.*' | xargs rm -rf find ../moodle_logstore_build -type f -name '*.md' | xargs rm -rf +find ../moodle_logstore_build -type f -name 'node_modules' | xargs rm -rf +find ../moodle_logstore_build -type f -name 'package-lock.json' | xargs rm -rf +find ../moodle_logstore_build -type f -name 'package.json' | xargs rm -rf # Creates the zip file. mv ../moodle_logstore_build xapi zip -r xapi.zip xapi -x "xapi/.git/**/*" rm -rf xapi - -# Updates Github. -git add xapi.zip -git commit -m "Builds zip file." -git push diff --git a/scripts/templateVersionFile b/scripts/templateVersionFile new file mode 100644 index 0000000000000000000000000000000000000000..c99de7516ae9049fbfd2b241bdb4eb0d8c58f4c1 --- /dev/null +++ b/scripts/templateVersionFile @@ -0,0 +1,30 @@ +<?php +// This file is part of Moodle - http://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 <http://www.gnu.org/licenses/>. +/** + * External xapi log store plugin + * + * @package logstore_xapi + * @copyright $year Jerrett Fowler <jfowler@charitylearning.org> + * Ryan Smith <ryan.smith@ht2.co.uk> + * David Pesce <david.pesce@exputo.com> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); +\$plugin->component = 'logstore_xapi'; +\$plugin->version = $version; +\$plugin->release = '$release'; +\$plugin->requires = 2014111000; +\$plugin->maturity = MATURITY_STABLE; diff --git a/version.php b/version.php index 4e17b0c1a2fa5dc189897bf6a905c7f7afeda7ce..13f248d981ad9f1dc846aa9d5e14140d5ed9cb15 100644 --- a/version.php +++ b/version.php @@ -28,6 +28,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'logstore_xapi'; $plugin->version = 2017061100; -$plugin->release = '2.0.0'; +$plugin->release = '0.0.0-development'; $plugin->requires = 2014111000; -$plugin->maturity = MATURITY_STABLE; +$plugin->maturity = MATURITY_ALPHA;