1
2/* base file for school database. Supposed to be called from school_*.yap */
3
4professor_key(Key) :-
5	professor(Key).
6
7professor_ability(Key,Abi) :-
8	abi_table(Key, AbiDist),
9	{ Abi = ability(Key) with p([h,m,l], AbiDist)   }.
10
11professor_popularity(Key, Pop) :-
12	professor_ability(Key, Abi),
13	pop_table(Key,PopTable),
14	{ Pop = popularity(Key) with
15		p([h,m,l], PopTable,[Abi]) }.
16
17registration_key(Key) :-
18	registration(Key, _, _).
19
20registration_course(Key, CKey) :-
21	registration(Key, CKey, _).
22
23registration_student(Key, SKey) :-
24	registration(Key, _, SKey).
25
26registration_grade(Key, Grade) :-
27	registration(Key, CKey, SKey),
28	course_difficulty(CKey, Dif),
29	student_intelligence(SKey, Int),
30	grade_table(Int, Dif, Table),
31	{ Grade = grade(Key) with Table }.
32
33% registration_satisfaction(r0, h) :- {}.
34registration_satisfaction(Key, Sat) :-
35	registration_course(Key, CKey),
36	course_professor(CKey, PKey),
37	professor_ability(PKey, Abi),
38	registration_grade(Key, Grade),
39	satisfaction_table(Abi, Grade, Table),
40	{ Sat = satisfaction(Key) with Table }.
41
42course_key(Key) :-
43	course(Key,_).
44
45course_professor(Key, PKey) :-
46	course(Key, PKey).
47
48course_rating(CKey, Rat) :-
49	setof(Sat, RKey^(registration_course(RKey,CKey), registration_satisfaction(RKey,Sat)), Sats),
50	{ Rat =  rating(CKey) with avg([h,m,l],Sats) }.
51
52course_difficulty(Key, Dif) :-
53	dif_table(Key, Dist),
54	{ Dif = difficulty(Key) with p([h,m,l], Dist) }.
55
56student_key(Key) :-
57	student(Key).
58
59student_intelligence(Key, Int) :-
60	int_table(Key, IDist, Domain),
61	{ Int = intelligence(Key) with p(Domain, IDist) }.
62
63student_ranking(Key, Rank) :-
64	setof(Grade, CKey^(registration_student(CKey,Key),
65			 registration_grade(CKey, Grade)), Grades),
66	{ Rank = ranking(Key) with avg([a,b,c,d],Grades) }.
67
68:- ensure_loaded(tables).
69
70
71
72