From 4c99f6513599a948ec7742fae8d9e0b3ccb61769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20M=2E=20Thi=C3=A9ry?= <nthiery@users.sf.net> Date: Thu, 2 Oct 2014 00:03:58 +0200 Subject: [PATCH] WIMS: debug reorganisation --- U2~coding~oefprogramC.fr/src/etat_civil.oef | 1 - .../data}/io-basic.cpp | 0 guess_output/INDEX | 24 ++++++ guess_output/Makefile | 25 ++++++ guess_output/NEWS | 5 ++ guess_output/README | 30 +++++++ guess_output/TODO | 0 guess_output/about.phtml | 1 + .../data}/function-blackjack.cpp | 82 +++++++++---------- .../data}/function-factorial.cpp | 0 .../data}/function-max.cpp | 0 .../data}/if-semicolon.cpp | 0 .../data}/loop-indices-2.cpp | 21 +++-- .../data}/loop-indices.cpp | 21 +++-- .../data}/loop-syracuse.cpp | 26 +++--- .../data}/loops-do-while-factorial.cpp | 0 .../data}/loops-for-factorial.cpp | 0 .../data}/loops-while-factorial.cpp | 0 .../data}/variables-assign.cpp | 0 .../data}/variables-factorial7.cpp | 0 guess_output/endhook.phtml | 1 + guess_output/help.phtml | 1 + guess_output/intro.phtml | 6 ++ guess_output/introhook.phtml | 9 ++ guess_output/main.phtml | 1 + guess_output/src/cpp/guess_output.oef | 70 ++++++++++++++++ guess_output/var.proc | 36 ++++++++ oef/Makefile | 3 - oef/TODO | 6 -- oef/footer.oef | 11 --- oef/header.oef | 7 -- oef/programs/guess-output/Makefile | 29 ------- 32 files changed, 283 insertions(+), 133 deletions(-) rename {oef/programs/choose-input => choose_input/data}/io-basic.cpp (100%) create mode 100644 guess_output/INDEX create mode 100644 guess_output/Makefile create mode 100644 guess_output/NEWS create mode 100644 guess_output/README create mode 100644 guess_output/TODO create mode 100644 guess_output/about.phtml rename {oef/programs/guess-output => guess_output/data}/function-blackjack.cpp (85%) rename {oef/programs/guess-output => guess_output/data}/function-factorial.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/function-max.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/if-semicolon.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/loop-indices-2.cpp (92%) rename {oef/programs/guess-output => guess_output/data}/loop-indices.cpp (92%) rename {oef/programs/guess-output => guess_output/data}/loop-syracuse.cpp (77%) rename {oef/programs/guess-output => guess_output/data}/loops-do-while-factorial.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/loops-for-factorial.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/loops-while-factorial.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/variables-assign.cpp (100%) rename {oef/programs/guess-output => guess_output/data}/variables-factorial7.cpp (100%) create mode 100644 guess_output/endhook.phtml create mode 100644 guess_output/help.phtml create mode 100644 guess_output/intro.phtml create mode 100644 guess_output/introhook.phtml create mode 100644 guess_output/main.phtml create mode 100644 guess_output/src/cpp/guess_output.oef create mode 100644 guess_output/var.proc delete mode 100644 oef/Makefile delete mode 100644 oef/TODO delete mode 100644 oef/footer.oef delete mode 100644 oef/header.oef delete mode 100644 oef/programs/guess-output/Makefile diff --git a/U2~coding~oefprogramC.fr/src/etat_civil.oef b/U2~coding~oefprogramC.fr/src/etat_civil.oef index 31a8e2f..9ecc7e8 100644 --- a/U2~coding~oefprogramC.fr/src/etat_civil.oef +++ b/U2~coding~oefprogramC.fr/src/etat_civil.oef @@ -8,7 +8,6 @@ \text{code_celibataire=randitem(célibataire, marié(e))} -<!-- Il faut que le source soit logique en fonction de la question 2 (célibataire ou marié(e)) --> \text{code_etat1=\code_celibataire issametext célibataire ? Mademoiselle : Madame} \text{code_etat2=\code_celibataire issametext célibataire ? Madame : Mademoiselle} diff --git a/oef/programs/choose-input/io-basic.cpp b/choose_input/data/io-basic.cpp similarity index 100% rename from oef/programs/choose-input/io-basic.cpp rename to choose_input/data/io-basic.cpp diff --git a/guess_output/INDEX b/guess_output/INDEX new file mode 100644 index 0000000..9f495c4 --- /dev/null +++ b/guess_output/INDEX @@ -0,0 +1,24 @@ +# This file is automatically generated by Modtool 4.05. +# Do not edit by hand. + +title=Exercices de programmation C++ +description=quelques exercices de lecture et interprétation de programmes en C++. +language=fr +category=oef, exercise +domain=programming, +level=U1 +keywords=C++ +require= +scoring=yes +copyright=© 2014 (<a href=\COPYING\>GNU GPL</a>) +author=Nicolas,Thiery +address=Nicolas.Thiery@u-psud.fr +version=1.00 +wims_version= +vardef=oef/var.def +translator= +translator_address= +data= +maintainer= +maintainer_address= +translation_language= diff --git a/guess_output/Makefile b/guess_output/Makefile new file mode 100644 index 0000000..c271f54 --- /dev/null +++ b/guess_output/Makefile @@ -0,0 +1,25 @@ +PROGRAMS=$(wildcard data/*.cpp) +OUTPUT=$(PROGRAMS:%=%.output) +TARGETS=variables if loop function +all: data/index $(OUTPUT) + +data/index: $(PROGRAMS) + cd data; \ + (echo "all: "`ls -m $$target_*.cpp`) > index; \ + for target in $(TARGETS); do \ + (echo "$$target: "`ls -m $${target}_*.cpp`) >> index; \ + done + +data/%.output: data/%.bin + ./$< > $@ + +data/%.cpp.bin: data/%.cpp + g++ $< -o $@ + +clean: + rm data/*.bin data/*.output data/index + +#main.oef: header.oef programs/guess-output/*.cpp footer.oef Makefile +# cd programs/guess-output; make all.oef +# cat header.oef programs/guess-output/all.oef footer.oef > main.oef + diff --git a/guess_output/NEWS b/guess_output/NEWS new file mode 100644 index 0000000..0628ff0 --- /dev/null +++ b/guess_output/NEWS @@ -0,0 +1,5 @@ +# This file registers changes to the module. +# Please write in reverse order: the last version first. + +Version 1.00: + First publication. diff --git a/guess_output/README b/guess_output/README new file mode 100644 index 0000000..2c3ad74 --- /dev/null +++ b/guess_output/README @@ -0,0 +1,30 @@ +Pour installer des exercices OEF dans un module : + + 1. Créer un module de type OEF + + 2. Pour chaque exercice, créer dans le module un nouveau fichier + d'extension oef dans le répertoire src/ (exemple : src/euclide.oef). + Une zone de texte apparaît ; y écrire (ou coller) le texte source + de l'exercice. Enregistrer les changements. + + 3. Tester le module. + + 4. Modifier à son goût intro.phtml et endhook.phtml, + et tester à nouveau. + + +%%%%%% Pour utiliser directement le module sur un serveur WIMS local, + +1- Mettre le template à la bonne place, +en changeant le nom. + +2. Modifier intro.phtml + +3. Modifier le fichier INDEX. + +4. Installer les fichiers sources. + +5. Exécuter le script $wims_home/other/bin/src2def. (Cette étape + doit être répétée à chaque fois que les fichiers sources sont modifiés). + + diff --git a/guess_output/TODO b/guess_output/TODO new file mode 100644 index 0000000..e69de29 diff --git a/guess_output/about.phtml b/guess_output/about.phtml new file mode 100644 index 0000000..46840e8 --- /dev/null +++ b/guess_output/about.phtml @@ -0,0 +1 @@ +!changeto oef/about.phtml diff --git a/oef/programs/guess-output/function-blackjack.cpp b/guess_output/data/function-blackjack.cpp similarity index 85% rename from oef/programs/guess-output/function-blackjack.cpp rename to guess_output/data/function-blackjack.cpp index 052bd34..1d5e7ca 100644 --- a/oef/programs/guess-output/function-blackjack.cpp +++ b/guess_output/data/function-blackjack.cpp @@ -1,42 +1,42 @@ #include <iostream> -using namespace std; - -int max(int x, int y) { - if(x > y) { - return x; - } - return y; -} - -int blackJack(int x, int y) { - if(x > 21) { - if(y > 21) { - return 0; - } - return y; - } - if (y > 21) { - return x; - } - return max(x,y); -} - - -int main() { - int x,y; - - x = 15; - y = 22; - cout << max(x,y) << endl; - cout << blackJack(x,y) << endl; - - x = 12; - y = 17; - cout << max(x,y) << endl; - cout << blackJack(x,y) << endl; - - x = 23; - y = 25; - cout << max(x,y) << endl; - cout << blackJack(x,y) << endl; -} +using namespace std; + +int max(int x, int y) { + if (x > y) { + return x; + } + return y; +} + +int blackJack(int x, int y) { + if (x > 21) { + if (y > 21) { + return 0; + } + return y; + } + if (y > 21) { + return x; + } + return max(x,y); +} + + +int main() { + int x,y; + + x = 15; + y = 22; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; + + x = 12; + y = 17; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; + + x = 23; + y = 25; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; +} diff --git a/oef/programs/guess-output/function-factorial.cpp b/guess_output/data/function-factorial.cpp similarity index 100% rename from oef/programs/guess-output/function-factorial.cpp rename to guess_output/data/function-factorial.cpp diff --git a/oef/programs/guess-output/function-max.cpp b/guess_output/data/function-max.cpp similarity index 100% rename from oef/programs/guess-output/function-max.cpp rename to guess_output/data/function-max.cpp diff --git a/oef/programs/guess-output/if-semicolon.cpp b/guess_output/data/if-semicolon.cpp similarity index 100% rename from oef/programs/guess-output/if-semicolon.cpp rename to guess_output/data/if-semicolon.cpp diff --git a/oef/programs/guess-output/loop-indices-2.cpp b/guess_output/data/loop-indices-2.cpp similarity index 92% rename from oef/programs/guess-output/loop-indices-2.cpp rename to guess_output/data/loop-indices-2.cpp index b4a69a9..7274438 100644 --- a/oef/programs/guess-output/loop-indices-2.cpp +++ b/guess_output/data/loop-indices-2.cpp @@ -1,12 +1,11 @@ #include <iostream> -using namespace std; - -int main() { - int i = 1; - - while(i < 11) { - cout << i << endl; - i = i * 2; - } - -} +using namespace std; + +int main() { + int i = 1; + + while(i < 11) { + cout << i << endl; + i = i * 2; + } +} diff --git a/oef/programs/guess-output/loop-indices.cpp b/guess_output/data/loop-indices.cpp similarity index 92% rename from oef/programs/guess-output/loop-indices.cpp rename to guess_output/data/loop-indices.cpp index 71ace57..e97c36b 100644 --- a/oef/programs/guess-output/loop-indices.cpp +++ b/guess_output/data/loop-indices.cpp @@ -1,12 +1,11 @@ #include <iostream> -using namespace std; - -int main() { - int i = 0; - - while(i < 11) { - cout << i << endl; - i = i + 2; - } - -} +using namespace std; + +int main() { + int i = 0; + + while(i < 11) { + cout << i << endl; + i = i + 2; + } +} diff --git a/oef/programs/guess-output/loop-syracuse.cpp b/guess_output/data/loop-syracuse.cpp similarity index 77% rename from oef/programs/guess-output/loop-syracuse.cpp rename to guess_output/data/loop-syracuse.cpp index 0f6e433..a97861a 100644 --- a/oef/programs/guess-output/loop-syracuse.cpp +++ b/guess_output/data/loop-syracuse.cpp @@ -1,14 +1,14 @@ #include <iostream> -using namespace std; - -int main() { - int i = 6; - while(i!=1) { - cout << i << endl; - if(i%2==1) { - i = 3*i + 1; - } else { - i = i/2; - } - } -} +using namespace std; + +int main() { + int i = 6; + while ( i != 1 ) { + cout << i << endl; + if ( i%2 == 1 ) { + i = 3*i + 1; + } else { + i = i/2; + } + } +} diff --git a/oef/programs/guess-output/loops-do-while-factorial.cpp b/guess_output/data/loops-do-while-factorial.cpp similarity index 100% rename from oef/programs/guess-output/loops-do-while-factorial.cpp rename to guess_output/data/loops-do-while-factorial.cpp diff --git a/oef/programs/guess-output/loops-for-factorial.cpp b/guess_output/data/loops-for-factorial.cpp similarity index 100% rename from oef/programs/guess-output/loops-for-factorial.cpp rename to guess_output/data/loops-for-factorial.cpp diff --git a/oef/programs/guess-output/loops-while-factorial.cpp b/guess_output/data/loops-while-factorial.cpp similarity index 100% rename from oef/programs/guess-output/loops-while-factorial.cpp rename to guess_output/data/loops-while-factorial.cpp diff --git a/oef/programs/guess-output/variables-assign.cpp b/guess_output/data/variables-assign.cpp similarity index 100% rename from oef/programs/guess-output/variables-assign.cpp rename to guess_output/data/variables-assign.cpp diff --git a/oef/programs/guess-output/variables-factorial7.cpp b/guess_output/data/variables-factorial7.cpp similarity index 100% rename from oef/programs/guess-output/variables-factorial7.cpp rename to guess_output/data/variables-factorial7.cpp diff --git a/guess_output/endhook.phtml b/guess_output/endhook.phtml new file mode 100644 index 0000000..85ba4ac --- /dev/null +++ b/guess_output/endhook.phtml @@ -0,0 +1 @@ +!! This file can contain contents which go to the end of the page. \ No newline at end of file diff --git a/guess_output/help.phtml b/guess_output/help.phtml new file mode 100644 index 0000000..120eda2 --- /dev/null +++ b/guess_output/help.phtml @@ -0,0 +1 @@ +!changeto oef/help.phtml diff --git a/guess_output/intro.phtml b/guess_output/intro.phtml new file mode 100644 index 0000000..783c373 --- /dev/null +++ b/guess_output/intro.phtml @@ -0,0 +1,6 @@ +!header +!read Exindex +Ce module regroupe pour l'instant $exototal exercices sur ..... + +!read oef/intromenu.phtml +!tail diff --git a/guess_output/introhook.phtml b/guess_output/introhook.phtml new file mode 100644 index 0000000..15bdcef --- /dev/null +++ b/guess_output/introhook.phtml @@ -0,0 +1,9 @@ +!!!! This file can contain contents which go after the exercicse list in the intro. +!!Model for some configuration parameters. Uncomment if necessary + + +!!<tr><td> </td> +!!<td> +!! !formradio confparm1 from 1 to 3 +!!</td> +!!</tr> diff --git a/guess_output/main.phtml b/guess_output/main.phtml new file mode 100644 index 0000000..c837b26 --- /dev/null +++ b/guess_output/main.phtml @@ -0,0 +1 @@ +!changeto oef/Main.phtml diff --git a/guess_output/src/cpp/guess_output.oef b/guess_output/src/cpp/guess_output.oef new file mode 100644 index 0000000..16922fb --- /dev/null +++ b/guess_output/src/cpp/guess_output.oef @@ -0,0 +1,70 @@ +target= all variables if loop function + +#define TITLE Deviner l'affichage d'un programme C++ + +#if defined TARGET_variables +\title{TITLE (variables)} +#endif + +#if defined TARGET_if +\title{TITLE (conditionnelles)} +#endif + +#if defined TARGET_loop +\title{TITLE (boucles)} +#endif + +#if defined TARGET_function +\title{TITLE (fonctions)} +#endif + +\description{Deviner l'affichage d'un programme C++} +\language{fr} +\niveau{U1} +\author{Nicolas M. Thiéry} +\email{Nicolas.Thiery@u-psud.fr} +\format{html} + +\text{programs=randomitem(wims(lookup TARGET of data/index))} +\text{program=randomitem(\programs)} +\text{code=wims(record 0 of data/\program)} +\text{output=wims(record 0 of data/\program.output)} + +\css{ +<script type="text/javascript" src="scripts/js/edit_area/edit_area_full.js"></script> +<script type="text/javascript"> + editAreaLoader.init({ + id: "wims_show" + ,start_highlight: true + ,allow_toggle: false + ,language: "fr" + ,syntax: "cpp" + ,min_height: 300 + ,min_width: 300 + ,is_editable:false + ,toolbar: "" + ,show_line_colors: true + }); + </script> +} + + +\statement{ +<p>Quel affichage exact produit le programme C++ suivant?</p> + +\programs<br> +\program<br> +\output<br> + +<p>Si l'affichage comporte plusieurs lignes, les donner les unes à la +suite des autres, séparées par des espaces.</p> + +\special{tabs2lines +<textarea id="wims_show" cols="100" rows="15" name="wims_show" readonly="readonly"> +\code +</textarea> +} + +} + +\answer{}{\output}{type=text} diff --git a/guess_output/var.proc b/guess_output/var.proc new file mode 100644 index 0000000..4890cdf --- /dev/null +++ b/guess_output/var.proc @@ -0,0 +1,36 @@ + +# Change to 0 if you don't want the choice `I don't know' +idontknow=1 + +# Change to 1 of you want all choices to be present +allchoices=0 + +# Computational precisions: you can change the defaults here. +# pari_precision=18 +# maxima_precision=8 +# print_precision=8 + +# Change to no if you don't want classes to import exercises in this module. +# A typical situation is that these exercises use common resources of the module. +class_importation=yes + +# Change to yes if you want to put images in common (images/) to all exercises. +# If you do so, you must disable class_importation. +# if you want to use a data module in modules/data/xx/yy write the address as +# datamodule/xx/yy : for example, common_images=datamodule/language/toto/images +common_images=no + +# Uncomment the following if your module depends on datamodules and if you want +# to let the execution to go on even if some datamodule is missing. +# allow_missing_data=yes + +# for experts : you can add your special commands in a file my_var.proc to create +# !read my_var.proc + +!! to create a multi-language version, uncomment the following lines and see how +!! to proceed in the README + +!!module_language=$lang +!!oefenv_lang=$lang + +!changeto oef/var.proc diff --git a/oef/Makefile b/oef/Makefile deleted file mode 100644 index 5ccb5b8..0000000 --- a/oef/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -main.oef: header.oef programs/guess-output/*.cpp footer.oef Makefile - cd programs/guess-output; make all.oef - cat header.oef programs/guess-output/all.oef footer.oef > main.oef diff --git a/oef/TODO b/oef/TODO deleted file mode 100644 index 3663d8d..0000000 --- a/oef/TODO +++ /dev/null @@ -1,6 +0,0 @@ -Randomization -Implement all the logic in WIMS -Onsite compilation and production of the output -Support for various programming languages, based on file extension -Selection of theme based on file prefix -CSS style sheet for colored syntax highlighting diff --git a/oef/footer.oef b/oef/footer.oef deleted file mode 100644 index a29f666..0000000 --- a/oef/footer.oef +++ /dev/null @@ -1,11 +0,0 @@ -\statement{ -<p> - -Quel affichage produit le programme C++ suivant? On donnera le -résultat sur une seule ligne, les éléments étant séparés par des -espaces. - -\special{expandlines \code} -} - -\answer{}{\output}{type=text} diff --git a/oef/header.oef b/oef/header.oef deleted file mode 100644 index 8c79f1b..0000000 --- a/oef/header.oef +++ /dev/null @@ -1,7 +0,0 @@ -\title{Deviner l'affichage d'un programme C++} -\description{Deviner l'affichage d'un programme C++} -\language{fr} -\niveau{U1} -\author{Nicolas M. Thiéry} -\email{Nicolas.Thiery@u-psud.fr} -\format{html} diff --git a/oef/programs/guess-output/Makefile b/oef/programs/guess-output/Makefile deleted file mode 100644 index 9a9105e..0000000 --- a/oef/programs/guess-output/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -PROGRAMS=$(wildcard *.cpp) -HTML=$(PROGRAMS:%.cpp=%.html) -OUTPUT=$(PROGRAMS:%.cpp=%.output) -BASENAMES=$(PROGRAMS:%.cpp=%) - -all: $(OUTPUT) $(HTML) filelist - -%.output: %.bin - ./$< > $@ - -%.bin: %.cpp - g++ $< -o $@ - -%.html: %.cpp - pygmentize -o $@ -O style=colorful $< # ,linenos=1 - -clean: - rm *.bin *.output *.html all.oef - -all.oef: Makefile $(OUTPUT) $(HTML) - echo "\\\\text{programName=random("`ls -m *.cpp`")}" > $@ - for basename in $(BASENAMES); do \ - echo "\\\\text{code=\\programName issametext $$basename.cpp ?"; \ - cat $$basename.html; \ - echo "}"; \ - echo "\\\\text{output=\\programName issametext $$basename.cpp ?"; \ - cat $$basename.output; \ - echo "}"; \ - done >> $@ -- GitLab