Naming conventions

From WeBWorK_wiki
Jump to navigation Jump to search


Extended and unified naming conventions

Rules set for Release_notes_for_WeBWorK_2.4.9 11/11/2013 -- Checked against 2.7 and release/2.8


  • Set names can contain alphanumeric characters, hyphens(-), underbars(_), periods(.), and commas(.), colons (:), and slashes(/).
    • WeBWorK/DB.pm -- checkKeyfields -- set_id must match /^[-a-zA-Z0-9_.,]*$/
  • User names can contain alphanumeric characters, hyphens(-), underbars(_), periods(.), and at signs(@). This allows the use of most email addresses as login user_id's.
    • WeBWorK/DB.pm -- check_user_id must match /^[-a-zA-Z0-9_.@]*,?(set_id:)?[-a-zA-Z0-9_.@]*(,g)?$/
    • WeBWorK/DB.pm -- checkKeyfields -- user_id (uses check_user_id)
  • For safety the at sign, comma and period are converted to underbars when labeling on-the-fly graphs.
  • Problem_id's can contain only numbers.
    • WeBWorK/DB.pm -- checkKeyfields -- problem_id
  • IP's (used in proctored gateway quizzes) can contain alphanumeric characters, hyphens(-), underbars(_), periods(.), commas(.), colons (:), and slashes(/).
    • WeBWorK/DB.pm -- checkKeyfields -- ip_mask
  • FileManager will allow commas in directory names.
  • Periods in set names are automatically converted to _ when printing hardcopy to avoid incompatibility with TeX. Still it is probably wise to limit set names characters to letters, numbers and underbars to avoid conflicts with auxiliary tools such as TeX, and mySQL.
  • Image names can contain underbars and still act peacefully with TeX (at least most of the time :-) ).
  • Spaces in directory paths should be avoided as they can cause uninformative errors on some unix installations but not on others, which is disconcerting and causes confusion. Use underbars instead of spaces.
Technical note:
In conjunction with this unified naming convention a centralized macro in DB.pm, check_user_id, is called to make sure that
user names conform to the standards above.  This is also done when uploading classlists.  It is
expected that this will eliminate a previous bug which allowed student ID's with non-English characters
to corrupt the database resulting in non-deletable users with "diamond" characters in their user names.
  • Enforcement subroutines.
WeBWorK::DB::checkKeyfields() checks allowed entries into the database. 
The default allowed characters are: /^[-a-zA-Z0-9_.]*$/
This is broadened for some keyfields -- particularly those using versions.