{"id":917,"date":"2022-09-16T10:01:28","date_gmt":"2022-09-16T07:01:28","guid":{"rendered":"https:\/\/www.juustila.com\/antti\/?p=917"},"modified":"2022-09-17T11:07:33","modified_gmt":"2022-09-17T08:07:33","slug":"automation-of-boring-tasks","status":"publish","type":"post","link":"https:\/\/www.juustila.com\/antti\/2022\/09\/16\/automation-of-boring-tasks\/","title":{"rendered":"Automation of boring tasks"},"content":{"rendered":"\n<p>My ongoing 1st year introductory course on computers has <a href=\"https:\/\/moodle.org\">Moodle<\/a> exams containing different kinds of automatically graded questions like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"386\" src=\"https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10-1024x386.png\" alt=\"\" class=\"wp-image-918\" srcset=\"https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10-1024x386.png 1024w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10-300x113.png 300w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10-768x290.png 768w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10-1200x453.png 1200w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-9.18.10.png 1410w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption>An arithmetic task containing radix conversions.<\/figcaption><\/figure>\n\n\n\n<p>We need to use automatically graded exams since there is 250-300 students each year, too few teachers participating, so evaluating the exams manually would take forever and would be very boring task to do.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>Perhaps a necessary disclaimer<\/em>: Everyone knows these conversions and arithmetics are, in practice, done oftentimes using software tools (programmer&#8217;s calculators) or web sites, when you need to. The actual learning goal here is <em>not<\/em> to say to students that doing this manually is something you have to learn to do for this profession. The learning goal is to expose the way data and simple arithmetics is handled in a computer and play around with these things to get an understanding of how computers work. And in time, you learn to see, for example, when debugging, some things that might be important in the hex, octal or binary values in memory.<\/p><\/blockquote>\n\n\n\n<p>Having a large set of questions for a course topic is a good thing to have. Then each exam generated for a student has <em>different<\/em> set of questions, randomly chosen by Moodle. <\/p>\n\n\n\n<p>This poses another boring task problem. I would have to write tens or hundreds of these questions, choosing the values to convert or calculate, converting them to different radices, calculate the result and then use Moodle question editor to write the questions. And translate them to Finnish (or from Finnish to English), since I teach the course in two languages.<\/p>\n\n\n\n<p>Well, what do you need when you have simple, boring repetitive tasks to do&#8230;?<\/p>\n\n\n\n<p><strong>A computer.<\/strong><\/p>\n\n\n\n<p>Well, a computer alone is just a bunch of metal, sand and plastics, so in addition, <strong>software<\/strong> would be needed.<\/p>\n\n\n\n<p>Since I enjoy programming much more than writing Moodle exam questions, I implemented a <a href=\"https:\/\/github.com\/anttijuu\/conversion-qs\">command line tool<\/a> using <a href=\"https:\/\/www.swift.org\">Swift<\/a>. This tool generates random number conversion tasks (decimal to hex to binary) and arithmetic tasks (summing different values in different radices). Then these tasks are saved in a Moodle XML exam question format in a file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/ConversionQs output-fi.xml 20 fi --verbose<\/code><\/pre>\n\n\n\n<p>The command above generates 20 conversion and arithmetic tasks each, in Finnish, outputs them to <code>output-fi.xml<\/code> file and shows me the progress in terminal window (<code>--verbose<\/code> flag). Below is an excerpt from an English output file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;quiz&gt;\n    &lt;question type=\"shortanswer\"&gt;\n        &lt;name&gt;\n            &lt;text&gt;Convert between radixes&lt;\/text&gt;\n        &lt;\/name&gt;\n        &lt;questiontext format=\"html\"&gt;\n            &lt;text&gt;&amp;lt;p&amp;gt;Convert the value 66 to radix: hexadecimal.&amp;lt;\/p&amp;gt; \t&amp;lt;p&amp;gt;Consider the values to be signed bytes, with eight bits.&amp;lt;\/p&amp;gt;\n\t&amp;lt;p&amp;gt;Write in the answer the prefix for the radix (0x, 0b) asked, if it is not decimal.&amp;lt;\/p&amp;gt;\n\t&amp;lt;p&amp;gt;Otherwise, use only the digits of the requested numbering system, no spaces or other punctuations.&amp;lt;\/p&amp;gt;&lt;\/text&gt;\n        &lt;\/questiontext&gt;\n        &lt;defaultgrade&gt;2.0000000&lt;\/defaultgrade&gt;\n        &lt;penalty&gt;0.3333333&lt;\/penalty&gt;\n        &lt;answer fraction=\"100\" format=\"moodle_auto_format\"&gt;\n            &lt;text&gt;0x42&lt;\/text&gt;\n        &lt;\/answer&gt;\n    &lt;\/question&gt;\n ...<\/code><\/pre>\n\n\n\n<p>Then I just import the XML file to Moodle, placing the questions into appropriate question category. Choosing a number of random questions from this set to an exam is an easy thing to do. Whenever I need a fresh set of questions, I just run the command again.<\/p>\n\n\n\n<p>What a rise in productivity level of a teacher! Implementing this took around one working day. Now generating tens or even hundreds of exam questions happens in a fraction of a second, instead of hours and hours of mind consuming boredom!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"544\" src=\"https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-1024x544.png\" alt=\"\" class=\"wp-image-922\" srcset=\"https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-1024x544.png 1024w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-300x159.png 300w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-768x408.png 768w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-1536x816.png 1536w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-2048x1087.png 2048w, https:\/\/www.juustila.com\/antti\/wp-content\/uploads\/2022\/09\/Nayttokuva-2022-9-16-kello-10.10.37-1200x637.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption>Swift code exporting the generated questions to an XML file.<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>My ongoing 1st year introductory course on computers has Moodle exams containing different kinds of automatically graded questions like: We need to use automatically graded exams since there is 250-300 students each year, too few teachers participating, so evaluating the exams manually would take forever and would be very boring task to do. Perhaps a &hellip; <a href=\"https:\/\/www.juustila.com\/antti\/2022\/09\/16\/automation-of-boring-tasks\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Automation of boring tasks&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[2],"tags":[70,46,12],"class_list":["post-917","post","type-post","status-publish","format-standard","hentry","category-coding","tag-programming","tag-swift","tag-teaching"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/posts\/917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":5,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"predecessor-version":[{"id":925,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/posts\/917\/revisions\/925"}],"wp:attachment":[{"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.juustila.com\/antti\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}