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

Do not depend un unzip being available/having the expected interface #1

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9b33ed6
Do not depend un `unzip` being available/having the expected interface
silviot Dec 3, 2019
8e141e3
Make tests run again
chiruzzimarco Jun 30, 2020
823ef9d
Run pre-commit hooks
chiruzzimarco Jun 30, 2020
760bb36
Restructure repository
chiruzzimarco Jul 2, 2020
6644d8a
Load scorm package from course files feature
chiruzzimarco Jul 3, 2020
974f339
Add ScormXBlock plugin to proxy MinIO files to avoid SAMEORIGIN issues
chiruzzimarco Jul 13, 2020
4c1abd2
Update scom_file field help text
chiruzzimarco Jul 13, 2020
1e9a30e
Code refactor
chiruzzimarco Aug 6, 2020
5110a9d
Update README
chiruzzimarco Aug 6, 2020
55518db
Rename package to abstract_scorm_xblock
chiruzzimarco Aug 13, 2020
891647e
Readability improvements and minor fixes
chiruzzimarco Aug 13, 2020
523ba87
Prevent XBlock from breaking if no valid SCORM package is loaded
chiruzzimarco Aug 13, 2020
2c216fe
Perform asynchrous AJAX calls when calling GetValue and SetValue LMS …
chiruzzimarco Aug 13, 2020
37615ae
Specifcy SettingsType.PRODUCTION compatible with Ironwood and Juniper…
chiruzzimarco Aug 13, 2020
667912c
Run pre-commit hooks
chiruzzimarco Aug 13, 2020
4246155
Improve README
chiruzzimarco Aug 13, 2020
b40e611
Install in editable mode togheter with test requirements
chiruzzimarco Aug 13, 2020
5459200
Use synchronous AJAX calls for LMSGetValue
chiruzzimarco Aug 13, 2020
03e1ffb
Use Enum object to handle SCORM versions
chiruzzimarco Aug 13, 2020
3372462
Fix canned scenario
chiruzzimarco Aug 13, 2020
9908ee4
Start fixing tests
chiruzzimarco Aug 13, 2020
66f3c01
Remove freezegun
chiruzzimarco Aug 13, 2020
300fc82
Expand README a bit
silviot Aug 14, 2020
45e224d
Fix tests
silviot Aug 14, 2020
900adec
Fix tests
chiruzzimarco Aug 14, 2020
1582d8d
Update README
chiruzzimarco Aug 14, 2020
c3e4b4d
Merge pull request #2 from Abstract-Tech/feature/upload-to-contentstore
chiruzzimarco Aug 14, 2020
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout python3
42 changes: 42 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements_dev.txt
- name: Run pre-commit hooks
run: |
pre-commit run -a
- name: Setup derex project
run: |
cd derex_project
ddc-services up -d
derex mysql reset --force
derex reset-rabbitmq
# We can't use `derex create-bucket` because github CI doesn't allocate a TTY
docker run --rm --network derex --entrypoint /bin/sh minio/mc -c 'mc config host add local http://minio:80 minio_derex "ICDTE0ZnlbIR7r6/qE81nkF7Kshc2gXYv6fJR4I/HKPeTbxEeB3nxC85Ne6C844hEaaC2+KHBRIOzGou9leulZ7t" --api s3v4; set -ex; mc mb --ignore-existing local/scorm; mc policy set download local/scorm/profile-images'
derex build final
- name: Run tests
run: |
cd derex_project
ddc-project run --rm lms python manage.py lms test abstract_scorm_xblock --keepdb
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ docs/_build/
# PyBuilder
target/

#Ipython Notebook
# Ipython Notebook
.ipynb_checkpoints

# Virtualenvs
.direnv
.venv

# Text editors configuration files
.vscode

# Derex files
*.derex
derex_project/settings/derex
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
- id: check-yaml
- id: flake8
args:
- --max-line-length=88
- --select=C,E,F,W,B,B950
- --ignore=E203,E501,W503,W504

- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black

