From f961e31eb4471c6ce6b0e3acbec2273c4d7c6a38 Mon Sep 17 00:00:00 2001 From: moisedk Date: Thu, 16 Jan 2025 23:29:44 -0500 Subject: [PATCH 01/11] Added feedback to question to fix #236 --- pretext/Turtles/turtle_and_turtlescreen.ptx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pretext/Turtles/turtle_and_turtlescreen.ptx b/pretext/Turtles/turtle_and_turtlescreen.ptx index 6e5826d..0aa0ef0 100644 --- a/pretext/Turtles/turtle_and_turtlescreen.ptx +++ b/pretext/Turtles/turtle_and_turtlescreen.ptx @@ -319,11 +319,13 @@ int main() {

Match the turtle method descriptions to the methods they belong to.

+

Feedback shows incorrect matches.

turn to the left.turtle.leftchange the speedturtle.speedturn to the right.turtle.rightpick pen up.turtle.penupput pen down.turtle.pendown

Match the turtle method descriptions to the methods they belong to.

+

Feedback shows incorrect matches.

what color to fill drawing with.turtle.fillcolorstart filling the shape.turtle.beginfillstops filling the shape.turtle.endfillchange the pen color.turtle.pencolorchange the pen size.turtle.width From 5ddbcff2d6ad000b311d10373244808181bb326c Mon Sep 17 00:00:00 2001 From: moisedk Date: Thu, 16 Jan 2025 23:38:20 -0500 Subject: [PATCH 02/11] Added feedback to question to fix #237 --- pretext/Turtles/summary.ptx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pretext/Turtles/summary.ptx b/pretext/Turtles/summary.ptx index c42c23a..a9e2e58 100644 --- a/pretext/Turtles/summary.ptx +++ b/pretext/Turtles/summary.ptx @@ -26,14 +26,16 @@ -

+

Match every turtle function name with the description of what it does.

+

Feedback shows incorrect matches.

what color to fill drawing with.turtle.fillcolorwrite some text to the canvas.turtle.writestart filling the shape.turtle.beginfillstops filling the shape.turtle.endfillchange the paintbrush color.turtle.pencolor
-

+

Match every turtle function name with the description of what it does.

+

Feedback shows incorrect matches.

change the speedturtle.speedmove backward.turtle.backmove forward.turtle.forwardmove to a specific coordinate.turtle.goto change the paintbrush size.turtle.width From 63984b6d7d52542c2a88230f0e0072c15cdfc76c Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 01:03:00 -0500 Subject: [PATCH 03/11] Fix multiple line maching issue --- pretext/Exception_Handling/Summary.ptx | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pretext/Exception_Handling/Summary.ptx b/pretext/Exception_Handling/Summary.ptx index e586b76..808ea2a 100644 --- a/pretext/Exception_Handling/Summary.ptx +++ b/pretext/Exception_Handling/Summary.ptx @@ -22,14 +22,14 @@

Click on the syntax error.

Remember, syntax errors occur more for people learning a new language.

