/* Copyright (C) Wolfgang Menzel, Universität Hamburg, 2003-07-11 based on the SWI-Prolog demo program demo_body.pl This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ %%% a web-server for grammar-based exercises %%% as tutor_helper.pl but without an exercise selection %%% and without offering a solution proposal :- module(tutor_helper, [ reply/1 ]). :- use_module(library( 'http/http_client' )). :- use_module(grammar_diag). :- style_check(-atom). % allow long atoms reply(Request) :- member(path('/tutor'), Request), !, title_html, selection_html, end_html. reply(Request) :- member(path('/prompt'), Request), member(search(Search),Request), member(exercise=exit,Search),!, format('Connection: close~n', []), title_html, format('
Thank you for using this program. Bye.
'). end_html. reply(Request) :- member(path('/prompt'), Request), !, member(search(Search),Request), member(exercise=Exercise,Search), memberchk(item=ItemId,Search), title_html, prompt_html(Exercise, ItemId), end_html. reply(Request) :- member(path('/feedback'), Request), member(search(Search),Request), member(exlevel='22222',Search),!, member(exercise=Exercise,Search), member(item=ItemId,Search), member(text=Text,Search), title_html, feedback_html(Exercise,ItemId,Text,'22222'), end_html. reply(Request) :- member(path('/feedback'), Request), !, member(search(Search),Request), member(exercise=Exercise,Search), member(item=ItemId,Search), member(text=Text,Search), member(exlevel=ExLevel,Search), title_html, feedback_html(Exercise,ItemId,Text,ExLevel), end_html. title_html :- format('Content-type: text/html~n~n'), format('~n'), format(' ~nWelcome!
~n'), % format('Which exercise?
~n'), format('~n'). prompt_html(Exercise,ItemId) :- get_prompt(Exercise,Prompt), next_item(Exercise,ItemId,Text,NewItemId), format('~w
~n~n',Prompt), format(' ~w ~n~n',Text), format('~n'). prompt_html(_,_) :- format('No more items available.
'), format('~n'). feedback_html(Exercise,ItemId,Text,'22222') :- !, format('Your sentence: ~w
', Text), get_sols(Exercise,ItemId,Sols), format('My proposal: ~w
~n', [Sols]), format('My comment: ~w
~n', Reply), (NewExLevel='33333' -> true ; (NewExLevel\=ExLevel -> format('To correct, go back in your browser and try again
~n') ; true)), format('