Giter Site home page Giter Site logo

openedx / xblock Goto Github PK

View Code? Open in Web Editor NEW
450.0 186.0 216.0 3.36 MB

Framework for building custom learning components that run in the Open edX LMS!

Home Page: https://edx.readthedocs.io/projects/xblock-tutorial/en/latest/overview/introduction.html

License: Apache License 2.0

Makefile 0.50% Python 95.86% JavaScript 2.21% HTML 1.44%

xblock's Introduction

XBlock

PyPI CI Codecov Documentation Supported Python versions License Repo is maintained.

Purpose

XBlock is the Open edX component architecture for building courseware.

This repo contains the core code for implementing XBlocks. Open edX courseware is built out of components that are combined hierarchically. These include components like the video player, LON-CAPA problems, as well as compound components like learning sequences. The API for these components is called XBlocks.

How does this differ from existing industry standards like Learning Tools Interoperability (LTI) and SCORM? On a high level, XBlocks is a Python language-level API, and it provides sensible defaults for things like storing data. XBlocks could be wrapped up in LTI, and one could make an LTI XBlock. The core reason to write an XBlock is that it is deployable. You can give us the code to an XBlock, and we can embed it in our courseware. LTI would require you to give us a virtual machine image which ran it.

Getting Started

Developing

One Time Setup

# Clone the repository
git clone [email protected]:openedx/XBlock.git
cd XBlock

# Set up a virtualenv using virtualenvwrapper with the same name as the repo and activate it
mkvirtualenv -p python3.8 XBlock

Every time you develop something in this repo

# Activate the virtualenv
workon XBlock

# Grab the latest code
git checkout main
git pull

# Install/update the dev requirements
make requirements

# Run the tests and quality checks (to verify the status before you make any changes)
make validate

# Make a new branch for your changes
git checkout -b <your_github_username>/<short_description>

# Using your favorite editor, edit the code to make your change.
vim ...

# Run your new tests
pytest ./path/to/new/tests

# Run all the tests and quality checks
make validate

# Commit all your changes
git commit ...
git push

# Open a PR and ask for review.

Deploying

To package a new release:

  1. Describe the release in CHANGELOG.rst
  2. Update the version number in xblock/VERSION.txt.
  3. Use the github release mechanism to release a new version. This will tag and publish the package.

Using the XBlock-SDK

The XBlock-SDK exists in a separate repository. The SDK contains useful tools for developing your own XBlocks, such as a template XBlock generator, sample XBlocks that demonstrate XBlock functionality.

You can find it in its own repository: https://github.com/openedx/xblock-sdk

Getting Help

Documentation

The docs for the XBlock API is on Read The Docs: https://xblock.readthedocs.org .

Reading the code

There are distinct layers to this code. In the docstrings, we've tried to make clear which layer the code lives in, though sometimes the lines are blurred:

  1. XBlock The sample XBlock code. This is the most important, it is the code that most third parties will be writing, and demonstrates the XBlock interfaces.
  2. Runtime The runtime code that we think will be common to all runtimes. This is the behind-the-scenes code edX will write to make XBlocks work. This layer may not be real code here, but we'll need to write real code to perform these functions.

Making your own XBlock

Making an XBlock can be as simple as creating a Python class with a few specific methods.

Instructions for constructing a new XBlock along with examples can be found in the XBlock SDK: https://github.com/openedx/xblock-sdk

More 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 anything non-trivial, the best path is to open an issue in this repository with as many details about the issue you are facing as you can provide.

https://github.com/openedx/XBlock/issues

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

License

The code in this repository is licensed the Apache 2.0 license unless otherwise noted.

Please see LICENSE.txt for details.

Contributing

Contributions are very welcome!

Please read How To Contribute for details.

This project is currently accepting all types of contributions, bug fixes, security fixes, maintenance work, or new features. However, please make sure to have a discussion about your new feature idea with the maintainers prior to beginning development to maximize the chances of your change being accepted. You can start a conversation by creating a new issue on this repo summarizing your idea.

