From d90c6cffeff2c1a99444e2529b892d397a96e9fa Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Tue, 17 Jun 2025 13:34:55 -0700 Subject: [PATCH] Remove old documentation --- doc/devel/DBglue.notes | 75 ---- doc/devel/URL-notes | 92 ----- doc/devel/cg-refactor-notes | 300 ---------------- doc/devel/converted-cgs | 81 ----- doc/devel/daemon-problem-environment | 70 ---- doc/devel/dont-forget | 24 -- doc/devel/hardcopy-notes | 22 -- doc/devel/new-DB-API | 91 ----- doc/devel/new-DB-architecture | 165 --------- doc/devel/new-DB-notes | 67 ---- doc/devel/new-DB-sql | 79 ----- doc/devel/new-DB-structure | 69 ---- doc/devel/pre-bugzilla-TODO-file | 186 ---------- doc/devel/schema-2002 | 77 ----- doc/devel/template-escapes | 14 - doc/devel/unified-prof-page-form-notes | 32 -- doc/parser/README | 145 -------- doc/parser/docs/ParserAnswerCheckers.pod | 423 ----------------------- doc/parser/docs/UsingParser.pod | 401 --------------------- doc/parser/extensions/1-function.pg | 79 ----- doc/parser/extensions/2-function.pg | 79 ----- doc/parser/extensions/3-operator.pg | 109 ------ doc/parser/extensions/4-list.pg | 102 ------ doc/parser/extensions/5-operator.pg | 85 ----- doc/parser/extensions/6-precedence.pg | 80 ----- doc/parser/extensions/7-context.pg | 82 ----- doc/parser/extensions/8-answer.pg | 110 ------ doc/parser/problems/sample01.pg | 64 ---- doc/parser/problems/sample02.pg | 57 --- doc/parser/problems/sample03.pg | 61 ---- doc/parser/problems/sample04.pg | 113 ------ doc/parser/problems/sample05.pg | 137 -------- doc/parser/problems/sample06.pg | 53 --- doc/parser/problems/sample07.pg | 49 --- doc/parser/problems/sample08.pg | 49 --- doc/parser/problems/sample09.pg | 49 --- doc/parser/problems/sample10.pg | 54 --- doc/parser/problems/sample11.pg | 48 --- doc/parser/problems/sample12.pg | 60 ---- doc/parser/problems/sample13.pg | 59 ---- doc/parser/problems/sample14.pg | 57 --- doc/parser/problems/sample15.pg | 57 --- doc/parser/problems/sample16.pg | 61 ---- doc/parser/problems/sample17.pg | 62 ---- doc/parser/problems/sample18.pg | 61 ---- doc/parser/problems/sample19.pg | 65 ---- doc/parser/problems/sample20.pg | 60 ---- doc/parser/problems/sample21.pg | 62 ---- doc/parser/problems/sample22.pg | 58 ---- 49 files changed, 4535 deletions(-) delete mode 100644 doc/devel/DBglue.notes delete mode 100644 doc/devel/URL-notes delete mode 100644 doc/devel/cg-refactor-notes delete mode 100644 doc/devel/converted-cgs delete mode 100644 doc/devel/daemon-problem-environment delete mode 100644 doc/devel/dont-forget delete mode 100644 doc/devel/hardcopy-notes delete mode 100644 doc/devel/new-DB-API delete mode 100644 doc/devel/new-DB-architecture delete mode 100644 doc/devel/new-DB-notes delete mode 100644 doc/devel/new-DB-sql delete mode 100644 doc/devel/new-DB-structure delete mode 100644 doc/devel/pre-bugzilla-TODO-file delete mode 100644 doc/devel/schema-2002 delete mode 100644 doc/devel/template-escapes delete mode 100644 doc/devel/unified-prof-page-form-notes delete mode 100644 doc/parser/README delete mode 100644 doc/parser/docs/ParserAnswerCheckers.pod delete mode 100644 doc/parser/docs/UsingParser.pod delete mode 100644 doc/parser/extensions/1-function.pg delete mode 100644 doc/parser/extensions/2-function.pg delete mode 100644 doc/parser/extensions/3-operator.pg delete mode 100644 doc/parser/extensions/4-list.pg delete mode 100644 doc/parser/extensions/5-operator.pg delete mode 100644 doc/parser/extensions/6-precedence.pg delete mode 100644 doc/parser/extensions/7-context.pg delete mode 100644 doc/parser/extensions/8-answer.pg delete mode 100644 doc/parser/problems/sample01.pg delete mode 100644 doc/parser/problems/sample02.pg delete mode 100644 doc/parser/problems/sample03.pg delete mode 100644 doc/parser/problems/sample04.pg delete mode 100644 doc/parser/problems/sample05.pg delete mode 100644 doc/parser/problems/sample06.pg delete mode 100644 doc/parser/problems/sample07.pg delete mode 100644 doc/parser/problems/sample08.pg delete mode 100644 doc/parser/problems/sample09.pg delete mode 100644 doc/parser/problems/sample10.pg delete mode 100644 doc/parser/problems/sample11.pg delete mode 100644 doc/parser/problems/sample12.pg delete mode 100644 doc/parser/problems/sample13.pg delete mode 100644 doc/parser/problems/sample14.pg delete mode 100644 doc/parser/problems/sample15.pg delete mode 100644 doc/parser/problems/sample16.pg delete mode 100644 doc/parser/problems/sample17.pg delete mode 100644 doc/parser/problems/sample18.pg delete mode 100644 doc/parser/problems/sample19.pg delete mode 100644 doc/parser/problems/sample20.pg delete mode 100644 doc/parser/problems/sample21.pg delete mode 100644 doc/parser/problems/sample22.pg diff --git a/doc/devel/DBglue.notes b/doc/devel/DBglue.notes deleted file mode 100644 index 3402a13a8d..0000000000 --- a/doc/devel/DBglue.notes +++ /dev/null @@ -1,75 +0,0 @@ -############## -# webwork_DB # -############## - -PSVN => - => - - (Generated during problem set build process:) - - stlg StudentLogin the login name of the student who owns this PSVN - stnm SetNumber the "number" (name) of the problem set associated with this PSVN - pse# ProblemSeed(#) the problem seed, a random integer between 0 and 5000 - - (Taken from set definition file:) - - shfn SetHeaderFileName the file name of the set header file (shown when selecting problem?) - phfn ProbHeaderFileName the file name of the problem header file (shown when viewing a problem) - opdt OpenDate the date that the problem set "opens" - dudt DueDate the date after which no credit can be recieved - andt AnswerDate the date when answers can be shown - pfn# ProblemFileName(#) the file name of the problem - pva# ProblemValue(#) the number of points that the problem is worth - pmia# ProblemMaxNumOfIncorrectAttempts(#) the number of times a student is allowed to answer incorrectly - - (Added when student works on problem set:) - - pst# ProblemStatus(#) the "correctness" of the problem: [0,1] - pat# ProblemAttempted(#) boolean, whether the problem has been attempted (answer has been submitted) - pan# ProblemStudentAnswer(#) the student's last answer (attempt) for a problem - pca# ProblemNumOfCorrectAns(#) number of correct answers (there can be more than one ANS per problem) - pia# ProblemNumOfIncorrectAns(#) number of incorrect answers - -LOGIN => - SetNumber => PSVN - ... - -SET_NUMBER => - StudentLogin => PSVN - ... - -################ -# classlist_DB # -################ - -LOGIN => - stln StudentLastName - stfn StudentFirstName - stea StudentEmailAddress - stid StudentID - stst StudentStatus - clsn ClassSection - clrc ClassRecitation - comt Comment - -######## -# keys # -######## - -LOGIN => - KEY the last key associated with the user - TIMESTAMP the time that this key was last used - -############### -# password_DB # -############### - -LOGIN => - PASSWORD the password set for this user - -################## -# permissions_DB # -################## - -LOGIN => - PERMISSIONS an integer representing the permissions allowed to the user (i.e. 10=prof, 5=ta) diff --git a/doc/devel/URL-notes b/doc/devel/URL-notes deleted file mode 100644 index 61c5cc672a..0000000000 --- a/doc/devel/URL-notes +++ /dev/null @@ -1,92 +0,0 @@ -THE CURRENT STRATEGY - -The URL strategy we've been basically using is to put the nouns in the path info and the verbs in the query string. The heirarchy of the path info mirrors the heirarchy of objects in the system. It works like this in the Problem.pm content generator (I think): - - /webwork/$courseID/$setID/$problemID?submitAnswer=Submit+Answer - -WeBWorK contains courses, courses contain sets, sets contain problems. This is reflected in the path info. The presence of a parameter named submitAnswer in the query string causes Problem.pm to record the answers given later in the query string. The set and problem to which the answers are recorded is given in the path info. Each content generator has a default action that is performed if no verbs are given in the query string. These default actions are non-destructive, i.e. "view" or "list". - -ADVANTAGES - -This scheme has the advantage of allowing a user (usually a professor) to easily reference a "location" within the system, without needing to worry about the relativly complicated syntax of the query string. For example, a professor could, after making a change to a problem, instruct students via email to "visit http://courses.webwork.rochester.edu/mth161/4/7/ to view the updated problem". This is certainly more manageable than a scheme in which the verb is in the path info and the nouns are in the query string (as in "http://courses.webwork.edu/viewProblem?course=mth161&set=4&problem=7"). - -It also allows us to, as we strive to reduce the amount of state that is passed through each request, pare the URL down so that very little query string remains. For example, the session key could be kept in a cookie, and the rest of the session data could be kept in the key table of the database. The only thing that would be left in the query string would be the verb and (I suppose) various "adverbs" and "adjectives". - -PROBLEMS - -Currently the dispatch() function uses only the path info to decide which content generator to invoke. This means that unless we wish to have the problem viewer and the problem editor be implemented in the same content generator, it would be impossible to have these two URIs: - - /webwork/$courseID/$setID/$problemID/?action=view - /webwork/$courseID/$setID/$problemID/?action=edit - -This, I think, can be solved by allowing the dispatch() function to inspect the query string in a limited fashion. If it were allowed to check for an "action" parameter, and a standard set of actions were defined, the combination of an action (in the query string) and a type of object (in the path info) could be used to select a content generator. - -A table would be needed to noun/action pairs to content generators and vice versa. For example: - - Problem + view <=> WeBWorK::ContentGenerator::Problem - Problem + edit <=> WeBWorK::ContentGenerator::Instructor::PGProblemEditor - -However, there are some tricky implementation problems with this approach. The value of a parameter triggered by a submit button (generated with the INPUT element) is the same as the text that is displayed on the button. This puts the desire for good UI at odds with having easily manageable action identifiers. We'd like to have a button named "Download Hardcopy for Selected Sets", but have the action identifier be "makeHardcopy" or something. The BUTTON element promises to solve this, but browser support is very broken for both the presentation and behavior of this element. - -Another problem with this scheme is that sometimes the nouns needed are not known when the form action is decided at page generation time. For example, the URI for creating a new set might be something like: - - /webwork/$courseID/instructor/sets/$setID?action=create - -The set name ($setID) would have be supplied by a text field on the form, and therefore would not be known at the time that the form was generated. One solution to this would be to name the "slots" in the path info, and have the dispatcher substitute in values from the query string before handing the request off to the content generator. A redirect to the URI with the values substituted in could fix the user experience somewhat. For example, the dispatcher could convert the URI: - - /webwork/mth161/instructor/sets/?action=create&setID=newIntegrals - -to: - - /webwork/mth161/instructor/sets/newIntegrals/?action=create - -In the example, the value of the parameter named "setID" was placed in the "setID" slot in the path info, and the parameter was deleted. - --------------------------------------------------------------------------------- - -(+) = list - -THE CURRENT URI HEIRARCHY - -$webworkURIRoot - $courseID - test - $setID - $problemID - hardcopy - $setID - login - logout - options - feedback - instructor - [some crap] - -PROPOSED URI HEIRARCHY - -$webworkURIRoot - $courseID -- lists sets - test -- prints debugging information - $setID -- lists problems in a set - $problemID -- displays problem (interactive mode) - hardcopy -- prompts user for which sets/users to generate - $setID (+) -- generates hardcopy for specified sets - login -- prompts for login information - logout -- deletes session information, displays logout message - options -- allows user to change email address and password - feedback -- allows user to send feedback to professor - instructor -- gives user a choice between user list and set list - sets -- lists/edits (global) sets - $setID -- displays/edits (global) set data - problems -- lists (global) problems for a set - $problemID -- displays/edits (global) set data - users -- lists/edits assigned users - $userID (+) -- displays/edits user-specific set data - problems -- lists/edits assigned problems - $problemID -- displays/edits user-specific problem data - users -- lists/edits users - $userID -- displays/edits user data - sets -- lists/edits assigned sets - $setID -- displays/edits user-specific set data - problems -- lists/edits assigned problems - $problemID -- displays/edits user-specific problem data diff --git a/doc/devel/cg-refactor-notes b/doc/devel/cg-refactor-notes deleted file mode 100644 index b9e0f4e35c..0000000000 --- a/doc/devel/cg-refactor-notes +++ /dev/null @@ -1,300 +0,0 @@ --------------------------------------------------------------------------------- -currently, ContentGenerators do several things: --------------------------------------------------------------------------------- - -display lists of objects and object details ("displays") -prompt for list filtering ("display filters") -prompt for creating, editing, and deleting objects ("action triggers") -create, edit, and delete objects ("actions") - --------------------------------------------------------------------------------- -goals: --------------------------------------------------------------------------------- - -have a chunk of code that takes care of each "action" -avoid duplication of code -preserve and "purify" noun-based URL path-info -have the noun-based path refer to the object or list being viewed - --------------------------------------------------------------------------------- -changes to request format: --------------------------------------------------------------------------------- - -Define some special parameters that are recognized by the dispatcher: - - "u" specifies the current user (i.e. the actual human using the system) - "p" specifies the password of the current user - "k" specifies the session key of the current user - "a" specifies an action to perform (like "a=deleteUser") - "o" specifies objects on which to perform an action (like "o=sh002i&o=dl001i") - -We should reserve all single-letter parameter names. -(UPDATE: I changed my mind. Single-letter param names are unneccesarily -obfuscated and annnoying.) - -We can't use - -An action trigger that would be put onto a user detail page: - - - --------------------------------------------------------------------------------- -development plan --------------------------------------------------------------------------------- - -1. write a "new" dispatcher -2. code display modules using display code from existing content generators -3. add actions and action triggers as needed, using code from existing content generators -4. ? -5. profit diff --git a/doc/devel/converted-cgs b/doc/devel/converted-cgs deleted file mode 100644 index 89d98aebcf..0000000000 --- a/doc/devel/converted-cgs +++ /dev/null @@ -1,81 +0,0 @@ -4 => 3 + GENERATE PATHS WITH URLPath INSTEAD OF HARD CODING -(this has to be done before we can change the virtual heirarchy.) - lib/WeBWorK/ContentGenerator.pm - lib/WeBWorK/ContentGenerator/EquationDisplay.pm - lib/WeBWorK/ContentGenerator/Error.pm - lib/WeBWorK/ContentGenerator/Feedback.pm - lib/WeBWorK/ContentGenerator/Grades.pm - lib/WeBWorK/ContentGenerator/Home.pm - lib/WeBWorK/ContentGenerator/Instructor.pm - lib/WeBWorK/ContentGenerator/Instructor/AddUsers.pm - lib/WeBWorK/ContentGenerator/Instructor/Assigner.pm - lib/WeBWorK/ContentGenerator/Instructor/FileXfer.pm - lib/WeBWorK/ContentGenerator/Instructor/Index.pm - lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm - lib/WeBWorK/ContentGenerator/Login.pm - lib/WeBWorK/ContentGenerator/Logout.pm - lib/WeBWorK/ContentGenerator/Options.pm - lib/WeBWorK/ContentGenerator/Problem.pm - lib/WeBWorK/ContentGenerator/ProblemSet.pm - lib/WeBWorK/ContentGenerator/ProblemSets.pm - - lib/WeBWorK/ContentGenerator/Instructor/ProblemList.pm - lib/WeBWorK/ContentGenerator/Instructor/ProblemSetEditor.pm - lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm - lib/WeBWorK/ContentGenerator/Instructor/Scoring.pm - lib/WeBWorK/ContentGenerator/Instructor/ScoringDownload.pm - lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm - lib/WeBWorK/ContentGenerator/Instructor/SetsAssignedToUser.pm - lib/WeBWorK/ContentGenerator/Instructor/ShowAnswers.pm - lib/WeBWorK/ContentGenerator/Instructor/Stats.pm - lib/WeBWorK/ContentGenerator/Instructor/UserList.pm - -3 => 2 + GET PATH DATA FROM URLPath INSTEAD OF FROM $self->r -(this has to be done before we can take advantage of path/param munging.) - lib/WeBWorK/ContentGenerator/GatewayQuiz.pm - - delaying path generation changes until major cleanup - lib/WeBWorK/ContentGenerator/Hardcopy.pm - - delaying path generation changes until major cleanup - - - - - - - - - - - - lib/WeBWorK/ContentGenerator/Instructor/UsersAssignedToSet.pm - -2 => 1 + GET $ce, $db, $authz FROM $self->r INSTEAD OF FROM $self -(this has to be done before we can remove ce/db/authz from $self.) - - -1 => REMOVE DEPENDANCY ON DATA FROM @_ (get from URLPath instead) -(this has to be done before things will work.) - - - - - -0 => NONE OF THE ABOVE DONE - ------ Code that needs cleaning ----- - -- lots of code needs to be factored out of Problem and GatewayQuiz: - - problem logic (recording answers, checking permissions, etc.) - - display idioms (attemptResults, etc.) -- Hardcopy: - - move actual PDF generation into a Utils::* module - - clean up error handling -- code can be factored out of Grades, Stats, and SendMail - - a widget for displaying the "student progress" chart - - util code for doing mail merge from scoring files (whatever it does) -- Instructor needs work -- there's a lot of cut-n-paste going on -- factor info box formatting code out of Login, ProblemSets, ProblemSet - and into WeBWorK::HTML::InfoBox -- some modules should probably go under Utils: - - Compatability.pm - - Timing.pm diff --git a/doc/devel/daemon-problem-environment b/doc/devel/daemon-problem-environment deleted file mode 100644 index fd9a98e296..0000000000 --- a/doc/devel/daemon-problem-environment +++ /dev/null @@ -1,70 +0,0 @@ -- = not in daemon problem environment from frontier - -- ALLOW_MAIL_TO - answerDate - CAPA_GraphicsDirectory - CAPA_Graphics_URL - CAPA_MCTools - CAPA_Tools - courseName - courseScriptsDirectory -- showHints - displayMode -- showSolutions - dueDate -- externalDvipngPath - externalGif2EpsPath -- externalGif2PngPath -- externalLaTeXPath - externalPng2EpsPath - externalTTHPath - fileName - formattedAnswerDate - formattedDueDate - formattedOpenDate - functAbsTolDefault - functLLimitDefault - functMaxConstantOfIntegration - functNumOfPoints - functRelPercentTolDefault - functULimitDefault - functVarDefault - functZeroLevelDefault - functZeroLevelTolDefault - htmlDirectory - htmlURL - inputs_ref -- languageMode - macroDirectory -- mailSmtpSender -- mailSmtpServer - numAbsTolDefault - numFormatDefault - numOfAttempts - numRelPercentTolDefault - numZeroLevelDefault - numZeroLevelTolDefault - openDate -- outputMode - PRINT_FILE_NAMES_FOR - probFileName - problemSeed - problemValue -- PROBLEM_GRADER_TO_USE - probNum - psvn - questionNumber -- QUIZ_PREFIX -- recitationName -- recitationNumber - sectionName - sectionNumber - sessionKey - setNumber -- studentID - studentLogin - studentName - tempDirectory - templateDirectory - tempURL - webworkDocsURL diff --git a/doc/devel/dont-forget b/doc/devel/dont-forget deleted file mode 100644 index feea0c1e9f..0000000000 --- a/doc/devel/dont-forget +++ /dev/null @@ -1,24 +0,0 @@ -Barbara from UNH had some ideas: - - " [x] destroy existing versions " on build problem sets page. - - others? - -Dan from UNH wants to be able to "name" math expressions so that images can be made conditional (i.e. if( blah ) { TEXT(\[ ... \]) } else { TEXT(\[ ... ]\) } (see email) - -Image generation alternatives: - - math2img, with some generalization - - math2img, as a function in dangerousMacros - - something out of http://preview-latex.sourceforge.net/ - - TeXd -- http://www.activetex.org/ - - - - -defaults.config: - - the "root" of the modperl handler should be sent in from outside - - right now, it's in $webworkURLs{root} - -fun Apache::* modules: - Apache::PerlVINC - Apache::SubProcess - output of subprocesses goes to client - -also: http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Exception_Handling_for_mod_perl diff --git a/doc/devel/hardcopy-notes b/doc/devel/hardcopy-notes deleted file mode 100644 index 8a47286378..0000000000 --- a/doc/devel/hardcopy-notes +++ /dev/null @@ -1,22 +0,0 @@ -students should be able to: - - generate hardcopy for a single problem set for themselves -professors should be able to: - - generate hardcopy of a single problem set for any user - - generate hardcopy of multiple problem sets for any user - - generate hardcopy of a single problem set for multiple users - -inputs: - - $singleSet (from PATH_INFO) - added to @sets list - @sets - lists sets to generate - @users - lists users to generate for - $generateHardcopy - true if "Generate Hardcopy" button has been clicked - -hardcopy generated is (sets x users), if permissions permit - -subroutines: - &generateHardcopy - - compiles tex, translates, converts to pdf - - throws exceptions on PG errors, returns PG warnings - &displayForm - - displays options form diff --git a/doc/devel/new-DB-API b/doc/devel/new-DB-API deleted file mode 100644 index 30c3e319cf..0000000000 --- a/doc/devel/new-DB-API +++ /dev/null @@ -1,91 +0,0 @@ --------------------------------------------------------------------------------- -DB API --------------------------------------------------------------------------------- - -The DB API defines the following methods. These methods are grouped according to which tables they access. A method followed by a list of "=>"-prefixed methods depends on the listed methods. - -password - - listPasswords() - addPassword($Password) - getPassword($userID) - putPassword($Password) - deletePassword($userID) - -permission - - listPermissionLevels() - addPermissionLevel($PermissionLevel) - getPermissionLevel($userID) - putPermissionLevel($PermissionLevel) - deletePermissionLevel($userID) - -key - - listKeys() - addKey($Key) - getKey($userID) - putKey($Key) - deleteKey($userID) - -user - - listUsers() - addUser($User) - getUser($userID) - putUser($User) - deleteUser($userID) - => deletePassword($userID) - => deletePermissionLevel($userID) - => deleteKey($userID) - => deleteUserSet($userID, *) - -set - - listGlobalSets() - addGlobalSet($GlobalSet) - getGlobalSet($setID) - putGlobalSet($GlobalSet) - deleteGlobalSet($setID) - => deleteGlobalProblem($setID, *) - => deleteUserSet(*, $setID) - -set_user - - listSetUsers($setID) - listUserSets($userID) - addUserSet($UserSet) - getUserSet($userID, $setID) - putUserSet($UserSet) - deleteUserSet($userID, $setID) - => deleteUserProblem($userID, $setID, *) - -problem - - listGlobalProblems($setID) - addGlobalProblem($GlobalProblem) - getGlobalProblem($setID, $problemID) - putGlobalProblem($GlobalProblem) - deleteGlobalProblem($setID, $problemID) - => deleteUserProblem(*, $setID, $problemID) - -problem_user - - listProblemUsers($setID, $problemID) - listUserProblems($userID, $setID) - addUserProblem($UserProblem) - getUserProblem($userID, $setID, $problemID) - putUserProblem($UserProblem) - deleteUserProblem($userID, $setID, $problemID) - -set+set_user - - getGlobalUserSet($userID, $setID) - => getGlobalSet($setID) - => getUserSet($userID, $setID) - -problem+problem_user - - getGlobalUserProblem($userID, $setID, $problemID) - => getGlobalProblem($setID, $problemID) - => getUserProblem($userID, $setID, $problemID) diff --git a/doc/devel/new-DB-architecture b/doc/devel/new-DB-architecture deleted file mode 100644 index 3bc4d72110..0000000000 --- a/doc/devel/new-DB-architecture +++ /dev/null @@ -1,165 +0,0 @@ --------------------------------------------------------------------------------- -Architecture --------------------------------------------------------------------------------- - -The new database system uses a three-tier architecture to insulate each layer from the adjacent layers. - -TOP LAYER: DB -------------- - -The top layer of the architecture is the DB module. It provides the methods -listed in doc/new-DB-API, and uses schema modules (via tables) to implement those methods. - - / list* exists* add* get* put* delete* \ <- api -+------------------------------------------------------------------+ -| DB | -+------------------------------------------------------------------+ - \ password permission key user set set_user problem problem_user / <- tables - - -MIDDLE LAYER: SCHEMAS ---------------------- - -The middle layer of the architecture is provided by one or more schema modules. They are called "schema" modules because they control the structure of the data for a table. This includes odd things like the way multiple tables are encoded in a single hash in the WWHash schema, and the encoding scheme used. - -The schema modules provide an API that matches the requirements of the DB layer, on a per-table basis. Each schema module has a style that determines which drivers it can interface with. For example, WWHash is a "hash" style schema. SQL is a "dbi" style schema. - -Both WeBWorK 1.x and 2.x courses use: - - / password permission key \ / user \ <- tables -+-----------------------------+ +----------------+ -| Auth1Hash | | Classlist1Hash | -+-----------------------------+ +----------------+ - \ hash / \ hash / <- style - -WeBWorK 1.x courses also use: - - / set_user problem_user \ / set problem \ -+-------------------------+ +---------------------+ -| WW1Hash | | GlobalTableEmulator | -+-------------------------+ +---------------------+ - \ hash / \ null / - -The GlobalTableEmulator schema emulates the global set and problem tables using data from the set_user and problem_user tables. - -WeBWorK 2.x courses also use: - - / set set_user problem problem_user \ -+-------------------------------------+ -| WW2Hash | -+-------------------------------------+ - \ hash / - -Other drop-in schema modules could be: - - / * \ / password \ -+-------+ +--------------+ -| SQL | | PasswordLDAP | -+-------+ +--------------+ - \ dbi / \ ldap / - - -BOTTOM LAYER: DRIVERS ---------------------- - -Driver modules implement a style for a schema. They provide physical access to a data source containing the data for a table. Some driver modules are as follows: - - / hash \ / hash \ / hash \ <- style -+--------+ +--------+ +--------+ -| DB | | GDBM | | DB3 | -+--------+ +--------+ +--------+ - - / dbi \ / ldap \ -+-------+ +--------+ -| DBI | | LDAP | -+-------+ +--------+ - --------------------------------------------------------------------------------- -Schema API --------------------------------------------------------------------------------- - -$record - an object representing a record in the table -@keyparts - values for fields that make up the table's key - -@tables = tables() - returns list of tables supported. - -$style = style() - returns the required driver style. - -$handle = new($db, $driver, $table, $record, $params) - creates a schema interface for $table, using the driver interface - provided by $driver and using the record class named in $record. dies - if the $driver does not support the driver style needed by the schema. - $params contains extra information needed by the schema. $db is provided - so that schemas can query other schemas. (This is used by the - GlobalTableEmulator schema.) - -@keys = $handle->list(@keyparts) - returns a list containing the key of each record in the table that - matches the values in @keyparts. (i.e. [$userID, undef] will return all - of the records with the specified user_id.) the elements of @keys are - \@keyparts. if no matching records exist, an empty list is returned. - -$result = $handle->exists(@keyparts) - returns whether a record matching @keyparts exists in the table. - -$result = $handle->add($record) - attempts to add $record to the table. die if a record with the same key - exists. - -$record = $handle->get(@keyparts) - attempts to retrieve the record matching @keyparts from the table. - returns undef if no record matches. - -$result = $handle->put($record) - attempts to replace the record in the table that matches the key of - $record. dies if no such record exists. - -$result = $handle->delete(@keyparts) - attempts to delete the record matching @keyparts from the table. returns - true if the record was successfully deleted, or false if it did not - exist. - --------------------------------------------------------------------------------- -Driver API --------------------------------------------------------------------------------- - -COMMON ------- - -$style = style() - returns the supported driver style. - -$handle = new($source, $params) - creates a new interface to the data contained in $source. $params - contains extra information needed by the schema. - -$result = $handle->connect($mode) - connects to the data source with access mode $mode. dies if connection - fails. - -$result = $handle->disconnect() - disconnects from the data source. dies if disconnection fails. - -STYLE: hash ------------ - -$ref = $handle->hash() - returns a reference to the underlying tied hash. dies if the hash is - not available (i.e. not connected). - --------------------------------------------------------------------------------- -@keyparts key order --------------------------------------------------------------------------------- - -table keyparts ------ -------- -password user_id -permission user_id -key user_id -user user_id -set set_id -set_user user_id, set_id -problem set_id, problem_id -problem_user user_id, set_id, problem_id diff --git a/doc/devel/new-DB-notes b/doc/devel/new-DB-notes deleted file mode 100644 index fb2baa0634..0000000000 --- a/doc/devel/new-DB-notes +++ /dev/null @@ -1,67 +0,0 @@ --------------------------------------------------------------------------------- -Notes on the new database system --------------------------------------------------------------------------------- - -CHANGES IN THE ARCHITECTURE ---------------------------- - -The architecture is now three-tier. For more information, consult the file doc/new-DB-architecture. - -CHANGES IN THE TABLE STRUCTURE ------------------------------- - -PSVNs have been added to the set_user table, eliminating the need for a separate PSVN table. - -set_user and problem_user tables have been added, containing student-specific data. In most cases, the override fields (marked `!' above) will be empty. The dynamic fields (marked `~' above) will be populated as the student works through problems. problem_seed (in problem_user) and psvn(in set_user) are neither dynamic or override fields -- they are set at assignment time. - -a problem_order field has been added to the set and set_user tables. It contains a definition of how the problems in each set will be ordered. - -RECORD CREATION DEPENDANCIES ----------------------------- - - password -> user - permission -> user - key -> user - user -> - set -> - set_user -> user, set - problem -> set -problem_user -> set_user, problem - -RECORD DELETION DEPENDANCIES ----------------------------- - - password -> - permission -> - key -> - user -> password permission key set_user - set -> set_user problem - set_user -> problem_user - problem -> problem_user -problem_user -> - -TABLE STRUCTURE IMPLEMENTATION IN HASH-BASED DATABASES ------------------------------------------------------- - -The GeneralHash schema module will implement a new table structure implementation for use with WeBWorK 2. Classlist1Hash, Auth1Hash, and WW1Hash will use the old implementation. - -Each table will be stored in a separate database file. Each table has one or more fields that make up a unique identifier for each record. In the case of a one field identifier, the value of that field will be used as the record's key in the hash. In the case of a two-field identifier, the string "FIELD1:FIELD2" will be used. Literal colons will be escaped as `\:', and literal backslashes as `\\'. - -Rather than use a custom encoding scheme for the hash data, as is done in the 1.x implementation, a simple table-based scheme will be used, in which each field is separated by a colon (`:'). Literal colons (and literal backslashes) will be dealt with as above. This sort of scheme is common in the UNIX world. For example, consider the UNIX password file. - -COMPATABILITY WITH 1.X DATABASES --------------------------------- - -By specifying the WW1Hash schema module for the appropriate tables, 1.x databases can be handled. - -Conversion of 1.x databases to 2.x databases can be achieved by using the most popular value for each field in each user-specific record as the global value, and merging PSVNs from the separate PSVN table. Conversion from 2.x databases to 1.x databases is trivial, if somewhat lossy (i.e. problem_order). - -TREATMENT OF THE CURRENT API ----------------------------- - -The current API (implemented by Auth.pm, Classlist.pm, and WW.pm) will be removed. The code base is currently small enough that it will be easy to migrate existing code to the new API. - -NEW API FUNCTIONS ------------------ - -The new API is outlined in the file doc/new-DB-API. diff --git a/doc/devel/new-DB-sql b/doc/devel/new-DB-sql deleted file mode 100644 index cdd3877fed..0000000000 --- a/doc/devel/new-DB-sql +++ /dev/null @@ -1,79 +0,0 @@ -# Feed this file to the mysql client to create a course database. Replace the -# string !!COURSENAME!! with the name of your course. - -CREATE DATABASE webwork_!!COURSENAME!!; -USE webwork_!!COURSENAME!!; - -CREATE TABLE user ( - user_id VARCHAR(255) NOT NULL PRIMARY KEY, - first_name TEXT, - last_name TEXT, - email_address TEXT, - student_id TEXT, - status TEXT, - section TEXT, - recitation TEXT, - comment TEXT -); - -CREATE TABLE password ( - user_id VARCHAR(255) NOT NULL PRIMARY KEY, - password TEXT -); - -CREATE TABLE permission ( - user_id VARCHAR(255) NOT NULL PRIMARY KEY, - permission INT -); - -CREATE TABLE key_not_a_keyword ( - user_id VARCHAR(255) NOT NULL PRIMARY KEY, - key_not_a_keyword TEXT, - timestamp INT -); - -CREATE TABLE set_not_a_keyword ( - set_id VARCHAR(255) NOT NULL PRIMARY KEY, - set_header TEXT, - problem_header TEXT, - open_date INT, - due_date INT, - answer_date INT -); - -CREATE TABLE set_user ( - user_id VARCHAR(255) NOT NULL, - set_id VARCHAR(255) NOT NULL, - psvn INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - set_header TEXT, - problem_header TEXT, - open_date INT, - due_date INT, - answer_date INT -); - -CREATE TABLE problem ( - set_id VARCHAR(255) NOT NULL, - problem_id VARCHAR(255) NOT NULL, - source_file TEXT, - value INT, - max_attempts INT -); - -CREATE TABLE problem_user ( - user_id VARCHAR(255) NOT NULL, - set_id VARCHAR(255) NOT NULL, - problem_id VARCHAR(255) NOT NULL, - source_file TEXT, - value INT, - max_attempts INT, - problem_seed INT, - status FLOAT, - attempted INT, - last_answer TEXT, - num_correct INT, - num_incorrect INT -); - -GRANT select ON webwork_!!COURSENAME!!.* TO webworkRead@localhost IDENTIFIED BY 'zaqwsxcderfv'; -GRANT select, insert, update, delete ON webwork_!!COURSENAME!!.* TO webworkWrite@localhost IDENTIFIED BY 'qwerfdsazxcv'; diff --git a/doc/devel/new-DB-structure b/doc/devel/new-DB-structure deleted file mode 100644 index 4e42f958b0..0000000000 --- a/doc/devel/new-DB-structure +++ /dev/null @@ -1,69 +0,0 @@ --------------------------------------------------------------------------------- -DB table structure --------------------------------------------------------------------------------- - -The DB API models an underlying table structure that may or may not literally exist, depending on what transformations the schema modules make. However, this is the table structure that is presented to users of the DB module. - -The order of key fields in this list is the order that arguments should be passed to the exists(), get(), and delete() schema functions, and the order of the values in the return value of the list() schema function. - -* indicates a key -=> indicates a relation -! indicates an override field -~ indicates a "dynamic" field (modified by the problem processor) - -password - user_id *,=> user.id - password -permission - user_id *,=> user.id - permission -key - user_id *,=> user.id - key -user - id * - first_name - last_name - email_address - student_id - status - section - recitation - comment -set - id * - set_header - problem_header - open_date - due_date - answer_date - problem_order (not implemented) -set_user - user_id *,=> user.id - set_id *,=> set.id - psvn - set_header ! - problem_header ! - open_date ! - due_date ! - answer_date ! - problem_order ! (not implemented) -problem - id * - set_id *,=> set.id - source_file - value - max_attempts -problem_user - user_id *,=> user.id - set_id *,=> set.id - problem_id *,=> problem.id - source_file ! - value ! - max_attempts ! - problem_seed - status ~ - attempted ~ - last_answer ~ - num_correct ~ - num_incorrect ~ diff --git a/doc/devel/pre-bugzilla-TODO-file b/doc/devel/pre-bugzilla-TODO-file deleted file mode 100644 index eaf799a3ba..0000000000 --- a/doc/devel/pre-bugzilla-TODO-file +++ /dev/null @@ -1,186 +0,0 @@ -################################################################################ -# WeBWorK mod_perl (c) 2000-2002 WeBWorK Project -# $Id: pre-bugzilla-TODO-file,v 1.1 2003-06-03 19:23:03 sh002i Exp $ -################################################################################ - -Son of WeBWorK - TODO list - -DONE write template file from what we drew on the board -DONE normalize files: - - (c) header on all files - - standard order of preamble lines: - 1. (c) header - - 2. package PACKAGENAME; - - 3. short summary of the package (pod's NAME section) - - 4. use - pragmatic modules - 5. use - standard perl modules - 6. use - CPAN modules - 7. use - webwork modules - - ALWAYS use strict and use warnings - - use "use base" rather than "our @ISA" - - no warnings or errors! - - (later on) POD documentation for all files -DONE fix templating code in ContentGenerator, add new escape functions -DONE implement the new template -DONE finish ProblemSets and ProblemSet - --------------------------------------------------------------------------------- - -DONE New interface to PG.pm - DONE - instead of it accessing the database directly, accept $user, - $set, and $problem as arguments (instead of $setName, etc.) - DONE - UPDATE PG.pm'S DOCS!!!!!!!!!!!!! - DONE - Fix Problem.pm and Hardcopy.pm to work with the new interface - - Hardcopy generation - DONE - ad-hoc version of &latex2png in Hardcopy.pm (move later) - DONE - fix code (heh heh) - DONE - fix hardcopySetHeader - - Integration of dvipng method of image generation - N/A - choice between writing to a temporary TeX file from within - dangerousMacros, or queueing the equations up in RAM and - passing them out to the caller (via PG_flags?) who will then - call &latex2png - DONE - write tempfile from dangerousMacros - - PRO: gets it out of RAM - - PRO: no dependancies between equations - - CON: have to coordinate between latex2png and - dangerous macros for tempfile locations - FORGET - queue equations in RAM - - PRO: all file access and external calls happen - outside of the safe compartment. - - PRO: latex2png gets to decide where to put files - - CON: stuff sits in RAM - - CON: uses a package array to queue equations :p - -DONE display of screen set header in ProblemSet.pm (easy) -DONE add -DONE fix alignment of displaymath images -DONE print $pg->{header_text} in head of Problem.pm -DONE remove "set" and "prob" from URL generation, remove s/^(set|prob)//; -DONE remove webwork-dvipng-xxxxx temp directories when finished with them -DONE make "enter" on the problem form trigger "submit answer", not "redisplay" -DONE handling of PG warnings (?!?!?!?!) -DONE time logging -DONE test transaction logging -DONE make static images work -DONE make GD-generated images work -DONE make HTML links work -DONE make images in PDFs work -DONE remove dependancies on Global:: from send_mail_to -DONE preview button in Problem -DONE handle PG errors (and warnings) in Hardcopy -DONE have logout button invalidate key -DONE Options - email address and password - --------------------------------------------------------------------------------- - ->>>>> FOR JANUARY PREVIEW RELEASE <<<<< - -DONE Feedback - need nice modular way of sending email -DONE customize reciever, make object dumps prettier, link to context -DONE Professor - redirect to the old system - pretty die messages (from outside of the translator) -DONE make sure students can't look at not-yet-open problem sets -DONE make answer previews use $displayMode -DONE make preview-on-submit optional - Increase border size on images by a couple pixels -DONE effectiveUser for at least Problem.pm -DONE add a "check answers" button if the user has the apropriate permissions -DONE write a template escape for printing $user, $effectiveUser, &c. nicely - calling logout requires valid key -- doesn't make sense. -DONE hardcopy - allow hardcopy with correct answers (BRANCH) -DONE sort problems by due date -DONE disable "show hint/solution" when there's no hint/solution -DONE results table -DONE part(or blank)/entered/preview/result/messages -DONE don't show messages unless there are some -DONE make displayMode sticky (for nav and siblings) -DONE check TTH mode character encodings on mac - grep for "***" in source, address all issues (hah!) - -mike wants: - problem credit indicator (graphical?) -DONE answers/solutions in hardcopy -DONE turn off verbose debugging in feedback mail -DONE URL on feedback from any module - email address change notification by email -arnie wants: - parse errors in student answers hilited more strongly - ->>>>> FOR SPRING RELEASE <<<<< - - write TeXImage module to take care of TeX image caching and generation - replace direct access of $permissionLevel with calls to Authz - replace hardcoded URL construction with some other method - (unify dispatcher URL parsing and module URL generation) - implement professor pages - have the prof modules be subclasses of the single Professor - ContentGenerator module? more structured? less structured? - THIS WILL TAKE LONGER THAN I THINK IT WILL - implement better (and more unified) file editor - ->>>>> AFTER SPRING RELEASE <<<<< - - MySQL and PostgreSQL database backend - problem library work (?) - PG language work (?) - renderer/frontend/database uncoupling (?) - --------------------------------------------------------------------------------- - -change notes - --------------------------------------------------------------------------------- - -IO functions (dependancies on other IO functions are not listed) - -all variables in the global namespace should be replaced with items in the -%envir hash. all functions that access the envir hash need to be evaluated -from within the safe compartment (i.e. &unrestricted_eval'd). - -includePGtext - $envir{probFileName} -send_mail_to - $REMOTE_HOST - $REMOTE_ADDR - #$Global::smtpServer - #$Global::webmaster - (&Global::wwerror) -read_whole_problem_file -read_whole_file -convertPath stub -getDirDelim stub -getCourseTempDirectory - $envir{tempDirectory} -surePathToTmpFile - #$Global::tmp_directory_permission - #$Global::numericalGroupID - (&Global::wwerror) -fileFromPath -directoryFromPath -createFile -createDirectory -getImageDimmensions - --------------------------------------------------------------------------------- - - Calling LaTeX/dvipng and PDFLaTeX in a nice way - - create LaTeX.pm (?) - - &latex2pdf - - create secure tempdir - - write hardcopy to tex file - - call pdflatex - - move resulting pdf file to tmp/hardcopy/whatever.pdf - - remove tempdir - - &latex2png (dvipng method) - - create secure tempdir - - write equations to tex file - - call latex - - run dvipng (as per ImageGenerator) on dvi file - - move resulting images to tmp/dvipng/whatever.png - - remove tempdir diff --git a/doc/devel/schema-2002 b/doc/devel/schema-2002 deleted file mode 100644 index e449eac1b8..0000000000 --- a/doc/devel/schema-2002 +++ /dev/null @@ -1,77 +0,0 @@ -=> denotes a field which corresponds to the key of another table - --------------------------------------------------------------------------------- -Database: COURSENAME_classlist (i.e. MTH161Q_classlist) --------------------------------------------------------------------------------- - -Table: user -Read by: scoring tools, classlist tools -Written by: classlist tools - - login - last_name - first_name - email_address - student_id - status - section - recitation - comment - -Table: access -Read by: authorization system -Written by: classlist tools - - login - password - permissions - --------------------------------------------------------------------------------- -Database: COURSENAME_webwork --------------------------------------------------------------------------------- - -Table: set -Read by: set lister, problem lister, harcopy generator, problem processor -Written by: set generator - - name - set_header - problem_header - open_date - due_date - answer_date - -Table: problem_SETNAME -Read by: problem lister, hardcopy generator, problem processor, scoring tools -Written by: set generator - - number - source_file - value - max_attempts - -Table: set_user -Read by: same as set table -Written by: set generator - - login => user.login - set => set.name - psvn - problem_order - open_date - due_date - answer_date - -Table: ww_USERNAME -Read by: same as problem_SETNAME table -Written by: set generator, problem processor - - set => set.name - problem => problem.number - max_attempts - problem_seed - status - attempted - last_answer - num_correct - num_incorrect diff --git a/doc/devel/template-escapes b/doc/devel/template-escapes deleted file mode 100644 index 9ddb4f7756..0000000000 --- a/doc/devel/template-escapes +++ /dev/null @@ -1,14 +0,0 @@ -head -path - style = text|image - image = URL of image - text = text separator -links -siblings -nav - style = text|image - imageprefix = prefix to image URL - imagesuffix = suffix to image URL - separator = HTML to place in between links -title -body diff --git a/doc/devel/unified-prof-page-form-notes b/doc/devel/unified-prof-page-form-notes deleted file mode 100644 index b147503bfc..0000000000 --- a/doc/devel/unified-prof-page-form-notes +++ /dev/null @@ -1,32 +0,0 @@ -{ - field_name => { - type => /number|text|date|password|enumerable/, - size => /\d*/, - specificity => /global|user/, - access => /readonly|writeonly|readwrite/, - items => { # Only for enumerable - value => "label", - value => "label", - } - synonyms => { - qr/pattern/ => "value", - qr/pattern/ => "value", - "*" => "value", - } - } -} - -type number, text, longtext, date -label -value -specificity global user - Indicates whether it is a global setting that is overridden for a user, - or a user-only setting that is only overwritten for multiUser editing. -synonyms - Regex-s indicating other values that could mean the same thing as the - keys in the "items" hash. This is for backwards compatibility with the - days when even multi-choice fields were given freeform frontends. - the special value "*" (an illegal regular expression) points to a value - that should be substituted for unrecognized values. The order that the - values are checked against the regular expressions is unspecified, and - probably won't be the order they are given in the source code. diff --git a/doc/parser/README b/doc/parser/README deleted file mode 100644 index 8c62267d3f..0000000000 --- a/doc/parser/README +++ /dev/null @@ -1,145 +0,0 @@ -OVERVIEW: - -This directory contains the documentation for a new -mathematical-expression parser written in perl. It was developed for -use with the WeBWorK on-line homework system, but it can be used in -any perl program. - -The goal was to process vector-valued expressions, but the parser was -designed to be extensible, so that you could add your own functions, -operators, and data types. It is still a work in progress, but should -provide a framework for building more sophisticated expression handling. - -Currenlty, the parser understands: - - - real and complex numbers, - - points, vectors, and matrices (with real or complex entries) - - arbitrary lists of elements - - intervals and unions of intervals - - predefined strings like 'infinity' - -Some other useful features are that you can write sin^2 x for (sin(x))^2 -and sin^-1 x for arcsin(x), and so on. - -Most of the documentation still needs to be written, but you can get some -ideas from the samples in the problems and extensions directories, and by -reading the files in the docs directory. - - -INSTALLATION: - -The parser should already be installed as part of the WeBWorK 2.1 -distribution, so you should not need to install it separately. If you -don't seem to have it installed, then it can be obtained from the -Union CVS repository at - - http://devel.webwork.rochester.edu/twiki/bin/view/Webwork/WeBWorKCVS - -The README file in that directory contains the installation instructions. - - -SAMPLE FILES: - -Sample problems are given in the problems and extensions directories. Move -these to the templates directory of a course where you want to test the -Parser, and move the contents of the macros directory to that course's -macros directory. - -Now try looking at these problems using the Library Browser. Edit the -source to see how they work, and to read the comments within the code -itself. - - -EXAMPLE FILES: - -The 'problems' directory contains several examples that show how to use -Parser within your problem files. - - sample01.pg - Uses the parser to make a string into a formula that you can - evaluate and print in TeX form - - sample02.pg - Shows how to create formulas using perl's usual mathematical - expressions rather than character strings. - - sample03.pg - Shows how to use the parser's differentiation abilities. - - sample04.pg and sample05.pg - Use the parser in conjunction with the graphics macros to generate - function graphs on the fly. These also show how to create a - perl function to evaluate an expression. - - sample06.pg - Shows some simple use of vectors in a problem. - - sample07.pg - Example if using the build-in Real object and its answer - checker - - sample08.pg - Uses complex numbers and the built-in checker - - sample09.pg and sample10.pg - Demonstrates points and vectors and their answer checkers - - sample11.pg and sample12.pg - Shows the answer checkers for intervals and unions. - - sample13.pg, sample14.pg, sample15.pg - Demonstrate various list checkers, including a check for the - word 'NONE', which is a predefined string. - - sample16.pg, sample17.pg, sample18.pg - These show the multi-variable function checker in use (for - functions of the form R->R, R^2->R and R->R^3). - - sample19.pg - Uses the function checker to implement a "constant" that can - be used in formulas. - - sample20.pg - Shows how to use the parser's substitution abilities. - - sample21.pg - Checks for a list of points. - - sample22.pg - Shows how to provide named constants that the student can - use in his answer. - -The 'examples' directory contains samples that show how to extend the -parser to include your own functions, operators, and so on. There are also -some samples of how to call the methods available for Formula objects -generated by the parser, and what some error messages look like. - - 1-function.pg - Adds a single-variable function to the parsers list of functions. - - 2-function.pg - Adds a two-variable function to the parser. - - 3-operator.pg - Adds a binary operator to the parser. (Unary operators are similar.) - - 4-list.pg - Adds a new "list type" object. In this case, it's really an - operation [n,r] that returns n choose r. - - 5-list.pg - Add a new "equality" operator that you can use to handle answers - like "x+y=0". - - 6-precedence.pg - Shows an experimental precedence setting that can be used to make - sin 2x return sin(2x) rather than (sin(2))x. - - 7-context.pg - Shows how to switch contexts (in this case, to complex and to vector - contexts), and how this affects the parsing. - - 8-answer.pg - Implements a simple vector-valued answer checker using the - parser's computation and comparison ability. - diff --git a/doc/parser/docs/ParserAnswerCheckers.pod b/doc/parser/docs/ParserAnswerCheckers.pod deleted file mode 100644 index 10d3f7ad69..0000000000 --- a/doc/parser/docs/ParserAnswerCheckers.pod +++ /dev/null @@ -1,423 +0,0 @@ -=head1 MathObjects-based Answer Checkers - -MathObjects is designed to be used in two ways. First, you can use -it within your perl code when writing problems as a means of making it -easier to handle formulas, and in particular, to genarate be able to -use a single object to produce numeric values, TeX output and answer -strings. This avoids having to type a function three different ways -(which makes maintaining a problem much harder). Since MathObjects -also included vector and complex arthimatic, it is easier to work with -these types of values as well. - -The second reason for MathObjects is to use it to process student -input. This is accomplished through special answer checkers that are -part of the Parser package (rather than the traditional WeBWorK answer -checkers). Checkers are available for all the types of values that -the parser can produce (numbers, complex numbers, infinities, points, -vectors, intervals, unions, formulas, lists of numbers, lists of -points, lists of intervals, lists of formulas returning numbers, lists -of formulas returning points, and so on). - -To use one of these checkers, simply call the ->cmp method of the -object that represents the correct answer. For example: - - $n = Real(sqrt(2)); - ANS($n->cmp); - -will produce an answer checker that matches the square root of two. -Similarly, - - ANS(Vector(1,2,3)->cmp); - -matches the vector <1,2,3> (or any computation that produces it, e.g., -i+2j+3k, or <4,4,4>-<3,2,1>), while - - ANS(Interval("(-inf,3]")->cmp); - -matches the given interval. Other examples include: - - ANS(Infinity->cmp); - ANS(String('NONE')->cmp); - ANS(Union("(-inf,$a) U ($a,inf)")->cmp); - -and so on. - -Formulas are handled in the same way: - - ANS(Formula("x+1")->cmp); - - $a = random(-5,5,1); $b = random(-5,5,1); $x = random(-5,5,1); - $f = Formula("x^2 + $a x + $b")->reduce; - ANS($f->cmp); - ANS($f->eval(x=>$x)->cmp); - - $x = Formula('x'); - ANS((1+$a*$x)->cmp); - - Context("Vector")->variables->are(t=>'Real'); - $v = Formula(""); $t = random(-5,5,1); - ANS($v->cmp); - ANS($v->eval(t=>$t)->cmp); - -and so on. - -Lists of items can be checked as easily: - - ANS(List(1,-1,0)->cmp); - ANS(List(Point($a,$b),Point($a,-$b))->cmp); - ANS(List(Vector(1,0,0),Vector(0,1,1))->cmp); - ANS(Compute("(-inf,2),(4,5)")->cmp); # easy way to get list of intervals - ANS(Formula("x, x+1, x^2-1")->cmp); - ANS(Formula(",,<0,x>")->cmp); - ANS(List('NONE')->cmp); - -and so on. The last example may seem strange, as you could have used -ANS(String('NONE')->cmp), but there is a reason for using this type -of construction. You might be asking for one or more numbers (or -points, or whatever) or the word 'NONE' of there are no numbers (or -points). If you used String('NONE')->cmp, the student would get an -error message about a type mismatch if he entered a list of numbers, -but with List('NONE')->cmp, he will get appropriate error messages for -the wrong entries in the list. - -It is often appropriate to use the list checker in this way even when -the correct answer is a single value, if the student might type a list -of answers. - -On the other hand, using the list checker has its disadvantages. For -example, if you use - - ANS(Interval("(-inf,3]")->cmp); - -and the student enters (-inf,3), she will get a message indicating -that the type of interval is incorrect, while that would not be the -case if - - ANS(List(Interval("(-inf,3]"))->cmp); - -were used. (This is because the student doesn't know how many -intervals there are, so saying that the type of interval is wrong -would inform her that there is only one.) - -The rule of thumb is: the individual checkers can give more detailed -information about what is wrong with the student's answer; the list -checker allows a wider range of answers to be given without giving -away how many answers there are. If the student knows there's only -one, use the individual checker; if there may or may not be more than -one, use the list checker. - -Note that you can form lists of formulas as well. The following all -produce the same answer checker: - - ANS(List(Formula("x+1"),Formula("x-1"))->cmp); - - ANS(Formula("x+1,x-1")->cmp); # easier - - $f = Formula("x+1"); $g = Formula("x-1"); - ANS(List($f,$g)->cmp); - - $x = Formula('x'); - ANS(List($x+1,$x-1)->cmp); - -See the files in webwork2/doc/parser/problems for more -examples of using the parser's answer checkers. - -=head2 Controlling the Details of the Answer Checkers - -The action of the answer checkers can be modified by passing flags to -the cmp() method. For example: - - ANS(Real(pi)->cmp(showTypeWarnings=>0)); - -will prevent the answer checker from reporting errors due to the -student entering in the wrong type of answer (say a vector rather than -a number). - -=head3 Flags common to all answer checkers - -There are a number of flags common to all the checkers: - -=over - -=item S1 or 0 >>> - -show/don't show messages about student -answers not being of the right type. -(default: 1) - -=item S1 or 0 >>> - -show/don't show messages produced by -trying to compare the professor and -student values for equality, e.g., -conversion errors between types. -(default: 1) - -=item S1 or 0 >>> - -show/don't show type mismatch errors -produced by strings (so that 'NONE' will -not cause a type mismatch in a checker -looking for a list of numbers, for example). -(default: 1) - -=back - -In addition to these, the individual types have their own flags: - -=head3 Flags for Real()->cmp - -=over - -=item S1 or 0 >>> - -Don't report type mismatches if the -student enters an infinity. -(default: 1) - -=back - -=head3 Flags for String()->cmp - -=over - -=item Svalue >>> - -Specifies the type of object that -the student should be allowed to enter -(in addition the string). -(default: 'Value::Real') - -=back - -=head3 Flags for Point()->cmp - -=over - -=item S1 or 0 >>> - -show/don't show messages about the -wrong number of coordinates. -(default: 1) - -=item S1 or 0 >>> - -show/don't show message about -which coordinates are right. -(default: 1) - -=back - -=head3 Flags for Vector()->cmp - -=over - -=item S1 or 0 >>> - -show/don't show messages about the -wrong number of coordinates. -(default: 1) - -=item S1 or 0 >>> - -show/don't show message about -which coordinates are right. -(default: 1) - -=item S1 or 0 >>> - -do/don't allow the student to -enter a point rather than a vector. -(default: 1) - -=item S1 or 0 >>> - -Mark the answer as correct if it -is parallel to the professor's answer. -Note that a value of 1 forces -showCoordinateHints to be 0. -(default: 0) - -=item S1 or 0 >>> - -During a parallel check, mark the -answer as correct only if it is in -the same (not the opposite) -direction as the professor's answer. -(default: 0) - -=back - -=head3 Flags for Matrix()->cmp - -=over - -=item S1 or 0 >>> - -show/don't show messages about the -wrong number of coordinates. -(default: 1) - -=back - -The default for showEqualErrors is set to 0 for Matrices, since -these errors usually are dimension errors, and that is handled -separately (and after the equality check). - -=head3 Flags for Interval()->cmp - -=over - -=item S1 or 0 >>> - -do/don't show messages about which -endpoints are correct. -(default: 1) - -=item S1 or 0 >>> - -do/don't show messages about -whether the open/closed status of -the enpoints are correct (only -shown when the endpoints themselves -are correct). -(default: 1) - -=back - -=head3 Flags for Union()->cmp and List()->cmp - -all the flags from the Real()->cmp, plus: - -=over - -=item S1 or 0 >>> - -do/don't show messages about which -entries are incorrect. -(default: $showPartialCorrectAnswers) - -=item S1 or 0 >>> - -do/don't show messages about having the -correct number of entries (only shown -when all the student answers are -correct but there are more needed, or -all the correct answsers are among the -ones given, but some extras were given). -(default: $showPartialCorrectAnswers) - -=item S1 or 0 >>> - -do/don't give partial credit for when -some answers are right, but not all. -(default: $showPartialCorrectAnswers) -(currently the default is 0 since WW -can't handle partial credit properly). - -=item S1 or 0 >>> - -give credit only if the student answers -are in the same order as the -professor's answers. -(default: 0) - -=item S'a (name)' >>> - -The string to use in error messages -about type mismatches. -(default: dynamically determined from list) - -=item S'a (name)' >>> - -The string to use in error messages -about numbers of entries in the list. -(default: dynamically determined from list) - -=item Svalue >>> - -Specifies the type of object that -the student should be allowed to enter -in the list (determines what -constitutes a type mismatch error). -(default: dynamically determined from list) - -=item S1 or 0 >>> - -Do/don't require the parentheses in the -student's answer to match those in the -professor's answer exactly. -(default: 1) - -=item S1 or 0 >>> - -Do/don't remove the parentheses from the -professor's list as part of the correct -answer string. This is so that if you -use List() to create the list (which -doesn't allow you to control the parens -directly), you can still get a list -with no parentheses. -(default: 0 for List() and 1 for Formula()) - -=back - -=head3 Flags for Formula()->cmp - -The flags for formulas are dependent on the type of the result of -the formula. If the result is a list or union, it gets the flags -for that type above, otherwise it gets that flags of the Real -type above. - -More flags need to be added in order to allow more control over the -answer checkers to give the full flexibility of the traditional -WeBWorK answer checkers. Note that some things, like whether trig -functions are allowed in the answer, are controlled through the -Context() rather than the answer checker itself. For example, - - Context()->functions->undefine('sin','cos','tan'); - -would remove those three functions from use. (One would need to remove -cot, sec, csc, arcsin, asin, etc., to do this properly; there could be -a function call to do this.) - -Similarly, which arithmetic operations are available is controlled -through Context()->operations. - -The tolerances used in comparing numbers are part of the Context as -well. You can set these via: - - Context()->flags->set( - tolerance => .0001, # the relative or absolute tolerance - tolType => 'relative', # or 'absolute' - zeroLevel => 1E-14, # when to use zeroLevelTol - zeroLevelTol => 1E-12, # smaller than this matches zero - # when one of the two is less - # than zeroLevel - limits => [-2,2], # limits for variables in formulas - num_points => 5, # the number of test points - ); - -[These need to be handled better.] - -Note that for testing formulas, you can override the limits and -num_points settings by setting these fields of the formula itself: - - $f = Formula("sqrt(x-10)"); - $f->{limits} = [10,12]; - - $f = Formula("log(xy)"); - $f->{limits} = [[.1,2],[.1,2]]; # x and y limits - -You can also specify the test points explicitly: - - $f = Formula("sqrt(x-10)"); - $f->{test_points} = [[11],[11.5],[12]]; - - $f = Formula("log(xy)"); - $f->{test_points} = [[.1,.1],[.1,.5],[.1,.75], - [.5,.1],[.5,.5],[.5,.75]]; - -[There still needs to be a means of handling the tolerances similarly, -and through the ->cmp() call itself.] - diff --git a/doc/parser/docs/UsingParser.pod b/doc/parser/docs/UsingParser.pod deleted file mode 100644 index 4ece7c5b90..0000000000 --- a/doc/parser/docs/UsingParser.pod +++ /dev/null @@ -1,401 +0,0 @@ -=head1 USING MATHOBJECTS - -To use MathObjects in your own problems, you need to load the -"MathObjects.pl" macro file: - - loadMacros("Parser.pl"); - -which defines the commands you need to interact with MathObjects. -Once you have done that, you can call the MathObjects functions to create -formulas for you. The main call is Formula(), which takes a string and -returns a parsed version of the string. For example: - - $f = Formula("x^2 + 3x + 1"); - -will set $f to a reference to the parsed version of the formula. - -=head2 Working With Formulas - -A formula has a number of methods that you can call. These include: - -=over - -=item $f->eval(x=>5) - -Evaluate the formula when x is 5. -If $f has more variables than that, then -you must provide additional values, as in -$f->eval(x=>3,y=>1/2); - -=item $f->reduce - -Tries to remove redundent items from your -formula. For example, Formula("1x+0") returns "x". -Reduce tries to factor out negatives and do -some other adjustments as well. (There still -needs to be more work done on this. What it does -is correct, but not always smart, and there need -to be many more situations covered.) All the -reduction rules can be individually enabled -or disabled using the Context()->reduction->set() -method, but the documentation for the various -rules is not yet ready. - -=item $f->substitute(x=>5) - -Replace x by the value 5 throughout (you may want -to reduce the result afterword, as this is not -done automatically). Note that you can replace a -variable by another formula, if you wish. To make -this easier, substitute will apply Formula() to -any string values automatically. E.g., - Formula("x-1")->substitute(x=>"y") - -returns "y-1" as a formula. - -=item $f->string - -returns a string representation of the formula -(should be equivalent to the original, though not -necessarily equal to it). - -=item $f->TeX - -returns a LaTeX representation of the formula. -You can use this in BEGIN_TEXT...END_TEXT blocks -as follows: - - BEGIN_TEXT - Suppose \(f(x) = \{$f->TeX}\). ... - END_TEXT - -=item $f->perl - -returns a representation of the formula that could -be evaluated by perl's eval() function. - -=item $f->perlFunction - -returns a perl code block that can be called to -evaluate the function. For example: - - $f = Formula('x^2 + 3')->perlFunction; - $y = &$f(5); - -will assign the value 28 to $y. -You can also pass a function name to perlFunction -to get a named function to call: - - Formula('x^2 + 3')->perlFunction('f'); - $y = f(5); - -If the formula involves more than one variable, -then the paramaters should be given in -alphabetical order. - - Formula('x^2 + y')->perlFunction('f'); - $z = f(5,3); # $z is 28. - -Alternatively, you can tell the order for the -parameters: - - Formula('x^2 + y')->perlFunction('f',['y','x']); - $z = f(5,3); $ now $z is 14. - -=back - -=head2 Combining Formulas - -There is a second way to create formulas. Once you have a formula, you can -create additional formulas simply by using perls' built-in operations and -functions, which have been overloaded to handle formulas. For example, - - $x = Formula('x'); - $f = 3*x**2 + 2*$x - 1; - -makes $f be a formula, and is equivalent to having done - - $f = Formula("3x^2 + 2x - 1"); - -This can be very convenient, but also has some pitfalls. First, you -need to include '*' for multiplication, since perl doesn't do implied -multiplication, and you must remember to use '**' not '^'. (If you use '^' -on a formula, the parser will remind you to use '**'.) Second, the -precedences of the operators in perl are fixed, and so changes you make to -the precedence table for the parser are not reflected in formulas produced -in this way. (The reason '^' is not overloaded to do exponentiation is -that the precedence of '^' is wrong for that in perl, and can't be -changed.) As long as you leave the default precedences, however, things -should work as you expect. - -Note that the standard functions, like sin, cos, etc, are overloaded to -generate appropriate formulas when their values are formulas. For example, - - $x = Formula('x'); - $f = cos(3*$x + 1); - -produces the same result as $f = Formula("cos(3x+1)"); and you can then go -on to output its TeX form, etc. - -=head2 Special Syntax - -This parser has support for some things that are missing from the current -one, like absolute values. You can say |1+x| rather than abs(1+x) -(though both are allowed), and even |1 - |x|| works. - -Also, you can use sin^2(x) (or even sin^2 x) to get (sin(x))^2. - -Finally, you can use sin^-1(x) to get arcsin(x). - -There is an experimental set of operator precedences that make it possible -to write sin 2x + 3 and get sin(2x) + 3. See examples/7-precedence.pg -for some details. - -=head2 The Formula Types - -The parser understands a wide range of data types, including real and -complex numbers, points, vectors, matrices, arbitrary lists, intervals, -unions of intervals, and predefined words. Each has a syntax for use -within formulas, as described below: - - numbers the usual form: 153, 233.5, -2.456E-3, etc. - - complex a + b i where a and b are numbers: 1+i, -5i, 6-7i, etc. - - infinitites the words 'infinity' or '-infinity' (or several - equivalents). - - point (a,b,c) where a, b and c are real or complex numbers. - any number of coordinates are allowed. Eg, (1,2), - (1,0,0,0), (-1,2,-3). Points are promoted to vectors - automatically, when necessary. - - vector or a i + b j + c k (when used in vector context). - As with points, vectors can have any number of - coordinates. For example, <1,0,0>, <-1,3>, , etc. - - matrix [[a11,...,a1n],...[am1,...amn]], i.e., use [..] around - each row, and around the matrix itself. The elements - are separated by commas (not spaces). e.g, - [[1,2],[3,4]] (a 2x2 matrix) - [1,2] (a 1x2 matrix, really a vector) - [[1],[2]] (a 2x1 matrix, ie. column vector) - Points and vectors are promoted to matrices when - appropriate. Vectors are converted to column vectors - when needed for matrix-vector multiplication. Matrices - can be 3-dimensional or higher by repeated nesting of - matrices. (In this way, a 2-dimensional matrix is really - thought of as a vector of vectors, and n-dimensional - ones as vectors of (n-1)-dimensional ones.) - - list (a,b,c) where a,b,c are arbitrary elements. - For example, (1+i, -3, <1,2,3>, Infinity). - The empty list () is allowed, and the parentheses are - optional if there is only one list. (This makes it - possible to make list-based answer checkers that - really know where the separations occur.) - - interval (a,b), (a,b], [a,b), [a,b], or [a,a] where a and b are - numbers or appropriate forms of infinity. - For example, (-INF,3], [4,4], [2,INF), (-INF,INF). - - union represented by 'U'. For example [-1,0) U (0,1]. - - string special predefined strings like NONE and DNE. - -These forms are what are used in the strings passed to Formula(). -If you want to create versions of these in perl, there are several -ways to do it. One way is to use the Compute() command, which takes a -string parses it and then evaluates the result (it is equivalent to -Formula(...)->eval). If the formula produces a vector, the result -will be a Vector constant that you can use in perl formulas by hand. - -For example: - - $v = Compute("<1,1,0> >< <-1,4,-2>"); - -would compute the dot product of the two vectors and assign the -resulting vector object to $v. - -Another way to generate constants of the various types is to use the -following routines. If their inputs are constant, they produce a -constant of the appropriate type. If an input is a formula, they -produce corresponding formula objects. - - Real(a) create a real number with "fuzzy" - comparisons (so that 1.0000001 == Real(1) is true). - - Complex(a,b) create a complex number a + b i - - Infinity creates the +infinity object - -(Infinity) creates -infinity - - Point(x1,...xn) or Point([x1,...,xn]) produces (x1,...,xn) - - Vector(x1,...,xn) or Vector([x1,...,xn]) produces - - Matrix([a11,...,a1m],...,[am1,...,amn]) or - Matrix([[a11,...,a1m],...,[am1,...,amn]]) produces an n x m matrix - - List(a,...,b) produces a list with the given elements - - Interval('(',a,b,']') produces (a,b], (the other endpoints work as - expected. Use 'INF' and '-INF' for infinities.) - - Union(I1,...,In) takes the union of the n intervals. (where I1 to In - are intervals.) - - String(word) Produces a string object for the given word (if it - is a known word). This is mostly to be able to - call the ->cmp and ->TeX methods. - -For example, - - $a = random(-5,5,1) - $V = Vector($a,1-$a,$a**2+1); - -produces a vector with some random coordinates. - -Objects of these types also have TeX, string and perl methods, so you can -use: - - Vector(1,2,3)->TeX - -to produce a TeX version of the vector, just as you can with formulas. - -There are several "constant" functions that generate common constant -values. These include pi, i, j, k and Infininty. you can use these -in perl expressions as though they were their actual values: - - $z = $a + $b * i; - $v = $a*i + $b*j + $c*k; - $I = Infinity; - -Note that because of a peculiarity of perl, you need to use -(pi) -or - pi (with a space) rather than -pi, and similary for the other -functions. Without this, you will get an error message about an -ambiguity being resolved. (This is not a problem if you process your -expressions through the parser itself, only if you are writing -expressions in perl directly. Note that since student answers are -processed by the parser, not perl directly, they can write -pi without -problems.) - -Another useful command is Compute(), which evaluates a formula and -returns its value. This is one way to create point or vector-valued -constants, but there is an easier way discussed below. - -=head2 Specifying the Context - -You may have noticed that "i" was used in two different ways in the -examples above. In the first example, it was treated as a complex -number and the second as a coordinate unit vector. To control which -interpretation is used, you specify a parser "context". - -The context controls what operations and functions are defined in the -parser, what variables and constants to allow, how to interpret -various paretheses, and so on. Changing the context can completely -change the way a formula is interpreted. - -There are several predefined contexts: Numeric, Complex, Vector, -Interval and Full. (You can also define your own contexts, but that -will be described elsewhere.) To select a context, use the Context() -function, e.g. - - Context("Numeric"); - -selects the numeric context, where i, j and k have no special meaning, -points and vectors can't be used, and the only predefined variable is -'x'. - -On the other hand, Context("Vector") makes i, j and k represent the -unit coordinate vectors, and defines variables 'x', 'y' and 'z'. - -Context("Interval") is like numeric context, but it also defines the -parentheses so that they will form intervals (rather than points or -lists). - -Once you have selected a context, you can modify it to suit the -particular needs of your problem. The command - - $context = Context(); - -gets you a reference to the current context object (you can also use -something like - - $context = Context("Numeric"); - -to set the context and get its reference at the same time). Once you -have this reference, you can call the Context methods to change values -in the context. These are discussed in more detail in the -documentation of the Context object [not yet written], but some of the -more common actions are described here. - -To add a variable, use, for example, - - $context->variables->add(y=>'Real'); - -To delete any existing variables and replace them with new ones, use - - $context->variables->are(t=>'Real'); - -To remove a variable, use - - $context->variables->remove('t'); - -To get the names of the defind variables, use - - @names = $context->variables->names; - - -Similarly, you can add a named constant via - - $context->constants->add(M=>1/log(10)); - -and can change, remove or list the constants via methods like those -used for variables above. The command - - $M = $context->constants->get('M'); - -will return the value of the consant M. (See the -pg/lib/Value/Context/Data.pm file for more information on the methods -you can call for the various types of context data.) - -To add new predefined words (like 'NONE' and 'DNE'), use something -like - - $context->strings->add(TRUE=>{},FALSE=>{}); - -Strings are case-insensitive, unless you say otherwise. To mark a -string as being case-senstive, use - - $context->strings->add(TRUE => {caseSensitive=>1}); - -You may want to privide several forms for the same word; to do so, -make the additional words into aliases: - - $context->strings->add( - T => {alias=>'TRUE'}, - F => {alias=>'FALSE'}, - ); - -so that either "TRUE" or "T" will be interpreted as TRUE, and -similarly for "FALSE" and "F"; - -There are a number of values stored in the context that control things -like the tolerance used when comparing numbers, and so on. You -control these via commands like: - - $context->flags->set(tolerance=>.00001); - -For example, - - $context->flags->set(ijk=>1); - -will cause the output of all vectors to be written in ijk format -rather than <...> format. - -Finally, you can add or modify the operators and functions that are -available in the parser via calls to $context->operators and -$context->functions. See the files in webwork2/docs/parser/extensions -for examples of how to do this. - diff --git a/doc/parser/extensions/1-function.pg b/doc/parser/extensions/1-function.pg deleted file mode 100644 index 1a4179becf..0000000000 --- a/doc/parser/extensions/1-function.pg +++ /dev/null @@ -1,79 +0,0 @@ -########################################################## -# -# Example showing how to add a new single-variable function to the Parser -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################### -# -# Use standard numeric mode -# -Context('Numeric'); - -############################################# -# -# Create a 'log2' function to the Parser for log base 2 -# - -package MyFunction1; -our @ISA = qw(Parser::Function::numeric); # this is what makes it R -> R - -sub log2 { - shift; my $x = shift; - return CORE::log($x)/CORE::log(2); -} - -package main; - -# -# Make it work on formulas as well as numbers -# -sub log2 {Parser::Function->call('log2',@_)} - -# -# Add the new functions into the Parser -# - -Context()->functions->add( - log2 => {class => 'MyFunction1', TeX => '\log_2'}, # fancier TeX output -); - -$x = Formula('x'); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we have added a new function to the Parser: ${BTT}log2(x)${ETT}. -(Edit the code to see how this is done.) -$PAR -Assuming that ${BTT}${DOLLAR}x = Formula('x')${ETT}, it can be used as follows: -$PAR - -\{ParserTable( - 'Formula("log2(x)")', - 'log2(8)', - 'log2($x+1)', - 'Formula("log2(x)")->eval(x=>16)', - '(log2($x))->eval(x=>16)', - 'Formula("log2()")', - 'Formula("log2(1,x)")', - 'log2()', - 'log2(1,3)', - )\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/2-function.pg b/doc/parser/extensions/2-function.pg deleted file mode 100644 index 2c68409c74..0000000000 --- a/doc/parser/extensions/2-function.pg +++ /dev/null @@ -1,79 +0,0 @@ -########################################################## -# -# Example showing how to add a new two-variable function to the Parser -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################### -# -# Use standard numeric mode -# -Context('Numeric'); - -############################################# -# -# Create a "Combinations" function -# - -package MyFunction2; -our @ISA = qw(Parser::Function::numeric2); # this is what makes it R^2 -> R - -sub C { - shift; my ($n,$r) = @_; my $C = 1; - $r = $n-$r if ($r > $n-$r); # find the smaller of the two - for (1..$r) {$C = $C*($n-$_+1)/$_} - return $C -} - -package main; - -# -# Make it work on formulas as well as numbers -# -sub C {Parser::Function->call('C',@_)} - -# -# Add the new functions into the Parser -# - -Context()->functions->add(C => {class => 'MyFunction2'}); - -$x = Formula('x'); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we have added a new function to the Parser: ${BTT}C(n,r)${ETT}. -(Edit the code to see how this is done). -$PAR -Assuming that ${BTT}${DOLLAR}x = Formula('x')${ETT}, it can be used as follows: -$PAR - -\{ParserTable( - 'Formula("C(x,3)")', - 'C(6,2)', - 'C($x,3)', - 'Formula("C(x,3)")->eval(x=>6)', - '(C($x,2))->eval(x=>6)', - 'Formula("C(x)")', - 'Formula("C(1,2,3)")', - 'C(1)', - 'C(1,2,3)', - )\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/3-operator.pg b/doc/parser/extensions/3-operator.pg deleted file mode 100644 index 1fa295c30a..0000000000 --- a/doc/parser/extensions/3-operator.pg +++ /dev/null @@ -1,109 +0,0 @@ -########################################################## -# -# Example showing how to add new operators to the Parser -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################## -# -# Define our own binary operator -# - -package MyOperator; -our @ISA = qw(Parser::BOP); # subclass of Binary OPerator - -# -# Check that the operand types are numbers. -# -sub _check { - my $self = shift; my $name = $self->{bop}; - return if $self->checkNumbers(); - $self->Error("Operands of '$name' must be Numbers"); -} - -# -# Compute the value of n choose r. -# -sub _eval { - shift; my ($n,$r) = @_; my $C = 1; - $r = $n-$r if ($r > $n-$r); # find the smaller of the two - for (1..$r) {$C = $C*($n-$_+1)/$_} - return $C -} - -# -# Non-standard TeX output -# -sub TeX { - my $self = shift; - return '{'.$self->{lop}->TeX.' \choose '.$self->{rop}->TeX.'}'; -} - -# -# Non-standard perl output -# -sub perl { - my $self = shift; - return '(MyOperator->_eval('.$self->{lop}->perl.','.$self->{rop}->perl.'))'; -} - -package main; - -########################################################## -# -# Add the operator into the current context -# - -$prec = Context()->operators->get('+')->{precedence} - .25; - -Context()->operators->add( - '#' => { - class => 'MyOperator', - precedence => $prec, # just below addition - associativity => 'left', # computed left to right - type => 'bin', # binary operator - string => ' # ', # output string for it - TeX => '\mathop{\#}', # TeX version (overridden above, but just an example) - } -); - - -$CHOOSE = MODES(TeX => '\#', HTML => '#'); - - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we have added a new operator to the Parser: ${BTT}n $CHOOSE r${ETT}, -which returns \(n\choose r\). -$PAR - -\{ParserTable( - 'Formula("x # y")', - 'Formula("x+1 # 5")', - 'Formula("x # 5")->eval(x=>7)', - 'Formula("(x#5)+(x#4)")', - 'Formula("x#5+x#4")', - 'Formula("x # y")', - 'Formula("x # y")->substitute(x=>5)', - 'Formula("x # y")->eval(x=>5,y=>2)', - 'Formula("x # y")->perlFunction(~~'C~~'); C(5,2)', - 'Formula("1 # ")', - )\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/4-list.pg b/doc/parser/extensions/4-list.pg deleted file mode 100644 index 0184117b22..0000000000 --- a/doc/parser/extensions/4-list.pg +++ /dev/null @@ -1,102 +0,0 @@ -########################################################## -# -# Example showing how to add a new list-type object -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################## -# -# Define our own [n,r] notation for n choose r -# - -package MyChoose; -our @ISA = qw(Parser::List); # subclass of List - -# -# Check that two numbers are given -# -sub _check { - my $self = shift; - $self->{type}{list} = 0; # our result is a single number, not really a list - $self->Error("You need two numbers within '[' and ']'") - if ($self->{type}{length} < 2); - $self->Error("Only two numbers can appear within '[' and ']'") - if ($self->{type}{length} > 2); - my ($n,$r) = @{$self->{coords}}; - $self->Error("The arguments for '[n,r]' must be numbers") - unless ($n->type eq 'Number' && $r->type eq 'Number'); - $self->{type} = $Value::Type{number}; -} - -# -# Compute n choose r -# -sub _eval { - shift; my ($n,$r) = @_; my $C = 1; - $r = $n-$r if ($r > $n-$r); # find the smaller of the two - for (1..$r) {$C = $C*($n-$_+1)/$_} - return $C -} - -# -# Non-standard TeX output -# -sub TeX { - my $self = shift; - return '{'.$self->{coords}[0]->TeX.' \choose '.$self->{coords}[1]->TeX.'}'; -} - -# -# Non-standard perl output -# -sub perl { - my $self = shift; - return '(MyChoose->_eval('.$self->{coords}[0]->perl.','.$self->{coords}[1]->perl.'))'; -} - - -package main; - -########################################################## -# -# Add the new list to the context -# - -Context()->lists->add(Choose => {class => 'MyChoose'}); -Context()->parens->replace('[' => {close => ']', type => 'Choose'}); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we have added a new list to the Parser: ${BTT}[n,r]${ETT}, -which returns \(n\choose r\). -$PAR - -\{ParserTable( - 'Formula("[x,3]")', - 'Formula("[5,3]")', - 'Formula("[x,3]")->eval(x=>5)', - '$C = Formula("[x,y]"); $C->substitute(x=>5)', - 'Formula("[x,y]")->perlFunction("C"); C(5,3)', - 'Formula("[x,y,3]")', - 'Formula("[x]")', - 'Formula("[x,[y,2]]")', - 'Formula("[x,<1,2>]")', - )\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/5-operator.pg b/doc/parser/extensions/5-operator.pg deleted file mode 100644 index 60dea5eb2b..0000000000 --- a/doc/parser/extensions/5-operator.pg +++ /dev/null @@ -1,85 +0,0 @@ -########################################################## -# -# Example of how to implement equalities in the Parser -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################## -# -# Define our own operator for equality -# - -package Equality; -our @ISA = qw(Parser::BOP); # subclass of Binary OPerator - -# -# Check that the operand types are numbers. -# -sub _check { - my $self = shift; my $name = $self->{bop}; - $self->Error("Only one equality is allowed in an equation") - if ($self->{lop}->class eq 'Equality' || $self->{rop}->class eq 'Equality') ; - $self->Error("Operands of '$name' must be Numbers") unless $self->checkNumbers(); - $self->{type} = Value::Type('Equality',1); # Make it not a number, to get errors with other operations. -} - -# -# Determine if the two sides are equal -# -sub _eval {return ($_[1] == $_[2])? 1: 0} - -package main; - -# -# Add the operator into the current context -# - -$prec = Context()->operators->get(',')->{precedence} + .25; - -Context()->operators->add( - '=' => { - class => 'Equality', - precedence => $prec, # just above comma - associativity => 'left', # computed left to right - type => 'bin', # binary operator - string => '=', # output string for it - perl => '==', # perl string - } -); - - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we have added a new operator to the Parser: ${BTT} a -= b${ETT}, for equality. -$PAR - -\{ParserTable( - 'Formula("x + y = 0")', - 'Formula("x + y = 0")->{tree}->class', - 'Formula("x + y = 0")->{tree}{lop}', - 'Formula("x + y = 0")->{tree}{rop}', - 'Formula("x + y = 0")->eval(x=>2,y=>3)', - 'Formula("x + y = 0")->eval(x=>2,y=>-2)', - 'Formula("x + y = 0 = z")', - 'Formula("(x + y = 0) + 5")', - 'Formula("x + y = 0, 3x-y = 4")', # you CAN get a list of equalities - )\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/6-precedence.pg b/doc/parser/extensions/6-precedence.pg deleted file mode 100644 index 5997a2a838..0000000000 --- a/doc/parser/extensions/6-precedence.pg +++ /dev/null @@ -1,80 +0,0 @@ -########################################################## -# -# Example of the non-standard precedences as a possible alternative -# that makes it possible to write "sin 2x" and get "sin(2x)" -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -########################################################## -# -# Use standard precedences for multiplication -# - -Context()->usePrecedence("Standard"); - -$standard = ParserTable( - 'Formula("sin 2xy/3")', - 'Formula("sin 2x y/3")', - 'Formula("sin 2x y / 3")', - 'Formula("sin 2x+5")', - 'Formula("sin x(x+1)")', - 'Formula("sin x (x+1)")', - 'Formula("1/2xy")', - 'Formula("1/2 xy")', - 'Formula("1/2x y")', - 'Formula("sin^2 x")', - 'Formula("sin^(-1) x")', - 'Formula("x^2x")', -); - -Context()->usePrecedence("Non-Standard"); - -$nonstandard = ParserTable( - 'Formula("sin 2xy/3")', - 'Formula("sin 2x y/3")', - 'Formula("sin 2x y / 3")', - 'Formula("sin 2x+5")', - 'Formula("sin x(x+1)")', - 'Formula("sin x (x+1)")', - 'Formula("1/2xy")', - 'Formula("1/2 xy")', - 'Formula("1/2x y")', - 'Formula("sin^2 x")', - 'Formula("sin^(-1) x")', - 'Formula("x^2x")', -); - - - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -In this problem, we compare the standard and non-standard precedences for -multiplication. -$PAR - -\{Title("The Non-Standard precedences:")\} -$PAR -$nonstandard -$PAR$BR - -\{Title("The Standard precedences:")\} -$PAR -$standard - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/7-context.pg b/doc/parser/extensions/7-context.pg deleted file mode 100644 index 191c22d2c7..0000000000 --- a/doc/parser/extensions/7-context.pg +++ /dev/null @@ -1,82 +0,0 @@ -########################################################## -# -# Example showing how to switch different contexts -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserTables.pl", -); - -BEGIN_TEXT - -In this problem, we compare formulas in complex and vector contexts. -Note the difference between how ${BTT}i${ETT} is treated in the two -contexts. Note that 'Number' comprises both real and complex numbers. -$PAR - -Assuming that ${BTT}${DOLLAR}x = Formula('x')${ETT}, it can be used as follows: -$PAR - -END_TEXT - -$x = Formula('x'); - -########################################################## -# -# Use Complex context -# - -Context('Complex'); - -BEGIN_TEXT -\{Title("The Complex context:")\} -$PAR -\{ParserTable( - 'i', - 'Formula("1+3i")', - 'Formula("x+3i")', - '1 + 3*i', - '$x + 3*i', - '$z = tan(2*i)', - 'Formula("sinh(zi)")', - 'Formula("3i+4j-k")', - 'Formula("3i+4j-k")->eval', - '3*i + 4*j - k', -)\} -$PAR$BR -END_TEXT - - -########################################################## -# -# Use Vector context -# - -Context('Vector'); - -BEGIN_TEXT -\{Title("The Vector context:")\} -$PAR -\{ParserTable( - 'i', - 'Formula("1+3i")', - 'Formula("x+3i")', - '1 + 3*i', - '$x + 3*i', - '$z = tan(2*i)', - 'Formula("sinh(zi)")', - 'Formula("3i+4j-k")', - 'Formula("3i+4j-k")->eval', - '3*i + 4*j - k', -)\} - -END_TEXT - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/extensions/8-answer.pg b/doc/parser/extensions/8-answer.pg deleted file mode 100644 index 9a45e3b720..0000000000 --- a/doc/parser/extensions/8-answer.pg +++ /dev/null @@ -1,110 +0,0 @@ -########################################################## -# -# Example showing an answer checker that uses the parser -# to evaluate the student (and professor's) answers. -# -# This is now obsolete, as the paser's ->cmp method -# can be used to produce an answer checker for any -# of the parser types. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################## -# -# Use Vector context -# - -Context('Vector'); - -########################################################## -# -# Make the answer checker -# -sub vector_cmp { - my $v = shift; - die "vector_cmp requires a vector argument" unless defined $v; - my $v = Vector($v); # covert to vector if it isn't already - my $ans = new AnswerEvaluator; - $ans->ans_hash(type => "vector",correct_ans => $v->string, vector=>$v); - $ans->install_evaluator(~~&vector_cmp_check); - return $ans; -} - -sub vector_cmp_check { - my $ans = shift; my $v = $ans->{vector}, - $ans->score(0); # assume failure - my $f = Parser::Formula($ans->{student_ans}); - my $V = Parser::Evaluate($f); - if (defined $V) { - $V = Formula($V) unless Value::isValue($V); # make sure we can call Value methods - $ans->{preview_latex_string} = $f->TeX; - $ans->{preview_text_string} = $f->string; - $ans->{student_ans} = $V->string; - if ($V->type eq 'Vector') { - $ans->score(1) if ($V == $v); # Let the overloaded == do the check - } else { - $ans->{ans_message} = $ans->{error_message} = - "Your answer doesn't seem to be a Vector (it looks like ".Value::showClass($V).")" - unless $inputs_ref->{previewAnswers}; - } - } else { - # - # Student answer evaluation failed. - # Report the error, with formatting, if possible. - # - my $context = Context(); - my $message = $context->{error}{message}; - if ($context->{error}{pos}) { - my $string = $context->{error}{string}; - my ($s,$e) = @{$context->{error}{pos}}; - $message =~ s/; see.*//; # remove the position from the message - $ans->{student_ans} = protectHTML(substr($string,0,$s)) . - '' . - protectHTML(substr($string,$s,$e-$s)) . - '' . - protectHTML(substr($string,$e)); - } - $ans->{ans_message} = $ans->{error_message} = $message; - } - return $ans; -} - -########################################################## -# -# The problem text -# - -$V = Vector(1,2,3); - -Context()->flags->set(ijk=>0); -Context()->constants->add(a=>1,b=>1,c=>1); - -$ABC = Formula(""); - -BEGIN_TEXT -Enter the vector \(\{$V->TeX\}\) in any way you like: \{ans_rule(20)\}. -$PAR -You can use either \(\{$ABC->TeX\}\) or \(\{$ABC->ijk\}\) notation,$BR -and can perform vector operations to produce your answer. -$PAR -${BBOLD}Note:${EBOLD} This problem is obsolete. -END_TEXT - -########################################################### -# -# The answer -# - -ANS(vector_cmp($V)); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample01.pg b/doc/parser/problems/sample01.pg deleted file mode 100644 index 2d810de877..0000000000 --- a/doc/parser/problems/sample01.pg +++ /dev/null @@ -1,64 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser to make -# a formula that you can evaluate and print in TeX form. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################### -# -# Use standard numeric mode -# -Context('Numeric'); - -# -# Define some functions -# -$a = non_zero_random(-8,8,1); -$b = random(1,8,1); - -@f = ( - "1 + $a*x + $b x^2", - "$a / (1 + $b x)", - "$a x^3 + $b", - "($a - x) / ($b + x^2)" -); - -# -# Pick one at random -# -$k = random(0,$#f,1); -$f = Formula($f[$k])->reduce; - -# -# Where to evaluate it -# -$x = random(-5,5,1); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -If \(\displaystyle f(x) = \{$f->TeX\}\) then \(f($x)=\) \{ans_rule(10)\}. - -END_TEXT - -########################################################### -# -# The answer -# -ANS(num_cmp($f->eval(x=>$x))); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample02.pg b/doc/parser/problems/sample02.pg deleted file mode 100644 index b57c1fadb2..0000000000 --- a/doc/parser/problems/sample02.pg +++ /dev/null @@ -1,57 +0,0 @@ -########################################################### -# -# Example showing how you can use perl expressions (not -# just character strings) to generate formulas. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################### -# -# Use standard numeric mode -# -Context('Numeric'); -$x = Formula('x'); # used to construct formulas below. - -# -# Define a function and its derivative and make them pretty -# -$a = random(1,8,1); -$b = random(-8,8,1); -$c = random(-8,8,1); - -$f = ($a*$x**2 + $b*$x + $c) -> reduce; -$df = (2*$a*$x + $b) -> reduce; - -$x = random(-8,8,1); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -Suppose \(f(x) = \{$f->TeX\}\). -$PAR -Then \(f'(x)=\) \{ans_rule(20)\},$BR -and \(f'($x)=\) \{ans_rule(20)\}. - -END_TEXT - -########################################################### -# -# The answers -# -ANS(fun_cmp($df->string)); -ANS(num_cmp($df->eval(x=>$x))); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample03.pg b/doc/parser/problems/sample03.pg deleted file mode 100644 index d473412c87..0000000000 --- a/doc/parser/problems/sample03.pg +++ /dev/null @@ -1,61 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's differentiation -# capabilities. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "Differentiation.pl", -); - -########################################################### -# -# Use standard numeric mode -# -Context('Numeric'); -$x = Formula('x'); # used to construct formulas below. - -# -# Define a function and its derivative and make them pretty -# -$a = random(1,8,1); -$b = random(-8,8,1); -$c = random(-8,8,1); - -$f = ($a*$x**2 + $b*$x + $c) -> reduce; -$df = $f->D('x'); - -$x = random(-8,8,1); - -########################################################### -# -# The problem text -# -BEGIN_TEXT - -Suppose \(f(x) = \{$f->TeX\}\). -$PAR -Then \(f'(x)=\) \{ans_rule(20)\},$BR -and \(f'($x)=\) \{ans_rule(20)\}. -$PAR -(Same as previous problem, but using the formal differentiation package. -Note that automatic differentiation does not always produce the simples form.) - -END_TEXT - -########################################################### -# -# The answers -# -ANS(fun_cmp($df->string)); -ANS(num_cmp($df->eval(x=>$x))); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample04.pg b/doc/parser/problems/sample04.pg deleted file mode 100644 index ea39ec7192..0000000000 --- a/doc/parser/problems/sample04.pg +++ /dev/null @@ -1,113 +0,0 @@ -################################################################ -# -# Example showing how to use the Parser to create functions you -# can call from perl, to substitute values into a formula, and to -# convert a formula to a form that can be used in graphics generated -# on the fly. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PG.pl", - "PGbasicmacros.pl", - "PGanswermacros.pl", - "PGgraphmacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -############################################## -# -# The setup -# - -Context('Vector'); -Context()->variables->add(a => 'Real', b => 'Real'); -$a = non_zero_random(-4,-1,1); -$b = non_zero_random(-3,3,1); - -# -# The function to plot -# -$f = Formula("ax^2 + by"); # the function to display - -# -# Traces to show -# -$x = non_zero_random(-1,1,1); -$y = non_zero_random(-1,1,1); - -# -# Graph domain and size -# -($xm,$xM) = (-2,2); -($ym,$yM) = (-2,2); -($zm,$zM) = (-5,5); -$size = [200,300]; -$tex_size = 350; - -############################################## - -# -# The plot defaults -# -@Goptions = ( - $ym,$zm,$yM,$zM, # dimensions of graph - axes => [0,0], grid => [$yM-$ym,$zM-$zm], # number of grid lines - size => $size # pixel dimension -); -@imageoptions = (size=>$size, tex_size=>$tex_size); - -$xdomain = "x in <$xm,$xM>"; -#$ydomain = "y in <$ym,$yM>"; # plot_functions only handles variable x -$ydomain = "x in <$ym,$yM>"; -$plotoptions = "using color:red and weight:2"; - -# -# Make the traces -# -$fx = $f->substitute(x=>$x, a=>$a, b=>$b, y=>'x')->reduce; # must have variable x -$Gx = init_graph(@Goptions); -plot_functions($Gx,"$fx for $ydomain $plotoptions"); -$Xtrace = Image($Gx,@imageoptions); - -$fy = $f->substitute(y=>$y, a=>$a, b=>$b)->reduce; -$Gy = init_graph(@Goptions); -plot_functions($Gy,"$fy for $xdomain $plotoptions"); -$Ytrace = Image($Gy,@imageoptions); - -# -# Make the table of images -# -@rowopts = (indent=>0, separation=>30); -$Images = - BeginTable(). - AlignedRow([$Xtrace,$Ytrace], @rowopts). - AlignedRow(["Trace for \(x=$x\)","Trace for \(y=$y\)"], @rowopts). - EndTable(); - -############################################## - -BEGIN_TEXT - -The graphs below are traces for a function \(f(x,y)\) at \(x=$x\) and -\(y=$y\). -$PAR - -$Images -$PAR - -If \(f(x,y) = \{$f->TeX\}\) then -\(a\) = \{ans_rule(6)\} and \(b\) = \{ans_rule(6)\}. - -END_TEXT - -################################################## - -ANS(std_num_cmp($a)); -ANS(std_num_cmp($b)); - -################################################## - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample05.pg b/doc/parser/problems/sample05.pg deleted file mode 100644 index 35ba15f09f..0000000000 --- a/doc/parser/problems/sample05.pg +++ /dev/null @@ -1,137 +0,0 @@ -################################################################ -# -# A more complex example showing how to use the Parser to create -# functions you can call from perl, to substitute values into a -# formula, and to convert a formula to a form that can be used in -# graphics generated on the fly. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "PGgraphmacros.pl", - "PGauxiliaryFunctions.pl", - "Parser.pl", - "parserUtils.pl", -); - -############################################## -# -# The setup -# - -Context('Vector'); -Context()->variables->add(a => 'Real', b => 'Real'); - -$c = non_zero_random(-1,1,1); -$a = $c*random(2,5,1)/2; -$b = -$c*random(2,5,1)/2; - -# -# The function to plot -# -$f = Formula("a x^2 y + b x y^2"); -$f->substitute(a=>$a,b=>$b)->perlFunction('f'); - -# -# Traces to show -# -$x1 = non_zero_random(-2,2,1); $x1 /= 2 if (abs($b) >= 2 && abs($x1) == 2); -$x2 = non_zero_random(-2,2,1); $x2 /= 2 if (abs($a) >= 2 && abs($x2) == 2); - -$x = max(.5,min(3,round(-2*$b*$x2/$a)/2)); -$y = max(.5,min(3,round(-2*$a*$x1/$b)/2)); - -# -# Points to show -# -$xv = round(-$b*$y/$a/2); $xv = 1 if ($xv == 0); -$fxv = f($xv,$y); if (abs($fxv) < .75) {$xv = -$xv; $fxv = f($xv,$y)} - -$yv = round(-$a*$x/$b/2); $yv = -1 if ($yv == 0); -$fyv = f($x,$yv); if (abs($fyv) < .75) {$yv = -$yv; $fyv = f($x,$yv)} - -$M = int(max(abs($fxv),abs($fyv),4))+1; -# -# Graph size -# -($xm,$xM) = (-3,3); -($ym,$yM) = (-3,3); -($zm,$zM) = (-$M,$M); -$size = [200,250]; -$tex_size = 350; - -############################################## - -# -# The plot defaults -# -@Goptions = ( - $ym,$zm,$yM,$zM, # dimensions of graph - axes => [0,0], grid => [$yM-$ym,$zM-$zm], # number of grid lines - size => $size # pixel dimension -); -@imageoptions = (size=>$size, tex_size=>$tex_size); - -$plotoptions = "using color:red and weight:2"; - -# -# Make the traces -# -$fx = $f->substitute(x => x, a => $a, b => $b, y => 'x')->reduce; -$Gx = init_graph(@Goptions); -plot_functions($Gx, - "$fx for x in <$ym,$yv] $plotoptions", - "$fx for x in <$yv,$yM> $plotoptions", -); -$Xtrace = Image($Gx,@imageoptions); - -$fy = $f->substitute(y => $y, a => $a, b => $b)->reduce; -$Gy = init_graph(@Goptions); -plot_functions($Gy, - "$fy for x in <$xm,$xv] $plotoptions", - "$fy for x in <$xv,$xM> $plotoptions", -); -$Ytrace = Image($Gy,@imageoptions); - -Context()->texStrings; - -# -# Make the table of images -# -@rowopts = (indent=>0, separation=>30); -$Images = - BeginTable(). - AlignedRow([$Xtrace,$Ytrace], @rowopts). - AlignedRow(["Trace for \(x=$x\) has","Trace for \(y=$y\) has"], @rowopts). - AlignedRow(["a point at \(($yv,$fyv)\).","a point at \(($xv,$fxv)\)."], @rowopts). - EndTable(); - -############################################## - -BEGIN_TEXT - -The graphs below are traces for a function \(f(x,y)\) at \(x=$x\) and -\(y=$y\). -$PAR - -$Images -$PAR - -If \(f(x,y) = \{$f->TeX\}\) then -\(a\) = \{ans_rule(6)\} and \(b\) = \{ans_rule(6)\}. - -END_TEXT - -Context()->normalStrings; - -################################################## - -ANS(std_num_cmp($a)); -ANS(std_num_cmp($b)); - -################################################## - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample06.pg b/doc/parser/problems/sample06.pg deleted file mode 100644 index e4d8102bee..0000000000 --- a/doc/parser/problems/sample06.pg +++ /dev/null @@ -1,53 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser to make -# a formula that you can evaluate and print in TeX form. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################### -# -# The setup -# -Context('Vector'); - -# -# Define a vector -# -$a = non_zero_random(-8,8,1); -$b = non_zero_random(-8,8,1); -$c = non_zero_random(-8,8,1); - -$V = $a*i + $b*j + $c*k; # equivalently: $V = Vector($a,$b,$c); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -The length of the vector \($V\) is \{ans_rule(20)\}. - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS(num_cmp(norm($V)->value)); # easier: ANS($V->cmp) -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample07.pg b/doc/parser/problems/sample07.pg deleted file mode 100644 index 64a320dc06..0000000000 --- a/doc/parser/problems/sample07.pg +++ /dev/null @@ -1,49 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################## -# -# The setup -# - -Context('Numeric'); - -$a = Real(random(2,6,1)); -$b = Real(random($a+1,$a+8,1)); - -$c = sqrt($a**2 + $b**2); # still a Real object - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose the legs of a triangle are of length \($a\) and \($b\).$BR -Then the hypoteneuse is of length \{ans_rule(20)\}. - -END_TEXT -Context()->normalStrings(); - -########################################################### -# -# The answer -# - -ANS($c->cmp); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample08.pg b/doc/parser/problems/sample08.pg deleted file mode 100644 index 6c7b6d73d1..0000000000 --- a/doc/parser/problems/sample08.pg +++ /dev/null @@ -1,49 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################## -# -# The setup -# - -Context('Complex'); - -$z = random(-5,5,1) + non_zero_random(-5,5,1)*i; - -$f = Formula('z^2 + 2z - 1'); -$fz = $f->eval(z => $z); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(z) = $f\).$BR -Then \(f($z)\) = \{ans_rule(20)\}. - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($fz->cmp); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample09.pg b/doc/parser/problems/sample09.pg deleted file mode 100644 index b2a9776653..0000000000 --- a/doc/parser/problems/sample09.pg +++ /dev/null @@ -1,49 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################## -# -# The setup -# - -Context('Vector'); - -$P1 = Point(-2,4,2); -$P2 = Point(2,-3,1); - -$M = ($P1+$P2)/2; - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -The midpoint of the line segment from \($P1\) to \($P2\) -is \{ans_rule(20)\}. - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($M->cmp); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample10.pg b/doc/parser/problems/sample10.pg deleted file mode 100644 index 5a25b8e800..0000000000 --- a/doc/parser/problems/sample10.pg +++ /dev/null @@ -1,54 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################## -# -# The setup -# - -Context('Vector'); - -$P1 = Point(1,random(-3,3,1),random(-3,3,1)); -$P2 = Point(random(-3,3,1),4,random(-3,3,1)); - -$V = Vector($P2-$P1); - -Context()->flags->set(ijk=>0); -Context()->constants->add(a=>1,b=>1,c=>1); - -$ABC = Formula(""); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT -The vector from \($P1\) to \($P2\) is \{ans_rule(20)\}. -$PAR -You can use either \($ABC\) or \(\{$ABC->ijk\}\) notation,$BR -and can perform vector operations to produce your answer. -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($V->cmp(promotePoints=>1)); # allow answers to be points or vectors - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample11.pg b/doc/parser/problems/sample11.pg deleted file mode 100644 index 8a1ff5e41d..0000000000 --- a/doc/parser/problems/sample11.pg +++ /dev/null @@ -1,48 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################## -# -# The setup -# - -Context('Interval'); - -$p1 = random(-5,2,1); -$p2 = random($p1+1,$p1+7,1); - -$f = Formula("x^2 - ($p1+$p2) x + $p1*$p2")->reduce; -$I = Interval("($p1,$p2)"); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT -The function \(f(x) = $f\) is negative for values of \(x\) in the interval -\{ans_rule(20)\}. -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($I->cmp); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample12.pg b/doc/parser/problems/sample12.pg deleted file mode 100644 index 36222469d9..0000000000 --- a/doc/parser/problems/sample12.pg +++ /dev/null @@ -1,60 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################## -# -# The setup -# - -Context("Interval"); - -$a = non_zero_random(-5,5,1); -$f = Formula("(x^2+1)/(x-$a)")->reduce; -$R = Union("(-inf,$a) U ($a,inf)"); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(\displaystyle f(x) = $f\). -$PAR -Then \(f\) is defined on the region \{ans_rule(30)\}. -$PAR -${BCENTER} -${BSMALL} -Several intervals can be combined using the -set union symbol, ${LQ}${BTT}U${ETT}${RQ}.$BR -Use ${LQ}${BTT}infinity${ETT}${RQ} for ${LQ}\(\infty\)${RQ} and -${LQ}${BTT}-infinity${ETT}${RQ} for ${LQ}\(-\infty\)${RQ}. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($R->cmp); -$showPartialCorrectAnswers=1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample13.pg b/doc/parser/problems/sample13.pg deleted file mode 100644 index 5ad161d529..0000000000 --- a/doc/parser/problems/sample13.pg +++ /dev/null @@ -1,59 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################## -# -# The setup -# - -Context("Interval"); - -$a = non_zero_random(-5,5,1); -$f = Formula("(x^2+1)/(x-$a)")->reduce; -$R = Compute("(-inf,$a),($a,inf)"); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(\displaystyle f(x) = $f\). -$PAR -Then \(f\) is defined on the intervals \{ans_rule(30)\}. -$PAR -${BCENTER} -${BSMALL} -To enter more than one interval, separate them by commas.$BR -Use ${LQ}${BTT}infinity${ETT}${RQ} for ${LQ}\(\infty\)${RQ} and -${LQ}${BTT}-infinity${ETT}${RQ} for ${LQ}\(-\infty\)${RQ}. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS($R->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample14.pg b/doc/parser/problems/sample14.pg deleted file mode 100644 index 5ffef3f161..0000000000 --- a/doc/parser/problems/sample14.pg +++ /dev/null @@ -1,57 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################## -# -# The setup -# - -Context("Numeric"); - -$a = random(1,5,1); -$f = Formula("(x^2+1)/(x^2-$a^2)")->reduce; - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(\displaystyle f(x) = $f\). -$PAR -Then \(f\) is defined for all \(x\) except for \{ans_rule(30)\}. -$PAR -${BCENTER} -${BSMALL} -To enter more than one value, separate them by commas.$BR -Enter ${LQ}${BTT}NONE${ETT}${RQ} if there are no such values. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS(List($a,-$a)->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample15.pg b/doc/parser/problems/sample15.pg deleted file mode 100644 index de84abe8b1..0000000000 --- a/doc/parser/problems/sample15.pg +++ /dev/null @@ -1,57 +0,0 @@ -########################################################## -# -# Example showing how to use the built-in answer checker for parsed values. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################## -# -# The setup -# - -Context("Numeric"); - -$a = random(1,5,1); -$f = Formula("(x^2-$a)/(x^2+$a)"); - -########################################################## -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(\displaystyle f(x) = $f\). -$PAR -Then \(f\) is defined for all \(x\) except for \{ans_rule(30)\}. -$PAR -${BCENTER} -${BSMALL} -To enter more than one value, separate them by commas.$BR -Enter ${LQ}${BTT}NONE${ETT}${RQ} if there are no such values. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answer -# - -ANS(List("NONE")->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample16.pg b/doc/parser/problems/sample16.pg deleted file mode 100644 index 4317142848..0000000000 --- a/doc/parser/problems/sample16.pg +++ /dev/null @@ -1,61 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "Differentiation.pl", -); - -########################################################### -# -# The setup -# -Context('Numeric'); -$x = Formula('x'); # used to construct formulas below. - -# -# Define a function and its derivative and make them pretty -# -$a = random(1,8,1); -$b = random(-8,8,1); -$c = random(-8,8,1); - -$f = ($a*$x**2 + $b*$x + $c) -> reduce; -$df = $f->D('x'); - -$x = random(-8,8,1); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(x) = $f\). -$PAR -Then \(f'(x)=\) \{ans_rule(20)\},$BR -and \(f'($x)=\) \{ans_rule(20)\}. - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS($df->cmp); -ANS($df->eval(x=>$x)->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample17.pg b/doc/parser/problems/sample17.pg deleted file mode 100644 index 4fea5b52da..0000000000 --- a/doc/parser/problems/sample17.pg +++ /dev/null @@ -1,62 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "Differentiation.pl", -); - -########################################################### -# -# The setup -# -Context('Numeric')->variables->add(y=>'Real'); -$x = Formula('x'); # used to construct formulas below. -$y = Formula('y'); - -# -# Define a function and its derivative and make them pretty -# -$a = random(1,8,1); -$b = random(-8,8,1); -$c = random(-8,8,1); - -$f = ($a*$x**2 + $b*$x*$y + $c*$y**2) -> reduce; -$fx = $f->D('x'); -$fy = $f->D('y'); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(x,y) = $f\). -$PAR -Then \(f_x(x,y) =\) \{ans_rule(30)\},$BR -and \(f_y(x,y) =\) \{ans_rule(30)\}. - - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS($fx->cmp); -ANS($fy->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample18.pg b/doc/parser/problems/sample18.pg deleted file mode 100644 index 8d6fa17afd..0000000000 --- a/doc/parser/problems/sample18.pg +++ /dev/null @@ -1,61 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "Differentiation.pl", -); - -########################################################### -# -# The setup -# -Context('Vector')->variables->are(t=>'Real'); - -# -# Define a function and its derivative and make them pretty -# -$a = random(1,8,1); -$b = random(-8,8,1); -$c = random(-8,8,1); - -$f = Formula("") -> reduce; -$df = $f->D('t'); - -$t = random(-5,5,1); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(t) = $f\). -$PAR -Then \(f'(t) =\) \{ans_rule(20)\},$BR -and \(f'($t) =\) \{ans_rule(20)\}. - - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS($df->cmp); -ANS($df->eval(t=>$t)->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample19.pg b/doc/parser/problems/sample19.pg deleted file mode 100644 index a0c0cf0e9a..0000000000 --- a/doc/parser/problems/sample19.pg +++ /dev/null @@ -1,65 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################### -# -# The setup -# -Context('Interval')->variables->add(a=>'Real'); -$x = Formula('x'); $a = Formula('a'); - -$f = log($x-$a); -$I = Formula("(-infinity,a]"); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(x) = $f\). -$PAR -Then \(f\) is undefined for \(x\) in the interval(s) -\{ans_rule(20)\}. -$PAR -${BCENTER} -${BSMALL} -To enter more than one interval, separate them by commas.$BR -Use ${LQ}${BTT}infinity${ETT}${RQ} for ${LQ}\(\infty\)${RQ} and -${LQ}${BTT}-infinity${ETT}${RQ} for ${LQ}\(-\infty\)${RQ}.$BR -Enter ${LQ}${BTT}NONE${ETT}${RQ} if the function is always defined. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS(List($I)->cmp( - list_type => 'a list of intervals', # override these names to avoid - entry_type => "an interval", # 'formula returning ...' messages -)); -Context()->variables->remove('x'); # error if 'x' is used in answer - -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample20.pg b/doc/parser/problems/sample20.pg deleted file mode 100644 index ecde485d70..0000000000 --- a/doc/parser/problems/sample20.pg +++ /dev/null @@ -1,60 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", -); - -########################################################### -# -# The setup -# -Context('Numeric')->variables->are( - x=>'Real',y=>'Real', - s=>'Real',t=>'Real' -); -$x = Formula('x'); $y = Formula('y'); - -$a = random(1,5,1); -$b = random(-5,5,1); -$c = random(-5,5,1); - -$f = ($a*$x**2 + $b*$x*$y + $c*$y**2) -> reduce; - -$x = random(-5,5,1); -$y = random(-5,5,1); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(x) = $f\). -$PAR -Then \(f($x,$y)\) = \{ans_rule(20)\},$BR -and \(f(s+t,s-t)\) = \{ans_rule(30)\}. - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS($f->eval(x=>$x,y=>$y)->cmp); -ANS($f->substitute(x=>'s+t',y=>'s-t')->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample21.pg b/doc/parser/problems/sample21.pg deleted file mode 100644 index bf5c213f85..0000000000 --- a/doc/parser/problems/sample21.pg +++ /dev/null @@ -1,62 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################### -# -# The setup -# -Context('Vector')->variables->are(x=>'Real',y=>'Real'); -$x = Formula('x'); $y = Formula('y'); - -$a = random(1,16,1); -$b = non_zero_random(-5,5,1); - -$f = ($x**2 + $a*$y**2 + $b*$x**2*$y) -> reduce; - -$x = sqrt(2*$a)/$b; $y = -1/$b; - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(f(x,y) = $f\). -$PAR -Then \(f\) has critical points at the following -points: \{ans_rule(30)\}. -$PAR -${BCENTER} -${BSMALL} -To enter more than one point, separate them by commas.$BR -Enter ${LQ}${BTT}NONE${ETT}${RQ} if there are none. -${ESMALL} -${ECENTER} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS(List(Point(0,0),Point($x,$y),Point(-$x,$y))->cmp); -$showPartialCorrectAnswers = 1; - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/doc/parser/problems/sample22.pg b/doc/parser/problems/sample22.pg deleted file mode 100644 index ba43b73657..0000000000 --- a/doc/parser/problems/sample22.pg +++ /dev/null @@ -1,58 +0,0 @@ -########################################################### -# -# Example showing how to use the Parser's function -# answer checker. -# - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGbasicmacros.pl", - "PGanswermacros.pl", - "Parser.pl", - "parserUtils.pl", -); - -########################################################### -# -# The setup -# -$context = Context('Vector'); -$context->variables->are(t=>'Real'); -$context->constants->add( - p0 => Point(pi,sqrt(2),3/exp(1)), - v => Vector(exp(1),log(10),-(pi**2)), -); -$context->constants->set(v => {TeX => '\boldsymbol{v}'}); # make it print nicer - -$L = Formula("p0+tv"); -$v = Formula('v'); - -########################################################### -# -# The problem text -# - -Context()->texStrings; -BEGIN_TEXT - -Suppose \(p_0\) is a point and \($v\) a vector in \(n\)-space. -$PAR -Then the vector-parametric form for the line through \(p_0\) in the -direction of \(v\) is$PAR -${BBLOCKQUOTE} -\(L(t)\) = \{ans_rule(30)\}. -${EBLOCKQUOTE} - -END_TEXT -Context()->normalStrings; - -########################################################### -# -# The answers -# -ANS($L->cmp); - -########################################################### - -ENDDOCUMENT(); # This should be the last executable line in the problem.