{% extends "linear_equations_1.html" %}
{% block generateequation %}
//generate the left and right terms for the first degree linear equations
var left_x_coefficients;
var right_x_coefficients;
var left_constants;
var right_constants;
function generateExercise()
{
left_x_coefficients= new Array();
right_x_coefficients= new Array();
left_constants = new Array();
right_constants = new Array();
left_x_coefficients[0]= get_random();
right_x_coefficients[0]= get_random();
left_constants[0]= get_random();
right_constants[0]= get_random();
if (Math.abs(get_random())<4) //30% chance
{
leftInvert = true;
leftMultiplier = get_random();
if (Math.abs(get_random())<6) //50% chance
{
rightInvert = true;
rightMultiplier = get_random();
}
}
if (leftInvert==false && rightInvert==false)
{
if (get_random()>get_random()) //50% chance
{
left_x_coefficients[1]=get_random();
}
if (get_random()>get_random()) //50% chance
{
right_x_coefficients[1]=get_random();
}
if (get_random()>get_random()) //50% chance
{
left_constants[1]=get_random();
}
if (get_random()>get_random()) //50% chance
{
right_constants[1]=get_random();
}
}
}
generateExercise();
while(array_sum(left_x_coefficients)==array_sum(right_x_coefficients))
generateExercise();
{% endblock generateequation %}