## WeBWorK Problems

### Restrict the scientific notation in student answer

by Edwin Flórez -
Number of replies: 0
Hello everybody,

I am a newbie in WeBWork from Puerto Rico. I installed it (http://webwork.uprm.edu) in a CentOS server using ww_install python script (https://github.com/aubreyja/ww_install), it is running so well.

Thank you very much to all who have contributed and contributes in this powerful tool.

I am coding some problems, I want restrict scientific notation like 3.25E3 in students solution. Of course, the problem is convert from scientific notation to standard.

I include the full code, it is in spanish, I hope this is not a problem. Maybe I'm not quite right encoding, suggestions are welcome.
#  DESCRIPTION
#
#  Tipo: respuesta corta
#  Pasar de notación científica a normal
#
#  Problema WebWork escrito por Edwin Florez,
#  edwin.florez at uprm dot edu
#  pedro_prebasica/notacion_cientifica/notacion_cientifica.db
#
#  ENDDESCRIPTION

## DBsubject(Prebasica)
## DBchapter(Sistemas numéricos)
## DBsection(Notación científica)
## Level(1)
## KEYWORDS('notacion', 'cientifica')
## Author(Edwin Florez)
## Institution(UPRM)
## Language(es)

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGgraphmacros.pl",
"problemRandomize.pl"
);

TEXT(beginproblem());
#$refreshCachedImages = 1; # Allow for the user to try another version of the problem once they get it correct. ProblemRandomize(when=>"Correct",XonlyAfterDue=>0); # Show which answers are correct and which ones are incorrect$showPartialCorrectAnswers = 0;

#################
### Setup

Context("Numeric");

#Number's parts: a.b x 10^n
$a = random(1,9);$b = random(1,99);
$n = non_zero_random(-6,6);$abs_n = abs($n); #Used in the solution #string of zeros with length n for padding$zeros = '0'x($abs_n); if ($n > 0 ){
$simbolo = ">";$direccion = "derecha";
$cadena_tmp = "$a.$b".$zeros;
}else{
$simbolo = "<";$direccion = "izquierda";
$cadena_tmp =$zeros."$a.$b";
}

#number in scientific notation like a string
$numero_nota_cient = "$a."."$b\times 10^{$n}";

#Building from a, b and n the answer
if ($b > 9){$rp = 100*$a +$b;
$r =$rp*(10**($n-2)); }else{$rp = 10*$a +$b;
$r =$rp*(10**($n-1)); }$answer = Compute($r); Context()->texStrings; BEGIN_TEXT Eliminar los productos y potencias del número $numero_nota_cient$$PAR
END_TEXT
Context()->normalStrings;

ANS( $answer->cmp() ); Context()->texStrings; SOLUTION(EV3(<<'END_SOLUTION'));$BBOLD Paso 1:$EBOLD Escribir el número $a.b$$PAR
$BBOLD Paso 2:$EBOLD Como $$n simbolo 0$$ se añade $abs_n cero(s) a la$direccion
$cadena_tmp$
y luego se mueve el punto decimal $abs_n unidad(es) a la$direccion y se obtiene:
$numero_nota_cient = answer,$
por lo tanto, la solución es: $$answer$$.
END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();


I read from another post that this is useful,

Page generated at 07/15/2014 at 02:22pm AST

Thanks,

Edwin F.