Académique Documents
Professionnel Documents
Culture Documents
119
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
For whatever languages the systems could support, The authors chose to develop a system based on the
there are two identified approaches in order to test or pseudocode comparison, which is a static analysis
mark the programming assignments. The approaches approach. The motivation behind this is to provide
that normally implemented are static or dynamic, or flexibility in student’s answers. In programming
sometimes both [13]. problem solving, students may solve an assignment
using different statements or different algorithms.
Static analysis involves the examination of program Hence, this will not restrict the student’s creativity.
source code without execution. The program source
code structure and syntax are inspected so as to The pseudocode is a general format of the source
highlight static errors and produce statistical code. By converting the source code into
information for the programmer [3]. This approach is pseudocodes can provide easier upgradeability. This
normally used for activities intended to pick up other is because the pseudocodes comparison module could
type of errors or potential error conditions, such as be used to assess source codes from other languages.
infinite loops, unreachable statements, conflicting What we need to do is to developed different
conditions, improperly nested loops and unused pseudocodes converter to cater other language.
variables [13].
120
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
separators [6]. Please refer appendix A for the The pseudocodes translation:
complete specification of the lexical syntax in START
Backus-Naur form. The source code will be declare i as integer
tokenized and as a result, a sequential list of tokens i=1
declare salary as float
will be produced.
declare tax as float
DO
display the value of i
3.2 Pseudocode generation display "Key in the salary\n"
get user data for variable
Next is the process of transforming the program into ,salary
pseudocodes. The list produced by the tokenization IF (salary < 1000)
calculate tax = salary*0.04
process will be used as the input of this process. This
ELSE
conversion into a general form will simplify the calculate tax = salary*0.08
comparison procedure, which is the last module. ENDIF
display the value of salary
A pseudocode standard suggested by Robertson, [8] display the value of tax
is chosen since there is no formal standard for i=+1
pseudocode. Translation is done by converting the WHILE i < 5
source code statements into the pseudocodes display "TQ"
END
language specification. For example if the generator
find int in as the first word in a statement, then the
generator will presume the statement is a variable
declaration of integer data type. Appendix B shows a 3.3 Comparing pseudocodes
table of the statements and the translation to the
pseudocodes. The student’s pseudocode is then compared to the
instructor’s pseudocodes. Assessment is done in two
This is an example of a source code, translated into separate categories. The first is the comparison of the
the pseudocode. number and types of variables, and the second is the
algorithm similarities between the two pseudocodes.
The code example: To handle various acceptable solutions with different
#include<stdio.h> algorithms, the instructor may provide more than one
#include<conio.h> solution model. The students answer will be
main(){ compared with all the solutions provided. The highest
int i=1; similarity percentage will be chosen for the mark.
float salary,tax;
The first step in this process is to segregate the part of
do{
variable declarations. Since the variable declarations
printf("Staff no : %d\n",i);
printf("Key in the salary\n"); could be anywhere in the student’s answer,
scanf("%f",&salary); separating them could increase the pseudocode
similarity level with the pseudocodes from the
if(salary<=1000){ solution models. Pseudocodes without the variable
tax=salary*0.04; declaration will then compared to the solution models
} provided. To handle various acceptable answers with
else{ different algorithms, the instructor may provide more
tax=salary*0.08;
}
than one solution models. The student’s solution will
printf("The salary is: RM.2%f\n", be compared with all the solution models provided.
salary); The highest similarity percentage will be chosen for
printf("Your tax is : the mark.
RM.2%f\n",tax);
i++; The comparison approach used in this application is a
}while (i<=5); non-structural similarity comparison as suggested by
Norshuhaini [2006]. The algorithm used for the
printf("TQ");
getch();
comparison is a string similarity algorithm that
} produces the similarity percentage between two
strings.
121
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
Student’s
pseudocode
Pseudocode Similarity
scheme 2 percentage 2
Pseudocode Similarity
scheme n percentage n
The highest
percentage
122
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
123
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
Whitespace: \b|\t|\r|\n|\f|\r\n
Comment:
LineComment|BlockComment
LineComment: // any string ended by \r or \n or \r\n
BlockComment: /* any string */
Letter: [A,…,Z,a,…,z]
Digit: [0,…,9]
ArithmetikOperator: ArithopMult|ArithopDiv|ArithopMod
|ArithopAdd|ArithopSub
ArithopMult: *
ArithopDiv: /
ArithopMod: %
ArithopAdd: +
ArithopSub: -
LogicalOperator: LogicopNot|LogicopAnd|LogicopOr
LogicopNot: !
LogicopAnd: &&
LogicopOr: ||
124
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
RelopGreaterthan: >
Relopltorequal: <=
Relopgtorequal: >=
Separator: Sepcoma|SepEOS|OpenStmtBlock|CloseStmtBlock
|OpenArrBound|CloseArrBound|OpenParenthesis
|CloseParenthesis
Sepcoma: ,
SepEOS: ;
OpenStmtBlock: {
CloseStmtBlock: }
OpenArrBound: [
CloseArrBound: ]
OpenParenthesis: (
CloseParenthesis: )
125
Conference on Information Technology Research and Applications 2007 (CITRA 2007), 4th – 5th April 2007, Selangor, Malaysia
126