- repo: https://github.com/prettier/prettier
rev: "2.0.1"
hooks:
- id: prettier
exclude: static/html/*
95 changes: 61 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,74 @@
THIS FORK HAS:
===
* merged branch with opening SCORM in popup
* plenty of popup options (open at start, show "open inline" button)
* isolated APIs for multiple xblocks - you can have more than one SCORM package in one vertical, and scores are calculated as they should

THIS FORK STILL DOESN'T HAVE:
===
* proper deleting zip & unzipped content on ~~package replacing and~~ xblock deletion
* localization working as it should

edx_xblock_scorm
=========================
XBlock to display SCORM content within the Open edX LMS. Editable within Open edx Studio. Will save student state and report scores to the progress tab of the course.
Currently supports SCORM 1.2 and SCORM 2004 standard.
# Abstract Scorm XBlock

Block displays SCORM which saved as `File -> Export -> Web Site -> Zip File`
Yet another SCORM XBlock for Open edX®.

Block displays SCORM which saved as `File -> Export -> SCORM 1.2`
Supports course export/import. Editable within Open edx Studio. Saves student state and reports scores to the progress tab of the course.
Currently supports SCORM 1.2 and SCORM 2004 standards.

Developed by [Abstract Technology](https://abstract-technology.de/), based on [edx_xblock_scorm](https://github.com/raccoongang/edx_xblock_scorm/) by [Raccoon Gang
](https://raccoongang.com/).

Block displays SCORM which saved as `File -> Export -> Web Site -> Zip File`
Block displays SCORM which saved as `File -> Export -> SCORM 1.2`

Installation
------------
## Installation

Install package

pip install -e git+https://github.com/raccoongang/edx_xblock_scorm.git#egg=edx_xblock_scorm
pip install git+https://github.com/Abstract-Tech/abstract-scorm-xblock.git#egg=abstract_scorm_xblock&subdirectory=abstract_scorm_xblock

**WARNING: This package have to be installed using the `subdirectory` option.**

## Usage

- Add `abstract_scorm_xblock` to the list of advanced modules in the advanced settings of a course.
- Add a `scorm` component to your Unit.
- Upload a zip file containing your content package. **The `imsmanifest.xml` file must be at the root of the zipped package. Make sure you don't have an additional directory at the root of the Zip archive.**
- Publish your content as usual.

## Development

### Setup

To setup the development environment:

- create a Python3 virtualenv. If direnv is installed a `direnv allow` should be enough.
- install derex with `pip install -r requirements.txt`
- setup the derex project. Read https://derex.page/quickstart.html#quickstart for further informations.

### Development and Debugging

In order to be able to develop and debug effectively some steps may be taken:

- get a shell inside the container:

```
cd derex_project
ddc-project exec cms sh
```

- setup the package in editable mode. This will allow for testing changes without the need to reinstall the package:

`pip install -e /openedx/derex.requirements/abstract_scorm_xblock`

- launch the Django debug server manually and bind it on port `81`:

`python manage.py cms runserver 0:81`

- on your browser https://studio.scorm.localhost:81 should now be available. You should now be able to insert debug code in both Python and JS files and benefit from Django runserver auto reload feature.

### Running tests

Tests can be run from the derex project directory by running:

Note: for OpenEdx releases prior ginkgo add required variables to CMS configuration ```<edx-platform-path>/cms/envs/aws.py```:
`ddc-project run --rm lms python manage.py lms test abstract_scorm_xblock --keepdb`

```
MEDIA_ROOT = ENV_TOKENS.get('MEDIA_ROOT', '/edx/var/edxapp/media/')
MEDIA_URL = ENV_TOKENS.get('MEDIA_URL', '/media/')
```
The first time this command is run it will initialize the test database. Remove the `--keepdb` flag if you want the test database to be created/destroyed each time.

# Usage
* Add `scormxblock` to the list of advanced modules in the advanced settings of a course.
* Add a `scorm` component to your Unit.
* Upload a zip file containint your content package. The `imsmanifest.xml` file must be at the root of the zipped package (i.e., make sure you don't have an additional directory at the root of the Zip archive which can handle if e.g., you select an entire folder and use Mac OS X's compress feature).
* Publish your content as usual.
## Caveats

Testing
-------
- If a SCORM package is deleted from the course "Files & Uploads" section, the Import/Export functionality will export a course with a broken XBlock.

Assuming `scormxblock` is installed as above, you can run tests like so:
## TODO

$ paver test_system -s lms -t scormxblock
- Delete extracted old SCORM packages from default storage
7 changes: 7 additions & 0 deletions abstract_scorm_xblock/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include LICENSE
include README.rst

recursive-include abstract_scorm_xblock *

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
Empty file.
47 changes: 47 additions & 0 deletions abstract_scorm_xblock/abstract_scorm_xblock/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
from openedx.core.djangoapps.plugins.constants import PluginSettings
from openedx.core.djangoapps.plugins.constants import PluginURLs
from openedx.core.djangoapps.plugins.constants import ProjectType
from openedx.core.djangoapps.plugins.constants import SettingsType


class AbstractScormXBlockAppConfig(AppConfig):
name = "abstract_scorm_xblock"
plugin_app = {
PluginURLs.CONFIG: {
ProjectType.LMS: {
PluginURLs.NAMESPACE: "abstract_scorm_xblock",
PluginURLs.REGEX: "abstract_scorm_xblock/",
PluginURLs.RELATIVE_PATH: "views",
},
ProjectType.CMS: {
PluginURLs.NAMESPACE: "abstract_scorm_xblock",
PluginURLs.REGEX: "abstract_scorm_xblock/",
PluginURLs.RELATIVE_PATH: "views",
},
},
PluginSettings.CONFIG: {
ProjectType.LMS: {
SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.TEST: {PluginSettings.RELATIVE_PATH: "app"},
},
ProjectType.CMS: {
SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.DEVSTACK: {PluginSettings.RELATIVE_PATH: "app"},
SettingsType.TEST: {PluginSettings.RELATIVE_PATH: "app"},
},
},
}


def plugin_settings(settings):
if not getattr(settings, "STORAGE_SCORM_PATH", None):
# This is used to build the path to the location where the
# SCORM packages are extracted into the default storage
# e.g. /scorm_packages/09c1735eaa57d78fe245868f0e07cf7b/index_lms.html
settings.STORAGE_SCORM_PATH = "scorm_packages"
29 changes: 29 additions & 0 deletions abstract_scorm_xblock/abstract_scorm_xblock/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from enum import Enum


ORDERED_VERSIONS = [
"SCORM_12",
"SCORM_2004_2_EDITION",
"SCORM_2004_3_EDITION",
"SCORM_2004_4_EDITION",
]


class ScormVersions(Enum):
"""
List SCORM versions which can be found in supported manifest templates.
Reference templates can be found at https://scorm.com/scorm-explained/technical-scorm/content-packaging/xml-schema-definition-files/
"""

SCORM_12 = "1.2"
SCORM_2004_2_EDITION = "CAM 1.3"
SCORM_2004_3_EDITION = "2004 3rd Edition"
SCORM_2004_4_EDITION = "2004 4th Edition"

def __lt__(self, other):
assert isinstance(other, self.__class__)
return ORDERED_VERSIONS.index(self.name) < ORDERED_VERSIONS.index(other.name)

def __gt__(self, other):
assert isinstance(other, self.__class__)
return ORDERED_VERSIONS.index(self.name) > ORDERED_VERSIONS.index(other.name)
6 changes: 6 additions & 0 deletions abstract_scorm_xblock/abstract_scorm_xblock/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class ScormPackageNotFoundException(Exception):
pass


class ScormManifestNotFoundException(Exception):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ msgstr "Altura del iframe"
#: static/html/author_view.html:3
msgid "Look in LMS"
msgstr "Ver en LMS"

Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ msgid "Allow open in place"
msgstr "Otwarcie w miejscu"

msgid "Show button for opening not-in-popup."
msgstr "Pokaż przycisk pozwalający na otwarcie nie-w-popupie."
msgstr "Pokaż przycisk pozwalający na otwarcie nie-w-popupie."
Loading