The Open edX Code of Conduct

All community members are expected to follow the Open edX Code of Conduct.

People

The assigned maintainers for this component and other project details may be found in Backstage. Backstage pulls this data from the catalog-info.yaml file in this repo.

Reporting Security Issues

Please do not report security issues in public. Please email [email protected]

xblock's People

Contributors

ahmedbilal avatar andy-armstrong avatar awais786 avatar brianhw avatar cpennington avatar dmitchell avatar e-kolpakov avatar edx-requirements-bot avatar farhan avatar feanil avatar filosottile avatar jawayria avatar jbau avatar jmbowman avatar jorr-at-google avatar jtauber avatar kenclary avatar lapentab avatar mhoeber avatar mraarif avatar nedbat avatar robrap avatar salman2013 avatar sarina avatar singingwolfboy avatar smarnach avatar thezaeemaanwar avatar tobz avatar tusbar avatar usamasadiq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xblock's Issues

Need sudo installing with virtualenv

it seems like if I have a django installed, there might be a permission issue, so sudo is required as opposed to what currently states in the doc.

I followed the direction:

  1. Clone the repo
  2. Install Virtualenv
  3. Create and activate Virtualenv
    virtualenv xblock
    source xblock/bin/activate
  4. cd to the repo
  5. pip install -r requirements.txt (no sudo)
    Error: Found existing installation: Django 1.5
    Uninstalling Django:
    OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/Django-1.5-py2.7.egg-info/dependency_links.txt'

Error when running "pip install lxml"

When running "pip install lxml" i am finding these errors:

Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.4
Downloading http://codespeak.net/lxml/lxml-2.2.4.tgz
Processing lxml-2.2.4.tgz
Running lxml-2.2.4\setup.py -q bdist_egg --dist-dir c:\users\rocco\appdata\local \temp\easy_install-1xwbhy\lxml-2.2.4\egg-dist-tmp-9zwhe4
Building lxml version 2.2.4.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' need s to be available. 
ERROR: 'xslt-config' is not recognized as an internal or external command, operable program or batch file.

manage.py

When I run step 4:
python manage.py runserver

I got the following message:
can't open file 'manage.py': [Errno 2] No such file or directory

I have tried many things, but I still do not get it working.

Prototype: React-enabled XBlocks

Background

See #635

Goals

  • On branches of edx-platform, frontend-app-learning, and any existing xblock:
    • Add a React-based student view to the XBlock.
    • Get it to render in the Learning MFE.
  • Write up a recommendation for how this could be generalized for all XBlocks & all views (student, public, author, and studio) and implemented.

Suggested approach

Here's how I would do it, but that doesn't mean it's the only way it could be done!

Choose an XBlock, ideally one of the ones that is defined in its own respository. Make these changes:

  • Add a student_view_data method, which will return a JSON representation of the block's student view. Example that exists in master today (it was used by alternative block frontends for the LabXChange project).
  • In the same repo, create an NPM package containing a new student view as a React component named StudentView. The student_view_data should be expected to be passed in via the component's props.
  • Publish the NPM package to a user account.
  • Add a new class-level field to the XBlock:
    class SomeBlock(XBlock):
        react_views = "someblock/path/to/view/module.js"
    where "path/to/view/module.js" is replaced by a path that the Learning MFE can dynamically import(...) in order to load this block's StudentView component.

In edx-platform:

  • Enhance the MFE Configuration API (defined in lms/djangoapps/mfe_config) to also return a dictionary of all "React-enabled" XBlocks, mapping from the XBlock tag to the React module path:
 {
     "someblock":  "someblock/path/to/view/module.js"
     ...
 }

This will allow the Learning MFE to dynamically discover the full list of React-enabled blocks.

In the Learning MFE:

  • Install the new NPM package.
  • Upon initialization, look at the list of React-enabled XBlocks returned by the MFE Config API. Load the StudentView of each block.
  • In courseware, if a unit is comprised entirely of React-enabled blocks, then render each block's StudentView component instead of rendering the standard iframe to edx-platform.

