{"id":1747,"date":"2021-08-01T13:46:30","date_gmt":"2021-08-01T17:46:30","guid":{"rendered":"https:\/\/www.yorku.ca\/professor\/drsmith\/?p=1747"},"modified":"2023-06-14T15:29:15","modified_gmt":"2023-06-14T19:29:15","slug":"vpl-using-maple-for-math-assignments","status":"publish","type":"post","link":"https:\/\/www.yorku.ca\/professor\/drsmith\/2021\/08\/01\/vpl-using-maple-for-math-assignments\/","title":{"rendered":"VPL: Using Maple for Math Assignments"},"content":{"rendered":"\n<p>One of the places that Moodle falls down in is in supporting math assignments.  It occurred to me that we could treat math assignments like we do programming assignments by <em>extending<\/em> the <a href=\"https:\/\/www.yorku.ca\/professor\/drsmith\/2020\/07\/01\/virtual-programming-lab\/\">Virtual Programming Lab<\/a> plugin for Moodle to support Maple.  This doesn't replace existing products like the Maple \/ DigitalEd <a href=\"https:\/\/www.digitaled.com\/mobius-and-maple#\">M\u00f6bius<\/a> platform, nor does it replace a student's existing Maple application.  It just allows us to leverage standard Maple within VPL.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image.png\" alt=\"\" class=\"wp-image-1749\" width=\"587\" height=\"346\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image.png 783w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-300x177.png 300w\" sizes=\"auto, (max-width: 587px) 100vw, 587px\" \/><figcaption>Here, we're using Maple within VPL to examine the difference between a student's math equation and the model solution (in \"run\" mode via the rocket icon)<\/figcaption><\/figure><\/div>\n\n\n\n<p>The student is expected to submit a file with the math solution written in it, formatted as required for <a href=\"https:\/\/maplesoft.com\/\">Maple<\/a>.  That means using semicolons at the end of commands that are to be displayed and colons for those for which commands are to be hidden. Students don't need to have Maple on their own computers to make this work.  If they want to they can, however install it on their own computers, or use the full graphical version of Maple on YorkU's <a href=\"https:\/\/myapps.yorku.ca\/login\">AppAnywhere<\/a> system through their web browser.  Students in the EECS department can access Maple through the <a href=\"https:\/\/remotelab.eecs.yorku.ca\/#\/\">remote lab<\/a> system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Requirements<\/h2>\n\n\n\n<p>You need to have <strong>your own VPL server <\/strong>for this and you need to have Maple installed on it.  You need to <em>explicitly<\/em> point any VPL activity you create to your local VPL server. Maple is not installed on the VPL developer's server and so this example will not work in the general case.  In our case we're using a positively ancient version of Maple (version 9, from 2003) but it works on our Linux boxes, so it's all good.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example 1: Test the correctness of an equation.<\/h3>\n\n\n\n<p>In this example we're going to test to see if the student's math equation is the same as the teacher's math equation.  The equation is<\/p>\n\n\n\n<p class=\"has-text-align-center\">x = 2 + y<sup>4<\/sup><\/p>\n\n\n\n<p>Like with other VPL activities, we typically set up both \"run\" and \"evaluate\" sessions using the vpl_run.sh and vpl_evaluate.sh scripts.  We don't use the vpl_evaluate.cases file as we build the answers into both the run and evaluate scripts.  Note that both the student submission and the teacher solution are written in Maple script but it's the Maple equation output, in ASCII text mode, that is examined, as shown in the figure below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"388\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-1-1024x388.png\" alt=\"\" class=\"wp-image-1756\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-1-1024x388.png 1024w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-1-300x114.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-1.png 1327w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>VPL will display different outputs in evaluation mode based on whether the student's submission is correct or not.  The equations displayed are interpretations, by Maple, of what the student and teacher submitted.<\/figcaption><\/figure>\n\n\n\n<p>Here are the three files that are used in this example.  We provide a template file to the student and, in this case, the template is a model solution for the student.  We call it studentTemplate.mw, and there's only one line in it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x:=2+y^4; <\/code><\/pre>\n\n\n\n<p>The student does not need to make any changes to it.<\/p>\n\n\n\n<p>This is the vpl_run.sh file.  The parts that make processing Maple files different than, say, C or Java or Python, are highlighted below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#\n# vpl_run.sh script (Maple version)\n# The output of the student program is tested against the expected output file.\n# \n# James Andrew Smith; drsmith@yorku.ca July 2021\n# Based on example by D. Thiebaut at Smith College\n# http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n# and\n# https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\n# -----------------------------------------------------------------\n\n\ncat &gt; vpl_execution &lt;&lt;EEOOFF\n#!\/bin\/bash\n\n# Variables (make changes here)\nteacherMapleSolution=\"x:=2+y^4;\"\nstudentProgram=studentTemplate\nmaxGrade=100\nminGrade=0\nconsolationGrade=10\n\n\n\n# --- create test (Teacher Solution) ---\n# Take the teacher's Maple-coded solution and run it through Maple.\n# use format echo \"x:=1+1;\" | maple -q \n# source: https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\n<mark class=\"kt-highlight\">echo \"\\${teacherMapleSolution}\" | maple -q &amp;&gt; solution.txt<\/mark>\n\n# Default grade is zero.\ngrade=\\$minGrade\n\nfor i in 1 ; do\n   echo \"TEST \\$i\"\n\n   # ==============================================\n   # TEST i\n   # ==============================================\n   #--- run program, capture output, display to student ---\n\n\n#   echo \"Running Maple on the student solution...\"\n<mark class=\"kt-highlight\">   maple -q \\${studentProgram}.mw  &gt; user.out<\/mark>\n#   echo \"... Maple finished.\"\n   \n   # all processing of whitespace to remove it has been, itself removed.\n   # want to see how that's done?  Go to \n   # http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n   \n   #--- compute difference, with exact whitespace --- \n   diff -y -w user.out solution.txt &gt; diff.out\n   \n   # debug:\n   # echo \"----- diff.out ------\"\n   # cat diff.out\n   # echo \"---------------------\"\n\n   \n   #--- reject if different ---\n   if ((\\$? &gt; 0)); then\n      echo \"Your output is NOT correct.\"\n\n\n      echo \"---------------\"\n      echo \"Your output:\"\n      echo \"---------------\"\n      cat user.out\n      \n      echo \"\"\n      echo \"---------------\"\n      echo \"Expected output  \"\n      echo \"---------------\"\n      cat solution.txt\n\n      grade=\\$( expr \\$minGrade )\n   \n      #--- consolation grade (\"thanks for coming out\")---   \n      #grade=\\$( expr \\$consolationGrade )\n\n      # --------------------- REWARD IF CORRECT OUTPUT -----------------\n   else\n      #--- good output ---\n      echo \"Congrats, your output is correct.\"\n      echo \" --------------------------------\"\n      cat user.out\n      echo \"--------------------------------\"\n      grade=\\$( expr \\$maxGrade )\n   fi\ndone\n\necho \"Possible Grade : \\$grade (you need to evaluate for official grade)\"\n\nexit 0\nEEOOFF\n\n \nchmod +x vpl_execution\nexit 0<\/code><\/pre>\n\n\n\n<p>This is the vpl_evaluate.sh file.  It is similar to the vpl_run.sh file, with a few notable differences, mostly related to the way that text is displayed or results sent back to Moodle during evaluation. First, the grade and comments that are sent back to Moodle at the evaluation stage are formatted with :=&gt;&gt;. Second, <a href=\"https:\/\/moodle.org\/mod\/forum\/discuss.php?d=425241#p1712582\">a prefix of '&gt;' is added<\/a> to the student's submission and the teacher result.  This is accomplished with thee <em>sed<\/em> lines, found below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#\n# vpl_evaluate.sh script (Maple version)\n# The output of the student program is tested against the expected output file.\n# \n# James Andrew Smith; drsmith@yorku.ca July 2021\n#\n# Based on example by D. Thiebaut at Smith College\n# http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n# and\n# https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\n# -----------------------------------------------------------------\n\n\ncat &gt; vpl_execution &lt;&lt;EEOOFF\n#!\/bin\/bash\n\n# Variables (make changes here)\n# ----------------------------------------------\n# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n# ----------------------------------------------\n<strong><mark class=\"kt-highlight\">teacherMapleSolution=\"x:=2+y^4;\"<\/mark><\/strong>\nstudentProgram=studentTemplate\nmaxGrade=100\nminGrade=0\nconsolationGrade=10\n# ----------------------------------------------\n# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n# ----------------------------------------------\n\n# --- create test (Teacher Solution) ---\n# Take the teacher's Maple-coded solution and run it through Maple.\n# use format echo \"x:=1+1;\" | maple -q \n# source: https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\necho \"\\${teacherMapleSolution}\" | maple -q &amp;&gt; solution.txt\n\n\n# Default grade is zero.\ngrade=\\$minGrade\n\n\nfor i in 1 ; do\n   echo \"Comment :=&gt;&gt;-TEST \\$i\"\n\n   # ==============================================\n   # TEST i\n   # ==============================================\n   #--- run program, capture output, display to student ---\n\n   echo \"Running Maple on the student solution...\"\n   maple -q \\${studentProgram}.mw  &gt; user.out\n   echo \"... Maple finished.\"\n   \n<mark class=\"kt-highlight\">    # add a '&gt;' prefix to student and teacher files\n    # sed -i -e 's\/^\/&gt;\/' myfile.txt \n    cp user.out modifiedUser.out\n    cp solution.txt modifiedSolution.txt\n    sed -i -e 's\/^\/&gt;\/' modifiedUser.out\n    sed -i -e 's\/^\/&gt;\/' modifiedSolution.txt\n    echo \"&gt; Modified Student and Teacher variations:\"\n    cat modifiedUser.out\n    cat modifiedSolution.txt<\/mark>\n\n   \n   # all processing of whitespace to remove it has been, itself removed.\n   # want to see how that's done?  Go to \n   # http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n   \n   #--- compute difference, with exact whitespace --- \n   diff -y -w user.out solution.txt &gt; diff.out\n   \n   #--- compute difference --- \n   diff -y -w --ignore-all-space user.out solution.txt &gt; diff.out\n   #echo \"----- diff.out ------\"\n   #cat diff.out\n   #echo \"---------------------\"\n   diff -y -w --ignore-all-space user.out solution.txt &gt; diff.out\n\n   \n   #--- reject if different ---\n   if ((\\$? &gt; 0)); then\n      echo \"Comment :=&gt;&gt;- Your output is incorrect.\"\n\n\n      echo \"<mark class=\"kt-highlight\">Comment :=&gt;&gt;<\/mark> ---------------\"\n      echo \"Comment :=&gt;&gt;- Your output:\"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"&lt;|--\"\n      cat modifiedUser.out\n      echo \"--|&gt;\"\n      echo \"\"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"Comment :=&gt;&gt;- Expected output: \"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"&lt;|--\"\n      cat modifiedSolution.txt\n      echo \"--|&gt;\"\n   \n      grade=\\$( expr \\$minGrade )\n   \n      #--- consolation grade (\"thanks for coming out\")---   \n      #grade=\\$( expr \\$consolationGrade )\n\n      # --------------------- REWARD IF CORRECT OUTPUT -----------------\n   else\n      #--- good output ---\n      echo \"Comment :=&gt;&gt;- Congrats, your output is correct.\"\n      echo \"Comment :=&gt;&gt; --------------------------------.\"\n      echo \"&lt;|--\"\n      cat modifiedUser.out\n      echo \"--|&gt;\"\n      grade=\\$( expr \\$maxGrade )\n   fi\ndone\n      \n\n<mark class=\"kt-highlight\">echo \"Grade :=&gt;&gt; \\$grade\"<\/mark>\nexit 0\nEEOOFF\n\n \nchmod +x vpl_execution\nexit 0<\/code><\/pre>\n\n\n\n<p>The teacher solution, t<code>eacherMapleSolution=\"x:=2+y^4;\"<\/code>, is highlighted in the code above.  You can also modify the maximum grade and file name for the student submission in there.<\/p>\n\n\n\n<p>The vpl_evaluate.cases file is blank because the model solutions are integrated in vpl_run.sh and vpl_evaluate.sh.<\/p>\n\n\n\n<p>Example 2: Graphs in Maple<\/p>\n\n\n\n<p>Graphical assignments are hard to do in VPL.  In that respect, Maple's M\u00f6bius and Matlab Grader have a distinct advantage.  That said, we can use Maple's admittedly old-fashioned ASCII-drawing approach to graphs to get something reasonable with little effort:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"362\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-2-1024x362.png\" alt=\"\" class=\"wp-image-1758\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-2-1024x362.png 1024w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-2-300x106.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-2.png 1357w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The run and evaluate output for the correct graphing solution in VPL with Maple.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"398\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-3-1024x398.png\" alt=\"\" class=\"wp-image-1759\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-3-1024x398.png 1024w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-3-300x116.png 300w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/08\/image-3.png 1365w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The incorrect solution for the Maple graphs, shown for both run and evaluate modes of VPL.<\/figcaption><\/figure>\n\n\n\n<p>Here is the student model solution, <strong>studentTemplate.mw,<\/strong> provided to the student in the requested files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plot( sin(x), x = 0..2*Pi);<\/code><\/pre>\n\n\n\n<p>Here is the <strong>vpl_run.sh<\/strong> file for this example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#\n# vpl_run.sh script (Maple version)\n# The output of the student program is tested against the expected output file.\n# \n# James Andrew Smith; drsmith@yorku.ca July 2021\n# Based on example by D. Thiebaut at Smith College\n# http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n# and\n# https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\n# -----------------------------------------------------------------\n\n\ncat &gt; vpl_execution &lt;&lt;EEOOFF\n#!\/bin\/bash\n\n# Variables (make changes here)\n<mark class=\"kt-highlight\">teacherMapleSolution=\"plot( sin(x), x = 0..2*Pi);\"<\/mark>\nstudentProgram=studentTemplate\nmaxGrade=100\nminGrade=0\nconsolationGrade=10\n\n\n\n# --- create test (Teacher Solution) ---\n# Take the teacher's Maple-coded solution and run it through Maple.\n# use format echo \"x:=1+1;\" | maple -q \n# source: https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\necho \"\\${teacherMapleSolution}\" | maple -q &amp;&gt; solution.txt\n\n# Default grade is zero.\ngrade=\\$minGrade\n\nfor i in 1 ; do\n   echo \"TEST \\$i\"\n\n   # ==============================================\n   # TEST i\n   # ==============================================\n   #--- run program, capture output, display to student ---\n\n#   .\/\\${studentProgram}  &amp;&gt; user.out\n#   echo \"Running Maple on the student solution...\"\n   maple -q \\${studentProgram}.mw  &gt; user.out\n#   echo \"... Maple finished.\"\n   \n   # all processing of whitespace to remove it has been, itself removed.\n   # want to see how that's done?  Go to \n   # http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n   \n   #--- compute difference, with exact whitespace --- \n   diff -y -w user.out solution.txt &gt; diff.out\n   \n   # debug:\n   # echo \"----- diff.out ------\"\n   # cat diff.out\n   # echo \"---------------------\"\n\n   \n   #--- reject if different ---\n   if ((\\$? &gt; 0)); then\n      echo \"Your output is NOT correct.\"\n\n\n      echo \"---------------\"\n      echo \"Your output:\"\n      echo \"---------------\"\n      cat user.out\n      \n      echo \"\"\n      echo \"---------------\"\n      echo \"Expected output  \"\n      echo \"---------------\"\n      cat solution.txt\n\n      grade=\\$( expr \\$minGrade )\n   \n      #--- consolation grade (\"thanks for coming out\")---   \n      #grade=\\$( expr \\$consolationGrade )\n\n      # --------------------- REWARD IF CORRECT OUTPUT -----------------\n   else\n      #--- good output ---\n      echo \"Congrats, your output is correct.\"\n      echo \" --------------------------------\"\n      cat user.out\n      echo \"--------------------------------\"\n      grade=\\$( expr \\$maxGrade )\n   fi\ndone\n\necho \"Possible Grade : \\$grade (you need to evaluate for official grade)\"\n\nexit 0\nEEOOFF\n\n \nchmod +x vpl_execution\nexit 0<\/code><\/pre>\n\n\n\n<p>Hhere is the <strong>vpl_evaluate.sh<\/strong> file for this example<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#\n# vpl_evaluate.sh script (Maple version)\n# The output of the student program is tested against the expected output file.\n# \n# James Andrew Smith; drsmith@yorku.ca July 2021\n#\n# Based on example by D. Thiebaut at Smith College\n# http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n# and\n# https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\n# -----------------------------------------------------------------\n\n\ncat &gt; vpl_execution &lt;&lt;EEOOFF\n#!\/bin\/bash\n\n# Variables (make changes here)\n# ----------------------------------------------\n# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n# ----------------------------------------------\n<mark class=\"kt-highlight\">teacherMapleSolution=\"plot( sin(x), x = 0..2*Pi);\"<\/mark>\nstudentProgram=studentTemplate\nmaxGrade=100\nminGrade=0\nconsolationGrade=10\n# ----------------------------------------------\n# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n# ----------------------------------------------\n\n# --- create test (Teacher Solution) ---\n# Take the teacher's Maple-coded solution and run it through Maple.\n# use format echo \"x:=1+1;\" | maple -q \n# source: https:\/\/www.mapleprimes.com\/posts\/38232-Scripting-With-Maple\necho \"\\${teacherMapleSolution}\" | maple -q &amp;&gt; solution.txt\n\n\n# Default grade is zero.\ngrade=\\$minGrade\n\n\nfor i in 1 ; do\n   echo \"Comment :=&gt;&gt;-TEST \\$i\"\n\n   # ==============================================\n   # TEST i\n   # ==============================================\n   #--- run program, capture output, display to student ---\n\n   echo \"Running Maple on the student solution...\"\n   maple -q \\${studentProgram}.mw  &gt; user.out\n   echo \"... Maple finished.\"\n   \n    # add a '&gt;' prefix to student and teacher files\n    # sed -i -e 's\/^\/&gt;\/' myfile.txt \n    cp user.out modifiedUser.out\n    cp solution.txt modifiedSolution.txt\n    sed -i -e 's\/^\/&gt;\/' modifiedUser.out\n    sed -i -e 's\/^\/&gt;\/' modifiedSolution.txt\n    echo \"&gt; Modified Student and Teacher variations:\"\n    cat modifiedUser.out\n    cat modifiedSolution.txt\n\n   \n   # all processing of whitespace to remove it has been, itself removed.\n   # want to see how that's done?  Go to \n   # http:\/\/www.science.smith.edu\/dftwiki\/index.php\/Tutorial:_Moodle_VPL_--_Testing_a_C_Program\n   \n   #--- compute difference, with exact whitespace --- \n   diff -y -w user.out solution.txt &gt; diff.out\n   \n   #--- compute difference --- \n   diff -y -w --ignore-all-space user.out solution.txt &gt; diff.out\n   #echo \"----- diff.out ------\"\n   #cat diff.out\n   #echo \"---------------------\"\n   diff -y -w --ignore-all-space user.out solution.txt &gt; diff.out\n\n   \n   #--- reject if different ---\n   if ((\\$? &gt; 0)); then\n      echo \"Comment :=&gt;&gt;- Your output is incorrect.\"\n\n\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"Comment :=&gt;&gt;- Your output:\"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"&lt;|--\"\n      cat modifiedUser.out\n      echo \"--|&gt;\"\n      echo \"\"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"Comment :=&gt;&gt;- Expected output: \"\n      echo \"Comment :=&gt;&gt; ---------------\"\n      echo \"&lt;|--\"\n      cat modifiedSolution.txt\n      echo \"--|&gt;\"\n   \n      grade=\\$( expr \\$minGrade )\n   \n      #--- consolation grade (\"thanks for coming out\")---   \n      #grade=\\$( expr \\$consolationGrade )\n\n      # --------------------- REWARD IF CORRECT OUTPUT -----------------\n   else\n      #--- good output ---\n      echo \"Comment :=&gt;&gt;- Congrats, your output is correct.\"\n      echo \"Comment :=&gt;&gt; --------------------------------.\"\n      echo \"&lt;|--\"\n      cat modifiedUser.out\n      echo \"--|&gt;\"\n      grade=\\$( expr \\$maxGrade )\n   fi\ndone\n\n# echo \"&lt;|--\"\n# echo \"&gt;                      1234\"\n# echo \"--|&gt;\"\n      \n      \n\necho \"Grade :=&gt;&gt; \\$grade\"\nexit 0\nEEOOFF\n\n \nchmod +x vpl_execution\nexit 0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Printing in Evaluation Mode: Some \"gotchas\"<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">Make visible by using \"&lt;|--\" and \"--|&gt;\"<\/h4>\n\n\n\n<p>it's important to note that if you don't begin and end print statements a particular way, they won't show up when it's time to evaluate, even if they show up during a run.  You need to start with<code> &lt;|--<\/code> and end with <code>--|&gt;<\/code>  For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"&lt;|--\"\necho \"1234\"\necho \"--|&gt;\"<\/code><\/pre>\n\n\n\n<p>will print <code>1234<\/code> to the screen <em>during evaluations<\/em>, whereas you simply would have used <code>echo \"1234\"<\/code> in <em>run<\/em> mode.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Maintain white-space formatting by using  \"&gt;\" at the beginning of a line<\/h4>\n\n\n\n<p>In certain types of assignments, it's important to show student submissions and teacher solutions with white-space.  This is the case with the equations that are displayed in ASCII text in Maple.  They will display fine in run mode, but won't in evaluation mode.  In order to display Maple equations correctly in evaluation mode, it's important to add a <code>&gt;<\/code> prefix to each line of the Maple interpretation of both the student's solution or in the teacher's answer.<\/p>\n\n\n\n<p>The  <code>&gt;<\/code>  prefix needs to be added <em>after<\/em> Maple has processed the commands from either the student or teacher.  Here it is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   #--- run program, capture output, display to student ---\n   echo \"Running Maple on the student solution...\"\n   maple -q \\${studentProgram}.mw  &gt; user.out\n   echo \"... Maple finished.\"\n   \n   # ---- add a '&gt;' prefix --------------------------------\n   # add a '&gt;' prefix to student and teacher files\n   # form: sed -i -e 's\/^\/&gt;\/' myfile.txt \n   cp user.out modifiedUser.out\n   cp solution.txt modifiedSolution.txt\n   sed -i -e 's\/^\/&gt;\/' modifiedUser.out\n   sed -i -e 's\/^\/&gt;\/' modifiedSolution.txt\n   # ------------------------------------------------------<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>This is a proof of concept for creating automatically-graded math assignments using Maple within the VPL framework in Moodle.  We can verify a student's equation or her graph against a teacher's model answer. It's not as feature-rich or refined as Matlab Grader or Maple's M\u00f6bius, but if you've already got Maple set up on your VPL server and you've already got VPL running on Moodle, then it might be worth a shot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Don't forget!<\/h2>\n\n\n\n<p>When setting up the activity, don't forget to include the <strong>local VPL server location<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-26.png\" alt=\"\" class=\"wp-image-1742\" width=\"385\" height=\"197\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-26.png 770w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-26-300x154.png 300w\" sizes=\"auto, (max-width: 385px) 100vw, 385px\" \/><figcaption><br>don't forget to add in the location of your local VPL (\"jail\") server.<\/figcaption><\/figure><\/div>\n\n\n\n<p>and don't forget to turn on \"run\", \"evaluate\" and \"autograde\" <strong>execution options<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-27.png\" alt=\"\" class=\"wp-image-1743\" width=\"504\" height=\"292\" srcset=\"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-27.png 1008w, https:\/\/www.yorku.ca\/professor\/drsmith\/wp-content\/uploads\/sites\/444\/2021\/07\/image-27-300x174.png 300w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><figcaption>Don't forget to set your execution options whens setting up your VPL assignment.<\/figcaption><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>James Andrew Smith is an associate professor in&nbsp;<a href=\"http:\/\/eecs.lassonde.yorku.ca\/\">Electrical Engineering and Computer Science Department<\/a>&nbsp;in York University's&nbsp;<a href=\"https:\/\/lassonde.yorku.ca\/\">Lassonde School<\/a>. &nbsp;He lived in Strasbourg, France and taught at the&nbsp;<a href=\"https:\/\/www.insa-strasbourg.fr\/en\/\">INSA Strasbourg<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/www.hs-karlsruhe.de\/\">Hochschule Karlsruhe<\/a>&nbsp;while on&nbsp;<a href=\"https:\/\/drsmith.blog.yorku.ca\/2019\/10\/sabbatical-report-summary\/\">sabbatical<\/a>&nbsp;in 2018-19 with his wife and kids. Some of his other blog posts discuss the family's sabbatical year, from both&nbsp;<a href=\"https:\/\/twitter.com\/search?q=(%23sabbaticallife)%20(from%3Aonnimikki)&amp;src=typed_query\">personal<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/twitter.com\/search?q=insa%20(from%3Ajasmith_yorku)&amp;src=typed_query\">professional<\/a>&nbsp;<a href=\"https:\/\/twitter.com\/search?q=karlsruhe%20(from%3Ajasmith_yorku)&amp;src=typed_query\">perspectives<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the places that Moodle falls down in is in supporting math assignments. It occurred to me that we could treat math assignments like we do programming assignments by extending the Virtual Programming Lab plugin for Moodle to support Maple. This doesn't replace existing products like the Maple \/ DigitalEd M\u00f6bius platform, nor does [&hellip;]<\/p>\n","protected":false},"author":762,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","footnotes":""},"categories":[47,294],"tags":[279,284,287,288,18,289,285,261,263,286,281,280],"class_list":["post-1747","post","type-post","status-publish","format-standard","hentry","category-eclass","category-vpl","tag-bash","tag-maple","tag-math","tag-math-activities","tag-matlab","tag-matlab-grader","tag-sed","tag-virtual-programming-lab","tag-vpl","tag-vpl_evaluate","tag-vpl_evaluate-sh","tag-vpl_run-sh"],"taxonomy_info":{"category":[{"value":47,"label":"eClass"},{"value":294,"label":"VPL"}],"post_tag":[{"value":279,"label":"bash"},{"value":284,"label":"maple"},{"value":287,"label":"math"},{"value":288,"label":"math activities"},{"value":18,"label":"matlab"},{"value":289,"label":"matlab grader"},{"value":285,"label":"sed"},{"value":261,"label":"virtual programming lab"},{"value":263,"label":"VPL"},{"value":286,"label":"vpl_evaluate"},{"value":281,"label":"vpl_evaluate.sh"},{"value":280,"label":"vpl_run.sh"}]},"featured_image_src_large":false,"author_info":{"display_name":"drsmith","author_link":"https:\/\/www.yorku.ca\/professor\/drsmith\/author\/drsmith\/"},"comment_info":"","category_info":[{"term_id":47,"name":"eClass","slug":"eclass","term_group":0,"term_taxonomy_id":47,"taxonomy":"category","description":"","parent":0,"count":32,"filter":"raw","cat_ID":47,"category_count":32,"category_description":"","cat_name":"eClass","category_nicename":"eclass","category_parent":0},{"term_id":294,"name":"VPL","slug":"vpl","term_group":0,"term_taxonomy_id":294,"taxonomy":"category","description":"","parent":0,"count":25,"filter":"raw","cat_ID":294,"category_count":25,"category_description":"","cat_name":"VPL","category_nicename":"vpl","category_parent":0}],"tag_info":[{"term_id":279,"name":"bash","slug":"bash","term_group":0,"term_taxonomy_id":279,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":284,"name":"maple","slug":"maple","term_group":0,"term_taxonomy_id":284,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":287,"name":"math","slug":"math","term_group":0,"term_taxonomy_id":287,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":288,"name":"math activities","slug":"math-activities","term_group":0,"term_taxonomy_id":288,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":18,"name":"matlab","slug":"matlab","term_group":0,"term_taxonomy_id":18,"taxonomy":"post_tag","description":"","parent":0,"count":7,"filter":"raw"},{"term_id":289,"name":"matlab grader","slug":"matlab-grader","term_group":0,"term_taxonomy_id":289,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":285,"name":"sed","slug":"sed","term_group":0,"term_taxonomy_id":285,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":261,"name":"virtual programming lab","slug":"virtual-programming-lab","term_group":0,"term_taxonomy_id":261,"taxonomy":"post_tag","description":"","parent":0,"count":14,"filter":"raw"},{"term_id":263,"name":"VPL","slug":"vpl","term_group":0,"term_taxonomy_id":263,"taxonomy":"post_tag","description":"","parent":0,"count":13,"filter":"raw"},{"term_id":286,"name":"vpl_evaluate","slug":"vpl_evaluate","term_group":0,"term_taxonomy_id":286,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":281,"name":"vpl_evaluate.sh","slug":"vpl_evaluate-sh","term_group":0,"term_taxonomy_id":281,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":280,"name":"vpl_run.sh","slug":"vpl_run-sh","term_group":0,"term_taxonomy_id":280,"taxonomy":"post_tag","description":"","parent":0,"count":3,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/1747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/users\/762"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/comments?post=1747"}],"version-history":[{"count":11,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/1747\/revisions"}],"predecessor-version":[{"id":2844,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/posts\/1747\/revisions\/2844"}],"wp:attachment":[{"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/media?parent=1747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/categories?post=1747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yorku.ca\/professor\/drsmith\/wp-json\/wp\/v2\/tags?post=1747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}