September 3rd, 2009
I’m now working on HTML to SCORM converter at Zekola. The command-line version is ready and produces SCORM 1.2 and 2004 conformant packages.
The converter reads headings structure from the source HTML, split HTML into chunks between headings and generates SCORM package with correct imsmanifest.xml etc. The great advantage comparing to other SCORM authoring tools is that you can author the whole coursebook say in MS Word, then save it as a single HTML, then convert to SCORM with a single step.
It doesn’t save much time for multimedia-rich or interactive courses, but it’s a precious tool for textbooks.
Tags: HTML, SCORM, textbook, word
Posted in SCORM, e-learning | No Comments »
January 29th, 2009
You can easily change collation with an ALTER TABLE … CONVERT statement. For example:
alter table book_category convert to character set utf8 collate utf8_unicode_ci;
Note, that it is not equivalent to
alter table book_category default collate utf8_unicode_ci;
which only changes a default collation, so the existing columns preserve their collation.
Tags: Collation, MySQL, Unicode
Posted in MySQL | No Comments »
August 18th, 2008
The way to specify admin interface options has changed in the recent development version of Django. An inline edited objects are now specified in a new way. Now you need to mention the link in an admin objects of both models participating in the relation.
So the question arises: how to make UserProfile to appear inline in the User editing interface in admin?
The solution is to import UserAdmin class and add an InlineAdmin objet to the inlines list. But there is a simple trick: you need to unregister and then register an AdminModel class for a User model. Here is an example.
models.py
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
website_url = models.URLField(verify_exists=False)
user = models.ForeignKey(User, unique=True)
admin.py
from django.contrib import admin
from someapp.models import *
from django.contrib.auth.admin import UserAdmin
# Define an inline admin descriptor for UserProfile model
class UserProfileInline(admin.TabularInline):
model = UserProfile
fk_name = 'user'
max_num = 1
# Define a new UserAdmin class
class MyUserAdmin(UserAdmin):
inlines = [UserProfileInline, ]
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
Tags: Django, Python
Posted in Django, Python | 7 Comments »
October 28th, 2007
How to round Decimal numbers with Symmetric Arithmetic Rounding (as described
in article “Rounding” on wikipedia.org?.
Rounding can be done with
decimal.Decimal
object’s quantize method. Use decimal.ROUND_HALF_UP flag to get
a Symmetric Arithmetic Rounding.
For example:
>>> from decimal import Decimal, ROUND_HALF_UP
>>> Decimal("234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.454")
>>> Decimal("234.4534").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.453")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")
So, the “traditional” round function will look like this:
from decimal import Decimal, ROUND_HALF_UP
def round(d, digits=0):
"""
Symmetric Arithmetic Rounding for decimal numbers
d - Decimal number to round
digits - number of digits after the point to leave
For example:
>>> round(Decimal("234.4536"), 3)
Decimal("234.454")
>>> round(Decimal("234.4535"), 3)
Decimal("234.454")
>>> round(Decimal("234.4534"), 3)
Decimal("234.453")
>>> round(Decimal("-234.4535"), 3)
Decimal("-234.454")
>>> round(Decimal("234.4535"), -1)
Decimal("2.3E+2")
"""
return d.quantize(Decimal("1") / (Decimal('10') ** digits), ROUND_HALF_UP)
Tags: decimal, Python, round
Posted in Python | 2 Comments »
May 20th, 2007
Docbook to SCORM Converter is now open source. It’s released under
GNU Lesser General Public License.
Source code and binary files can are available from the project site
at Google Code.
See updated description and usage instructions.
Tags: Docbook, SCORM
Posted in Docbook, SCORM, e-learning | No Comments »