Notes

See parent issue for more ideas and discussion.

A report for building & testing on linux with python3.8

((The only reason why this summary is using python3.8 is because that was the version of python I happened to be using when I got tox to run! I tried five different builds before getting ./configure correct, anyone reading this should probably stick to the python3.5, as noted in the readme))

This was my first foray into XBlock. On debian, python3.5/stable appears to be considered so old that all that remains in the repo is python3.5-minimal/now, which doesn't sound promising. So anyways I hit a couple hurdles and thought I would share what I did to get tests running.

Grabbed a copy of python 3.8.3 from the python website.

$ sudo apt install libsqlite3-dev
$ mkdir python-3.8.3

Then configured python.

$ ./configure --enable-loadable-sqlite-extensions --enable-optimizations --prefix=/full/path/to/python-3.8.3
$ make && make install

set up the virtualenv

$ cd your-virtual-envs
$ virtualenv -p /path/to/python-3.8.3/bin/python3.8 xblock-env-38

grabbed xblock

$ git clone "https://github.com/edx/XBlock.git"
$ cd XBlock
$ source /path/to/your-virtual-envs/xblock-env-38/bin/activate
$ make requirements

Ran into this issue with the new version of pip so had to downgrade

$ pip install --upgrade pip==20.0.2
$ tox 

with only 1 test failing

===================================== short test summary info =====================================
FAILED xblock/test/django/test_field_translation.py::TestXBlockStringFieldDefaultTranslation::test_lazy_translation
========================== 1 failed, 1367 passed, 371 warnings in 5.88s ===========================

Not sure if this is the right place for this note, but maybe it will help someone get started or be of interest to xblock devs.

Install errors

Hello please tell me whats going on

src/lxml/lxml.etree.c:180049: warning: implicit declaration of function ‘exsltRegisterAll’

error: command 'gcc' failed with exit status 1

----------------------------------------

Command /var/www/xblock/bin/python2.7 -c "import setuptools;__file__='/var/www/xblock/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-VurR9y-record/install-record.txt --single-version-externally-managed --install-headers /var/www/xblock/include/site/python2.7 failed with error code 1 in /var/www/xblock/build/lxml

Exception information:
Traceback (most recent call last):
  File "/var/www/xblock/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
    status = self.run(options, args)
  File "/var/www/xblock/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 271, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/var/www/xblock/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 1185, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/var/www/xblock/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 592, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/var/www/xblock/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/util.py", line 662, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /var/www/xblock/bin/python2.7 -c "import setuptools;__file__='/var/www/xblock/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-VurR9y-record/install-record.txt --single-version-externally-managed --install-headers /var/www/xblock/include/site/python2.7 failed with error code 1 in /var/www/xblock/build/lxml

helppppp

Xblock workbench and edx-platform don't easily coexist

If you go through the standard "devstack" setup of edx-platform, then do (in some other directory):

git clone https://github.com/edx/XBlock.git xblock
cd xblock
pip install -r requirements.txt

Then go back to platform, and do:

rake devstack[studio]

The following error results:

edxapp@precise64:~/edx-platform$ rake devstack[studio]
Node requirements unchanged, nothing to install
Ruby requirements unchanged, nothing to install
pip install -q --exists-action w -r requirements/edx/pre.txt
pip install -q --exists-action w -r requirements/edx/base.txt
  Could not find a tag or branch 'd89aae2a82f2b', assuming commit.
  Could not find a tag or branch '88ec8a011e481918fdc9d2682d4017c835acd8be', assuming commit.
  Could not find a tag or branch '41815e2ef1b0323f92900f8e60711b0f0c37766b', assuming commit.
  Could not find a tag or branch 'cccc3978ad2df82a78b6f9648fe2e9baddd22f88', assuming commit.
  Could not find a tag or branch '776973740bdaad83a3b029f96e415a7d1e8bec2f', assuming commit.
  Could not find a tag or branch 'd53fe0e81b623f084e91776bcf6369f8b7b63879', assuming commit.
  Could not find a tag or branch 'a1a3e76b269d15b7bbd11976d8aef63e1db6c4c2', assuming commit.
  Could not find a tag or branch 'e3d98f9455', assuming commit.
  Could not find a tag or branch '823a102e48', assuming commit.
  Could not find a tag or branch 'f0211d702d', assuming commit.
  Could not find a tag or branch 'bc6f1adbe439618162079f1004b2b3db3b6f8916', assuming commit.
  Could not find a tag or branch 'afef6647edb488afc471b0239ef8c4b0669e5fdf', assuming commit.
