/* Quizz Server - DMS - march 98 - by Sylvain HUET */ defcom Cquizz=quizz S I;; struct Qz=[cliQz:CLIENT,txtQz:S,numQz:I]mkQz;; typeof quizz=[S r1];; typeof qu=[Qz r1];; fun byboth(a,z)=let z->[c i] in c==a.cliQz && i==a.numQz;; fun __answer(i,yes)= let search_in_list qu @byboth [DMSsender i] -> x in if x==nil then nil else (set qu=remove_from_list qu x; _DMSevent this DMSsender strcat if yes then "yes" else "no" itoa i nil nil);; fun removecli(l,c)= if l==nil then nil else let l->[a n] in if a.cliQz==c then removecli n c else a::removecli n c;; fun logout(cli)= set qu=removecli qu cli; 0;; fun activate(from,cli,action,param,rep)= if !_DMSclientAlive cli then nil else if !strcmp substr action 0 5 "quizz" then let if !strcmp action "quizz" then nil else atoi substr action 5 100 -> i in let if i==nil then param else nth_list quizz i -> txt in (_DMScreateClientDMI this cli nil; _DMSsend this cli Cquizz [txt i]; set qu=(mkQz[cli txt i])::qu; 0) else nil;; fun getQuizz(l)= if l==nil then nil else let l->[q n] in if !strcmp hd q "quizz" then (hd tl q)::getQuizz n else getQuizz n;; fun IniDMI(file)= let strextr _getpack _checkpack file ->l in (set quizz=getQuizz l); _DMSregisterDMI this @activate nil @logout nil;;