-int age;: -cout << "age:";: -cin >> age;: -if (age > 18) {: +int age; +cout << "age"; +cin >> age; +if (age > 18) { -cout << "You can vote in all countries with an 18 year old age for voting!";}: -else {: -cout << You cannot vote in all countries with an 18 year old age for voting.;: +cout << "You can vote in all countries with an 18 year old age for voting!";} +else { +cout << You cannot vote in all countries with an 18 year old age for voting.; }
@@ -37,14 +37,14 @@

Click on the logic error.

If we want the code to say when we are old enough to vote, what cases should it say when can and cannot?

-int age;: -cout << "age:";: -cin >> age;: -if (age > 18) {: +int age; +cout << "age"; +cin >> age; +if (age > 18) { -cout << "You can vote in all countries with an 18 year old age for voting!";}: -else {: -cout << You cannot vote in all countries with an 18 year old age for voting.;: +cout << "You can vote in all countries with an 18 year old age for voting!";} +else { +cout << "You cannot vote in all countries with an 18 year old age for voting."; }
From 353e1838340d4a63025ca85cbfa2d32df342c6aa Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 01:26:02 -0500 Subject: [PATCH 04/11] Fixed overlooked logic error --- pretext/Exception_Handling/Summary.ptx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/Exception_Handling/Summary.ptx b/pretext/Exception_Handling/Summary.ptx index 808ea2a..beedac9 100644 --- a/pretext/Exception_Handling/Summary.ptx +++ b/pretext/Exception_Handling/Summary.ptx @@ -40,7 +40,7 @@ int age; cout << "age"; cin >> age; -if (age > 18) { +if (age < 18) { cout << "You can vote in all countries with an 18 year old age for voting!";} else { From 4845aca86b3cb5e0eaa5300a4b447d1d64c80036 Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 01:39:15 -0500 Subject: [PATCH 05/11] Pulled code out of Replit to make it a simple codeblock --- .../DealingWithIOFailures.ptx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/pretext/Input_and_Output/DealingWithIOFailures.ptx b/pretext/Input_and_Output/DealingWithIOFailures.ptx index 028147e..d0f1c1a 100644 --- a/pretext/Input_and_Output/DealingWithIOFailures.ptx +++ b/pretext/Input_and_Output/DealingWithIOFailures.ptx @@ -15,9 +15,29 @@ occured, in_stream may be in a corrupted state and it is best not to attempt any more operations with it.

The following example code fragment safely quits the program entirely in case an I/O operation fails:

- <div> - <iframe height="400px" width="100%" src="https://repl.it/@CodyWMitchell/File-Handling-1?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> -</div> +
+ + + #include <cstdlib< // for the fail member function + #include <fstream< // for file I/O definitions + #include <iostream< // for cout definition + using namespace std; + + int main() { + ifstream in_stream; + // Try changing this to realFile.txt + in_stream.open("realFile.txt"); + if (in_stream.fail()) { + cout << "Sorry, the file couldn't be opened!\n"; + exit(1); // This exit value indicates an error happened (usual exit + // value is 0) + } + + return 0; + } + + +

After opening the myFile.txt file, the if conditional checks to see if there was an error. If so, the program will output the apologetic error message and then exit. The exit(1) function from the library cstdlib enables the program to terminate at that point and have it return a 1 versus a 0, indicating an Error has occurred.

For more on Error Handling, see section 1.11.

From dd6a825264ea3af7271ec18a8f9d8091fc8c6327 Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 02:07:49 -0500 Subject: [PATCH 06/11] Removed non working replit reference and reformatted code block for syntax highlighting --- pretext/Input_and_Output/TheEOF.ptx | 121 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/pretext/Input_and_Output/TheEOF.ptx b/pretext/Input_and_Output/TheEOF.ptx index 0b89c5d..666f232 100644 --- a/pretext/Input_and_Output/TheEOF.ptx +++ b/pretext/Input_and_Output/TheEOF.ptx @@ -26,67 +26,72 @@

Here is an example of a program that essentially uses the second technique mentioned above to read all the numbers in a file and output them in a neater format. The while loop to scan through a file is located in the make_neat(...) function.

-
// Illustrates output formatting instructions.
-// Read all the numbers in the file rawdata.dat and write the numbers
-// to the screen and to the file neat.dat in a neatly formatted way.
+
+ + + // Illustrates output formatting instructions. + // Read all the numbers in the file rawdata.dat and write the numbers + // to the screen and to the file neat.dat in a neatly formatted way. -#include <cstdlib> // for the exit function -#include <fstream> // for I/O member functions -#include <iomanip> // for the setw function -#include <iostream> // for cout -using namespace std; -void make_neat( - ifstream &messy_file, - ofstream &neat_file, - int number_after_decimalpoint, - int field_width); + #include <cstdlib> // for the exit function + #include <fstream> // for I/O member functions + #include <iomanip> // for the setw function + #include <iostream> // for cout + using namespace std; + void make_neat( + ifstream &messy_file, + ofstream &neat_file, + int number_after_decimalpoint, + int field_width); -int main() { - ifstream fin; - ofstream fout; + int main() { + ifstream fin; + ofstream fout; - fin.open("rawdata.txt"); - if (fin.fail()) { // oops the file did not exist for reading? - cout << "Input file opening failed." << endl; - exit(1); - } + fin.open("rawdata.txt"); + if (fin.fail()) { // oops the file did not exist for reading? + cout << "Input file opening failed." << endl; + exit(1); + } - fout.open("neat.txt"); - if (fout.fail()) { // oops the output file open failed! - cout << "Output file opening failed.\n"; - exit(1); - } - make_neat(fin, fout, 5, 12); + fout.open("neat.txt"); + if (fout.fail()) { // oops the output file open failed! + cout << "Output file opening failed.\n"; + exit(1); + } + make_neat(fin, fout, 5, 12); - fin.close(); - fout.close(); - cout << "End of program." << endl; - return 0; -} -// Uses iostreams, streams to the screen, and iomanip: -void make_neat( - ifstream &messy_file, - ofstream &neat_file, - int number_after_decimalpoint, - int field_width) { - // set the format for the neater output file. - neat_file.setf(ios::fixed); - neat_file.setf(ios::showpoint); - neat_file.setf(ios::showpos); - neat_file.precision(number_after_decimalpoint); - // set the format for the output to the screen too. - cout.setf(ios::fixed); - cout.setf(ios::showpoint); - cout.setf(ios::showpos); - cout.precision(number_after_decimalpoint); - double next; - while (messy_file >> next) { // while there is still stuff to read - cout << setw(field_width) << next << endl; - neat_file << setw(field_width) << next << endl; - } -} - -// Code by Jan Pearce
+ fin.close(); + fout.close(); + cout << "End of program." << endl; + return 0; + } + // Uses iostreams, streams to the screen, and iomanip: + void make_neat( + ifstream &messy_file, + ofstream &neat_file, + int number_after_decimalpoint, + int field_width) { + // set the format for the neater output file. + neat_file.setf(ios::fixed); + neat_file.setf(ios::showpoint); + neat_file.setf(ios::showpos); + neat_file.precision(number_after_decimalpoint); + // set the format for the output to the screen too. + cout.setf(ios::fixed); + cout.setf(ios::showpoint); + cout.setf(ios::showpos); + cout.precision(number_after_decimalpoint); + double next; + while (messy_file >> next) { // while there is still stuff to read + cout << setw(field_width) << next << endl; + neat_file << setw(field_width) << next << endl; + } + } + // Code by Jan Pearce + + +

This is the rawdata.txt inputed into the make_neat(...).

10 -20 30 -40
 500 300 -100 1000
@@ -109,9 +114,7 @@ void make_neat(
   -20.00000
   +30.00000
   -40.00000
- <div> - <iframe height="400px" width="100%" src="https://repl.it/@CodyWMitchell/File-Handling-2?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> -</div> +

The input file rawdata.txt must be in the same directory (folder) as the program in order for it to open successfully. The program will create a file called neat.dat to output the results.

Reading Question From 3f60ccd44cd4cdc286a6d99d5fc40178dc39116a Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 02:13:49 -0500 Subject: [PATCH 07/11] Section 6.9: Removed non working replit reference and reformatted code block for syntax highlighting --- .../Input_and_Output/PuttingItAllTogether.ptx | 96 ++++++++++--------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/pretext/Input_and_Output/PuttingItAllTogether.ptx b/pretext/Input_and_Output/PuttingItAllTogether.ptx index ff68f0d..dcd83f9 100644 --- a/pretext/Input_and_Output/PuttingItAllTogether.ptx +++ b/pretext/Input_and_Output/PuttingItAllTogether.ptx @@ -1,64 +1,66 @@
Putting it all Together

The following program combines all of the elements above and asks the user for the input and output filenames. After testing for open failures, it will read three numbers from the input file and write the sum into the output file.

-
#include <cstdlib>  // for the exit function
-#include <fstream>  // for I/O member functions
-#include <iostream> // for cout
-using namespace std; // To avoid writing std:: before standard library components
+
+ + + #include <cstdlib> // for the exit function + #include <fstream> // for I/O member functions + #include <iostream> // for cout + using namespace std; // To avoid writing std:: before standard library components -int main() { - // Declare variables for file names and file streams - char in_file_name[16], // Arrays to store filenames (max 15 chars + null terminator) - out_file_name[16]; - ifstream in_stream; // Input file stream object - ofstream out_stream;// Output file stream object + int main() { + // Declare variables for file names and file streams + char in_file_name[16], // Arrays to store filenames (max 15 chars + null terminator) + out_file_name[16]; + ifstream in_stream; // Input file stream object + ofstream out_stream;// Output file stream object - // Prompt the user for input and output file names - cout << "This program will sum three numbers taken from an input\n" - << "file and write the sum to an output file." << endl; - cout << "Enter the input file name (maximum of 15 characters):\n"; - cin >> in_file_name; - cout << "\nEnter the output file name (maximum of 15 characters):\n"; - cin >> out_file_name; - cout << endl; + // Prompt the user for input and output file names + cout << "This program will sum three numbers taken from an input\n" + << "file and write the sum to an output file." << endl; + cout << "Enter the input file name (maximum of 15 characters):\n"; + cin >> in_file_name; + cout << "\nEnter the output file name (maximum of 15 characters):\n"; + cin >> out_file_name; + cout << endl; - // Condensed input and output file opening and checking. - in_stream.open(in_file_name); - out_stream.open(out_file_name); + // Condensed input and output file opening and checking. + in_stream.open(in_file_name); + out_stream.open(out_file_name); - if (in_stream.fail() || out_stream.fail()) { - cout << "Input or output file opening failed.\n"; - exit(1); // Terminate the program with an error code - } + if (in_stream.fail() || out_stream.fail()) { + cout << "Input or output file opening failed.\n"; + exit(1); // Terminate the program with an error code + } - // Declare variables to store numbers and their sum - double firstn, secondn, thirdn, sum = 0.0; + // Declare variables to store numbers and their sum + double firstn, secondn, thirdn, sum = 0.0; - // Read the first three numbers from the input file - cout << "Reading numbers from the file " << in_file_name << endl; - in_stream >> firstn >> secondn >> thirdn; - sum = firstn + secondn + thirdn; + // Read the first three numbers from the input file + cout << "Reading numbers from the file " << in_file_name << endl; + in_stream >> firstn >> secondn >> thirdn; + sum = firstn + secondn + thirdn; - // The following set of lines will write to the screen - cout << "The sum of the first 3 numbers from " << in_file_name << " is " - << sum << endl; + // The following set of lines will write to the screen + cout << "The sum of the first 3 numbers from " << in_file_name << " is " + << sum << endl; - cout << "Placing the sum into the file " << out_file_name << endl; + cout << "Placing the sum into the file " << out_file_name << endl; - // The following set of lines will write to the output file - out_stream << "The sum of the first 3 numbers from " << in_file_name - << " is " << sum << endl; + // The following set of lines will write to the output file + out_stream << "The sum of the first 3 numbers from " << in_file_name + << " is " << sum << endl; - // Close the file streams - in_stream.close(); - out_stream.close(); + // Close the file streams + in_stream.close(); + out_stream.close(); - cout << "End of Program." << endl; + cout << "End of Program." << endl; - return 0; -}
- <div> - <iframe height="400px" width="100%" src="https://repl.it/@CodyWMitchell/File-Handling-3?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> -</div> + return 0; + + +}
From f91956ac18d4140d41d547eb75f25ce93f9a98fd Mon Sep 17 00:00:00 2001 From: moisedk Date: Fri, 17 Jan 2025 02:19:53 -0500 Subject: [PATCH 08/11] Section 6.9: Removed non working replit reference and reformatted code block for syntax highlighting --- pretext/Input_and_Output/PuttingItAllTogether.ptx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/Input_and_Output/PuttingItAllTogether.ptx b/pretext/Input_and_Output/PuttingItAllTogether.ptx index dcd83f9..81a9b46 100644 --- a/pretext/Input_and_Output/PuttingItAllTogether.ptx +++ b/pretext/Input_and_Output/PuttingItAllTogether.ptx @@ -2,7 +2,7 @@ Putting it all Together

The following program combines all of the elements above and asks the user for the input and output filenames. After testing for open failures, it will read three numbers from the input file and write the sum into the output file.

- + #include <cstdlib> // for the exit function #include <fstream> // for I/O member functions From d47efaf77aa28ab1bd2a2b6f3af20b6ca3cdf8b8 Mon Sep 17 00:00:00 2001 From: coco3427 Date: Mon, 12 May 2025 11:29:52 -0400 Subject: [PATCH 09/11] fixed issue #194 --- pretext/Functions/FunctionOverloading.ptx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/Functions/FunctionOverloading.ptx b/pretext/Functions/FunctionOverloading.ptx index 4d4d835..5ef1825 100644 --- a/pretext/Functions/FunctionOverloading.ptx +++ b/pretext/Functions/FunctionOverloading.ptx @@ -74,7 +74,7 @@ main() -

Helps keep consintency in the way your functions are named across your program.

+

Helps keep consistency in the way your functions are named across your program.

Take a look at the other answers as well...

From 01857bd62e47233443d3cb59898984c8c68f4c7a Mon Sep 17 00:00:00 2001 From: coco3427 Date: Mon, 12 May 2025 14:21:01 -0400 Subject: [PATCH 10/11] fixed issue #246 --- pretext/CollectionData/summary.ptx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretext/CollectionData/summary.ptx b/pretext/CollectionData/summary.ptx index 53e12a1..951fe68 100644 --- a/pretext/CollectionData/summary.ptx +++ b/pretext/CollectionData/summary.ptx @@ -1,6 +1,6 @@
Summary and Reading Questions -

    +

    1. A statically allocated C++ array is an ordered collection of one or more C++ data values of identical type stored in contiguous memory. From 1a1df15ea4fa8450bd2dd0e20c7e0fd656b89516 Mon Sep 17 00:00:00 2001 From: Jan Pearce Date: Tue, 13 May 2025 12:12:38 -0400 Subject: [PATCH 11/11] update pretext version to v2 --- old-project.ptx | 64 ++++++++++++++ pretext/{cpp4python.ptx => main.ptx} | 0 project.ptx | 84 ++++++------------- .../publication.ptx | 0 .../runestone.ptx | 0 requirements.txt | 5 +- 6 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 old-project.ptx rename pretext/{cpp4python.ptx => main.ptx} (100%) rename pretext/publication-rs-for-all.xml => publication/publication.ptx (100%) rename pretext/publication-rs-academy.xml => publication/runestone.ptx (100%) diff --git a/old-project.ptx b/old-project.ptx new file mode 100644 index 0000000..d96d920 --- /dev/null +++ b/old-project.ptx @@ -0,0 +1,64 @@ + + + + + + html + pretext/cpp4python.ptx + pretext/publication-rs-for-all.xml + output/html + + + html + pretext/cpp4python.ptx + pretext/publication-rs-academy.xml + published/cpp4py-v2 + + + epub + pretext/cpp4python.ptx + pretext/publication-pub.xml + published/epub + + + latex + pretext/cpp4python.ptx + pretext/publication-rs-for-all.xml + output/latex + + + pdf + pretext/cpp4python.ptx + pretext/publication-rs-for-all.xml + output/pdf + + + html + source/cpp4python.ptx + publication/publication.ptx + output/subset + + + ch-first + + + + latex + pdflatex + xelatex + pdf2svg + asy + sage + convert + pdftops + pdf-crop-margins + pageres + node + file2brl + + diff --git a/pretext/cpp4python.ptx b/pretext/main.ptx similarity index 100% rename from pretext/cpp4python.ptx rename to pretext/main.ptx diff --git a/project.ptx b/project.ptx index d96d920..e4a1f7b 100644 --- a/project.ptx +++ b/project.ptx @@ -1,64 +1,32 @@ - + - - html - pretext/cpp4python.ptx - pretext/publication-rs-for-all.xml - output/html - - - html - pretext/cpp4python.ptx - pretext/publication-rs-academy.xml - published/cpp4py-v2 - - - epub - pretext/cpp4python.ptx - pretext/publication-pub.xml - published/epub - - - latex - pretext/cpp4python.ptx - pretext/publication-rs-for-all.xml - output/latex - - - pdf - pretext/cpp4python.ptx - pretext/publication-rs-for-all.xml - output/pdf - - - html - source/cpp4python.ptx - publication/publication.ptx - output/subset - - - ch-first - + + + + + + + + + - - latex - pdflatex - xelatex - pdf2svg - asy - sage - convert - pdftops - pdf-crop-margins - pageres - node - file2brl - - + \ No newline at end of file diff --git a/pretext/publication-rs-for-all.xml b/publication/publication.ptx similarity index 100% rename from pretext/publication-rs-for-all.xml rename to publication/publication.ptx diff --git a/pretext/publication-rs-academy.xml b/publication/runestone.ptx similarity index 100% rename from pretext/publication-rs-academy.xml rename to publication/runestone.ptx diff --git a/requirements.txt b/requirements.txt index c01ba91..834f79c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ -runestone>=7.0.0 +runestone>=3.2.11 SQLAlchemy>=1.0.8 -pretext>=1.6.0 \ No newline at end of file +jupyterlite-sphinx +pretext=2.18.0 \ No newline at end of file