pip install -q --exists-action w -r requirements/edx/post.txt
xmodule_assets common/static/xmodule
./manage.py cms --settings devstack preprocess_assets --traceback 
Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 217, in execute
    translation.activate('en-us')
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 105, in activate
    return _trans.activate(language)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 194, in activate
    _active.value = translation(language)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 183, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 160, in _fetch
    app = import_module(appname)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 4, in <module>
    from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 8, in <module>
    from django.contrib.admin import widgets, helpers
ImportError: cannot import name widgets
asset preprocessing failed!
node_modules/.bin/coffee --compile `find lms/ cms/ common/ -type f -name *.coffee` 
edxapp@precise64:~/edx-platform$ 

However, this can be solved by doing:

pip uninstall XBlockWorkbench

Implicit dirty breaks read-only fields

This problem can be reproduced with the edX demo course. If you are logged in as the instructor and, in the LMS, navigate to "Homework - Essays / Self Assessed Essay" you'll get an InvalidWriteError ('Not allowed to overwrite descriptor model data', 'graceperiod').

The reason for this is that in xblock.core.ModelType.get, the code marks the graceperiod field as "dirty" because self.MUTABLE == True and therefore might be mutated without a call to set. The open ended module marks the graceperiod field as readonly. As a result, even though we're only reading the value of graceperiod here, we get an InvalidWriteError.

has_score=True is not working in my custom Xblock

I have installed my xblock on the openedx and its a problem builder xblock. When I put my xblock on the course it did not registered as a problem and when I look at it as a student's progress bar it did not get a score section just like other native problem builder xblocks.

Javascript Initialization

@pmitros: "It'd be nice if I could pass parameters to frag.initialize_js. I'd suggest these could be JSON objects (so string, dicts, arrays, integers), and I could have anywhere between 0 and infinity of them.

Right now my options for doing this are:

  1. Add templates to my HTML/JS/CSS. This is ugly.
    a. I can no longer develop in browser without running the workbench. It forces my code to couple to workbench. I know I could probably find some way to split this among files where there is a test file and a workbench file, but that kind of sucks.
    b. It forces me to put things inside HTML/CSS/JS files that break the semantics of what those files mean. I have to template in big data blobs in human-readable files.
  2. I can do AJAX, with extra requests.

In addition, in both cases, it's an extra chunk of unnecessary code. I have to do $("#script_tag").text() or make web requests or similar."

@cpennington: "How does it couple you to workbench? Unlike XModules, w/ XBlocks we're advocating that users do their own templating (rather than relying on the runtime for templating). For instance, you could just do native python string interpolation, if that's enough for your needs.

Otherwise, I like the idea."

@pmitros: "If I can keep pure JavaScript, HTML, and CSS in files, I can develop and debug directly in Chrome/Firefox, as per my preference, and I can deploy either to the XBlock, or just upload static files to the web.

The instance I have /any/ kind of templates, be it Python .replace(), Python .format(), mako, etc., the code can only work inside of some kind of server which does that templating. I'm coupled to a more complex development and deployment mechanism. In abstract, I could build a separate server, one for XBlocks and one not to do the templating, or build an independent deployment mechanism, but in practice, that's a lot of work with no benefit (if I need a server, workbench is as good as any and better than most), so I'm left with developing in workbench. Being able to develop and deploy just in-browser is, on the other hand, a big benefit, as is being able to use the same HTML/CSS/JS files for both interactives on static pages as in XBlocks."

