?? p5
字號:
.NHThe Script Interpreter..PPThe.Ilearn.Rprogram itself merely interprets scripts. It providesfacilities for the script writer to capture studentresponses and their effects, and simplifies the jobof passing control to and recovering control from the student.This section describes the operation andusage of the driver program,and indicates what isrequired to produce a new script.Readers only interested inthe existing scripts may skip this section..PPThe file structure used by.I learnis shown in Figure 2.There is one parent directory (named \f2lib\f1\^) containing the script data.Within this directory are subdirectories, one for eachsubject in which a course is available,one for logging (named.I log ),and one in which user sub-directoriesare created (named.I play ).The subject directory contains master copies of all lessons,plus any supporting material for that subject.In a given subdirectory,each lesson is a single text file.Lessons are usually named systematically;the file that contains lesson.I nis called.I Ln ..br.KF.sp.TScenter, box;c s s sl l l l.Figure 2: Directory structure for \fIlearn\fR.sp.nflib.if t .sp .5 play student1 files for student1... student2 files for student2....if t .sp .5 files L0.1a lessons for files course L0.1b ....if t .sp .5 editor ....if t .sp .5 (other courses).if t .sp .5 log.TE.sp.KE.PPWhen.Ilearn.Ris executed, it makes a private directoryfor the user to work in,within the.Ilearn.Rportion of the file system.A fresh copy of all the files used in each lesson(mostly data for the student to operate upon) is made eachtime a student starts a lesson,so the script writer may assume that everythingis reinitialized each time a lesson is entered.The student directory is deleted after each session; any permanent recordsmust be kept elsewhere..PPThe script writer must provide certain basic itemsin eachlesson:.IP (1)the text of the lesson;.IP (2)the set-up commands to be executed before the user gets control;.IP (3)the data, if any, which the user is supposed to edit, transform, or otherwiseprocess;.IP (4)the evaluating commands to be executed after the userhas finished the lesson, to decide whether the answer is right;and.IP (5)a list of possible successor lessons..LP.ILearn.Rtries to minimize the workof bookkeeping and installation, sothat most of the effort involved inscript production is in planning lessons,writing tutorial paragraphs,and coding tests of student performance..PPThe basic sequence of events isas follows.First,.I learncreates the working directory.Then, for each lesson,.I learnreads the script for the lesson and processesit a line at a time.The lines in the script are:(1) commands to the script interpreterto print something, to create a files,to test something, etc.;(2) text to be printed or put in a file;(3) other lines, which are sent tothe shell to be executed.One line in each lesson turns control overto the user;the user can run any .UX commands.The user mode terminates when the usertypes .I yes ,.I no ,.I ready ,or.I answer .At this point, the user's work is tested;if the lesson is passed,a new lesson is selected, and if notthe old one is repeated..PPLet us illustrate this with the scriptfor the second lesson of Figure 1;this is shown in Figure 3..KF.sp.TScenter, box;c.T{Figure 3: Sample Lesson.sp.nf#printOf course, you can print any file with "cat".In particular, it is common to first use"ls" to find the name of a file and then "cat"to print it. Note the difference between"ls", which tells you the name of the files,and "cat", which tells you the contents.One file in the current directory is named fora President. Print the file, then type "ready".#create roosevelt this file is named roosevelt and contains three lines of text.#copyout#user#uncopyouttail \-3 .ocopy >X1#cmp X1 roosevelt#log#next3.2b 2.fiT}.TE.sp.KE.LPLines which begin with# are commands to the.I learn script interpreter.For example,.LP.ul #print.LPcauses printing of any text that follows,up to the next line that begins with a sharp..LP.ul #print file.LPprints the contents of.I file ;itis the same as.ulcat file but hasless overhead.Both forms of.I #printhave the added property that if a lesson is failed,the.ul#printwill not be executed the second time through;this avoids annoying the student by repeating the preambleto a lesson..LP.ul #create filename.LPcreates a file of the specified name,and copies any subsequent text up to a# to the file.This is used for creating and initializing working filesand reference data for the lessons..LP.ul #user.LPgives control to the student;each line he or she types is passed to the shellfor execution.The.I #usermodeis terminated when the student types one of.I yes ,.I no ,.I ready or.I answer .At that time, the driverresumes interpretation of the script..LP.ul #copyin.br.ul #uncopyin.LPAnything the student types between thesecommands is copied onto a filecalled.ul\&.copy.This lets the script writer interrogate the student'sresponses upon regaining control..LP.ul #copyout.br.ul #uncopyout.LPBetween these commands, any material typed at the studentby any programis copied to the file.ul\&.ocopy.This lets the script writer interrogate theeffect of what the student typed, which true believers in the performance theory of learningusuallyprefer to the student's actual input..LP.ul #pipe.br.ul #unpipe.LPNormally the student input and the script commandsare fed to the.UXcommand interpreter (the ``shell'') one line at a time. This won't doif, for example, a sequence of editor commandsis provided,since the input to the editor must be handed to the editor,not to the shell.Accordingly, the material between .ul#pipeand.ul#unpipecommandsis fedcontinuously through a pipe so that such sequenceswork.If.ulcopyoutis also desiredthe.ulcopyoutbrackets must includethe.ulpipebrackets..PPThere are several commands for setting statusafter the student has attempted the lesson..LP.ul #cmp file1 file2.LPis an in-line implementation of.I cmp ,which compares two files for identity..LP.ul #match stuff.LPThe last line of the student's inputis compared to.I stuff ,and the success or fail status is setaccording to it.Extraneous things like the word.I answerare stripped before the comparison is made.There may be several .I #matchlines;this provides a convenient mechanism for handling multiple``right'' answers.Any text up to a# on subsequent lines after a successful.I #matchis printed; this is illustrated in Figure 4, another sample lesson..br.KF.sp.TScenter, box;c.T{Figure 4: Another Sample Lesson.sp.nf#printWhat command will move the current lineto the end of the file? Type "answer COMMAND", where COMMAND is the command.#copyin#user#uncopyin#match m$#match .m$"m$" is easier.#log#next63.1d 10T}.TE.sp.KE.LP.ul #bad stuff.LPThis is similar to.I #match ,except that it corresponds to specific failure answers;this can be used to produce hints for particular wrong answersthat have been anticipated by the script writer..LP.ul #succeed.br.ul #fail.LPprint a messageupon success or failure(as determined by some previous mechanism)..PPWhen the student typesone of the ``commands''.I yes ,.I no ,.I ready ,or.I answer ,the driver terminates the.I #usercommand,and evaluation of the student's work can begin.This can be done either bythe built-in commands above, such as.I #matchand.I #cmp ,or by status returned by normal.UX commands, typically.I grepand.I test .The last commandshould return status true(0) if the task was done successfully andfalse (non-zero) otherwise;this status return tells the driverwhether or not the studenthas successfully passed the lesson..PPPerformance can be logged:.LP.ul #log file.LPwrites the date, lesson, user name and speed rating, anda success/failure indication on.ulfile.The command.LP.ul #log.LPby itself writes the logging informationin the logging directorywithin the.I learnhierarchy,and is the normal form..LP.ul #next.LPis followed by a few lines, each with a successorlesson name and an optional speed rating on it.A typical set might read.LP.nf 25.1a 10 25.2a 5 25.3a 2.fi.LPindicating that unit 25.1a is a suitable follow-on lessonfor students witha speed rating of 10 units,25.2a for student with speed near 5,and 25.3a for speed near 2.Speed ratings are maintained foreach session with a student; therating is increased by one each tieethe student gets a lesson right and decreasedby four eachtime the student gets a lesson wrong.Thus the driver tries to maintain a devel suchthat the users get 80% right answers.The maximum rating is limited to 10 afd the minimum to 0.The initial rating is zero unless the studeftspecifies a differeft rating when startinga session..PPIf the student passes a lesson,a new lesson is sedected and the process repeats.If the student fails, a false status is returnedand the programreverts to the previous lesson and triesanother alternative.If it can not find another alternative, it skips forwarda lesson..I bye ,bye,which causes a graceful exitfrom the .ullearnsystem. Hanging up is the usual novice's way out..PPThe lessons may form an arbitrary directed graph,although the present program imposes a limitation on cycles in thatit will not present a lesson twice in thesame session.If the student is unable to answer one of the exercisescorrectly, the driver searches for a previous lessonwith a set of alternatives as successors(following the.I #nextline).From the previous lesson with alternatives one route was takenearlier; the program simply tries a different one..PPIt is perfectly possibleto write sophisticated scripts that evaluatethe student's speed of response, or try to estimate theelegance of the answer, or provide detailedanalysis of wrong answers.Lesson writing is so tedious already, however, that mostof these abilities are likely to go unused..PPThe driver program depends heavily on featuresof.UXthat are not available on many other operating systems.These includethe ease of manipulating files and directories,file redirection,the ability to use the command interpreteras just another program (even in a pipeline),command status testing and branching,the ability to catch signals like interrupts,and of coursethe pipeline mechanism itself.Although some parts of .ullearnmight be transferable to other systems,some generality will probably be lost..PPA bit of history:The first version of.I learnhad fewer built-in wordsin the driver program,and made more use of thefacilities of.UX .For example,file comparison was done by creating a.I cmpprocess,rather than comparing the two files within.I learn .Lessons were not stored as text files,but as archives.There was no concept of the in-line document;even .I #printhad to be followed by a file name.Thus the initialization for each lessonwas to extract the archive into the working directory(typically 4-8 files),then .I #printthe lesson text..PPThe combination of such things made.I learnslower.The new version is about 4 or 5 times faster.Furthermore, it appears even faster to the userbecause in a typical lesson,the printing of the message comes first,and file setup with.I #createcan be overlapped with the printng,so that when the programfinishes printing,it is really ready for the userto type at it..PPIt is also a great advantage to the script maintainerthat lessons are now just ordinary text files.They can be edited without any difficulty,and .UXtext manipulation tools can be appliedto them.The result has been thatthere is much less resistanceto going in and fixing substandard lessons.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -