Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/validators/equalMatrix.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
%%% Apend code via \appendtoverbtoks

\appendtoverbtoks?
//<![CDATA[
// We want to define a validator that allows us to check a matrix.
function equalMatrix(f,g) {
/* We expect that f is a matrix provided by the student in the format:
Expand Down Expand Up @@ -104,6 +105,7 @@ function equalMatrix(f,g) {

return true
}
//]]>
?
%</classXimera>
% \end{macrocode}
Expand Down
26 changes: 14 additions & 12 deletions src/validators/factorCheck.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
%%% Apend code via \appendtoverbtoks

\appendtoverbtoks?
//<![CDATA[
/*
HOW THIS SHOULD WORK:
Initially check to make sure the submitted answer (and proposed answer) are at least in some kind of theoretically factored form.
Expand Down Expand Up @@ -95,7 +96,7 @@ function degreeHunt(tree,position,curDeg) {

var tempDeg = 0;

for (var j = 1; j < tree[position].length; ++j) {
for (var j = 1; j<tree[position].length; ++j) {
// Walk the array to find any powers of x.
if (tree[position][j]=='x') {
// If the entry is just x, then we have pos deg and we are done.
Expand Down Expand Up @@ -201,7 +202,7 @@ function degreeHunt(tree,position,curDeg) {
debugText('Processing a product sign.');

var tempDeg = 0;
for (var j = 0; j < tree[position].length; ++j) {
for (var j = 0; j<tree[position].length; ++j) {
// Add the degree of each thing being multiplied, even though most are probably zero.
if (tree[position][j]=='x') {
// If the entry is just x, then we have deg 1.
Expand Down Expand Up @@ -229,7 +230,7 @@ function degreeHunt(tree,position,curDeg) {

debugText('Processing an unknown sign... Specifically: '+tree[position][0]);

for (var j = 0; j < tree[position].length; ++j) {
for (var j = 0; j<tree[position].length; ++j) {
// Walk the array to find any powers of x.
if (tree[position][j]=='x') {
// If the entry is just x, then we have deg 1.
Expand All @@ -251,10 +252,10 @@ function degreeHunt(tree,position,curDeg) {
// Subfunction just to make sure that the submitted function is in a legitimately factored form.

function JNFisFactored(factorTree) {

// First we check to see if we have a negative factored out, which messes everything up in the tree.
if ((factorTree[0]=='-')||(factorTree[0]=='*')||((factorTree[0]=='/')*(isNum(JNFoperation[1])))
) {return true} else {return false}
// Most recent Math Expressions lib converted -f(x) style to ['-',[f_array]], and
// f(x) - g(x) style to ['+' [f_array],['-'[g_array]]], so we can take either '*' or '-' as top operation.
if ((factorTree[0]=='-')||(factorTree[0]=='*'))
{return true} else {return false}
}


Expand Down Expand Up @@ -295,7 +296,7 @@ function factorCheck(f,g) {
// Now we want to fold up any root-level exponents into duplicate children of the master tree,
// This lets us assume the top-level node has 1 child per factor.
debugText('folding up external exponents of studentTree so factors do not have exponents');
for (var i = 0; i < studentAns.length; ++i) {
for (var i = 0; i<studentAns.length; ++i) {
if ((studentAns[i][0] == '^')*(isPosInt(studentAns[i][2]))) {
studentAns=studentAns.concat(Array(studentAns[i][2]).fill(studentAns[i][1]));
studentAns.splice(i,1);// This should theoretically remove the original term now that we've duplicated it.
Expand All @@ -312,7 +313,7 @@ function factorCheck(f,g) {

// Now re repeat with instructor tree:
debugText('folding up external exponents of instructorTree so factors do not have exponents')
for (var i = 0; i < instructorAns.length; ++i) {
for (var i = 0; i<instructorAns.length; ++i) {
if ((instructorAns[i][0] == '^')*(isPosInt(instructorAns[i][2]))) {
instructorAns=instructorAns.concat(Array(instructorAns[i][2]).fill(instructorAns[i][1]));
instructorAns.splice(i,1);// This should theoretically remove the original term now that we've duplicated it.
Expand All @@ -331,7 +332,7 @@ function factorCheck(f,g) {
*/

var studentDegList=[0]
for (var i = 0; i < studentAns.length; ++i) {
for (var i = 0; i<studentAns.length; ++i) {
if (studentAns[i] == 'x') {
// If the factor is simply 'x', then it's a degree 1 factor... yay...
studentDegList.push(1);
Expand All @@ -357,7 +358,7 @@ function factorCheck(f,g) {
*/

var instructorDegList=[0]
for (var i = 0; i < instructorAns.length; ++i) {
for (var i = 0; i<instructorAns.length; ++i) {
if (instructorAns[i] == 'x') {
// If the factor is simply 'x', then it's a degree 1 factor... yay...
instructorDegList.push(1);
Expand Down Expand Up @@ -386,7 +387,7 @@ function factorCheck(f,g) {
return false
}

for (var i = 0; i < studentDegList.length; ++i) {
for (var i = 0; i<studentDegList.length; ++i) {
if (studentDegList[i] !== instructorDegList[i]) {
console.log('Ans Rejected: At least one factor is the wrong degree.');
return false
Expand All @@ -400,6 +401,7 @@ function factorCheck(f,g) {

return (f.equals(g))
}
//]]>
?
%</classXimera>
% \end{macrocode}
Expand Down
2 changes: 2 additions & 0 deletions src/validators/multiAns.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
%%% Apend code via \appendtoverbtoks

\appendtoverbtoks?
//<![CDATA[
// We want to define a validator that allows us to check against a list of possibilities.
function multiAns(f,g) {
// We expect that f is a single function provided by the student,
Expand Down Expand Up @@ -40,6 +41,7 @@ function multiAns(f,g) {
}
return false
}
//]]>
?
%</classXimera>
% \end{macrocode}
Expand Down
2 changes: 2 additions & 0 deletions src/validators/sameDerivative.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
%%% Apend code via \@addToValidators

\appendtoverbtoks?
//<![CDATA[
// NOTE: The below are intended to be used inside an \answer optional argument with the validator key, NOT in a validator environment.

// sameDerivative checks to see if the derivative with respect to x and c are equal.
Expand Down Expand Up @@ -60,6 +61,7 @@
a.derivative('Z').equals( b.derivative('Z') )
)
}
//]]>
?
%</classXimera>
% \end{macrocode}
Expand Down
8 changes: 8 additions & 0 deletions src/validators/supplementalCommands.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
% \begin{macrocode}
%<*classXimera>
\appendtoverbtoks?
//<![CDATA[
var debugInfo = false;

function numberLessThan(a,b) {
// Returns true if a is less than b, and false if a is greater than or equal to b.
if (Math.min(a,b) == a) return true;
if (Math.max(a,b) == a) return false;
}

function debugText(debugMsg) {
if (debugInfo) {
console.log(debugMsg);
Expand Down Expand Up @@ -39,6 +46,7 @@ function compSubTree(f, treeOne,treeTwo) {
// Now we return the validity of their equality using Ximera equality validation.
return (fTemp.equals(gTemp))
}
//]]>
?
%</classXimera>
% \end{macrocode}
6 changes: 6 additions & 0 deletions src/validators/unactivatedValidators.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
%%% Apend code via \verb|\appendtoverbtoks|

%\appendtoverbtoks?
%//<![CDATA[
%%%// NOTE: The below are intended to be used inside an \verb|\answer| optional argument with the validator key, NOT in a validator environment.
%
%// Check to see if two inputs are the same parity in terms of even/odd.
% function sameParity(a,b) {
% return (a-b)%2 == 0;
% };
%//]]>
%?
%
%</classXimera>
Expand All @@ -44,11 +46,13 @@
%%% Apend code via \verb|\appendtoverbtoks|

%\appendtoverbtoks?
%//<![CDATA[
%var x
%// Check to see if input is positive.
% function isPositive(number) {
% return number > 0;
% };
%//]]>
%?
%
%</classXimera>
Expand All @@ -71,12 +75,14 @@
%%% Apend code via \verb|\appendtoverbtoks|

%\appendtoverbtoks?
%//<![CDATA[
%// NOTE: The below are intended to be used inside an \answer optional argument with the validator key, NOT in a validator environment.
%
%// Check to see if two strings match in a case-insensitive way.
% caseInsensitive = function(a,b) {
% return a.toLowerCase() == b.toLowerCase();
% };
%//]]>
%?
%
%</classXimera>
Expand Down