From: Sam H. <sa...@sa...> - 2007-10-17 17:00:55
|
Hello, I'm about to commit some useful tools for managing NPL-style tags in PG problems. These tools were developed in the course of managing the Rogawski problem library for W.H.Freeman, and are being contributed back to the WeBWorK project in accordance with the GPL. Please feel free to take a look at these and use/improve them. -sam lib/WeBWorK/NPL.pm - Useful routines for parsing and writing PG tags format as well as the Textbooks file format. Also contains a routine gen_find_tags which generates a "wanted" function for File::Find that finds files that match a certain tags specification. As of now, editing of tags is somewhat limited -- a facility for appending tags to the end of the tag block is given, which should be sufficient for adding a new textbook to existing files. The tag parsing routine is all new, and should be somewhat more robust and harder to abuse. One notable improvement is that it can handle escaped single quotes within values, making it possible to say things lik= e: ## DBsection('L\'Hospital\'s Rule') However, the stricter value parsing makes it reject some broken values already in the NPL. In the case of KEYWORDS, if a parse error is encountered it will fall back on the old keyword parsing method. This could be extended to other values if need be. bin/pg-find-tags - Prints file names for files that match specifications given on the command line. Good demo of how to use gen_find_tags. Can be easily modified to perform other tasks. bin/pg-append-textbook-tags - Appends tags for a new textbook to the end of the tag block in an already-tagged file. bin/pg-pull - Pull files from an existing library into a new library. Directory and file names for the new library can be generated from the tags in the problem (and optionally use the names from a Textbooks file). We use this to pull Rogawski-tagged NPL problems out for separate distribution. This script has some annoying limitations right now -- read the comments. |