Canvas LMS集成Analysis插件

2022-04-24 14:29:09 浏览数 (1)

Canvas LMS:https://github.com/instructure/canvas-lms Canvas Analytics 1.0:https://github.com/instructure/analytics

Canvas官方Production Start安装的平台并不包括分析模块,在Canvas开源库中看到了Canvas Analytics ,集成过程如下。

1. 安装依赖

1.1 因Cassandra依赖jdk和pyhon,服务器环境为Ubuntu 16.04,此处只安装了jdk1.8.
代码语言:javascript复制
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-set-default
java -version

python请自行安装,3.X版本没有尝试。

1.2 安装Cassandra

参考官方文档,安装最新版:http://cassandra.apache.org/download/

代码语言:javascript复制
echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
sudo apt-get update
sudo apt-get install cassandra
nodetool status

注:如刚安装好cassandra执行nodetool status提示连接被拒绝,可稍等一两分钟再执行,可查看已经启动。 默认安装后没有监听9160端口,canvas中无法获取数据!!/etc/cassandra/cassandra.yaml文件末尾增加一行start_rpc: true,然后重启sudo service cassandra restart 参考: 安装Cassandra:https://www.liquidweb.com/kb/install-cassandra-ubuntu-16-04-lts/ Cassandra db:migrate fail: https://github.com/instructure/canvas-lms/issues/1072

2. 创建表空间

run cqlsh

代码语言:javascript复制
CREATE KEYSPACE page_views WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE KEYSPACE page_views_test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE KEYSPACE auditors WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE KEYSPACE auditors_test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };

拷贝config/cassandra.yml.example到cassandra.yml 配置文件,取消注释 cd /var/canvas cp config/cassandra.yml.example cassandra.yml vi config/cassandra.yml

代码语言:javascript复制
 production:
   page_views:
     servers:
     - 127.0.0.1:9160
     keyspace: page_views
   auditors:
     servers:
     - 127.0.0.1:9160
     keyspace: auditors
 test:
   page_views:
     servers:
     - 127.0.0.1:9160
     keyspace: page_views_test
   auditors:
     servers:
     - 127.0.0.1:9160
     keyspace: auditors_test

注:官方配置文件没有production,手动将development或者test改为production吧。 模板配置文件如下:https://github.com/instructure/canvas-lms/blob/stable/config/cassandra.yml.example

3. 克隆analytics及编译Canvas

依次执行以下命令

代码语言:javascript复制
cd /var/canvas
git clone https://github.com/instructure/analytics.git gems/plugins/analytics
bundle update
 RAILS_ENV=production bundle exec rake db:migrate
sudo su canvas -c "env GEM_HOME=/var/canvas/gems  RAILS_ENV=production script/rails console" 
Setting.set('enable_page_views', 'cassandra')
RAILS_ENV=production bundle exec rake canvas:compile_assets
RAILS_ENV=production bundle exec rake db:migrate_pageviews_to_cassandra 

第5行:进入rails控制台,自己从网上找的命令进入的,script目录下没有console… 其中第一个canvas为服务器用户名,/var/canvas/gems为canvas安装目录下的gems文件夹位置 。 第6行:执行第5行之后,会进入rails控制台,然后输入Setting…带命令完成后输入exit

4. 大功告成,重启服务
代码语言:javascript复制
sudo /etc/init.d/canvas_init restart
sudo /etc/init.d/apache2 restart
script/delayed_job restart

注:sudo /etc/init.d/canvas_init restart 之后执行sudo /etc/init.d/canvas_init status发现提示No delayed jobs pool running 个别数据会出现一直加载中,访问https://your_domain/jobsprocess表显示很多任务没有执行,意识到job没有启动,又使用sudo /etc/init.d/canvas_init start启动,再次运行sudo /etc/init.d/canvas_init status看到Delayed jobs running, pool PID: 31693方可

进入管理员设置中,打开Analytics功能

在管理员设置中会出现你分析菜单,发布的课程右侧出现查看课程分析

效果如下

0 人点赞