Documentation: https://xblock.readthedocs.org/en/latest/

Unclear Sections

"XBlocks are not limited to just delivering courses. A complete educational ecosystem will make use of a number of web applications, all of which will need access to course content and data. XBlocks provide the structure and APIs needed to build components for use in all of these applications."

  • Sounds like internal-speak. Needs to be simpler for newcomers.

Typo `simplesjson` -> `simplejson`

there are two occurrences of this mistake in the code

try:
    import simplesjson as json  # pylint: disable=F0401
except ImportError:
    import json

Missing python 2.7.3 library for windows 7?

Import error, webob. First, django_nose was missing. After install, webob is missing. Is there library I should install on Windows 7, for xblock? Or, is there some other problem at work?

Enabling translations

Hello!
I'm trying to enable translations for an xblock but I can't seem to do it successfully. I've compiled the Frensh language .po file (I've added dummy translations) to the .mo file and enabled fr language in studio with ?preview-lang=fr, everything changed to French but not the text in the edit modal of my xblock.
How can I enable the translations?

XBlock Scoping

Reported by @pmitros:

"NONE and ALL mean the same things, and expose our particular implementation details to XBlock authors.

Students may want to modify a course. Examples:

  • Contribute hints around a problem (experiment last summer)
  • Ike's dogfood.
  • MakerPhysics course, where students construct a course

See:
http://en.wikipedia.org/wiki/Von_Neumann_architecture
http://en.wikipedia.org/wiki/Harvard_architecture

TYPE should be BLOCK_TYPE

DEFINITION and USAGE should be the same. The set of things which are overridable/advertisable should not be pre-defined by the XBlock author. Especially things like number of attempts can fall into either bin, and which makes more sense depends on how they are used. This is an artificial split due to architectural issues on our side, but it shouldn't be exposed to an XBlock author.

I can see there being something here, but not this. SCOPE could have an additional axis indicating something along the lines of whether something is mutable or read-only, or perhaps whether it ought to be versioned, or whether Big Things Happen when it changes (e.g. other chunks of state become inconsistent) or something, but I'm not quite sure what that is. I'm pretty sure it's not what we've got, though."

Unique Id for Block

Reported by @pmitros: "To construct useful XBlocks, I need access to a unique ID per element. Cale mentioned this is available in self.scope_ids.usage_id. This is good and useful, but entirely undocumented."

@nedbat: "Yes, let's add this to the list of useful factoids that can be retrieved from the information service, along with student name, course name, etc."

Why I got a "PluginMissingError" ?

I followed the steps from README, but I got a plugin missing error. I did not start LMS or CMS when I started XBlock, would this be a problem ?

BTW, the LMS is started at port 8000 by default and XBlock is also using the same port if you just run "python manage.py runserver". Why using the same port?

"Mutable" no longer being used

In fields.py class Field we have a property MUTABLE which was originally created for bulk save logic.

My understanding is that this property is no longer being used with @cpennington's changes to XBlock save logic. If this is the case, we should strip out all references to MUTABLE within XBlock.

Thanks @dmitchell for noting this.

Acceptance Criteria:

  • Make sure MUTABLE is no longer used.
  • Strip out all references to MUTABLE within XBlock.
  • Install the Xblock as a package on some customized Xblock and make sure everything is working fine

issue with videojsXBlock installation

Hello,
I have an issue with videojsXBlock installation.
I wanna to work with xBlock, I tried to install the videojsXBlock https://github.com/MarCnu/videojsXBlock and integrat it into my OpenEdx plateform
Will finishing the execution of the commands, I got this issue:

