diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8654bc0..e4e4803 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,15 @@ instructions, because git commits are used to generate release notes:
+
+## v18.0.0 (2024-06-20)
+
+- 💥[Feature] Upgrade to Redwood. (by @Fahadkhalid210)
+- [Bugfix] Make plugin compatible with Python 3.12 by removing dependency on `pkg_resources`. (by @regisb)
+- [Improvement] Update User Activity dataset query by extending time span to 120 seconds and selecting all events where course ID is not null to improve average time spent in course. (by @Fahadkhalid210)
+- [Improvement] Added CORS for embedded Dashboards. (by @Fahadkhalid210)
+- 💥[Feature] Upgrade Clickhouse to version 24.1.8.22 and fix query issues due to deprecation of live views. (by @Fahadkhalid210)
+
## v17.1.0 (2024-02-09)
diff --git a/changelog.d/20240212_115536_regis_pkg_resources.md b/changelog.d/20240212_115536_regis_pkg_resources.md
deleted file mode 100644
index 35b6d20..0000000
--- a/changelog.d/20240212_115536_regis_pkg_resources.md
+++ /dev/null
@@ -1 +0,0 @@
-- [Bugfix] Make plugin compatible with Python 3.12 by removing dependency on `pkg_resources`. (by @regisb)
diff --git a/changelog.d/20240405_151230_fahad.khalid.md b/changelog.d/20240405_151230_fahad.khalid.md
deleted file mode 100644
index 83f660b..0000000
--- a/changelog.d/20240405_151230_fahad.khalid.md
+++ /dev/null
@@ -1 +0,0 @@
-- [Improvement] Update User Activity dataset query by extending time span to 120 seconds and selecting all events where course ID is not null to improve average time spent in course. (by @Fahadkhalid210)
diff --git a/setup.py b/setup.py
index 6e1e20f..ce5caa5 100644
--- a/setup.py
+++ b/setup.py
@@ -41,8 +41,8 @@ setup(
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.8",
- install_requires=["tutor>=17.0.0,<18.0.0"],
- extras_require={"dev": ["tutor[dev]>=17.0.0,<18.0.0"]},
+ install_requires=["tutor>=18.0.0,<19.0.0"],
+ extras_require={"dev": ["tutor[dev]>=18.0.0,<19.0.0"]},
entry_points={"tutor.plugin.v1": ["cairn = tutorcairn.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
diff --git a/tutorcairn/__about__.py b/tutorcairn/__about__.py
index 1bef254..c6a8b8e 100644
--- a/tutorcairn/__about__.py
+++ b/tutorcairn/__about__.py
@@ -1 +1 @@
-__version__ = "17.1.0"
+__version__ = "18.0.0"
diff --git a/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0012_modify_course_enrollments.sql b/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0012_modify_course_enrollments.sql
new file mode 100644
index 0000000..75cc839
--- /dev/null
+++ b/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0012_modify_course_enrollments.sql
@@ -0,0 +1,23 @@
+RENAME TABLE _openedx_course_enrollments TO openedx_course_enrollments;
+RENAME TABLE _openedx_user_profiles TO openedx_user_profiles;
+RENAME TABLE _openedx_users TO openedx_users;
+
+DROP TABLE course_enrollments;
+CREATE VIEW course_enrollments AS
+SELECT
+ openedx_course_enrollments.course_id AS course_id,
+ openedx_course_enrollments.created AS enrollment_created,
+ openedx_course_enrollments.is_active AS enrollment_is_active,
+ openedx_course_enrollments.mode AS enrollment_mode,
+ openedx_course_enrollments.user_id AS user_id,
+ openedx_users.username AS username,
+ openedx_users.email AS user_email,
+ openedx_user_profiles.year_of_birth AS user_year_of_birth,
+ openedx_user_profiles.gender AS user_gender,
+ openedx_user_profiles.level_of_education AS user_level_of_education,
+ openedx_user_profiles.city AS user_city,
+ openedx_user_profiles.state AS user_state,
+ openedx_user_profiles.country AS user_country
+FROM openedx_course_enrollments
+INNER JOIN openedx_user_profiles ON openedx_course_enrollments.user_id = openedx_user_profiles.user_id
+INNER JOIN openedx_users ON openedx_course_enrollments.user_id = openedx_users.id;
diff --git a/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0013_modify_course_block_completion.sql b/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0013_modify_course_block_completion.sql
new file mode 100644
index 0000000..523530b
--- /dev/null
+++ b/tutorcairn/templates/cairn/apps/clickhouse/migrations.d/0013_modify_course_block_completion.sql
@@ -0,0 +1,15 @@
+RENAME TABLE _openedx_block_completion TO openedx_block_completion;
+
+DROP TABLE course_block_completion;
+
+CREATE VIEW course_block_completion AS
+SELECT
+ openedx_block_completion.course_key AS course_id,
+ openedx_block_completion.block_key AS block_key,
+ openedx_block_completion.user_id AS user_id,
+ openedx_block_completion.completion AS completion,
+ course_blocks.position as position,
+ course_blocks.display_name as display_name,
+ course_blocks.full_name as full_name
+FROM openedx_block_completion
+INNER JOIN course_blocks ON openedx_block_completion.block_key = course_blocks.block_key;
diff --git a/tutorcairn/templates/cairn/apps/superset/superset_config.py b/tutorcairn/templates/cairn/apps/superset/superset_config.py
index 1aa11d6..27e4df0 100644
--- a/tutorcairn/templates/cairn/apps/superset/superset_config.py
+++ b/tutorcairn/templates/cairn/apps/superset/superset_config.py
@@ -41,6 +41,7 @@ available_languages = {
"ru": {"flag": "ru", "name": "Russian"},
"sk": {"flag": "sk", "name": "Slovak"},
"sl": {"flag": "si", "name": "Slovenian"},
+ "uk": {"flag": "uk", "name": "Ukranian"},
"zh": {"flag": "cn", "name": "Chinese"},
}
{#- https://github.com/apache/superset/blob/master/docs/docs/contributing/translations.mdx#enabling-language-selection #}
diff --git a/tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile b/tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile
index 32af310..ab8edf9 100644
--- a/tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile
+++ b/tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile
@@ -1,11 +1,6 @@
-# https://hub.docker.com/r/yandex/clickhouse-server/tags
-FROM docker.io/yandex/clickhouse-server:22.1.3.7
+# https://hub.docker.com/r/clickhouse/clickhouse-server/tags
+FROM docker.io/clickhouse/clickhouse-server:24.1.8.22
-# The clickhouse repo is currently unavailable in some parts of the world. If we don't
-# remove this repo here then `apt update` will fail. Check if the problem is resolved with:
-# curl https://repo.yandex.ru/clickhouse/deb/stable/
-# The above command should be a 200, and not a 404.
-RUN rm /etc/apt/sources.list.d/clickhouse.list
RUN apt update && apt install -y python3
COPY ./scripts /scripts
RUN chmod a+x /scripts/*
diff --git a/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile b/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile
index dc5efaa..9ec0368 100644
--- a/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile
+++ b/tutorcairn/templates/cairn/build/cairn-superset/Dockerfile
@@ -3,7 +3,7 @@
# https://github.com/apache/superset/releases
# https://github.com/apache/superset/blob/master/Dockerfile
# https://superset.apache.org/docs/databases/installing-database-drivers
-FROM docker.io/apache/superset:3.0.1
+FROM docker.io/apache/superset:4.0.0
USER root
@@ -18,11 +18,11 @@ RUN apt-get update \
pkg-config
RUN --mount=type=cache,target=/root/.cache/pip,sharing=shared pip install \
- clickhouse-driver==0.2.6 \
- mysqlclient==2.2.0 \
- clickhouse-connect==0.6.20 \
+ clickhouse-driver==0.2.7 \
+ mysqlclient==2.2.4 \
+ clickhouse-connect==0.7.8 \
clickhouse-sqlalchemy==0.2.4 \
- authlib==1.2.1
+ authlib==1.3.0
USER superset
diff --git a/tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py b/tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py
index 25ba62f..65354c0 100644
--- a/tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py
+++ b/tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py
@@ -88,7 +88,8 @@ def create_superset_db_role(role_name: str, superset_database_name: str) -> None
return False
# Create or update role with the same name as the user
- security_manager.set_role(role_name, check_permission)
+ pvms = security_manager._get_all_pvms()
+ security_manager.set_role(role_name, check_permission, pvms)
def create_clickhouse_user(clickhouse_username):
@@ -117,11 +118,17 @@ def grant_clickhouse_row_based_access(clickhouse_username, course_ids=None):
for table in make_clickhouse_query("SHOW TABLES").split("\n"):
if not table.startswith("_"):
make_clickhouse_query(
- f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
- )
- make_clickhouse_query(
- f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
- )
+ f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
+ )
+
+ if table in ["openedx_users", "openedx_user_profiles", "openedx_block_completion"]:
+ make_clickhouse_query(
+ f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING 1 TO '{clickhouse_username}';"""
+ )
+ else:
+ make_clickhouse_query(
+ f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
+ )
def make_clickhouse_query(query):
diff --git a/tutorcairn/templates/cairn/build/cairn-superset/cairn/ctl.py b/tutorcairn/templates/cairn/build/cairn-superset/cairn/ctl.py
index ce8bd0b..4f5bf48 100644
--- a/tutorcairn/templates/cairn/build/cairn-superset/cairn/ctl.py
+++ b/tutorcairn/templates/cairn/build/cairn-superset/cairn/ctl.py
@@ -13,7 +13,7 @@ from superset.connectors.sqla.models import SqlaTable
from superset.models.core import Database
from superset.models.slice import Slice
from superset.extensions import db, security_manager
-import superset.dashboards.commands.importers.v0 as importers
+import superset.commands.dashboard.importers.v0 as importers
from werkzeug.security import generate_password_hash
# Our convenient library