{ MC_SCHOOL.PAS Copyright (c) TrSek alias Zdeno Sekerak } { Multiple-Choise Analysis Report } { } { Na medziskolskej matematickej sutazi, formov testou otazok bola } { zorganizovana sutaz. Odpovedne harky pre ucastnikov boli citane } { pomocou Optickeho spracovania vysledkov (OMR) a volby boli } { konvertovane do textoveho suboru. } { } { Predstavte si ze ste programator. Idete vyvyjat pocitacovy } { program na citanie vsetkých suborovych textovych dat a produkovat } { detailne analyzy zo skusok. } { } { Analyzy budu obsahovat. } { - celkovy pocet ucastnikov, celkovy pocet skol, } { celkovy pocet ucastnikov z kazdej skoly } { - vitaza jednotlivych cien a vitaza za skolu } { - otazky zanalyzujte s percentualnym vyjadrenim } { - zobrazte jasny vysledok } { } { Author: Zdeno Sekerak } { Date : 29.07.2008 http://www.trsek.com } program mc; const MAX=50; type pperson = record name : string[14]; ans : string[40]; mark : integer; sch : string[20]; end; pschool = record name : string[14]; count: integer; end; var fn, fa: string; count : integer; count_sch : integer; count_ans : integer; i, fi : integer; answer: string; person: array[1..MAX] of pperson; school: array[1..MAX] of pschool; anmark: array[1..40] of real; { read txt file } procedure read_file_mc( name: string ); var f: text; s: string; is,ie: integer; {start, end} ic: integer; begin assign(f, name); reset(f); count:=0; While not eof(f) do begin count:= count + 1; readln(f, s); { now find first char answer } is:=14; while((s[is] = ' ') and (is ' ') and (ie person[i].sch)) do y:=y+1; { no found } if( count_sch < y )then begin count_sch:=count_sch+1; school[y].name := person[i].sch end; { count it } school[y].count := school[y].count+1; end; end; { find the first person of school } function find_school(sch:string): integer; var i:integer; begin find_school:=1; for i:=1 to count do if( person[i].sch = sch )then begin find_school:=i; break; end; end; { percent answer } procedure answer_percent; var i,y:integer; begin count_ans := length(answer); for i:=1 to count_ans do begin anmark[i]:=0; for y:=1 to count do if( upcase(person[y].ans[i]) = upcase(answer[i]))then anmark[i]:=anmark[i]+1; anmark[i]:= 100*(anmark[i]/count); end; end; begin writeln('File name:'); {fn:='input.txt';} readln(fn); read_file_mc(fn); writeln('File answer:'); {fa:='answer.txt';} readln(fa); read_file_ans(fa); writeln('wait I counting'); correct_answer; sort_answer_mark; count_per_school; answer_percent; { answer } for i:=1 to 25 do writeln; writeln('Total person is ', count); writeln('Total school is ', count_sch); writeln('School'); for i:=1 to count_sch do writeln(i:2,' ', school[i].name:10,' person = ',school[i].count); writeln; writeln('The highest is ', person[1].mark); writeln('He/She is ', person[1].name); writeln('He/She is in ', person[1].sch, ' Secondary School.'); writeln; writeln('The highest per school'); for i:=1 to count_sch do begin fi := find_school( school[i].name ); writeln(person[fi].sch, ' Secondary School.'); writeln('The highest is ', person[fi].mark); writeln('He/She is ', person[fi].name); writeln; end; writeln('Percentual answer'); for i:=1 to count_ans do writeln(i:2, ' ', anmark[i]:4:1, '% correct = ', answer[i]); readln; end.