edxapp@precise64:~/edx-platform$ fun cms.dev run --fast
Traceback (most recent call last):
File "/edx/app/edxapp/venvs/edxapp/bin/fun", line 9, in
load_entry_point('fun-cmd==0.1', 'console_scripts', 'fun')()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/funcmd/cmd.py", line 13, in fun
run_command(settings, service, fun_args, other_args)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/funcmd/cmd.py", line 72, in run_command
arguments = get_manage_command_arguments(settings, service, *other_args)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/funcmd/cmd.py", line 87, in get_manage_command_arguments
setup_environment(settings, service)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/funcmd/cmd.py", line 121, in setup_environment
startup = importlib.import_module(startup_module)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/edx/app/edxapp/edx-platform/cms/startup.py", line 8, in
settings.INSTALLED_APPS # pylint: disable=pointless-statement
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/init.py", line 95, in init
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'fun.envs.cms.dev' (Is it on sys.path?): No module named validation

Anyone have faced the same issue ?
Do you suggest any solution.

Thanks

Failure to run clang and no module named django_nose on OSX 10.8.2, Python 2.7.2

Just tried ran sudo pip install -r requirements.txton OSX 10.8.2 with Python 2.7.2

full log here at gist below, but got this failure:

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/libxml2 -I/private/tmp/pip-build/lxml/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.8-intel-2.7/src/lxml/lxml.etree.o -flat_namespace

unable to execute clang: No such file or directory

error: command 'clang' failed with exit status 1

https://gist.github.com/tansaku/5186171

Any ideas?

If I now try runserver I get this:

Samuels-MacBook-Pro:XBlock sam$ python manage.py runserver
Error: No module named django_nose

Handlers don't work from remote services

From a developer:

[quote]
All the handlers I am creating that are accessed by remote tools using POST requests (settings service, outcomes service and memberships service) are all blocked by django's CSRF protection. Adding the @csrf_exempt decorator to the handlers in the XBlock has no effect. I have only been able to get it working by adding @csrf_exempt to the handler function in workbench/views.py

diff --git a/workbench/views.py b/workbench/views.py
index b8f97e6..72037a5 100644
--- a/workbench/views.py
+++ b/workbench/views.py@@ -75,7 +76,9 @@ def show_scenario(request, scenario_id, view_name='student_view'):
})

+from django.views.decorators.csrf import csrf_exempt
+@csrf_exempt
def handler(request, usage_id, handler_slug):
student_id = get_student_id(request)
log.info("Start handler %s/%s for student %s", usage_id, handler_slug, student_id)
usage = Usage.find_usage(usage_id)

[end quote]

Clearly, we don't want to exempt all handlers from CSRF protection, so we need a way to indicate which handlers are from the authenticated browser, and which are not.

Set up Xblock SDK Error

I use Open edX XBlock Tutorial to setup Xblock. I install the XBlock SDK requirements:
(venv) $ pip install -r requirements.txt
And I get error:
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' Storing debug log for failure in /root/.pip/pip.log
pig.log:
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' Exception information: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 262, in run for req in parse_requirements(filename, finder=finder, options=options, session=session): File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1546, in parse_requirements session=session, File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 278, in get_file_content raise InstallationError('Could not open requirements file: %s' % str(e)) InstallationError: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

Only last cookie is sent to client in response

When setting multiple headers with the same name Set-Cookie, only the last one is actually in the django response object.
For instance, this response:

HTTP/2.0 200 OK
Content-Type: text/html
Set-Cookie: yummy_cookie=choco
Set-Cookie: tasty_cookie=strawberry
[page content]

It will only set this Set-Cookie: tasty_cookie=strawberry to response.

A call to django_response.set_cookie() method if the header is "Set-Cookie" might fix it.

https://github.com/edx/XBlock/blob/316cc376945f0c748d4ec7b780ee55bd6aef4425/xblock/django/request.py#L12

https://tools.ietf.org/html/rfc7230

Note: In practice, the "Set-Cookie" header field ([RFC6265]) often
appears multiple times in a response message and does not use the
list syntax, violating the above requirements on multiple header
fields with the same name. Since it cannot be combined into a
single field-value, recipients ought to handle "Set-Cookie" as a
special case while processing header fields. (See Appendix A.2.3
of [Kri2001] for details.)

