diff --git a/U2~coding~oefprogramC.fr/src/etat_civil.oef b/U2~coding~oefprogramC.fr/src/etat_civil.oef index 31a8e2ffc85f5d2d90b4436c6ee28b0baf27016a..9ecc7e848d532da2184c6547f8a542d9d6d7e749 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 0000000000000000000000000000000000000000..9f495c42fa9204bb8e57b74410d2863beee658db --- /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 0000000000000000000000000000000000000000..c271f5421730cea5a6c168497f1bd29e7f7527ff --- /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 0000000000000000000000000000000000000000..0628ff02ec8b4ac4d8f695ebc01415a5a0a3a56e --- /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 0000000000000000000000000000000000000000..2c3ad741a30876a4371ca08224c32735455ff6ab --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/guess_output/about.phtml b/guess_output/about.phtml new file mode 100644 index 0000000000000000000000000000000000000000..46840e89d8ecc79fba18ef8e3afb7f8880357799 --- /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 052bd344f9f661a34433ab8353972ce7f348ecc8..1d5e7ca816d0a39e1c03b334949fa6aa735a533c 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 b4a69a9cbd1fd390f501a6b494bd0a6f13b0942f..72744388f7280d58a5d877e02e6b57c83f7d6894 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 71ace576611bcc50d5fea8c3aa795f3e369f5cb2..e97c36bbd4d2c1e6e7a2385e4400396c11ae8147 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 0f6e433ceae4c12154576ad54e4e05d298de0335..a97861a1a5b80c40b6b3fd0a5a856d8623212747 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 0000000000000000000000000000000000000000..85ba4ac317efc93816a18e63e15e2f8cf10474b2 --- /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 0000000000000000000000000000000000000000..120eda296be75643b671a7420d4185f3dacc4e36 --- /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 0000000000000000000000000000000000000000..783c373100e193318e230b3304a5ba1d19b8f5cb --- /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 0000000000000000000000000000000000000000..15bdcef330ed75b4b0067d7a6cb70920fe75f6ce --- /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 0000000000000000000000000000000000000000..c837b267d55ac699f32d49b2096212833ba6046d --- /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 0000000000000000000000000000000000000000..16922fb4d4f42a33be55d26ecd255ce62cc2e9b7 --- /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 0000000000000000000000000000000000000000..4890cdfed5838eb0e831a3159dabf771209ce1ed --- /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 5ccb5b8f9ed5fd39b50516eb293cd89a06c21fec..0000000000000000000000000000000000000000 --- 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 3663d8d9569ca04ac3969a05bdbb36df9c704b84..0000000000000000000000000000000000000000 --- 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 a29f666fd51acf1bed7848f1d778f007cc6e38c0..0000000000000000000000000000000000000000 --- 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 8c79f1b03af862b9446e99689eea11113a2f0c67..0000000000000000000000000000000000000000 --- 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 9a9105e0407a1014fe1ef42bc39532a77f91c80c..0000000000000000000000000000000000000000 --- 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 >> $@