Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
feat: upgrade to redwood and add deprecation notice (#23)
Browse files Browse the repository at this point in the history
upgrade to redwood, add deprecation notice, migrate to github actions, remove python 2.7 support and remove test workflow

The tests depend on xblock-utils package which depends on some workbench
module that does not exists. Since the repository is planned to be
deprecated until we get real users, we don't want to spend time fixing
it.
  • Loading branch information
navinkarkera authored Jun 17, 2024
1 parent 0b931ae commit 952c160
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 89 deletions.
56 changes: 0 additions & 56 deletions .circleci/config.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python quality

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

jobs:
check_quality:
name: Quality
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
python-version: ['3.8', '3.11']
steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install dependencies
run: pip install tox

- name: Check Quality
run: tox -e quality
1 change: 0 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ disable=
I,
attribute-defined-outside-init,
maybe-no-member,
star-args,
too-few-public-methods,
too-many-ancestors,
too-many-instance-attributes,
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-e git+https://github.com/edx/XBlock.git#egg=XBlock
git+https://github.com/edx/xblock-utils.git#egg=xblock-utils
-e git+https://github.com/openedx/XBlock.git#egg=XBlock
git+https://github.com/openedx/xblock-utils.git#egg=xblock-utils
-e .
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Setup for vectordraw XBlock."""

from __future__ import absolute_import

import os

from setuptools import setup


Expand All @@ -27,9 +27,8 @@ def package_data(pkg, roots):
version='0.4.0',
description='vectordraw XBlock', # TODO: write a better description.
url='https://github.com/open-craft/xblock-vectordraw',
license = 'AGPLv3',
license='AGPLv3',
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'License :: OSI Approved :: GNU Affero General Public License v3',
],
Expand Down
5 changes: 2 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Django>=1.8, <2.0; python_version == '2.7'
Django>=2.2, <3.3; python_version > '2.7'
Django>=3.2, <3.3

-r requirements.txt

-e git+https://github.com/edx/xblock-sdk.git#egg=xblock-sdk
-e git+https://github.com/openedx/xblock-sdk.git#egg=xblock-sdk

ddt
pycodestyle
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[tox]
envlist = py{36,38}-django{22,32}
envlist = py{38}-django{32}

[pycodestyle]
exclude = .git,.tox
max-line-length = 100

[testenv]
deps =
django22: Django>=2.2,<2.3
django32: Django>=3.2,<3.3
-rtest-requirements.txt
commands =
Expand Down
9 changes: 3 additions & 6 deletions vectordraw/grader.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,7 @@ def grade(self, answer):
Short-circuit as soon as a single check fails.
"""
check_data = dict(
vectors=self._get_vectors(answer),
points=self._get_points(answer),
)
check_data = {'vectors': self._get_vectors(answer), 'points': self._get_points(answer)}
for check in answer['checks']:
# pylint: disable=deprecated-method
check_data['check'] = check
Expand All @@ -385,7 +382,7 @@ def grade(self, answer):
return {'correct': False, 'msg': msg}
return {'correct': True, 'msg': self.success_message}

def _get_vectors(self, answer): # pylint: disable=no-self-use
def _get_vectors(self, answer):
"""
Turn vector info in `answer` into a dictionary of Vector objects.
"""
Expand All @@ -396,7 +393,7 @@ def _get_vectors(self, answer): # pylint: disable=no-self-use
vectors[name] = Vector(name, tail[0], tail[1], tip[0], tip[1])
return vectors

def _get_points(self, answer): # pylint: disable=no-self-use
def _get_points(self, answer):
"""
Turn point info in `answer` into a dictionary of Point objects.
"""
Expand Down
7 changes: 7 additions & 0 deletions vectordraw/templates/html/vectordraw.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% load i18n %}
<div class="vectordraw_block">
<div class="page-banner mb-4">
<div class="alert alert-warning d-flex" role="alert">
<span class="icon icon-alert fa fa fa-warning" aria-hidden="true"></span>
{% trans "Note: The vector draw component is no longer maintained and will soon stop working. If you are a course author who relies on this, please contact OpenCraft to discuss options." %}
</div>
</div>


<h2>{{ self.display_name }}</h2>

Expand Down
25 changes: 9 additions & 16 deletions vectordraw/vectordraw.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""An XBlock that allows course authors to define vector drawing exercises."""

from __future__ import absolute_import

import json
import logging

import six
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.exceptions import JsonHandlerError
from xblock.fields import Scope, Boolean, Dict, Float, Integer, String
from xblock.fragment import Fragment
from xblock.fields import Boolean, Dict, Float, Integer, Scope, String
from xblock.validation import ValidationMessage
from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin
Expand All @@ -23,7 +22,6 @@
from .grader import Grader
from .utils import get_doc_link


loader = ResourceLoader(__name__) # pylint: disable=invalid-name

log = logging.getLogger(__name__) # pylint: disable=invalid-name
Expand Down Expand Up @@ -275,7 +273,7 @@ def settings(self):
"""
width_scale = self.width / float(self.height)
box_size = self.bounding_box_size
bounding_box = [-box_size*width_scale, box_size, box_size*width_scale, -box_size]
bounding_box = [-box_size * width_scale, box_size, box_size * width_scale, -box_size]
return {
'width': self.width,
'height': self.height,
Expand Down Expand Up @@ -315,7 +313,7 @@ def background(self):
'description': self.background_description,
}

def _get_default_vector(self): # pylint: disable=no-self-use
def _get_default_vector(self):
"""
Return dictionary that represents vector with default values filled in.
"""
Expand Down Expand Up @@ -352,7 +350,7 @@ def get_vectors(self):
vectors.append(default_vector)
return vectors

def _get_default_point(self): # pylint: disable=no-self-use
def _get_default_point(self):
"""
Return dictionary that represents point with default values filled in.
"""
Expand Down Expand Up @@ -495,7 +493,7 @@ def add_error(msg):
"that would allow anyone to solve the problem if the image did not load."
)

def _validate_check_answer_data(self, data): # pylint: disable=no-self-use
def _validate_check_answer_data(self, data):
"""
Validate answer data submitted by user.
"""
Expand Down Expand Up @@ -539,21 +537,16 @@ def check_answer(self, data, suffix=''): # pylint: disable=unused-argument
except ValueError as error:
raise JsonHandlerError(400, "Invalid data") from error
# Save answer
self.answer = dict(
vectors=data["vectors"],
points=data["points"]
)
self.answer = {'vectors': data["vectors"], 'points': data["points"]}
# Compute result
grader = Grader()
result = grader.grade(data)
# Save result
self.result = result
# Publish grade data
score = 1 if result["correct"] else 0
self.runtime.publish(self, 'grade', dict(value=score, max_value=1))
return {
"result": result,
}
self.runtime.publish(self, 'grade', {"value": score, "max_value": 1})
return {"result": result}

@staticmethod
def workbench_scenarios():
Expand Down

0 comments on commit 952c160

Please sign in to comment.