How can JS files get access to xblock fields?

I have some settings in my xblock:

<myxblock question="Question 1"/>
<myxblock question="Question 2"/>

In my HTML, I can do:

<p>{self.question}</p>

I'm looking for an equivalent syntax for my Javascript. Ned suggested that I submit a ticket as he's not aware of a way to do this. I naively tried:

 var question = '{self.question}';

but that doesn't work.

Make Runtime Services Plugin-able

Handwavey Sketch:

  1. Use stevadore to register/lookup installed plugin implementations (plugins for the 'i18n' service would be registered under the entry_point key 'xblock.service.i18n', and would be named for their function ['null', 'django', etc])
  2. XBlock runtime should look for services in the following order:
    1. Explicitly provided in the services kwarg
    2. Enabled entry_point plugins in the provided services configuration dictionary, configured by that same dictionary
    3. Default plugins registered with stevadore (maybe?)

Error generating when using demo

Hello,

After I installed XBlock, I ran the Django development server as described
in step 4. When I click on "a bunch of html", this error is generated.

2013-03-26 17:00:17,855 django.request ERROR: Internal Server Error: /handler/usage_46/update/
Traceback (most recent call last): 
  File "/home/jkern/pyEnv/edx_py2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response 
    response = callback(request, *callback_args, **callback_kwargs) 
  File "/home/jkern/workspace/python/edX/XBlock/workbench/views.py", line 86, in handler 
    result = block.runtime.handle(block, handler_slug, request) 
  File "/home/jkern/workspace/python/edX/XBlock/xblock/runtime.py", line 191, in handle
    return handler(data) 
  File "/home/jkern/workspace/python/edX/XBlock/xblock/slider.py", line 47, in update 
    response = super(ProgressSlider, self).handle_update(request) 
AttributeError: 'super' object has no attribute 'handle_update'

-jk

InvalidScopeError when using custom Scope in Field

This is the code I'm currently using to try to do this:

tableStructure = Dict(default={}, scope=Scope(UserScope.NONE, BlockScope.TYPE), help="Help Text")

Whenever I attempt to read the value of the Field, an InvalidScopeError is raised. This doesn't seem to happen with the other predefined Scopes (e.g Scope.content). Furthermore, the error only seems to happen if I attempt to access the value of the Field from within the student_view.

Here is a stack trace:

2014-09-10 10:15:13,883 WARNING 2366 [contentstore.views.preview] preview.py:223 - Unable to render student_view for <TableXBlockWithMixins @4644 rerandomize='never', graded=False, annotation_token_secret='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', giturl=None, source_file=None, course_edit_method='Studio', default_tab=None, showanswer='finished', display_name='Table XBlock', video_speed_optimizations=True, chrome=None, showColumns=[], due=None, start=datetime.datetime(2030, 1, 1, 0, 0, tzinfo=<UTC>), tags=[], days_early_for_beta=None, max_attempts=None, text_customization={}, userRows={}, parent=None, format=None, matlab_api_key=None, xqa_key=None, annotation_storage_url='http://your_annotation_storage.com', use_latex_compiler=False, extended_due=None, static_asset_path='', hide_from_toc=False, count=0, name=None, ispublic=None, user_partitions=[], graceperiod=None, visible_to_staff_only=False, tableStructure=???>
Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/preview.py", line 221, in get_preview_fragment
    fragment = module.render(preview_view, context)
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/core.py", line 289, in render
    return self.runtime.render(self, view, context)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1166, in render
    return block.xmodule_runtime.render(to_render, view_name, context)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1029, in render
    return super(MetricsMixin, self).render(block, view_name, context=context)
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/runtime.py", line 586, in render
    frag = view_fn(context)
  File "/edx/app/edxapp/edx-platform/Table-XBlock/table/table.py", line 68, in student_view
    tab = self.tableStructure
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/fields.py", line 369, in __get__
    if xblock._field_data.has(xblock, self.name):
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/field_data.py", line 174, in has
    return self._field_data(block, name).has(block, name)
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/field_data.py", line 153, in _field_data
    raise InvalidScopeError(scope)
InvalidScopeError: ScopeBase(user=UserScope.NONE, block=BlockScope.TYPE, name=u'UserScope.NONE_BlockScope.TYPE')
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/handlers.py", line 810, in emit
    self.socket.sendto(msg, self.address)
TypeError: getsockaddrarg: AF_INET address must be tuple, not NoneType
Logged from file preview.py, line 223
[10/Sep/2014 10:15:13] "GET /xblock/i4x://ADL/ADL101/table/ac25938d0f7941878430fbf40c501747/student_view?_=1410358513743 HTTP/1.1" 200 1686

startnew.py should be installed as a script

From PR #147:

Not for this PR, but we should use the console_scripts entry point to just install the startnew script into the virtualenv when you install xblocks. That way, in the future, you'll just be able to pip install XBlock && start_xblock, or something similar.

Error 500 after installing Xblock

I installed xblock using this doc --> https://github.com/edx/edx-platform/wiki/Installing-a-new-XBlock
But after I got a problem with LMS and CMS (Error 500).
Log file:

Traceback (most recent call last):
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 419, in course_listing
    courses, in_process_course_actions = get_courses_accessible_to_user(request)
  File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 577, in get_courses_accessible_to_user
    courses, in_process_course_actions = _accessible_courses_list(request)
  File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 356, in _accessible_courses_list
    courses = filter(course_filter, modulestore().get_courses())
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/mixed.py", line 90, in inner
    retval = func(field_decorator=strip_key_collection, *args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/mixed.py", line 276, in get_courses
    for course in store.get_courses(**kwargs):
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py", line 83, in get_courses
    return super(DraftVersioningModuleStore, self).get_courses(ModuleStoreEnum.BranchName.draft, **kwargs)
  File "/edx/app/edxapp/venvs/edxapp/src/mongodb-proxy/mongodb_proxy.py", line 53, in wrapper
    return func(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py", line 932, in get_courses
    return self._get_structures_for_branch_and_locator(branch, self._create_course_locator, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py", line 892, in _get_structures_for_branch_and_locator
    structures_list = self._load_items(envelope, [root], depth=0, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py", line 763, in _load_items
    return [runtime.load_item(block_key, course_entry, **kwargs) for block_key in block_keys]
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py", line 130, in _load_item
    block = self.xblock_from_json(class_, course_key, block_key, block_data, course_entry_override, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py", line 241, in xblock_from_json
    error_msg=exc_info_to_str(sys.exc_info())
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/error_module.py", line 144, in from_json
    location=location
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/error_module.py", line 124, in _construct
    for_parent=for_parent,
  File "/edx/app/edxapp/venvs/edxapp/src/xblock/xblock/runtime.py", line 635, in construct_xblock_from_class
    *args, **kwargs
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1001, in __init__
    super(XModuleDescriptor, self).__init__(*args, **kwargs)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 299, in __init__
    super(XModuleMixin, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'for_parent'

Syntax warning due to comparison of literals using is in Python 3.8

find . -iname '*.py' | grep -Ev 'setup|rdf4|tool' | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./xblock/test/test_runtime.py:459: SyntaxWarning: "is" with a literal. Did you mean "=="?
  assert 1 is self.mixologist.mix(FieldTester).number
./xblock/test/test_runtime.py:460: SyntaxWarning: "is" with a literal. Did you mean "=="?
  assert 1 is self.mixologist.mix(FieldTester).fields['field'].default

Provide support for migrations

As an xblock changes what fields it understands, previous versions of the data written by that block will have to be migrated. Currently, the only way to support that is to keep all old versions of the fields around, and to perform checks in __init__.

It would be nice instead to have a standard way to convert from one version of the xblock's fields to another.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.