ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Otared Kavian <otared@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Randomize order of blocks
Date: Wed, 6 Jan 2021 09:55:54 +0100	[thread overview]
Message-ID: <420F432C-D23F-4C23-9BCB-AE95FCD8750A@gmail.com> (raw)
In-Reply-To: <41222137-331F-4121-9142-F81FCF92A7CC@gmail.com>

Following up my previous message, here is an example:

%% begin shuffled list of exercises
\setuprandomize[2021]

\startluacode
	function shuffle(tableau)
		local maxsize, t, tt
		maxsize = #tableau
		tt = {}
		t = {}
		for i = 1, maxsize do
			t[i] = {}
			t[i]["columnOne"] = tableau[i]
			t[i]["columnTwo"] = math.random(1,100*maxsize)
		end
		table.sort(t, function(a,b) return a.columnTwo < b.columnTwo end)
		for i = 1, maxsize do
			tt[i] = t[i]["columnOne"]
		end
		return tt
	end
\stopluacode

% We define three arrays
% with the names, the functions and their derivatives
% One could also add a ListOfVariables...

\startluacode

	ListOfNames = {
		"f",
		"g",
		"h",
		"u",
		"v",
		"F",
		"G",
		"H",
	}
	
	ListOfFunctions = {
		"\\cos(x^2)",
		"x\\sin(x)",
		"\\tan(x)",
		"x^3 - 3x^2 + 1",
		"\\frac{1}{1 + x^2}",
		"\\sin(\\log(x))",
		}
		
	ListOfDerivatives = {
		"-2x\\sin(x^2)",
		"x\\cos(x) + \\sin(x)",
		"1 + \\tan(x)^2",
		"3x^2 - 6x",
		"\\frac{-2x}{(1 + x^2)^2}",
		"\\frac{\\cos(\\log(x))}{x}",
		}
		
\stopluacode

\starttext

% We define a buffer and a shuffled list of integers

\startbuffer[test-derivatives]
\startluacode
	ShuffledList = shuffle({1,2,3,4,5,6})
\stopluacode

Let $\cldcontext{ListOfNames[ShuffledList[\recurselevel]]}(x) := \cldcontext{ListOfFunctions[ShuffledList[\recurselevel]]}$. Prove that
\startformula
\cldcontext{ListOfNames[ShuffledList[\recurselevel]]}'(x) = \cldcontext{ListOfDerivatives[ShuffledList[\recurselevel]]}
\stopformula
\stopbuffer
	
\dorecurse{6}{\blank[medium]{\bf Exercise #1.}
	\getbuffer[test-derivatives]
	}

\stoptext

%% end shuffled list of exercises


> On 6 Jan 2021, at 09:41, Otared Kavian <otared@gmail.com> wrote:
> 
> Hi Jairo,
> 
> One can indeed make quizzes and exams with randomized order of problems, randomized values and even randomized names of functions and variables.
> I have some examples which I have been using for several years (they are useful especially in these days of giving exams online…): I can send them to you as they are, or if you tell me what kind of problems you want, then I can adapt my examples before sending them to you.
> 
> Best regards: Otared 
> 
>> On 5 Jan 2021, at 17:18, Jairo A. del Rio <jairoadelrio6@gmail.com> wrote:
>> 
>> Hi, list.
>> 
>> Some time ago I realized ConTeXt has "blocks" which allow one to make quizzes, exams and related with ease. However, I want to know if there's an option to randomize their order when printed. Thank you in advance.
>> 
>> Jairo
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to the Wiki!
>> 
>> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki     : http://contextgarden.net
>> ___________________________________________________________________________________
> 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-01-06  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 16:18 Jairo A. del Rio
2021-01-06  8:41 ` Otared Kavian
2021-01-06  8:55   ` Otared Kavian [this message]
2021-01-07  1:36     ` Jairo A. del Rio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=420F432C-D23F-4C23-9BCB-AE95FCD8750A@gmail.com \
    --to=otared@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).