Posts for the month of December 2006

Using Trac for Teaching

This is something I wrote up a while back (Trac 0.9). Now it's even easier since 0.10 doesn't need the svn backend.

Using Trac in a Teaching Environment

Obviously, some paths and usernames/groups etc may need to be changed...

  1. Install trac. I used 0.9.6.
  2. Create the repository (fake)
    1. svnadmin create /var/www/svn/teacher
    2. TMPDIR=`mktemp -d`
    3. svn import "${TMPDIR}" file:////var/www/svn/teacher -m "initial setup"
    4. rm -rf "${TMPDIR}"
    5. chown -R apache.apache /var/www/svn/teacher
  3. Create the trac project
    1. trac-admin /var/www/svn/teacher initenv "Mrs. M Web World" sqlite:db/trac.db /var/www/svn/teacher /usr/share/trac/templates
    2. chown -R apache.apache /var/www/trac/teacher
    3. trac-admin /var/www/svn/teacher permission add "Admin" "TRAC_ADMIN"
  4. Set up Apache as needed...
    1. htpasswd -cm /var/www/trac/teacher/.htpasswd Admin
    2. htpasswd -m /var/www/trac/teacher/.htpasswd Teacher
    3. htpasswd -m /var/www/trac/teacher/.htpasswd TestStudent [pwd: test]
    4. Create/modify trac.conf in Apache's conf.d directory (see below)
  5. (Test login at this point)
  6. Install some needed plugins
    1. WebAdmin
    2. TicketDeletePlugin
  7. Now we need to edit trac itself, to make it look nicer for student interface:
  1. Edit /usr/lib/python2.3/site-packages/trac/ticket/web_ui.py
    1. Search for "New Ticket" within a util.Markup() call and change it to "New Question"
  2. Edit /usr/lib/python2.3/site-packages/trac/ticket/roadmap.py
    1. Search for "Roadmap" within a Markup() call (with accesskey 3) and change it to "Syllabus"
  1. Edit trac.ini as needed:
    1. I changed the [header_logo] with an image of the county school system and associated link.
    2. Make sure the various plugins are enabled/disabled in [components] section of trac.ini (see below)
  2. Login again (as 'Admin'). You should have an 'Admin option'.
  3. Permissions. I made two groups "@teachers" and "@students".
    1. @students get TICKET_APPEND, TICKET_CREATE, TICKET_VIEW, ROADMAP_VIEW, MILESTONE_VIEW, WIKI_VIEW
    2. @teachers get TICKET_ADMIN, WIKI_ADMIN, MILESTONE_ADMIN, ROADMAP_VIEW
  4. At this point, we're done with the main server stuff (until the term starts and you need to add more users as above). Now the teacher can customize with that login (recommended).
  5. My recommendations:
    1. Milestones:
      1. These should be based on the syllabus (that's what the students see it as). I assume each major section of the class would get one. The "due date" could be the Monday of the Quiz week or something similar.
    2. Ticket types: General Question and Clarification Request
    3. Components: None (removed them all)
    4. Priorities: None (removed them all)
    5. Severities: None (removed them all)
    6. Versions: None (removed them all)

httpd.conf

Alias /trac/ "/usr/share/trac/htdocs/"

<Location /teacher>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /var/www/trac/teacher
   AuthType Basic
   AuthName "Mrs. M's Web World"
   AuthUserFile /var/www/trac/teacher/.htpasswd
   Require valid-user
</Location>

trac.ini excerpts

[components]
webadmin.* = enabled
trac.wiki.macros.macrolistmacro = disabled
trac.versioncontrol.web_ui.log.logmodule = disabled
trac.about = disabled
trac.search.searchmodule = disabled
ticketdelete.* = enabled
trac.versioncontrol.web_ui.changeset.changesetmodule = disabled
trac.ticket.web_ui.updatedetailsfortimeline = disabled
trac.mimeview.patch.patchrenderer = disabled
trac.mimeview.rst.restructuredtextrenderer = disabled
trac.wiki.macros.pageoutlinemacro = disabled
trac.attachment.attachmentmodule = disabled
trac.wiki.macros.imagemacro = disabled
trac.versioncontrol.web_ui.browser.browsermodule = disabled
trac.mimeview.php.phprenderer = disabled
trac.timeline.timelinemodule = disabled

The opposite of chmod

Well, I've been using Unix for since 1993, and I just realized I don't know what the opposite of chmod is - how do I just show the permissions, not set them? lsmod is Linux kernel module listing. So, I used stat which is likely overkill. But sadly that took me a while to think of.

Rsync over ssh for backing up some files

  1. Make a file with the ssh user and password called /etc/backupcredentials_ssh
    1. Make a directory on the backup server called /mnt/backup/this_hostname/
      • Make sure it is owned by backup_user
rsync -av --delete -e ssh -l backup_user -i /etc/backupcredentials_ssh /mnt/backup backup_server:/mnt/backup/this_hostname/

This way I was able to avoid using a samba mount between the two.

Automated diffs in trac

Somebody on the mailing list for trac wanted to make a daily wiki page with the diffs for a build. He already had the scripts to do a nightly build, so I suggested this, and tried it and it worked:

echo {{{ > /tmp/tempo
echo '#!diff' >> /tmp/tempo
svn diff -r70:76 >> /tmp/tempo
echo }}} > /tmp/tempo
trac-admin /var/www/trac/personal wiki import TodaysDiff /tmp/tempo