-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation to describe the new method of @problemset macro
- Loading branch information
kagalenko-m-b
authored and
kagalenko-m-b
committed
Jan 7, 2025
1 parent
0c50110
commit 41ff910
Showing
6 changed files
with
126 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ProblemSet" | ||
uuid = "806f51fd-16a3-4f55-bd44-f0d72f9cf926" | ||
authors = ["kagalenko-m-b <[email protected]> and contributors"] | ||
version = "0.7.5" | ||
version = "0.7.6" | ||
|
||
[deps] | ||
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Random selection of problems from a set | ||
|
||
A simplest set may be created by giving to the `@problemset` macro a list of questions | ||
as a multiline string: | ||
```julia | ||
@problemset question_set """The first question. | ||
The second question. | ||
... | ||
The tenth question." | ||
``` | ||
This creates a workspace vector named `question_set` that contains ten functions | ||
`question_set_1()`, `question_set_2()`, … `question_set_10()`. Suppose you wish | ||
an individual assignment to contain one question from the first half of the vector | ||
and two questions from the second half. That may be accomplished as follows: | ||
```julia | ||
student_names = ["A", "B", "C", "D"]; | ||
rng_seed = 123; | ||
subsets = [1=>1:5, 2=>6:10] | ||
txt, = problemset_latex(student_names, question_set, subsets, rng_seed); | ||
write("questions.tex", latex_preamble()*txt); | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## Random variation of a problem's statement | ||
|
||
Problem template will typically include the statement's text with a few placeholder | ||
variables. Percentage signs before and after mark the | ||
placeholder variables within the template text. Function `problemset_latex()` | ||
then generates the latex source of the assignment and solutions for a vector of students' | ||
names. In the latex source assigned values replace the placeholder variables. | ||
Every placeholder variable must appear at least once as the left-hand of | ||
an assignment where the tilde replaces the equality sign. | ||
|
||
This is an example set: | ||
```julia | ||
@problemset my_set begin | ||
@problem pool begin | ||
pool_size_liters ~ rand(1000:10:2000) | ||
inflow_liters_sec ~ rand(10:20) | ||
outflow_max = inflow_liters_sec ÷ 2 | ||
outflow_liters_sec ~ rand(1:outflow_max) | ||
@solution begin | ||
fill_rate = inflow_liters_sec - outflow_liters_sec | ||
time_to_fill = pool_size_liters / fill_rate | ||
time_to_fill_min ~ round(time_to_fill / 60, digits=3) | ||
leaked_liters ~ round(time_to_fill*outflow_liters_sec, digits=3) | ||
end | ||
@text """ | ||
An empty pool can hold %pool_size_liters% liters of water. Pipe | ||
fills it at the rate %inflow_liters_sec%~liters/sec while another | ||
drains it at the rate %outflow_liters_sec%~liters/sec. How many minutes | ||
will it take to fill the pool and how many liters of water will | ||
drain out by the time the pool is full? | ||
""" | ||
@text_solution """ | ||
It will take %time_to_fill_min% minutes to fill the pool and | ||
%leaked_liters%~liters of water will drain out. | ||
""" | ||
end | ||
@problem addition begin | ||
x ~ rand(1:3) | ||
y ~ rand(2:5) | ||
@solution xy ~ x + y | ||
@text raw""" Find the sum \(c = a + b\) of two values: \(a = %x%\) and | ||
\(b = %y%\) | ||
""" | ||
@text_solution raw""" | ||
Sum is equal to \(c = %xy%\) | ||
""" | ||
end | ||
@problem subtraction begin | ||
z ~ rand(7:9) | ||
w ~ rand(1:5) | ||
@solution zw ~ z - w | ||
@text raw""" Find the difference \(c = a - b\) of two values: \(a = %z%\) and | ||
\(b = %w%\) | ||
""" | ||
@text_solution raw""" | ||
Difference is equal to \(c = %zw%\) | ||
""" | ||
end | ||
end | ||
``` | ||
|
||
Executing this macro creates a workspace vector named `my_set` | ||
that contains three functions `my_set_pool()`, `my_set_addition()` and | ||
`my_set_subtraction()`. Text-generating function makes use of their | ||
[methods](Generated_methods.md). This is how an assignment may be produced: | ||
```julia | ||
student_names = ["A", "B", "C", "D"]; | ||
rng_seed = 123; | ||
txt,txt_sol = problemset_latex(student_names, my_set, 2=>1:3, rng_seed); | ||
write("problems.tex", latex_preamble()*txt); | ||
write("solutions.tex", latex_preamble()*txt); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41ff910
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
Release notes:
Added method to the
@problemset
macro for easy generation of a static set (no placeholder variables within theproblems' statements)
41ff910
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/122541
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: