LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510. fc* TZ 3. goto 2 -7» 3 •^ 4. get J' 2 1 5. put 1 3 n 6. call 1 4 1 Enter the new number of questions and the screen will rep lot to the chosen value. Press NEXT to leave this entry unchanged. Figure 2.3 Problem specification option two, Modifying specifications of a problem type 1. Specifications for a Problem type 2" Enter the number of questions (statements' 1 to be generated ( max of 6 ) . 6 Enter the weight to oe assigned to ever 1 ; quest i on . 12 Enter the maximum number of syntactic errors in every question (m.=.x of 4) . £> 4 Enter the type of syntax errors. (0= random, 1 = extra, 2 = m i ss l ng , 3 = rep 1 aced) . 2 Press: To: . l»EXT | change the next entry l|ME) change the last entry (piiTrt) go back to the mair page GjJ^eHCK) return tc the- cover page Figure 2.4 Problem specification option three, Writing specifications for a problem type 2. 10 1 Generat l on o f Prob 1 em di ff as the student will see it err IF.Q=>0CKK) : ,THEN.N= .81; ,ELSE.ID= N; f 1 E DO FK= MU) TO. CG. BY 8 WHILE (RO> = 35) ; END.; 2 M GO UC; t 8 R GET SKIP < KU(Q,fU,B(58)) ; t t 1 PUT LIST (R(52 8) ,BM) , t tt 2 E CRLL XN, (7 3, 15, B) ; t fuExij to continue the generation (pack) to return to the main page ! i Figure 2.5 Problem specification option four, Looking at the problem as student will see it. 11 Finally, the last option of Figure 2.2 is to go back to the exam monitor cover page, finishing the interaction with the syntax PG/G. 2.2 Student Solving the Problem To take an exam, the student has to enter via the exam monitor, that provides the security checks and data collection mechanisms of the system. The student is presented a cover page, where information is given on the problems that have been specified by the instructor for that exam and its associated weight. The student has to go back to this page ever time he wants to work on a different problem. When working on a syntax problem, the student will see, upon entering from the cover page, the display shown in Figure 2.6, referred to as selection page. Its function is similar to the exam cover page except that this page directs the student to the different questions (up to a max of 6) on syntax of programming languages. The language together with the type of statement and number of answers are also shown on this page. It is recommended that before starting to answer any question, the student goes through the directions shown in Figures 2.7 and 2.8 that explain the kind of errors, the symbols that are permitted as errors, and some other remarks to avoid confusion when entering his answer. When the student selects a question marked as '*' in the column of # of answers (meaning that the question has not yet been generated) the display of Figure 2.9 will appear on the screen with a message that will last until the question has been completely generated, the screen 4 will be transformed to the one shown in Figure 2.10. PL/1 Syntax 12 ques. . # statement # of answers 1 l f # t- do * *3 goto * 4 . get # c put * 6 ca 1 1 # Type the number of your choice IhETpj for directions, or SHIS^ck ) return to the cover page * means not vet generated Figure 2.6 Student solving a problem. Question selection page. 13 PL/ 1 Syntax D i rect i ons 1. Assume, all identifiers have properly been declared. Arrays can be bi dimensional with an' upper bound of 9 9. 2 . The errors (max . of 4) may be composed o f one or any two of the following Symbols: Reserved Rnth. Logical Delimiters words operators operators THEN + < ( ELSE - > ) SKIP * PAGE . I ; END & WHILE TO Any of the above or a * correct abbreviation will be accepted as a valid answer ( not necessar i 1 y a correct one ) . (nryr) for more (em:)- to return Figure 2.7 Student solving a problem. Help page number one. 14 3. Types of errors: r^T Extra Symbol. One of the symbols has been L ~ J missp laced. Press E and type the symbol . rpj-t M i ss i ng Symbo 1 . H valid syrnbo 1 l s rn i ss i rig L — ' in the statement. Press M and the symbol. Replaced Symbol. A syntactically incorrect symbol hat: been placed instead* of a correct one. Type them in the same order. No Errors. Used only when the statement contains no error in it. •4. Notice that even though error type ' R' could be considered as being formed of error 'E' and 'M' 'R' is required as a correct answer; the correct answer also in cases whe^e two different answers make the' statm. syntactically correct, the least redundant is required ( Extra ' (' and Miss. ') ') , 5. An incorrect answer will subtract half of the value of a correct one to the total grade. F^xt) to return l fftcT> to see the last page Figure 2.8 Student solving a problem, Help page number two. IS PL/1 Syntax errors Quest 1 on * 2 o 1 6 Find all the syntactic errors in the following PL/1 statement DO. WHILE . , (C ( i,6 6) >7S) ; KQ= H; P 1 ease wa i t , your prob 1 en is now be ins- generated TF*'=™t\ When you are done Figure 2.9 Student solving a problem. Generation of a question in progress. 16 PL''l Svnta.x errors Quest ion * 1 of 2 Find all the syntactic errors in the following PL/ 1 st a t emen t DO. .WHILE. USU.H,J) =>M) ,; YC= .LII; QN= .VD; END.; What's extra & comma ei -rors symbo 1 s # type i nvo 1 ved 1 ( r c z "» * 3 1 E ' A (NEXTI move a IlheI eras- rrow down an si er ' -♦ move arrow up fljEEtt lREl I'Jhen you ere: done Figure 2.10 Student solving a problem. Program waiting for student to enter his answers. 17 The student enters first the type of the error he has recognized pressing one of four keys (E,M,R,0) after which the system requires him to enter the Extra, Missing, or Replacing symbol as shown in Figure 2.11. The program will accept the symbol or any reasonable abbreviation of it as a valid answer. Figure 2.11 also shows the message to the student when requesting some help, after which the symbols accepted as error entries are displayed. This sequence of events is repeated as many times as the student wishes to work on a new question or modify one previously worked on until he decides to return to the Exam Cover Page and start another problem. 2.3 Student Reviewing an Exam After the student has finished working on a problem, he may take the review option and the Exam Monitor will have him reenter this PG/G, now in a review mode, which means that the student cannot modify anything. A table is displayed as shown in Figure 2.12 with the number of questions, the statement involved in each question, and the score obtained in each question. The score column of the table shows the total number of points the student received as opposed to the total number of points possible. The student may also review any and all of the questions simply by entering the number of the question he wants to see. Figure 2.13 is an example of what the student sees when reviewing a question. 18 PL/ 1 Syntax errors Quest 1 on # 1 of 2 F i ncl all the synt act i c er rors l n t lie f o 1 1 ouj i rig PL/1 statement IF. C(I->38) I (5=U) .OH; .R.2; What ' s mi ss i ng S> ei "rors symbo 1 s # type l nvo 1 ved 1 l.Jj THEN !&-. = (),:;. END THEN ELSE LIST PRGE SKIP WHILE TO £E3*Ln|] When von are done Figure 2.11 Student solving a problem. Help sequence available to the student to enter his answers. PL/1 Syntax rev 1 ew mode 19 que 5 . # statement SCORE 9 <%*' 13 1 i 1 1 .6 2 . do 1 3 goto 1 4 . •i at .0 c put 2 6 ca 1 1 ^> Type the number of your choice [helpj for directions, or Iffitdt&HCK] ret urn tc the cover page * means not vet generated Figure 2.12 Student reviewing a problem. Question selection page. 20 Grade this question _2 out of Grade this problem __4 out of • quest i-on # 1 of 2 IF. ((I-i>38) I (5=U) OH; R.2; CORRECT ANSWERS STUDENT ANSWERS errors symk •ols # type l nvo 1 ved 1 rpf! THEN z = o ELSE 4 Tf 1 lI.j = errors syrribo 1 s Score 2 # type i nvo 1 ved 1 L..J THEN i 2 i [ ]i L-_J = i 3 1 1 I 1 L-.J = i 4 E ELSE i IHEXTJ It fib) wher see next quest l on see pr ev i ou s qu es t i on ■i i • re done Figure 2.13 Student reviewing a problem. Score and correct answers of a question. 21 3. SYNTAX ERRORS The decision on the type of errors that will be generated and the specific locations of these errors, is largely dependent on the syntax tables used to guide the generation of statements. In every place where provisions are made to catch syntactic errors when writing a program, the generator converts it into a candidate to generate an error. The table of Figure 3.1 represents the errors from the compiler that are used to generate syntax errors in the PG/G. 3.1 Error Types Three types of errors are considered by the PG/G involving only reserved words, arithmetic operators, logical operators, and delimiters. All of them considered under the generic name of SYMBOLS. 3.1.1 Extra Symbol This error type consist in the insertion of an invalid table selected symbol in addition to the correct symbol. The decision to insert the incorrect symbol before or after the correct one, depends on the most sensible location of the first one with respect to the latter one. For example: After the Symbol Before the Symbol ex. 1 IF (x 20), THEN... IF (x 20,) THEN ex. 2 WP =: 20 + U WP := 20 + U 22 In the first example, the position of the EXTRA COMMA is preferred AFTER as opposed to BEFORE the right paren, as it is evident that coming before it the comma is obviously erroneous. The second example, however, the similitude of the corresponding ALGOL assignment statement when the extra colon is before the equal sign is preferred to the apparently nonsensical position after the equal sign. 3.1.2 Missing Symbol This type of error is made by deleting (not displaying on the screen) a symbol that is required by the syntax of the statement being generated, for example: example 1. DO WHILE ( (PQ x) & (A(2) B(3)) ; example 2. IF P=Y THEN x = PQ(2,6) In the first example the missing of a right paren results less evidently as the nesting of parenthesis is increased. Among beginners, forgetting to place a semi-colon at the end of a PL/1 statement occurs frequently, the second example shows that case. 3.1.3 Replaced Symbol In this type of error, a syntactically correct symbol has been substituted by a syntactically incorrect symbol, for example: example 1. GET LIST (A(5 . B) ... example 2. IF A = B ELSE ... Even though this type may be considered a composition of an EXTRA symbol and a MISSING symbol, the required solution is type REPLACED. 23 error number PL/ 1 requ i res : 1 • » 2 = 3 ( 5 ) 9 THEN 11 LIST 12 WHILE, DECLARE or ; 15 WHILE or ; 16 , or ) 18 TO 28 , or 92 Too many ) 9 7 Too many ) Figure 3.1 Table of syntax errors that are used to generate questions, 3.2 Syntax Error Tables The tables in Figures 3.2 through 3.11 show the possible errors that can be generated for every statement, classified by statement type and error type. 24 statement err typ Possible errors IF E IF \\\\t\ *HEN ( EI ^ D ] ; ELSE [(] 1™] ; M IF (THEN) {?} (ELSE) {;} R IF , | j : J ("THEN | |-:| BY , f I WHILE J L.J Figure 3.2 Table of errors for an IF statement, statement GOTO _typ_ ! f Possible errors ■] f: T < label* •! i ' - i 'END " STCP el> Figure 3.3 Table of errors for a GOTO statment. 25 statement err Possible errors DO, D0{ END } ; { END | . END DO {;} «stmt> {;} END {;} DO f : l PI , , END D0 2 DO- R M DO j"| - [) } L ' J .BY... TO {> } \f /u ; BY [)}\ WHILE... DO {=} ^ TO. BY. DO < do 1 var > I - \ < expr > < l/J TO. BY. W DO WHILE f: «ccond> ) \) } I > DO WHILE {() {) } {;} DO WHILE (!) {;}{• Figure 3.4 Table of errors for a DO statement 26 statement err Possible errors fSKIP] - - GET PAGE LIST | . l J (< var 1 1 st » {) } ; GET M GET {LIST] {(} < var list- {) } {;) GET fSKip-i m f>i r- (PRGEj : J : : Figure 3.5 Table of errors for a GET statement. statement typ Possible errors STOP E STOP , : M STOP {;) R STOP . Figure 3.6 Table of errors for a STOP statement, 27 statement tvEL Po53 i b 1 e errors PUT M 1 ; SKIP < L.J f 1 rn PUT f— PAGE \y (skip ] en , . LIST PRGE , ( {) } SKIP \ / N ( < expr > ) PUT< — PRGE \ ^ . PI \fl.0HlLE| |"<1 roJ , :j ( If* |) j l,\ M < dc i va r > ! = \ < G>pr > { ; j R l" + l f : l .del var. - r Figure 3.8 Table of errors for an ASSIGN statement. statement err b p — - ■- . -i Ross i b 1 e errors RETURN E RETURN I'J ^-l' r> > {•} j^'j ■ fl RETURN ((} <~pr> {)}\,} R RETURN i;j p l-j l-J Figure 3.9 Table of errors for a RETURN statement, 29 statement err tvp Poss i b 1 e errors CALL E CfiLL ' >{<] ( r> )('] {.j Nexter/ '" ' J L ' J LJ M , < node 1 > CHLL <^ >{(} ex P r> {) } [;} R Ne.,t„-/ l;J " l;J i:j Figure 3.10 Table of errors for a CALL statement statement err taa. Possible errors ENTRY R ENTRY ( ] f ,)N, ; L/.i J u :}■ ENTRY* I { (} | < attr i b > . {)}{;} {'} ENTRY Lit MW YTL IZG*246: t t SBM= H; t IF . 2 > = 99 1) THEN X/ CUP* *CB) ■ t t t ELSE. ,f1K= HSO-ZIUI: t 1 1 1 I IE CVQ=<979) G/ TL; t t .BY. 02V, = 38**725: t t , ! * R IF ( • 3 i - > 5 9 9) I (HZL 4 1 ) UIH I LE RS+ WT ; t t THEN Y= 35; t E IF . ( (0L: :->Rrti -, (WD< =? 1 4)1 : THEN OJ: = ZZ+8; t t .ELSE 1= BI.; t -> R IF . ( ( l 5 9 > «547) -. (225 «8) -1 (HM01I=.IJR.T0.SL WHILE (94=L FT ) ; M.Q; f f END . ; 2 E DO. .WHILE., (HY<64).J ; H=.59; f f X><= .7; END . ; Ihext) to continue the generation i [back] to return to the main page Figure 3.13 Sample of errors for a DO statement. 33 1] Generat i on o f Prob 1 em cliff as the student will see it err GO END W; t l E GO . . TO . ST ; l GO : TO DP; t 3 R GO .RHK; t 3 M GO MT; t R GO. END. T; (next) to continue the generation i&fr.Kj to return to the main page i ii Figure 3.14 Sample of errors for a GOTO statement. 34 Genera 1 1 on o f Prob 1 ern diff as the student will see it err E GET , LIST . (Z.J (GJ) , N (9) ,C (1 6, LO) ) ; t M GET (GZ CSD . PY) , F ( 8 ) , S ( 8 2 , FT) ) ; t 1 R GET. .SKIP.< .HZ(L, ,G(2,RL) ,XX(S)) ; ft t 2 R GET . PAGE . , H (7 , V) , NR (K) ) ; ft E GET . , LIST ( (JV CFUI*- . , F) , CP (R, T) , Y (LF) ) ; t t t 3 M GET . LIST . XD CNI . YP . , Z (O , B (Z Z) , B (J) ) : t ft t Imext) to continue the generation [tftcy.) to return to the main page Figure 3.15 Sample of errors for a GET statement. 35 Gener at l on o f Prob 1 em cliff 5.5 the student will see it err PUT LIST. (MUJ) ; M PUT.PRGE.; l M PUT.PRGE LIST KV (ZFF 4)); t t l E PUT. LIST., (SYCl) ,PX) ; • t 2 R PUT. LIST. :HL (J. 4, ,0,6, ,XHQ(3)) ; t ft t 2 R PUT .LIST . (BUL , S , EY ( 1 3 , , I) ; t [meet] to continue the generation ffjcK) to return to the main page Figure 3.16 Sample of errors for a PUT statement. 36 Genet ■ a 1 1 on o f Prob 1 em diff as the student will see it err o STOP . , ; t 1 E STOP END t 2 M STOP . t 1 STOP : t 2 R STOP . . t 3 R STOP : t [HEXTJ to co nt i nu e t he gener a t i on (back) to return to the main page i Figure 3.17 Sample of errors for a STOP statement. 37 Generat i on of Prob 1 em diff as the student will see it err E 0:= .VT; 1 1 R I- .84+V; t 2 Z , = . W J (NY ,5 - 5 4 * * YN (QK) ; t t M E.81; t 1 ZK + 5>E(S,36) ; t 3 K . l/96**S) / (5-91) - (9 + 9) - (UI-QR (Y0) ,) ; T t iMExjj to continue the generation \z-m~v\ to return to the main page Figure 3.18 Sample of errors for an ASSIGN statement. 38 Gener 3 1 1 on o f Prob 1 ern *s the student wi 1 1 see it d i f f err E RETURN (P) ) ; t 1 RETURN < . 3 4/GN CQ , C) } ; 2 . R RETURN, 95 M4-LG ; t M RETURN BP) ; t 2 RETURN UJ, IN SCO -I (Qi,?n ; t t 3 R RETURN ( (5 + 5 4) * (TX**ST) * (1*7) ** (XDr'3 4) , ; 1 .HEXT ) to continue the generation (BflCKj to return to the main page Figure 3.19 Sample of errors for a RETURN statement. 39 Generat l on of Prob 1 em cliff as the student will see it err E CALL.RCK* ) ; t 1 M CRLL U K,34 ; t t 2 R CALL RJ< Y0,2,W) ; t 3 E CRLL. OS, (ND, JG.OP.fl:) ; t t A M CRLL. H.UC, 97, 1,4,66 ; t t 5 R CRLL.B(VF,9,TY,U.V,79: ; t (hext) to continue the generation (&"Ck) to return to the main page Figure 3.20 Sample of errors for a CALL statement . 40 Generat i on o f Prob 1 em diff as the student will see it err E ENTRY ( (DECIMAL) ; t 1 11 ENTRY CHAR) ; t 2 R ENTRY, FLOAT, FLOAT) ; t 3 E ENTRY (FIXED, FIXED, CHARACTER) ; 4 n ENTRY . DEC I MAL , F I XED , F I XED , F I XED) ; t 5 R ENTRY: FIXED, FIXED, CHAR, DECIMAL, FIXED) ; t («ext) to continue the generation (bSck) to return to the main page . li Figure 3.21 Sample of errors for an ENTRY statement. 41 4. APPROACH TO THE GENERATION OF QUESTIONS The syntax tables used by the table driven compiler available in CAPS are used to keep the productions of the generator syntactically correct, a brief description of the tables and other elements is given below. 4.1 The Syntax Parser Table The syntax table is an encoding of the programming language syntax productions in a small interpretable instruction set. The parser consists of a routine that interprets this instruction set in an appropriate way, maintaining also other tables (useful to the generator) located in a region of memory referred to as Parser Storage area (array PS). Three more tables are necessary in the generative part of this program: the symbol-table, the name-table, and the character-table. These tables are used to store identifiers generated by the program and retrieve the information on reserved words, operators, etc. There are two predefined parser variables that can be tested and used as legal parameters anywhere in the syntax specification and that are of particular use and importance during the generation of questions. Parser variable CLASS will have the class value of the token to be generated, i.e. keyword, relational operator, etc. Parser variable PDN will have the unique identification number for a predefined token, i.e. (IF = 0, D0 = 1, etc.) a similar definition of values is given in GENDEFS (part 3, block 6) . 42 The parser action instructions allows for the specification of syntactic and semantic requirements of the language, consequently, provisions are made to invoke and return from procedures (PROCs) , to test the current input token for validity and some others to change the parser environment (i.e. symbol table modifications). The set of action instructions include SCAN, GOTO, CALL, RET, BC and SEMA, fully discussed by Tindall [ 6] . 4.2 Generation of Questions The generation of questions (statements) is based in the syntax tables description of the language as interpreted by the parser (unit stmtgen), modified to perform additional actions necessary for generation tasks. These additional tasks are briefly described below and a detailed description is given in Chapter 5. Instruction CALL, besides invoking a procedure and modifying the parser stack accordingly, is used to preset values for PDN and CLASS; these values depend on the type of statement to be generated and the level of difficulty. It also pushes into the generator stack information on the type and difficulty of the statement being generated and the value of recursion counters. Instruction RET (or RETI, where RET = RETI + SCAN) uses the information on the stack (recursion counters) to decide which way generation should resume upon return to the calling procedure, this is accomplished by setting appropriate values for PDN, CLASS, or both. Instruction BC (conditional branch) decides in accordance with the values of the variables tested (mostly PDN or CLASS) what displaying routines should be called, if the value of the tested value is zero 43 generates a random number to decide the way generation should follow. Another important task is to call the error generation routine every time an error label appears in the branching tag of this instruction. Instruction SCAN will set to zero variables PDN and CLASS except for special cases shown in unit SCANCONT. 4.3 An Example Figure 4.1 shows a portion of the PL/1 syntax tables corresponding to the description of the IF statement. Below is described the sequence of events that follow after a PROC STMT has been called where CLASS has been set to reserved word (12) and PDN to IF (200). Variable NESTLEV is initialized to zero. Before getting to location shown as line #3 in Figure 4.1, which represents the beginning of the syntactic description for an IF statement, a number of tests similar to line #2 were made to variable PDN but all of them failed because of its preset value. Line #2. If PDN is not equal to IFX, then branch to label STSTOP (stop statement). This condition is false because PDN is equal to IFX; the matching of the two parameters when one of them is either CLASS or PDN will cause a call to a routine (INSTCLASS or INSTPDN) that will display either a token of class determined by variable CLASS or a predefined symbol (i.e. 'IF') on the screen. Line #4 will cause execution of a CALL instruction and a jump to PROC COND- where a condition of the form: COND := EXPR OPREL EXPR will be generated, the details of how it's generated will be skipped for 44 later discussion. However, return from PROC COND will always be made to label 'STIF2'. Line #5 serves no useful purpose in the generative part of this program. Line #6 is similar to line //7. 1 * 2 st l f be ne, pdn, l fx, st stop 3 * IF statement 4 cal 1 cond, then st i f 2 , st i ferr 5 st i f err be true, error 98 * only expr in cond 6 st i f 2 be eq, pdn, rightp, error 9 7 * too many ) in condexpr 7 be ne pdn, therrx, error 9 * req THEN here 8 cal 1 strnnt 9 be ne , pdn , e 1 sex , st i f 1 10 call strnnt 11 stifl reti 12 * 13 st st op be ne , pdn , st op x , st do Figure 4.1 PL/1 syntax description for an IF statement. Line #7 offers a good example of the treatment given in unit TOKGEN to instructions with an error label in the branching field. Unit ERRGEN will be called, and as a result of this, two possibilities exist: that an error will be generated or no error generated at all. This decision is based on the total number of errors for this statement and some additional logic to avoid (to a certain extent) consecutive errors. If an error was generated, unit TOKGEN will be finished, otherwise a call will be made to the display unit INSTPDN that will write the predefined 'THEN' on the screen. 45 Line #8 is an example of recursion when PROC statement calls itself. Unit CALLCONT will set PDN and CLASS to ASSIGN (7) and RSWD (reserved word = 12), see Section 5.3.4. So an assignment statement (difficulty 0) will be generated in the THEN part of the IF statement, insuring with this that no further recursion will occur at this point. Line #9 will generate a predefined ELSE if unit RETCONT, executed at the end of procedure STMT, set PDN to ELSE (depending on the degree of IF STMT) and continue to execute line #10; otherwise it will resume at line #11. Line #10, same as line #8. Line #11 is the return from the procedure STMT, since no other procedure called the current one variable NESTLEV is equal to zero and ENPROG flag is set to one so that the next instruction will end the generation. 46 5. SYNTAX PG/G TECHNICAL DOCUMENTATION Plato lesson 'CSXPL1SYN' contains the tutor code written for the PL/1 syntax PG/G and lesson 'CSXFORTSYN' the corresponding to the Fortran one. Part 1 of the first lesson contains the routines to write problem specifications, Part 2 to administer the problem, and Parts 3 and 4 are the question generator. To read this chapter it is necessary to have a print-out of lesson ' CSXPL1SYN' and a copy of the PL/1 syntax tables from lesson ' TRW6 ' . Throughout this chapter, a number and a letter enclosed in parentheses (for example (3-c)) is used to denote part 3 block c; all additional strings of characters as (4-c-4opnd) will represent a label in that block. 5.1 Problem Specifications Writer Unit WRITER (1-c) , the main unit for this part, receives control from the Exam Monitor which passes information such as the Problem Specifications Header (4 words) and if there is a problem to be modified will be passed starting in word nc5 of storage. Upon entering unit writer a call (do) is made to execute unit IEU to load the PL/1 charset from lesson 'PL1C0MP' and to transfer from storage (ncl) to student variables (n76) and the Problem Specifications Header as shown in Figure 5.1. 47 After the instructor has specified a problem, unit RET will transfer back from student variables to storage the Problem Specifications Header plus the Problem Specifications themselves (PS_SIZ) . The following values have to be modified before returning: PS_SIZ total length of Header plus length of Problem Specifications PS_GTW Grand Total Weight of the Problem. The Problem Specifications are composed of the Generator Header (1 word) and the question specification (1 word per question). See block of defines (1-b). 5.2 Problem Administrator Unit ADMIN (2-a) gets the Problem Specifications from the Exam Monitor and presents the student th options (selection page) and controls the calls to the question generator and problem review units. Problem Specifications are also passed via storage and a transfer is done to student variables. Figure 5.1 also shows the map of the question area (10 words per question) composed as follows: A) BUFFER (6 words) This area is used to store the string of characters generated. Unit GENTOK (4-c) does the updating. B) ERRORS (2 words) contains the data on the errors generated. 2 errors per word, for a max of 4 errors. C) ANSWERS (2 words) Student answers and errors are stored in a similar format. Unit SELECT is called only when the problem is a type 2 (probtyp = 2) then a random selection of questions will be done. 48 n7 6 n8fl nSl n8 7 PROBLEM HERDER (4 words) GENERATOR HERDER ri word) QUESTION SPECIFICATIONS (. 1 word per quest i on) 1 2 Quest i on J generated 4 buffer 5 6 1 errors 2 generated 1 student 2 answers QUESTION NUMBER ONE 1. 1 0' words per que st i on) Figure 5.1 Map of the problem and question specification areas on student variables (n76-nl47). procedure stkptr d< ftO ree counter 1 1 * r 1 I 16 12 S 4 topstk next op botstk location 13 48 on the character table Figure 5.2 Map of the generator stack on the character table. 49 Unit SCORE tallies up the score for each question after the student is done with it. Unit FINSCORE tallies up the final score before jumping back to the cover page. It should be noted that student variables nl48 - nl50 are used by the Exam Monitor and should not be modified by this program 5.3 Question Generator Parts 3 and 4 are the code to generate questions in the form of programming language statements with syntax errors. Block COMPDEFS (3-a) is a copy of the compiler variables used by the generator to manipulate the tables; comments for this variable are given in lesson TRW blocks c, d, and e. Block GENDEFS (3-b) are the Generator Define commands, where three define commands require special attention: define N° 5: GENERATOR STACK. Besides the stack maintained by the parser (unit STMTGEN) an additional stack had to be implemented to keep the status of certain variables useful to the generator while calling secondary procedures like condition, expression, etc. Figure 5.2 shows the name of locations tested more frequently. TOPSTK has the value of the current procedure. If 10 it is the PDN value of the statement being generated +10 TOPDGRE difficulty of the question TOPCOUN miscellaneous counter 50 Define commands 8 and 9 correspond to the values assigned to predefined values and class values in the syntax tables. 5.3.1 Unit STMTGEN (3-d and e) This unit is the interpreter for the syntax descriptor language as implemented in lesson TRW but modified to perform additional functions described in Section 4 . 2 by calling (do'ing) units CALLCONT, RETCONT, SCANCONT, etc. The initialization of tables and variables is done by unit GENERTR that calls unit STMTGEN and displays the "WAIT" message on the student's screen. 5.3.2 Unit CALLCONT (3-f) Unit FINDPROC is executed in order to determine the PROC that has been CALLed since the only way to know it is by the branching address; variable I is set to a value less than 10, see unit FINDPROC (3-g) . The basic procedures are discussed now. Procedure STMT (3-f-0stmf) may be either called by the main program (NESTLEV = 0) or recursively by another PROC STMT. In the first case the specifications for the question indexed by variable PROB will be assigned variables CLASS and PDN (CLASS = RESERVED WORD, PDN = STATEMENT TYPE); in the latter case an assignment statement is specified to be generated; for example the THEN part of an IF STMT calls PROC STMT. Procedure EXPR (3-f-lexpr) . For all practical purposes the degree of an expression will be the same as the statement that called this PROC, and the meaning of DEGREE is the number of operands that will be generated for this expression; however, PROC SUBSC (subscript) and COND (condition) are exceptions, and their degree is always zero. 51 When called recursively, the degree of the expression called will be equal to the degree of the calling procedure subtracted by two. PROC OPND (3-f-2opnd) is only called by PROC EXPR and the value of CLASS will depend on the degree of EXPR which can either be CONST (constant), DCLVAR (declared variable) or ARRAY; if degree is greater than two a left parenthesis will be generated (PDN = LP) and this will allow a CALL to PROC EXPR. PROC COND (3-f-5cond) is another case where possibility of recursion exists. Depending on the degree of the statement calling this PROC, a number of recursive calls will be made until this number is equal to the degree. In the first case PDN is set to left parenthesis in the latter case to anything except L paren (i.e. PDN = DO) . At the end of unit CALLCONT, variable STKPTR (stack pointer) is incremented by 4. 5.3.3 Unit RETCONT (3-g) Variable TOPSTK has the value of the PROC that is executing the RETURN so its value is used to branch to the label of the corresponding PROC. Label Ostmt (PROC STMT). Variable NESTLEV is decremented. A branch to label Ochk will be performed for any statement other than DO; in which case a test will be done on the number of assignment statements generated (NEXCOUN) and the degree (NEXDGRE) of the DO statement, if test is true an END statement will be specified (PDN = END) otherwise nothing is done. If NESTLEV is equal to zero, the end of Generation Flag (END PROG) is set to 1. 52 Label lexpr (PROC EXPR) . When RETurning from PROC EXPR, two cases require specific actions: when returning to a PROC COND and when returning to PROC STMT (PL/1 CALL or RETURN statements). In the first case PDN is set to OPREL (relational operator) so as to control the number of conditional operands to two. In the second case, PDN will be set to COMMA if the counter is less than the degree. Label 2opnd (PROC OPND) . Since EXPR is the only PROC that calls PROC OPND, the actions taken when returning from OPND are fundamental to control recursion on itself. The cases in which CLASS is set to three to finish EXPR are: degree of EXPR is zero, COND called EXPR, and counter of operands is equal to the degree of EXPR; in any other case the counter is incremented and CLASS set to OPBIN. Label 3subs (PROC SUBSCRIPT). The actions taken when returning from this PROC, affected only when statements PUT or GET are being generated, control the length according to the degree. Label 5cond (PROC CONDITION). When returning to another PROC COND a check is made on the number of recursive calls (STACK (-9)) if it is less than the degree of the IF statement PDN is set to Left Paren and CLASS to OPCOND causing another recursive call otherwise CLASS is set to OPREL causing the end of PROC COND. At the end of unit RETCONT, STKPTR is decremented by four. 5.3.4 Unit BCCONT (3-c) The instructions before label 0start are just special cases difficult to handle by any of the units discussed before. 53 Instruction label 0start branches off to label 4forcd when the parser instruction BC has branching label of the type 'ERROR // ' for instance: first parameter second parameter k \ +1 l be ne , pan , t henx , er ror 9 T T operator branch label Figure 5.3 Sample of a BC instruction with an error branching label. and in the ELSE part of an IF statement (special case) . The instructions following label 0start are the logic used in deciding whether or not to display a token according to the values of PDN or CLASS. This can be summarized as follows: 1. If the first parameter (PDN or CLASS) is equal to zero, then choose randomly (label 3rand) whether or not to perform the branch. 2. If the first parameter (X) is different than zero, then check if the operator (OPRTR) is equal (eq) or not equal (ne) . In the first case, if X = Y goto label 6ins or to 9end. In the second case and if X = Y, goto label 9end or to 6ins. OPER has the value of -1 if the condition is true or if false. Label 6ins will call (do) unit INSTPDN or INSTCLAS depending on the variable tested (PDN or CLASS) . The branch instruction right after label 6ins is a special case. Unit INSTPDN (4-b) (INSerT Pre-DefiNed) assigns variable NTA (Name Table Address) the value of the location in the name table where that 54 PDN name is specified. This unit calls unit INSERT (4-b), that getting the information on that PDN brings it from the character table, displays it on the screen and stores a copy in array BUFFGEN. Unit INSTCLAS (4-a) displays one token of class "Y" randomly selected from the name table (for example OPBIN = binary operator) or generates it if it is not necessary to access the name table (for example, a not declared a constant, etc.). 5.3.5 Unit ERRGEN (4-c) This unit is called only from TOKGEN (3-c). It decides whether or not to generate an error, displays the symbols involved and stores the error data. The first CALCS instruction will assign variable OP the value of the error label (i.e., Figure 5.2 OP is set to 9). An error will be generated if the number of errors generated (NUM_ER) is less than the max specified, and FLG1 is different than zero (to avoid consecutive errors) and the random variable Rl is two, and finally, if the current PROC is STMT. Variable ERRIDN will bet a value less than 15 depending on the error label (OP), and will be set to zero if it doesn't match any of the OP's supported by this error generator in which case a branch will be made to 9dcr. In the contrary case, a call to unit ERRSET will be issued. Unit ERRSET (4-d) will use the value of ERRIDN to branch to a label that is of the form '//err' where it corresponds to the value of OP; there, by means of an error function ERRFUN, that depends on the TYPE of error to be generated and a random number R3, will assign to PDERR the value of the PDN selected to be an error. A typical example is: 55 * requu res ) 1 Strr 2 ca 1 cs err fun, pcterr* , , comma , rp, rp, , , , rbrk , co Ion, comma , 3 calcc flg2 • 1, pderr * comma, x 4 branch 2br b * Figure 5.4 Code corresponding to unit ERRSET, to select symbols when generating questions. ERRFUN (ERRFUN = (TYP-1) 3 + R3) will have a value from 1-3 if TYP is EXTRA or 7-9 if TYP is REPLACE. So, PDERR will be determined by the random variable R3. Line #3 is used to avoid displaying an EXTRA right paren when an EXTRA left paren has been generated. The branch to label 2br causes the variable 'W to be set to two, which in turn means that upon return to unit ERRGEN and if the TYP is EXTRA, the extra symbol must be inserted AFTER (label 4after) the correct symbol. From unit ERRGEN, unit SETVAR is also called to store the internal values of the PDN's in the generated errors area (ER_PDN and ER_PDW) . 5.3.6 Debugging Facilities To enter this lesson in debug mode just condense it from the author mode page. It isn't necessary to enter via monitor, unit GEN2 (4-e) will take over the control of generating tasks. Figure 5.5 shows the display when debugging the generator, 4 tracing options are available and are now briefly described: 1) SYNTAX (unit trace) (4-g) This option will list every syntax instruction to be executed, with values for both parameters and the 56 GET. LIST., L( 0. if 1. do 2.. = goto 3. dec 1 are 4. get 5. put 6. stop 7. ass i gn 8. ret 9. call a. entry ERRLIST pos typ pdn pderr 113 ( < stmt nest errs typ 4 4 4 3 NEXT no trace, DRTR al 1 , LRB details' DUMPSTK TRTCE topstK-» 3 8' J0f sptr= 62 3 call nextop-* 1 4 4 £' 8 ptr-» 8,1 clas-» 17 pdn-* 100 pr-*subs nesting-* 1 ERRPMP typ *errs err err fun idn y pderr r3 erpiln erpdw 2 3 1 4 7 3 1.0 41 1 11 5 41 Figure 5.5 Display shown when executing the lesson in debugging mode. 57 condition, the value of the random number generated (if any) and the display unit called (if any). 2) STACK (unit dumpstk) (3-g) A dump of the topmost three rows of the stack is provided every time units CALLCONT or RETCONT are executed. The dump includes name of the PROC, stack pointer value (STKPTR) and the new values of CLASS and PDN. 3) ERDUMP (unit ERDUMP) (4-f) Every time unit errgen is called and an error is generated, a complete dump of all the variables involved is given at the bottom of the screen. 4) ERRLIST (unit ERRLIST) (4-f) A list of the errors is displayed and updated every time a new error is generated. Every one of these options may be selected before starting the generation by pressing a number less than 4 and turned OFF individually while generating, by pressing STOP right after the corresponding PAUSE. 58 LIST OF REFERENCES 1 Alpert, D. and D. L. Bitzer, "Advances in Computer-Based Education," Science 167 (1970), 1582-1590. 2 Barta, B. Z. and L. R. Whitlock, "ISAEPS: Interactive System for Automatic Examination of Programming Skills," unpublished report, University of Illinois at Urbana-Champaign, February 1975. 3 Davis, A. M. , "An Interactive Analysis System for Execution Time Errors," Ph.D. Thesis, Department of Computer Science, University of Illinois at Urbana-Champaign, January 1975. 4 Hoffman, R. B. and J. P. Seagle, "A Problem Oriented Computer Based Instructional Procedure," Proceedings of 24th ACM National Conference , 1969, 97-110. 5 Nievergelt, J., "Interactive Systems for Education — The New Look of CAI," invited paper to the IFIP 2nd World Conference on Computer Education, Marseilles, France, September 1975. 6 Tindall, M. H. , "An Interactive Table-Driven Parser System," Master's Thesis, Department of Computer Science, University of Illinois at Urbana-Champaign. 7 Whitlock, L. R. , "A Generative Tailored Exam System," Research Proposal, Department of Computer Science, University of Illinois at Urbana- Champaign, April 1975. BLIOGRAPHIC DATA EET 1. Report Ni UIUCDCS-R-75-755 3. Recipient's Accession N< I'u K .ind Suht itle A GENERATOR/GRADER OF PROBLEMS ABOUT SYNTAX OF PROGRAMMING LANGUAGES TO BE USED IN AN AUTOMATED EXAM SYSTEM 5- Krport Date September 1975 Author(s) Francisco J. Izquierdo 8. Performing Organization Kept. No. Performing Organization Name and Address Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 10. Project/Task/Worlc Unit Nc 11. Contract/Grant No. NSF EC -41511 Sponsoring Organization Name and Address National Science Foundation Washington, D.C. 13. Type of Report & Period Covered 14. Supplementary Notes Abstracts The approach to generate problems about errors in the syntax of programming languages is presented. The three modes of using described are instructor writing problem specifications, student working on a problem, and student reviewing a problem. Key Words and Document Analysis. 17a. Descriptors Ident if iers /Open-Ended Terms I COSATI Fie Id /Group (Availability Statement 19. Security Class (This Report ) UNCLASSIFIED 20. Security Class (This Page UNCLASSIFIED 21. No. ot Pages 22. Price r »M NTIS-35 I 10-70) _■ USCOMM-DC 40329-P7 1 ;> lv sen 7** \* * & %