diff --git a/stack/maxima/contrib/validators.mac b/stack/maxima/contrib/validators.mac index 9d82e9d9e8d810b9254377f68a7cdee77a883f43..46a2a89057aa2d0418e5a0ba8b7f54086b1a3978 100644 --- a/stack/maxima/contrib/validators.mac +++ b/stack/maxima/contrib/validators.mac @@ -33,7 +33,6 @@ s_test_case(validate_underscore(1+a1), ""); s_test_case(validate_underscore(1+a_1), "Underscore characters are not permitted in this input."); /* The student may not use a user-defined function, or arrays, anywhere in their input. */ - validate_nofunctions(ex):= block([op1], if atom(ex) then return(""), op1:ev(op(ex)), @@ -49,3 +48,12 @@ s_test_case(validate_nofunctions(x(2)), "User-defined functions are not permitte s_test_case(validate_nofunctions(x(t)), "User-defined functions are not permitted in this input."); s_test_case(validate_nofunctions(1+f(x+1)), "User-defined functions are not permitted in this input."); +/* The student may only use single-character variable names in their answer. */ +/* This is intended for use when Insert Stars is turned off, but we still want to indicate to students that they may have forgotten a star */ +validate_all_one_letter_variables(ex) := if not(is(ev(lmax(map(lambda([ex2],slength(string(ex2))),listofvars(ex))),simp)>1)) then "" + else "Only single-character variable names are permitted in this input. Perhaps you forgot to use an asterisk (*) somewhere, or perhaps you used a Greek letter."; + +s_test_case(validate_all_one_letter_variables(1), ""); +s_test_case(validate_all_one_letter_variables((A*x+B)/(x^2+1) + C/x), ""); +s_test_case(validate_all_one_letter_variables((Ax+B)/(x^2+1) + C/x), "Only single-character variable names are permitted in this input. Perhaps you forgot to use an asterisk (*) somewhere, or perhaps you used a Greek letter."); +s_test_case(validate_all_one_letter_variables((theta*x+B)/(x^2+1) + C/x), "Only single-character variable names are permitted in this input. Perhaps you forgot to use an asterisk (*) somewhere, or perhaps you used a Greek letter.");