diff --git a/README.md b/README.md index b5578962dcc..18811ed3d79 100755 --- a/README.md +++ b/README.md @@ -23,12 +23,25 @@ We assume you already have: - yarn +4.x - https://yarnpkg.com/getting-started/install - Node >= v18+ (lts) - https://github.com/nodesource/distributions/blob/master/README.md - Configuring a virtualhost in a domain, not in a sub folder inside a domain. -- A working LAMP/WAMP server with PHP 8.1+ +- A working LAMP/WAMP server with PHP 8.2+ ### Software stack install (Ubuntu) -You will need PHP8+ and NodeJS v18+ to run Chamilo 2. -On a fresh Ubuntu 22.04, you can prepare your server by issuing an apt command like the following with sudo (or as root, but not recommended for security reasons): +You will need PHP8.2+ and NodeJS v18+ to run Chamilo 2. + +On Ubuntu 24.04+, the following should take care of most dependencies. + +~~~~ +sudo apt update +sudo apt -y upgrade +sudo apt install apache2 libapache2-mod-php mariadb-client mariadb-server redis php-pear php-{apcu,bcmath,cli,curl,dev,gd,intl,mbstring,mysql,redis,soap,xml,zip} git unzip +sudo mysql +mysql> GRANT ALL PRIVILEGES ON chamilo.* TO chamilo@localhost IDENTIFIED BY '{password}'; +mysql> exit +~~~~ +(replace 'chamilo' by the database name and user you want, and '{password}' by a more secure password) + +On older Ubuntu versions (like 22.04), you have to install PHP through third-party sources: ~~~~ sudo apt update @@ -36,50 +49,63 @@ sudo apt -y upgrade sudo apt -y install ca-certificates curl gnupg software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update -sudo apt install apache2 libapache2-mod-php8.1 mariadb-client mariadb-server php-pear php8.1-{dev,gd,curl,intl,mysql,mbstring,zip,xml,cli,apcu,bcmath,soap} git unzip +sudo apt install apache2 libapache2-mod-php8.3 mariadb-client mariadb-server redis php-pear php8.3-{apcu,bcmath,cli,curl,dev,gd,intl,mbstring,mysql,redis,soap,xml,zip} git unzip ~~~~ +(replace 'chamilo' by the database name and user you want, and '{password}' by a more secure password) + +#### NodeJS, Yarn, Composer + If you already have nodejs installed, check the version with `node -v` -Otherwise, install node 18 or above: -* following the instructions here: https://deb.nodesource.com/node_20.x/. - The following lines use a static version of those instructions, so probably not very sustainable over time +Otherwise, install node 18 or above. + +The following lines use a static version from https://deb.nodesource.com/ (not very sustainable over time). ~~~~ cd ~ -curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg -NODE_MAJOR=20 -echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list -apt update && apt -y install nodejs +curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - +sudo apt-get install -y nodejs ~~~~ -* Other option to install nodejs is by using NVM (Node Version Manager). You can install it following the instructions [here](https://github.com/nvm-sh/nvm#installing-and-updating). - Then, you can install the node version required. Preferably, the LTS version. + +Another option to install nodejs is by using NVM (Node Version Manager). You can install it following the instructions [here](https://github.com/nvm-sh/nvm#installing-and-updating). +You can install the desired node version (preferably, the LTS version): ~~~~ sudo nvm install --lts sudo nvm use --lts ~~~~ + With NodeJS installed, you must enable corepack and then continue with the requirements ~~~~ sudo corepack enable cd ~ -# follow the instructions at https://getcomposer.org/download/ +~~~~ + +Follow the instructions at https://getcomposer.org/download/ to get Composer, then: +~~~~ sudo mv composer.phar /usr/local/bin/composer -# optionally, you might want this: +~~~~ + +#### Apache tweaks + +Optionally, you might want this to enable a series of Apache modules, but only ``rewrite` is 100% necessary: +~~~~ sudo apt install libapache2-mod-xsendfile sudo a2enmod rewrite ssl headers expires sudo systemctl restart apache2 ~~~~ When your system is all set, you can use the following: - ~~~~ cd /var/www -git clone https://github.com/chamilo/chamilo-lms.git chamilo2 -cd chamilo2 +git clone https://github.com/chamilo/chamilo-lms.git chamilo +cd chamilo composer install -# not recommended to do this as the root user! -# when asked whether you want to execute the recipes or install plugins for some of the components, -# you can safely type 'n' (for 'no'). +~~~~ + +We do not recommend running composer as the root user! +When asked whether you want to execute the recipes or install plugins for some of the components, you can safely type 'n' (for 'no'). +~~~~ yarn set version stable -# delete yarn.lock as it might contain restrictive packages from a different context +# delete yarn.lock if present, as it might contain restrictive packages from a different context yarn up yarn install yarn dev @@ -89,35 +115,59 @@ sudo chown -R www-data: var/ .env config/ ~~~~ In your web server configuration, ensure you allow for the interpretation of .htaccess (`AllowOverride all` and `Require all granted`), and point the `DocumentRoot` to the `public/` subdirectory. +Finally, make sure your PHP config points at Redis for sessions management. +This should look similar to this very short excerpt (in your Apache vhost block): +~~~~ + + ServerName my.chamilo.net + RewriteEngine On + RedirectMatch 302 (.*) https://my.chamilo.net$1 + + + DocumentRoot /var/www/chamilo/public/ + ServerName my.chamilo.net + # Error logging rules... + # SSL rules... + RewriteEngine On + + AllowOverride All + Require all granted + + + Require all denied + + php_value session.cookie_httponly 1 + php_admin_value session.save_handler "redis" + php_admin_value session.save_path "tcp://127.0.0.1:6379" + +~~~~ +Don't forget to reload your Apache configuration after each change: +~~~~ +sudo systemctl reload apache2 +~~~~ ### Web installer -Once the above is ready, enter the **main/install/index.php** and follow the UI instructions (database, admin user settings, etc). +Once the above is ready, use your browser to load the URL you have defined for your host, e.g. https://my.chamilo.net (this should redirect you to `main/install/index.php`) and follow the UI instructions (database, admin user settings, etc). After the web install process, change the permissions back to a reasonably safe state: ~~~~ chown -R root .env config/ ~~~~ -## Quick update +## Quick update for development/testing purposes If you have already installed it and just want to update it from Git, do: ~~~~ git pull composer install - -# Database update php bin/console doctrine:schema:update --force --complete - -# Clean Symfony cache php bin/console cache:clear - -# js/css update yarn install yarn dev ~~~~ -Note for developers in pre-alpha stage: the doctrine command will try to update +Note for developers in alpha stage: the doctrine command will try to update your database schema to the expected database schema in a fresh installation. This is not always perfect, as Doctrine will take the fastest route to do this. For example, if you have a migration to rename a table (which would apply just @@ -131,63 +181,87 @@ php bin/console doctrine:migrations:execute "Chamilo\CoreBundle\Migrations\Schem ``` This will respect the migration logic and do the required data processing. -This will update the JS (yarn) and PHP (composer) dependencies in the public/build folder. +The commands above will update the JS (yarn) in public/build/ and PHP (composer) dependencies in vendor/. -Sometimes there are conflicts with existing files so to avoid those here are some hints : -- for composer errors you can remove the vendor folder and composer.lock file -- for yarn erros you can remove yarn.lock .yarn/cache/* node_modules/* -- when opening Chamilo, it does not load, then you can delete var/cache/* +Sometimes there are conflicts with existing files so, to avoid those, here are some hints : +- for composer errors, you can remove the vendor folder and composer.lock file +- for yarn errors, you can remove yarn.lock .yarn/cache/* node_modules/* +- when opening Chamilo, if the page does not load, then you might want to delete var/cache/* ### Refresh configuration settings -In case you believe some settings in Chamilo might not have been processed correctly based on an incomplete migration -or a migration that was added after you installed your development version of Chamilo, the URL /admin/settings_sync is -built to try and fix that automatically by updating PHP classes based on the database state. -This issue rarely happens, though. +In case you believe some settings in Chamilo might not have been processed +correctly based on an incomplete migration or a migration that was added +after you installed your development version of Chamilo, the +/admin/settings_sync URL is built to try and fix that automatically by updating +PHP classes based on the database state. This issue rarely happens, though. ## Quick re-install -If you have it installed in a dev environment and feel like you should clean it up completely (might be necessary after changes to the database), you can do so by: +If you have it installed in a dev environment and feel like you should clean it +up completely (might be necessary after changes to the database), you can do so +by: * Removing the `.env` file -* Load the {url}/main/install/index.php script again +* Loading the {url}/main/install/index.php page again -The database should be automatically destroyed, table by table. In some extreme cases (a previous version created a table that is not necessary anymore and creates issues), you might want to clean it completely by just dropping it, but this shouldn't be necessary most of the time. +The database should be automatically destroyed, table by table. In some extreme +cases (a previous version created a table that is not necessary anymore and +creates issues), you might want to clean it completely by just dropping the +database, but this shouldn't be necessary most of the time. -If, for some reason, you have issues with either composer or yarn, a good first step is to delete completely the `vendor/` folder (for composer) or the `node_modules/` folder (for yarn). +If, for some reason, you have issues with either composer or yarn, a good first +step is to delete completely the `vendor/` folder (for composer) or the +`node_modules/` folder (for yarn). ## Development setup (Dev environment, stable environment not yet available) -If you are a developer and want to contribute to Chamilo in the current development branch (not stable yet), -then please follow the instructions below. Please bear in mind that the development version is NOT COMPLETE at this time, -and many features are just not working yet. This is because we are working on root components that require massive changes to the structure of the code, files and database. As such, to get a working version, you might need to completely uninstall and re-install from time to time. You've been warned. +If you are a developer and want to contribute to Chamilo in the current +development branch (not stable yet), then please follow the instructions below. +Please bear in mind that the development version is NOT STABLE at this time, +and many features are just not working yet. This is because we are working on +root components that require massive changes to the structure of the code, +files and database. As such, to get a working version, you might need to +completely uninstall and re-install from time to time. You've been warned. -First, apply the procedure described here: [Managing CSS and JavaScript in Chamilo](assets/README.md) (in particular, make sure you follow the given links to install all the necessary components on your computer). +First, apply the procedure described here: +[Managing CSS and JavaScript in Chamilo](assets/README.md) (in particular, +make sure you follow the given links to install all the necessary components +on your computer). -Then make sure your database supports large prefixes (see [this Stack Overflow thread](https://stackoverflow.com/questions/43379717/how-to-enable-large-index-in-mariadb-10/43403017#43403017) if you use MySQL < 5.7 or MariaDB < 10.2.2). +Then make sure your database supports large prefixes +(see [this Stack Overflow thread](https://stackoverflow.com/questions/43379717/how-to-enable-large-index-in-mariadb-10/43403017#43403017) +if you use MySQL < 5.7 or MariaDB < 10.2.2). -Load the (your-domain)/main/install/index.php URL to start the installer (which is very similar to the installer in previous versions). -If the installer is pure-HTML and doesn't appear with a clean layout, that's because you didn't follow these instructions carefully. +Load the (your-domain)/main/install/index.php URL to start the installer (which +is very similar to the installer in previous versions). + +If the installer is pure-HTML and doesn't appear with a clean layout, that's +probably because you didn't follow these instructions carefully. Go back to the beginning of this section and try again. -If you want hot reloading for assets use the command `yarn run encore dev-server`. This will refresh automatically -your assets when you modify them under `assets/vue`. Access your chamilo instance as usual. In the background, this will serve -assets from a custom server on http://localhost:8080. Do not access this url directly since -[Encore](https://symfony.com/doc/current/frontend.html#webpack-encore) is in charge of changing url assets as needed. +If you want hot reloading for assets use the command `yarn run encore dev-server`. +This will refresh automatically your assets when you modify them under +`assets/vue`. Access your chamilo instance as usual. In the background, this +will serve assets from a custom server on http://localhost:8080. Do not access +this url directly since [Encore](https://symfony.com/doc/current/frontend.html#webpack-encore) +is in charge of changing url assets as needed. -### Supporting PHP 7.4 and 8.1 in parallel +### Supporting PHP 7.4 and 8.3 in parallel -You might want to support PHP 8.1 (for Chamilo 2) and PHP 7.4 (for all other things) on the same server simultaneously. On Ubuntu, you could do it this way: +You might want to support PHP 8.3 (for Chamilo 2) and PHP 7.4 (for all other +things) on the same server simultaneously. On Ubuntu, you could do it this way: ``` sudo add-apt-repository ppa:ondrej/php sudo apt update -sudo apt install php8.1 libapache2-mod-php7.4 php8.1-{modules} php7.4-{modules} -sudo apt remove libapache2-mod-php8.1 php7.4-fpm +sudo apt install php8.3 libapache2-mod-php7.4 php8.3-{modules} php7.4-{modules} +sudo apt remove libapache2-mod-php8.3 php7.4-fpm sudo a2enmod proxy_fcgi sudo vim /etc/apache2/sites-available/[your-chamilo2-vhost].conf ``` -In the vhost configuration, make sure you set PHP 8.1 FPM to answer this single vhost by adding, somewhere between your `` tags, the following: +In the vhost configuration, make sure you set PHP 8.3 FPM to answer this single +vhost by adding, somewhere between your `` tags, the following: ``` @@ -195,7 +269,7 @@ In the vhost configuration, make sure you set PHP 8.1 FPM to answer this single SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 - SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost" + SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost" Require all denied @@ -212,19 +286,29 @@ Then exit and restart Apache: sudo systemctl restart apache2 ``` -Finally, remember that PHP settings will have to be changed in /etc/php/8.1/fpm/php.ini and you will have to reload php8.1-fpm to take those config changes into account. +Finally, remember that PHP settings will have to be changed in +`/etc/php/8.3/fpm/php.ini` and you will have to reload `php8.3-fpm` to take +those config changes into account. ``` -sudo systemctl reload php8.1-fpm +sudo systemctl reload php8.3-fpm ``` -When using 2 versions, you will also have issues when calling `composer update`, as this one needs to be called by the relevant PHP version. +When using 2 versions, you will also have issues when calling +`composer update`, as this one needs to be called by the relevant PHP version. This can be done like so: ``` -/usr/bin/php8.1 /usr/local/bin/composer update +/usr/bin/php8.3 /usr/local/bin/composer update or, for Chamilo 1.11 /usr/bin/php7.4 /usr/local/bin/composer update ``` -If your default php-cli uses PHP7.4 (see `ln -s /etc/alternatives/php`), you might have issues running with a so-called `platform_check.php` script when running `composer update` anyway. This is because this script doesn't user the proper launch context, and you might need to change your default settings on Ubuntu (i.e. change the link /etc/alternatives/php to point to the other php version) before launching `composer update`. You can always revert that operation later on if you need to go back to work on Chamilo 1.11 and Composer complains again. +If your default php-cli uses PHP7.4 (see `ln -s /etc/alternatives/php`), +you might have issues running with a so-called `platform_check.php` script +when running `composer update` anyway. This is because this script doesn't +user the proper launch context, and you might need to change your default +settings on Ubuntu (i.e. change the link /etc/alternatives/php to point to +the other php version) before launching `composer update`. You can always +revert that operation later on if you need to go back to work on Chamilo 1.11 +and Composer complains again. ### git hooks @@ -236,26 +320,31 @@ following commands can be used. ## Changes from 1.x * in general, the main/ folder has been moved to public/main/ +* a big part of the frontend has been migrated to VueJS + Tailwind CSS * app/Resources/public/assets moved to public/assets * main/inc/lib/javascript moved to public/js * main/img/ moved to public/img * main/template/default moved to src/CoreBundle/Resources/views * src/Chamilo/XXXBundle moved to src/CoreBundle or src/CourseBundle * bin/doctrine.php removed use bin/console doctrine:xyz options -* Plugin images, css and js libs are loaded inside the public/plugins folder +* Plugin images, CSS and JS libs are loaded inside the public/plugins folder (composer update copies the content inside plugin_name/public inside web/plugins/plugin_name -* Plugins templates use asset() function instead of using "_p.web_plugin" -* Remove main/inc/local.inc.php -* Translations managed through Gettext +* Plugins templates use the ``asset()` function instead of using "_p.web_plugin" +* `main/inc/local.inc.php` has been removed +* Translations are managed through Gettext Libraries -* Integration with Symfony 5 +* Integration with Symfony 6 * PHPMailer replaced with Symfony Mailer -* bower replaced by [yarn](https://yarnpkg.com) +* Bower replaced by [yarn](https://yarnpkg.com) ## JWT Authentication +This version of Chamilo allows you to use a JWT (token) to use the Chamilo API +more securely. In order to use it, you will have to generate a JWT token as +follows. + * Run ```shell php bin/console lexik:jwt:generate-keypair @@ -290,8 +379,8 @@ If you want to submit new features or patches to Chamilo 2, please follow the Github contribution guide https://guides.github.com/activities/contributing-to-open-source/ and our [CONTRIBUTING.md](CONTRIBUTING.md) file. In short, we ask you to send us Pull Requests based on a branch that you create -with this purpose into your repository forked from the original Chamilo repository. +with this purpose into your repository, forked from the original Chamilo repository (`master` branch). ## Documentation -For more information on Chamilo, visit https://campus.chamilo.org/documentation/index.html +For more information on Chamilo, visit https://2.chamilo.org/documentation/index.html diff --git a/assets/vue/composables/language.js b/assets/vue/composables/language.js new file mode 100644 index 00000000000..b098553de45 --- /dev/null +++ b/assets/vue/composables/language.js @@ -0,0 +1,22 @@ +export function useLanguage() { + const defaultLanguage = { originalName: "English", isocode: "en" } + + /** + * @type {{originalName: string, isocode: string}[]} + */ + const languageList = window.languages || [defaultLanguage] + + /** + * @param {string} isoCode + * @returns {{originalName: string, isocode: string}|undefined} + */ + function findByIsoCode(isoCode) { + return languageList.find((language) => isoCode === language.isocode) + } + + return { + defaultLanguage, + languageList, + findByIsoCode, + } +} diff --git a/assets/vue/router/account.js b/assets/vue/router/account.js index 42a8d52147f..9dfd192095f 100644 --- a/assets/vue/router/account.js +++ b/assets/vue/router/account.js @@ -1,14 +1,14 @@ export default { - path: '/account', + path: "/account", meta: { requiresAuth: true }, - name: 'account', - component: () => import('../components/course/Layout.vue'), + name: "account", + component: () => import("../components/course/Layout.vue"), children: [ { - name: 'AccountHome', - path: 'home', - component: () => import('../views/account/Home.vue'), - meta: {requiresAuth: true}, + name: "AccountHome", + path: "home", + component: () => import("../views/account/Home.vue"), + meta: { requiresAuth: true }, }, - ] -}; + ], +} diff --git a/assets/vue/router/admin.js b/assets/vue/router/admin.js index eaaf86b4945..78d42192b15 100644 --- a/assets/vue/router/admin.js +++ b/assets/vue/router/admin.js @@ -1,21 +1,20 @@ export default { - path: '/admin', - name: 'admin', - meta: { requiresAuth: true, showBreadcrumb: true }, - component: () => import('../components/admin/AdminLayout.vue'), - children: [ - { - path: '', - name: 'AdminIndex', - meta: { requiresAdmin: true, requiresSessionAdmin: true, showBreadcrumb: false }, - component: () => import('../views/admin/AdminIndex.vue'), - }, - { - name: 'AdminConfigurationColors', - path: 'configuration/colors', - meta: { requiresAdmin: true, requiresSessionAdmin: true, showBreadcrumb: true }, - component: () => import('../views/admin/AdminConfigureColors.vue'), - } - ], -}; - + path: "/admin", + name: "admin", + meta: { requiresAuth: true, showBreadcrumb: true }, + component: () => import("../components/admin/AdminLayout.vue"), + children: [ + { + path: "", + name: "AdminIndex", + meta: { requiresAdmin: true, requiresSessionAdmin: true, showBreadcrumb: false }, + component: () => import("../views/admin/AdminIndex.vue"), + }, + { + name: "AdminConfigurationColors", + path: "configuration/colors", + meta: { requiresAdmin: true, requiresSessionAdmin: true, showBreadcrumb: true }, + component: () => import("../views/admin/AdminConfigureColors.vue"), + }, + ], +} diff --git a/assets/vue/router/assignments.js b/assets/vue/router/assignments.js index fc1fc9ca426..19243c17cac 100644 --- a/assets/vue/router/assignments.js +++ b/assets/vue/router/assignments.js @@ -25,4 +25,4 @@ export default { props: true, }, ], -}; +} diff --git a/assets/vue/router/cataloguecourses.js b/assets/vue/router/cataloguecourses.js index 663c9af4ce1..29c97e03bc3 100644 --- a/assets/vue/router/cataloguecourses.js +++ b/assets/vue/router/cataloguecourses.js @@ -1,6 +1,6 @@ export default { - path: '/catalogue/courses', - name: 'CatalogueCourses', - meta: { requiresAdmin: true, requiresSessionAdmin: true }, - component: () => import('../views/course/CatalogueCourses.vue') -}; + path: "/catalogue/courses", + name: "CatalogueCourses", + meta: { requiresAdmin: true, requiresSessionAdmin: true }, + component: () => import("../views/course/CatalogueCourses.vue"), +} diff --git a/assets/vue/router/cataloguesessions.js b/assets/vue/router/cataloguesessions.js index 3f9fd1a86a4..336307b201f 100644 --- a/assets/vue/router/cataloguesessions.js +++ b/assets/vue/router/cataloguesessions.js @@ -1,6 +1,6 @@ export default { - path: '/catalogue/sessions', - name: 'CatalogueSessions', - meta: { requiresAdmin: true, requiresSessionAdmin: true }, - component: () => import('../views/course/CatalogueSessions.vue') -}; + path: "/catalogue/sessions", + name: "CatalogueSessions", + meta: { requiresAdmin: true, requiresSessionAdmin: true }, + component: () => import("../views/course/CatalogueSessions.vue"), +} diff --git a/assets/vue/router/ccalendarevent.js b/assets/vue/router/ccalendarevent.js index 81446f34904..888ab20a66b 100644 --- a/assets/vue/router/ccalendarevent.js +++ b/assets/vue/router/ccalendarevent.js @@ -1,25 +1,25 @@ export default { - path: '/resources/ccalendarevent', + path: "/resources/ccalendarevent", meta: { requiresAuth: true }, - name: 'ccalendarevent', - redirect: { name: 'CCalendarEventList' }, - component: () => import('../components/ccalendarevent/CCalendarEventLayout.vue'), + name: "ccalendarevent", + redirect: { name: "CCalendarEventList" }, + component: () => import("../components/ccalendarevent/CCalendarEventLayout.vue"), children: [ { - name: 'CCalendarEventShow', - path: 'show', - component: () => import('../views/ccalendarevent/CCalendarEventShow.vue') + name: "CCalendarEventShow", + path: "show", + component: () => import("../views/ccalendarevent/CCalendarEventShow.vue"), }, { - name: 'CCalendarEventCreate', - path: 'new', - component: () => import('../views/ccalendarevent/CCalendarEventCreate.vue') + name: "CCalendarEventCreate", + path: "new", + component: () => import("../views/ccalendarevent/CCalendarEventCreate.vue"), }, { - name: 'CCalendarEventList', - path: '', - component: () => import('../views/ccalendarevent/CCalendarEventList.vue'), - props: (route) => ({ type: route.query.type }) - } - ] -}; + name: "CCalendarEventList", + path: "", + component: () => import("../views/ccalendarevent/CCalendarEventList.vue"), + props: (route) => ({ type: route.query.type }), + }, + ], +} diff --git a/assets/vue/router/course.js b/assets/vue/router/course.js index b11a138d060..da0e5ee7461 100644 --- a/assets/vue/router/course.js +++ b/assets/vue/router/course.js @@ -1,29 +1,29 @@ export default { - path: '/resources/courses', + path: "/resources/courses", meta: { requiresAuth: true }, - name: 'courses', - component: () => import('../components/course/Layout.vue'), - redirect: { name: 'CourseList' }, + name: "courses", + component: () => import("../components/course/Layout.vue"), + redirect: { name: "CourseList" }, children: [ { - name: 'CourseList', - path: '', - component: () => import('../views/course/List.vue') + name: "CourseList", + path: "", + component: () => import("../views/course/List.vue"), }, { - name: 'CourseCreate', - path: 'new', - component: () => import('../views/course/Create.vue') + name: "CourseCreate", + path: "new", + component: () => import("../views/course/Create.vue"), }, { - name: 'CourseUpdate', - path: ':id/edit', - component: () => import('../views/course/Update.vue') + name: "CourseUpdate", + path: ":id/edit", + component: () => import("../views/course/Update.vue"), }, { - name: 'CourseShow', - path: ':id', - component: () => import('../views/course/Show.vue') - } - ] -}; + name: "CourseShow", + path: ":id", + component: () => import("../views/course/Show.vue"), + }, + ], +} diff --git a/assets/vue/router/coursecategory.js b/assets/vue/router/coursecategory.js index e76ba8da9b7..ef2ab0758c1 100644 --- a/assets/vue/router/coursecategory.js +++ b/assets/vue/router/coursecategory.js @@ -1,29 +1,29 @@ export default { - path: '/resources/course_categories', + path: "/resources/course_categories", meta: { requiresAuth: true }, - name: 'course_categories', - component: () => import('../components/coursecategory/Layout.vue'), - redirect: { name: 'CourseCategoryList' }, + name: "course_categories", + component: () => import("../components/coursecategory/Layout.vue"), + redirect: { name: "CourseCategoryList" }, children: [ { - name: 'CourseCategoryList', - path: '', - component: () => import('../views/coursecategory/List.vue') + name: "CourseCategoryList", + path: "", + component: () => import("../views/coursecategory/List.vue"), }, { - name: 'CourseCategoryCreate', - path: 'new', - component: () => import('../views/coursecategory/Create.vue') + name: "CourseCategoryCreate", + path: "new", + component: () => import("../views/coursecategory/Create.vue"), }, { - name: 'CourseCategoryUpdate', - path: ':id/edit', - component: () => import('../views/coursecategory/Update.vue') + name: "CourseCategoryUpdate", + path: ":id/edit", + component: () => import("../views/coursecategory/Update.vue"), }, { - name: 'CourseCategoryShow', - path: ':id', - component: () => import('../views/coursecategory/Show.vue') - } - ] -}; + name: "CourseCategoryShow", + path: ":id", + component: () => import("../views/coursecategory/Show.vue"), + }, + ], +} diff --git a/assets/vue/router/ctoolintro.js b/assets/vue/router/ctoolintro.js index 929b591ec0d..9bba071e97c 100644 --- a/assets/vue/router/ctoolintro.js +++ b/assets/vue/router/ctoolintro.js @@ -1,25 +1,25 @@ export default { - path: '/resources/ctoolintro/', + path: "/resources/ctoolintro/", meta: { requiresAuth: true, showBreadcrumb: true }, - name: 'ctoolintro', - component: () => import('../components/ctoolintro/Layout.vue'), - redirect: { name: 'ToolIntroList' }, + name: "ctoolintro", + component: () => import("../components/ctoolintro/Layout.vue"), + redirect: { name: "ToolIntroList" }, children: [ { - name: 'ToolIntroCreate', - path: 'new/:courseTool', - component: () => import('../views/ctoolintro/Create.vue') + name: "ToolIntroCreate", + path: "new/:courseTool", + component: () => import("../views/ctoolintro/Create.vue"), }, { - name: 'ToolIntroUpdate', + name: "ToolIntroUpdate", //path: ':id/edit', - path: 'edit', - component: () => import('../views/ctoolintro/Update.vue') + path: "edit", + component: () => import("../views/ctoolintro/Update.vue"), }, { - name: 'ToolIntroShow', - path: '', - component: () => import('../views/ctoolintro/Show.vue') - } - ] -}; + name: "ToolIntroShow", + path: "", + component: () => import("../views/ctoolintro/Show.vue"), + }, + ], +} diff --git a/assets/vue/router/documents.js b/assets/vue/router/documents.js index 0306507e0b0..c8d5b5c2dd4 100644 --- a/assets/vue/router/documents.js +++ b/assets/vue/router/documents.js @@ -1,55 +1,55 @@ export default { - path: '/resources/document/:node/', + path: "/resources/document/:node/", meta: { requiresAuth: true, showBreadcrumb: true }, - name: 'documents', - component: () => import('../components/layout/SimpleRouterViewLayout.vue'), - redirect: { name: 'DocumentsList' }, + name: "documents", + component: () => import("../components/layout/SimpleRouterViewLayout.vue"), + redirect: { name: "DocumentsList" }, children: [ { - name: 'DocumentsList', - path: '', - component: () => import('../views/documents/DocumentsList.vue') + name: "DocumentsList", + path: "", + component: () => import("../views/documents/DocumentsList.vue"), }, { - name: 'DocumentsCreate', - path: 'new', - component: () => import('../views/documents/Create.vue') + name: "DocumentsCreate", + path: "new", + component: () => import("../views/documents/Create.vue"), }, { - name: 'DocumentsCreateFile', - path: 'create', - component: () => import('../views/documents/CreateFile.vue') + name: "DocumentsCreateFile", + path: "create", + component: () => import("../views/documents/CreateFile.vue"), }, { - name: 'DocumentsUploadFile', - path: 'upload', - component: () => import('../views/documents/DocumentsUpload.vue') + name: "DocumentsUploadFile", + path: "upload", + component: () => import("../views/documents/DocumentsUpload.vue"), }, { - name: 'DocumentsUpdate', + name: "DocumentsUpdate", //path: ':id/edit', - path: 'edit', - component: () => import('../views/documents/Update.vue') + path: "edit", + component: () => import("../views/documents/Update.vue"), }, { - name: 'DocumentsUpdateFile', + name: "DocumentsUpdateFile", //path: ':id/edit', - path: 'edit_file', - component: () => import('../views/documents/UpdateFile.vue') + path: "edit_file", + component: () => import("../views/documents/UpdateFile.vue"), }, { - name: 'DocumentsShow', - path: 'show', - component: () => import('../views/documents/DocumentShow.vue') + name: "DocumentsShow", + path: "show", + component: () => import("../views/documents/DocumentShow.vue"), }, { - name: 'DocumentForHtmlEditor', - path: 'manager', - component: () => import('../views/documents/DocumentForHtmlEditor.vue'), + name: "DocumentForHtmlEditor", + path: "manager", + component: () => import("../views/documents/DocumentForHtmlEditor.vue"), meta: { - layout: 'Empty', - showBreadcrumb: false - } + layout: "Empty", + showBreadcrumb: false, + }, }, - ] -}; + ], +} diff --git a/assets/vue/router/filemanager.js b/assets/vue/router/filemanager.js index 0748fe3b92e..ded0c5e8da0 100644 --- a/assets/vue/router/filemanager.js +++ b/assets/vue/router/filemanager.js @@ -1,25 +1,25 @@ export default { - path: '/resources/filemanager', + path: "/resources/filemanager", meta: { requiresAuth: true }, - component: () => import('../components/filemanager/Layout.vue'), + component: () => import("../components/filemanager/Layout.vue"), children: [ { - path: 'personal_list/:node?', - name: 'FileManagerList', - component: () => import('../views/filemanager/List.vue'), + path: "personal_list/:node?", + name: "FileManagerList", + component: () => import("../views/filemanager/List.vue"), meta: { emptyLayout: true }, }, { - name: 'FileManagerUploadFile', - path: 'upload', - component: () => import('../views/filemanager/Upload.vue'), + name: "FileManagerUploadFile", + path: "upload", + component: () => import("../views/filemanager/Upload.vue"), meta: { emptyLayout: true }, }, { - name: 'CourseDocumentsUploadFile', - path: '/course-upload', + name: "CourseDocumentsUploadFile", + path: "/course-upload", meta: { emptyLayout: true }, - component: () => import('../views/documents/DocumentsUpload.vue') + component: () => import("../views/documents/DocumentsUpload.vue"), }, ], -}; +} diff --git a/assets/vue/router/index.js b/assets/vue/router/index.js index caf74d496e9..86e51c5cae0 100644 --- a/assets/vue/router/index.js +++ b/assets/vue/router/index.js @@ -46,7 +46,6 @@ import catalogueSessions from "./cataloguesessions" import { customVueTemplateEnabled } from "../config/env" import { useCourseSettings } from "../store/courseSettingStore" import { checkIsAllowedToEdit, useUserSessionSubscription } from "../composables/userPermissions" -import { usePlatformConfig } from "../store/platformConfig" const router = createRouter({ history: createWebHistory(), @@ -140,25 +139,20 @@ const router = createRouter({ } // Exercise auto-launch - const platformConfigStore = usePlatformConfig() - const isExerciseAutoLaunchEnabled = - "true" === platformConfigStore.getSetting("exercise.allow_exercise_auto_launch") - if (isExerciseAutoLaunchEnabled) { - const exerciseAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_exercise_auto_launch"), 10) || 0 - if (exerciseAutoLaunch === 2) { + const exerciseAutoLaunch = parseInt(courseSettingsStore.getSetting("enable_exercise_auto_launch"), 10) || 0 + if (exerciseAutoLaunch === 2) { + sessionStorage.setItem(autoLaunchKey, "true") + window.location.href = + `/main/exercise/exercise.php?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "") + return false + } else if (exerciseAutoLaunch === 1) { + const exerciseId = await courseService.getAutoLaunchExerciseId(courseId, sessionId) + if (exerciseId) { sessionStorage.setItem(autoLaunchKey, "true") window.location.href = - `/main/exercise/exercise.php?cid=${courseId}` + (sessionId ? `&sid=${sessionId}` : "") + `/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}` + + (sessionId ? `&sid=${sessionId}` : "") return false - } else if (exerciseAutoLaunch === 1) { - const exerciseId = await courseService.getAutoLaunchExerciseId(courseId, sessionId) - if (exerciseId) { - sessionStorage.setItem(autoLaunchKey, "true") - window.location.href = - `/main/exercise/overview.php?exerciseId=${exerciseId}&cid=${courseId}` + - (sessionId ? `&sid=${sessionId}` : "") - return false - } } } diff --git a/assets/vue/router/message.js b/assets/vue/router/message.js index d8e90f3b4aa..6b991037b64 100644 --- a/assets/vue/router/message.js +++ b/assets/vue/router/message.js @@ -1,24 +1,24 @@ export default { - path: '/resources/messages', + path: "/resources/messages", meta: { requiresAuth: true }, - name: 'messages', - component: () => import('../components/message/MessageLayout.vue'), - redirect: { name: 'MessageList' }, + name: "messages", + component: () => import("../components/message/MessageLayout.vue"), + redirect: { name: "MessageList" }, children: [ { - name: 'MessageList', - path: '', - component: () => import('../views/message/MessageList.vue') + name: "MessageList", + path: "", + component: () => import("../views/message/MessageList.vue"), }, { - name: 'MessageCreate', - path: 'new', - component: () => import('../views/message/MessageCreate.vue') + name: "MessageCreate", + path: "new", + component: () => import("../views/message/MessageCreate.vue"), }, { - name: 'MessageReply', - path: 'reply', - component: () => import('../views/message/MessageReply.vue') + name: "MessageReply", + path: "reply", + component: () => import("../views/message/MessageReply.vue"), }, /*{ name: 'MessageUpdate', @@ -26,10 +26,10 @@ export default { component: () => import('../views/message/Update.vue') },*/ { - name: 'MessageShow', + name: "MessageShow", //path: ':id', - path: 'show', - component: () => import('../views/message/MessageShow.vue') - } - ] -}; + path: "show", + component: () => import("../views/message/MessageShow.vue"), + }, + ], +} diff --git a/assets/vue/router/page.js b/assets/vue/router/page.js index b2347d307cf..b634a297324 100644 --- a/assets/vue/router/page.js +++ b/assets/vue/router/page.js @@ -1,36 +1,36 @@ export default { - path: '/resources/pages', + path: "/resources/pages", meta: { requiresAuth: true }, - name: 'pages', - component: () => import('../components/page/Layout.vue'), - redirect: { name: 'PageList' }, + name: "pages", + component: () => import("../components/page/Layout.vue"), + redirect: { name: "PageList" }, children: [ { - name: 'PageList', - path: '', - component: () => import('../views/page/List.vue') + name: "PageList", + path: "", + component: () => import("../views/page/List.vue"), }, { - name: 'PageCreate', - path: 'new', - component: () => import('../views/page/Create.vue') + name: "PageCreate", + path: "new", + component: () => import("../views/page/Create.vue"), }, { - name: 'PageUpdate', + name: "PageUpdate", //path: ':id/edit', - path: 'edit', - component: () => import('../views/page/Update.vue') + path: "edit", + component: () => import("../views/page/Update.vue"), }, { - name: 'PageShow', + name: "PageShow", //path: ':id', - path: 'show', - component: () => import('../views/page/Show.vue') + path: "show", + component: () => import("../views/page/Show.vue"), }, { - name: 'PageEditorDemo', - path: 'editor-demo', - component: () => import('../views/page/EditorDemo.vue') + name: "PageEditorDemo", + path: "editor-demo", + component: () => import("../views/page/EditorDemo.vue"), }, - ] -}; + ], +} diff --git a/assets/vue/router/personalfile.js b/assets/vue/router/personalfile.js index 74b471ee286..3b42472fd1e 100644 --- a/assets/vue/router/personalfile.js +++ b/assets/vue/router/personalfile.js @@ -1,42 +1,42 @@ export default { - path: '/resources/personal_files', + path: "/resources/personal_files", meta: { requiresAuth: true }, - name: 'personal_files', - component: () => import('../views/personalfile/Home.vue'), + name: "personal_files", + component: () => import("../views/personalfile/Home.vue"), children: [ { - name: 'personal_files', - path: ':node/', - component: () => import('../components/personalfile/Layout.vue'), - redirect: { name: 'PersonalFileList' }, + name: "personal_files", + path: ":node/", + component: () => import("../components/personalfile/Layout.vue"), + redirect: { name: "PersonalFileList" }, children: [ { - name: 'PersonalFileList', - path: '', - component: () => import('../views/personalfile/List.vue') + name: "PersonalFileList", + path: "", + component: () => import("../views/personalfile/List.vue"), }, { - name: 'PersonalFileUploadFile', - path: 'upload', - component: () => import('../views/personalfile/Upload.vue') + name: "PersonalFileUploadFile", + path: "upload", + component: () => import("../views/personalfile/Upload.vue"), }, { - name: 'PersonalFileShared', - path: 'shared', - component: () => import('../views/personalfile/Shared.vue') + name: "PersonalFileShared", + path: "shared", + component: () => import("../views/personalfile/Shared.vue"), }, { - name: 'PersonalFileUpdate', + name: "PersonalFileUpdate", //path: ':id/edit', - path: 'edit_file', - component: () => import('../views/personalfile/Update.vue') + path: "edit_file", + component: () => import("../views/personalfile/Update.vue"), }, { - name: 'PersonalFileShow', - path: 'show', - component: () => import('../views/personalfile/Show.vue') - } - ] + name: "PersonalFileShow", + path: "show", + component: () => import("../views/personalfile/Show.vue"), + }, + ], }, - ] -}; + ], +} diff --git a/assets/vue/router/social.js b/assets/vue/router/social.js index 4e2c6a1d495..94e61081d01 100644 --- a/assets/vue/router/social.js +++ b/assets/vue/router/social.js @@ -1,18 +1,18 @@ export default { - path: '/social', + path: "/social", meta: { requiresAuth: true }, - name: 'Social', - component: () => import('../views/social/SocialLayout.vue'), + name: "Social", + component: () => import("../views/social/SocialLayout.vue"), children: [ { - name: 'SocialWall', - path: ':filterType?', - component: () => import('../views/social/SocialWall.vue') + name: "SocialWall", + path: ":filterType?", + component: () => import("../views/social/SocialWall.vue"), }, { - name: 'SocialSearch', - path: 'search', - component: () => import('../views/social/SocialSearch.vue') - } - ] + name: "SocialSearch", + path: "search", + component: () => import("../views/social/SocialSearch.vue"), + }, + ], } diff --git a/assets/vue/router/terms.js b/assets/vue/router/terms.js index 8469649549c..fdef744f555 100644 --- a/assets/vue/router/terms.js +++ b/assets/vue/router/terms.js @@ -1,23 +1,23 @@ export default { - path: '/resources/terms-conditions', + path: "/resources/terms-conditions", meta: { requiresAuth: true }, - name: 'TermsConditions', - component: () => import('../views/terms/TermsLayout.vue'), + name: "TermsConditions", + component: () => import("../views/terms/TermsLayout.vue"), children: [ { - name: 'TermsConditionsList', - path: '', - component: () => import('../views/terms/TermsList.vue') + name: "TermsConditionsList", + path: "", + component: () => import("../views/terms/TermsList.vue"), }, { - name: 'TermsConditionsEdit', - path: 'edit', - component: () => import('../views/terms/TermsEdit.vue') + name: "TermsConditionsEdit", + path: "edit", + component: () => import("../views/terms/TermsEdit.vue"), }, { - name: 'TermsConditionsView', - path: 'view', - component: () => import('../views/terms/Terms.vue') - } - ] + name: "TermsConditionsView", + path: "view", + component: () => import("../views/terms/Terms.vue"), + }, + ], } diff --git a/assets/vue/router/user.js b/assets/vue/router/user.js index 40d8cca352a..ac67352669d 100644 --- a/assets/vue/router/user.js +++ b/assets/vue/router/user.js @@ -1,19 +1,19 @@ export default { - path: '/resources/users', + path: "/resources/users", meta: { requiresAuth: true }, - name: 'users', - component: () => import('../components/user/Layout.vue'), + name: "users", + component: () => import("../components/user/Layout.vue"), children: [ { - name: 'UserGroupShow', + name: "UserGroupShow", //path: ':id', - path: 'show', - component: () => import('../views/usergroup/Show.vue') + path: "show", + component: () => import("../views/usergroup/Show.vue"), }, { - name: 'PersonalData', - path: 'personal_data', - component: () => import('../views/user/PersonalData.vue') + name: "PersonalData", + path: "personal_data", + component: () => import("../views/user/PersonalData.vue"), }, - ] -}; + ], +} diff --git a/assets/vue/router/usergroup.js b/assets/vue/router/usergroup.js index 4e7cac812c9..044b5bc5164 100644 --- a/assets/vue/router/usergroup.js +++ b/assets/vue/router/usergroup.js @@ -1,37 +1,37 @@ export default { - path: '/resources/usergroups', + path: "/resources/usergroups", meta: { requiresAuth: true }, - name: 'usergroups', - component: () => import('../components/usergroup/Layout.vue'), - redirect: { name: 'UserGroupList' }, + name: "usergroups", + component: () => import("../components/usergroup/Layout.vue"), + redirect: { name: "UserGroupList" }, children: [ { - name: 'UserGroupList', - path: '', - component: () => import('../views/usergroup/List.vue') + name: "UserGroupList", + path: "", + component: () => import("../views/usergroup/List.vue"), }, { - name: 'UserGroupShow', - path: 'show/:group_id?', - component: () => import('../views/usergroup/Show.vue'), - props: true + name: "UserGroupShow", + path: "show/:group_id?", + component: () => import("../views/usergroup/Show.vue"), + props: true, }, { - name: 'UserGroupSearch', - path: 'search', - component: () => import('../views/usergroup/Search.vue'), + name: "UserGroupSearch", + path: "search", + component: () => import("../views/usergroup/Search.vue"), }, { - name: 'UserGroupInvite', - path: 'invite/:group_id?', - component: () => import('../views/usergroup/Invite.vue'), - props: true + name: "UserGroupInvite", + path: "invite/:group_id?", + component: () => import("../views/usergroup/Invite.vue"), + props: true, }, { - name: 'UserGroupDiscussions', - path: 'show/:group_id/discussions/:discussion_id', - component: () => import('../components/usergroup/GroupDiscussionTopics.vue'), - props: true - } - ] -}; + name: "UserGroupDiscussions", + path: "show/:group_id/discussions/:discussion_id", + component: () => import("../components/usergroup/GroupDiscussionTopics.vue"), + props: true, + }, + ], +} diff --git a/assets/vue/router/userreluser.js b/assets/vue/router/userreluser.js index 63f9c5c2854..882822f4347 100644 --- a/assets/vue/router/userreluser.js +++ b/assets/vue/router/userreluser.js @@ -1,29 +1,29 @@ export default { - path: '/resources/friends', + path: "/resources/friends", meta: { requiresAuth: true }, - name: 'friends', - component: () => import('../components/userreluser/Layout.vue'), - redirect: { name: 'UserGroupList' }, + name: "friends", + component: () => import("../components/userreluser/Layout.vue"), + redirect: { name: "UserGroupList" }, children: [ { - name: 'UserRelUserList', - path: '', - component: () => import('../views/userreluser/UserRelUserList.vue') + name: "UserRelUserList", + path: "", + component: () => import("../views/userreluser/UserRelUserList.vue"), }, { - name: 'UserRelUserAdd', - path: 'add', - component: () => import('../views/userreluser/UserRelUserAdd.vue') + name: "UserRelUserAdd", + path: "add", + component: () => import("../views/userreluser/UserRelUserAdd.vue"), }, { - name: 'UserRelUserSearch', - path: 'search', - component: () => import('../views/userreluser/UserRelUserSearch.vue') + name: "UserRelUserSearch", + path: "search", + component: () => import("../views/userreluser/UserRelUserSearch.vue"), }, { - name: 'Invitations', - path: 'invitations', - component: () => import('../views/userreluser/Invitations.vue') - } - ] -}; + name: "Invitations", + path: "invitations", + component: () => import("../views/userreluser/Invitations.vue"), + }, + ], +} diff --git a/assets/vue/services/courseService.js b/assets/vue/services/courseService.js index 1f6e10737bc..6f49cb3a54c 100644 --- a/assets/vue/services/courseService.js +++ b/assets/vue/services/courseService.js @@ -4,6 +4,12 @@ import baseService from "./baseService" export default { find: baseService.get, + /** + * @param {Object} searchParams + * @returns {Promise<{totalItems, items}>} + */ + listAll: async (searchParams = {}) => await baseService.getCollection("/api/courses", searchParams), + /** * @param {number} cid * @param {object} params diff --git a/assets/vue/services/trackCourseRankingService.js b/assets/vue/services/trackCourseRankingService.js new file mode 100644 index 00000000000..3561bf62879 --- /dev/null +++ b/assets/vue/services/trackCourseRankingService.js @@ -0,0 +1,26 @@ +import baseService from "./baseService" + +/** + * @param {string} courseIri + * @param {number} urlId + * @param {number} sessionId + * @param {number} totalScore + * @returns {Promise} + */ +export async function saveRanking({ courseIri, urlId, sessionId, totalScore }) { + return await baseService.post("/api/track_course_rankings", { + totalScore, + course: courseIri, + urlId, + sessionId, + }) +} + +/** + * @param {string} iri + * @param {number} totalScore + * @returns {Promise} + */ +export async function updateRanking({ iri, totalScore }) { + return await baseService.put(iri, { totalScore }) +} diff --git a/assets/vue/views/course/CatalogueCourses.vue b/assets/vue/views/course/CatalogueCourses.vue index 6d609e90a4c..1d03746d6e8 100644 --- a/assets/vue/views/course/CatalogueCourses.vue +++ b/assets/vue/views/course/CatalogueCourses.vue @@ -175,15 +175,15 @@ v-else-if="data.visibility === 2 && !isUserInCourse(data)" :label="$t('Not subscribed')" class="btn btn--primary text-white" - icon="pi pi-times" disabled + icon="pi pi-times" />