Skip to content

Commit

Permalink
E0d/makefile improvements (#45)
Browse files Browse the repository at this point in the history
* fix: adding pylint support

* fix: standard requirements files

* fix: patterned on lti xb, work around pip bug

* fix: support for standard make targets

* fix: modeled on lti xb, standard targets

* fix: adding new in files to upgrade

* fix: adding standard translation targets

* fix: quality

* fix: unused import

* fix: irrelevant disable

* fix: adding a specific req file for quality

* fix: adding a basic tox file

* fix: adding a manifest

* fix: adding a NOTICE file

* fix: also upgrade quality requirements

* fix: removing Django 4 for now

* fix: adding ci

* fix: adding ci related requirements

* fix: processing new requirements

* fix: update requirements

* fix: simplified test entry

* fix: install pytest in the venv

* fix: make upgrade

* fix: pointless test to exercise the harness

* fix: making module

* fix: quality

* fix: adding CI badge

* fix: use a title

* fix: iterate toward README standard

* fix: coverage config

* fix: unmix md and rst

* fix: mixed up link

* fix: changing to RST

* fix: more conversion fixes

* fix: more syntax

* fix: more syntax

* fix: ffs

* fix: rst syntax

* fix: so fiddly

* fix: so fiddly

* fix: more fiddles

* fix: images

Co-authored-by: Edward Zarecor <ed@tcril.org>
  • Loading branch information
e0d and Edward Zarecor authored Jun 17, 2022
1 parent 57528d3 commit a878c17
Show file tree
Hide file tree
Showing 30 changed files with 1,696 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .coveragerc for xblock-lti-consumer
[run]
data_file = .coverage
source = done
omit = */urls.py
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Python CI

on:
push:
branches: [master]
pull_request:
branches:
- '**'

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [py38-django32, quality]

steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run Coverage
if: matrix.python-version == '3.8' && matrix.toxenv=='py38-django32'
uses: codecov/codecov-action@v1
with:
flags: unittests
fail_ci_if_error: true

4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include requirements/base.in
include NOTICE
include LICENSE
include requirements/constraints.txt
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
install-test:
pip install -q -r requirements/test.txt

install-dev:
pip install -q -r requirements/dev.txt

install: install-test

quality: ## Run the quality checks
pycodestyle --config=.pep8 done
pylint --rcfile=pylintrc done
python setup.py -q sdist
twine check dist/*

test: ## Run the tests
mkdir -p var
rm -rf .coverage
python -m coverage run --rcfile=.coveragerc -m pytest

covreport: ## Show the coverage results
python -m coverage report -m --skip-covered

COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
Expand All @@ -6,5 +28,40 @@ $(COMMON_CONSTRAINTS_TXT):
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -q -r requirements/pip_tools.txt
pip-compile --upgrade --allow-unsafe -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/dev.txt requirements/dev.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
pip-compile --upgrade -o requirements/quality.txt requirements/quality.in
pip-compile --upgrade -o requirements/tox.txt requirements/tox.in
pip-compile --upgrade -o requirements/ci.txt requirements/ci.in

## Localization targets

WORKING_DIR := done
EXTRACT_DIR := $(WORKING_DIR)/translations/en/LC_MESSAGES
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po

extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT)
tail -n +20 $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT)
rm $(EXTRACTED_DJANGOJS)
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_TEXT)
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_TEXT)

compile_translations: ## compile translation files, outputting .mo files for each supported language
cd $(WORKING_DIR) && i18n_tool generate

detect_changed_source_translations:
cd $(WORKING_DIR) && i18n_tool changed

dummy_translations: ## generate dummy translation (.po) files
cd $(WORKING_DIR) && i18n_tool dummy

build_dummy_translations: dummy_translations compile_translations ## generate and compile dummy translation files

validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations
16 changes: 16 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Open edX Done XBlock

Copyright (C) 2015-2022, The Center for Reimagining Learning

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
28 changes: 0 additions & 28 deletions README.md

This file was deleted.

93 changes: 93 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
##########
DoneXBlock
##########
| |License: AGPL v3| |Python CI| |Publish package to PyPi|
.. |License: AGPL v3| image:: https://img.shields.io/badge/License-AGPL_v3-blue.svg
:target: https://www.gnu.org/licenses/agpl-3.0

.. |Python CI| image:: https://github.com/openedx/DoneXBlock/actions/workflows/ci.yml/badge.svg
:target: https://github.com/openedx/DoneXBlock/actions/workflows/ci.yml

.. |Publish package to PyPi| image:: https://github.com/openedx/DoneXBlock/actions/workflows/pypi-release.yml/badge.svg
:target: https://github.com/openedx/DoneXBlock/actions/workflows/pypi-release.yml

Purpose
=======

Lets a student mark they've finished an activity. The student can
click through two states of the XBlock, shown below:

| |mark|
| |undo|
.. |mark| image:: completionxblock_mark.png
.. |undo| image:: completionxblock_undo.png

Status
======

Maintained

Getting Help
============

If you're having trouble, we have discussion forums at https://discuss.openedx.org where you can connect with others in the community.

Our real-time conversations are on Slack. You can request a `Slack invitation`_, then join our `community Slack workspace`_.

For more information about these options, see the `Getting Help`_ page.

.. _Slack invitation: https://openedx-slack-invite.herokuapp.com/
.. _community Slack workspace: https://openedx.slack.com/
.. _Getting Help: https://openedx.org/getting-help


How to Contribute
=================

Details about how to become a contributor to the Open edX project may
be found in the wiki at `How to contribute`_

.. _How to contribute: https://openedx.atlassian.net/wiki/spaces/COMM/pages/941457737/How+to+start+contributing+to+the+Open+edX+code+base

The Open edX Code of Conduct
----------------------------

All community members should familarize themselves with the `Open edX Code of Conduct`_.

.. _Open edX Code of Conduct: https://openedx.org/code-of-conduct/

People
======

The assigned maintainers for this component and other project details
may be found in `Backstage`_ or groked from inspecting catalog-info.yaml.

.. _Backstage: https://open-edx-backstage.herokuapp.com/catalog/default/component/DoneXBlock,

Reporting Security Issues
=========================

Please do not report security issues in public. Please email security@edx.org.


History
=======

FutureLearn uses this kind of thing to great effect. Students can read
text, watch videos, etc., and indicate when their done. This is
convenient both for progress indication to the student (know what
they've done, and for honor code grading (indicating to us that they
believe they've finished an activity).

I copied some of the UX patterns from FutureLearn so that users of
both platforms would have consistency of user experience between
MOOCs. I didn't copy them exactly since I wanted to be unambiguously
in the clear with IP issues around look-and-feel, and this was on a short
anough timeline that I did not have a chance to reach out to
FutureLearn for permission. As a footnote, this kind of collaboration
between MOOC providers is probably worth pursuing -- it'd be to the
benefit of learners on all platforms, and ultimately, the industry as
a whole if we had consistency of experience between platforms where
convenient.
4 changes: 4 additions & 0 deletions done/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Runtime will load the XBlock class from here.
"""

from .done import DoneXBlock

__version__ = '2.0.4'
4 changes: 1 addition & 3 deletions done/done.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import uuid

import six

import pkg_resources
from xblock.core import XBlock
from xblock.fields import Boolean, DateTime, Float, Scope, String
Expand Down Expand Up @@ -80,7 +78,7 @@ def student_view(self, context=None): # pylint: disable=unused-argument
'align': self.align.lower()})
return frag

def studio_view(self, _context=None): # pylint: disable=unused-argument
def studio_view(self, _context=None):
'''
Minimal view with no configuration options giving some help text.
'''
Expand Down
3 changes: 3 additions & 0 deletions done/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Module containing tests for DoneXBlock
"""
8 changes: 8 additions & 0 deletions done/tests/test_nothing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Tests for the DoneXBlock
"""


# Adding a pointless test to exercise CI as this project has not current tests
def test_always_passes():
assert True
Loading

0 comments on commit a878c17

Please sign in to comment.