Beispiel #1
0
function build(&$a)
{
    if (!array_key_exists('assignment', $a['request'])) {
        unset($a['question_num']);
        \Edu8\Http::redirect('/');
    }
    $a['alpha'] = ['Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'];
    $a['from_alpha'] = ['Z' => 0, 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9];
    $a['assignment'] = $a['request']['assignment'];
    $connection = \Edu8\Config::initDb();
    if (!array_key_exists('question_num', $a)) {
        $completed_statement = \Edu8\Sql::runStatement($connection, 'completed', ['student' => $a['student']['student_'], 'assignment' => $a['assignment']]);
        $q_completed = $completed_statement->fetchAll();
        $question_statement = \Edu8\Sql::runStatement($connection, 'assignment_question', ['assignment' => $a['assignment']]);
        $a['question'] = $question_statement->fetchAll();
        $question_total_statement = \Edu8\Sql::runStatement($connection, 'assignment_question_count', ['assignment' => $a['assignment']]);
        $a['question_total'] = reset($question_total_statement->fetch());
        /* foreach ($a['question'] as &$q) {
           $q['concepts'] = preg_split('/,/', $q['concepts']);
           } */
        $a['concepts'] = [['Dynamics', [['What phenomena are we seeing?', [['Single mass', ['On a flat surface', 'On inclined plane', ['Moving in a circle', ['Horizontal circle', 'Vertical circle']]]], ['Multiple interacting masses', [['connected by ropes & pulleys', ['Massless approximation on pulley', 'Non-negligible mass of pulley']], 'directly in contact with each other', 'directly in contact with each other & connected by ropes & pulleys']], ['Extended rigid rotating object', ['About a fixed point', 'About a moving point ']]]], ['What are the relevant variables or quantities?', [['Forces', [['Contact Forces', [['Friction', ['Magnitude & direction of Force of Static friction depends on initial conditions of masses involved', 'Magnitude & direction of Force of Kinetic friction is always = ukFN, and always opposes direction of motion']], ['Normal Force', ['Force exerted on an object by the surface supporting it, perpendicular to the plane of the surface', 'Also known as “apparent weight”', 'FN > mg ?', 'FN = mg ?', 'FN < mg ?']], ['Tension', ['Tension force always acts along direction of the string', 'For massless string approximation, magnitude of tension is the same all along the length of the string']], ['Drag', ['Always opposite the direction of velocity']], 'Applied Force']], ['Long Range Forces', [['Gravity', ['Always points towards the center of the earth']], 'Electrostatic', 'Magnetic']]]], ['Net Force', ['Vector sum of all the forces', 'Directly proportional to acceleration']]]]]], ['Energy', [['What are the phenomena we are seeing?', [['Single mass in motion', ['Inclined plane', 'Vertical loop-the-loop', 'Irregular shaped track', 'Other cases']], ['Single mass feeling a variable force (non-constant acceleration)', ['Spring', 'Pendulum', 'Other variable force']], 'Elastic Collision']], ['What are the quantities and relevant definitions and special cases?', [['Kinetic energy', ['Related to object’s motion', 'Proportional to square of object’s speed', 'Proportional to object’s mass', 'Translational kinetic energy', 'Rotational kinetic energy']], ['Potential energy', ['Related to object’s position', 'Potential energy must be defined relative to a reference frame', 'Derivative of potential energy with respect to position equals negative of  (conservative) force', ['Gravitational potential energy', ['Proportional to object’s mass and height (from reference)']], ['Elastic potential energy', ['Reference position is at system’s equilibrium position']], 'Due to other conservative force']], ['Work', ['Dot product of constant force and displacement', 'Area under a (component) force vs. position graph (integral)', 'Work done by a force is positive if it is adding energy to the system'], 'Work done by a force is negative if it is removing energy from the system', 'Path independent if done by a conservative force', 'Depends on path if done by a non-conservative force'], ['Power', ['Rate at which work is done', 'Dot product of constant force and velocity', 'Area under a (component) force vs. velocity graph (integral)']]]], ['What are the physical laws involved?', ['The work done by all external forces on an object equals the change in its kinetic energy.', 'The work done by all non-conservative forces equals the change in the total mechanical energy of a system']]]], ['Kinematics', [['What phenomena are we seeing?', [['Free-fall', ['Air drag negligible ', 'Air drag not negligible', 'Near Earth’s surface', 'Not near Earth’s surface']], ['Motion on an inclined surface', ['Friction negligible', 'Friction not negligible', 'Gravity is only force pulling', 'Some force (other than gravity) pushing/pulling?']], ['Motion on a horizontal surface', ['Friction negligible', 'Friction is not negligible']], ['Motion described as a function of time', ['One dimensional', 'Multidimensional']], ['Projectile motion (in two dimensions)', ['Air friction negligible', 'Air friction not negligible', 'Something (other than gravity) pushing/pulling']], ['Circular motion', ['Horizontal circle', ['Vertical circle', ['Gravity is only force pulling', ['Something (other than gravity) pushing/pulling', ['Parallel to path', 'Perpendicular to path', 'Has components both parallel and perpendicular']]]]]]]], ['Important quantities, definitions and special cases', [['Position', ['Equal to location of dot/point on graph or motion diagram', ['Horizontal', ['Initial horizontal position is zero', 'Initial horizontal position of both objects are the same']], ['Vertical', ['Initial vertical position is zero', 'Initial vertical position of both objects are the same']], ['Angular', ['Initial angular position is zero', 'Initial angular position of both objects are the same']]]], ['Distance', ['Equal to sum of the displacement values']], ['Displacement', ['Equal to the difference in position', 'Equal to the area under a velocity graph']], ['Speed', ['Related to distance between dots on a motion diagram', 'Equal to steepness of position function', 'Speed decreases when velocity and acceleration are in opposite directions', 'Speed increases when velocity and acceleration are in the same direction']], ['Velocity', [['Horizontal', ['Initial horizontal velocity is zero', 'Initial horizontal velocity of both objects are the same', 'Initial horizontal velocity of both objects are different']], ['Vertical', ['Initial vertical velocity is zero', 'Initial vertical velocity of both objects are the same', 'Initial vertical velocity of both objects are different']], ['Angular', ['Initial angular velocity is zero', 'Initial angular velocity of both objects are the same', 'Initial angular velocity of both objects are different']], ['Average (1D only)', ['Equal to displacement/time interval', 'Related to distance between dots on a motion diagram']], ['Instantaneous', ['Equal to slope of position graph', 'Equal to derivative of position function', 'Constant', 'Not constant']]]], ['Acceleration', [['Average (1D only)', ['Equal to change in velocity/time interval', 'Related to the change in distance between dots on a motion diagram']], ['Instantaneous', ['Equal to derivative of velocity function', 'Equal to slope of velocity graph', 'Equal to curvature of position function']], ['Object is slowing', ['Direction of acceleration and velocity are opposite']], ['Object is speeding up', ['Direction of acceleration and velocity are parallel']], ['Constant', ['has magnitude = g', 'has magnitude = 0', 'has magnitude = g sinθ', 'has magnitude = v2/R']], 'Constant during intervals but changes suddenly in-between', 'Not constant']]]]]], ['Momentum', [['Phenomena and cases', [['Collisions', ['Elastic', 'Inelastic', 'Perfectly inelastic']], 'Explosions', 'Single mass begin hit/pulled by a force', ['Multiple Masses Pushing/Pulling Each Other', ['Horizontal Fnet=0', 'Vertical Fnet=0', 'All directions Fnet=0']]]], ['Important quantities, definitions and special cases', [['Mass', ['mass before = mass after', 'mass before≠ mass after']], ['Velocity', ['Must be treated as a vector (components)', 'velocity before = velocity after', 'velocity before≠velocity after']], ['Momentum', ['Must be treated as a vector (components)', 'Is in the same direction as velocity', 'momentum before = momentum after', 'momentum before≠momentum after']], ['Time interval', ['If time interval of interaction is very short then Δp≈0', 'If time interval of interaction is not short then Δp≠0']], ['Impulse', ['Equal to the change in momentum', 'Area under a force vs. time graph (integral)']]]], ['Laws', ['If net external force on the system is zero then the system’s momentum is the same before and after.', 'The rate of change of momentum is equal to the net external force acting on an object.']]]]];
        $a['question_num'] = $q_completed[0]['q_completed'] >> 1;
        // div by 2 | note: >> will have no effect if 0.
        if (count($a['question']) <= $a['question_num']) {
            \Edu8\Http::redirect('/question-review');
        }
        tagLabels($a['concepts']);
    }
}
Beispiel #2
0
function build(&$a)
{
    if (!array_key_exists('assignment', $a['request'])) {
        unset($a['question_num']);
        \Edu8\Http::redirect('/');
    }
    if ($a['question_num'] < $a['question_total'] - 1) {
        if (array_key_exists('question_num', $a)) {
            $a['question_num']++;
        } else {
            $a['question_num'] = 0;
        }
    } else {
        unset($a['question_num']);
        \Edu8\Http::redirect('/');
    }
    $a['alpha'] = ['Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'];
    $a['from_alpha'] = ['Z' => 0, 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9];
    $a['assignment'] = $a['request']['assignment'];
    $connection = \Edu8\Config::initDb();
    if ($a['question_num'] == 0) {
        $question_statement = \Edu8\Sql::runStatement($connection, 'assignment_question_response', ['student' => $a['student']['student_'], 'assignment' => $a['assignment']]);
        $a['question'] = $question_statement->fetchAll();
        $question_total_statement = \Edu8\Sql::runStatement($connection, 'assignment_question_count', ['assignment' => $a['assignment']]);
        $a['question_total'] = reset($question_total_statement->fetch());
        /* foreach ($a['question'] as &$q) {
           $q['concepts'] = preg_split('/,/', $q['concepts']);
           } */
    }
}
Beispiel #3
0
function build(&$a)
{
    unset($a['question_num']);
    unset($a['message_dlg']);
    $connection = \Edu8\Config::initDb();
    $db_statement = \Edu8\Sql::runStatement($connection, 'student_assignment', ['student_' => $a['student']['student_']]);
    $a['assignments'] = $db_statement->fetchAll();
}
Beispiel #4
0
function build(&$a)
{
    $a['request']['postvar'] = '';
    $connection = \Edu8\Config::initDb();
    $db_statement = \Edu8\Sql::runStatement($connection, 'prof_courses', ['professor' => $a['student']['student_']]);
    $a['courses'] = $db_statement->fetchAll();
    $db_statement = \Edu8\Sql::runStatement($connection, 'all_questions');
    $a['all_questions'] = $db_statement->fetchAll();
}
Beispiel #5
0
function post(&$a)
{
    if ($a['request']['log']) {
        $connection = \Edu8\Config::initDb();
        $db_statement = \Edu8\Sql::runStatement($connection, 'login', ['login' => $a['request']['log']]);
        $students = $db_statement->fetchAll();
        if (count($students)) {
            $a['student'] = $students[0];
            if (!strcmp($a['student']['password'], $a['request']['pwd'])) {
                $a['auth'] = true;
                return;
            }
        }
        $a['message_dlg'] = 'Please provide correct login and password';
    }
}
Beispiel #6
0
function build(&$a)
{
    $connection = \Edu8\Config::initDb();
    $questions = \Edu8\Sql::runStatement($connection, 'assignment_question', ['assignment' => $a['request']['assignment']]);
    $results = \Edu8\Sql::runStatement($connection, 'results', ['assignment' => $a['request']['assignment']]);
    $a['question_list'] = $questions->fetchAll();
    $rows = $results->fetchAll();
    $lastSid = $rows[0]['student_'];
    $a['student_results'] = [];
    $work = [];
    foreach ($rows as $row) {
        if ($row['student_'] != $lastSid) {
            $lastSid = $row['student_'];
            $a['student_results'][] = $work;
            $work = [];
        }
        $work[] = $row;
    }
    $a['student_results'][] = $work;
}
Beispiel #7
0
function build(&$a)
{
    $connection = \Edu8\Config::initDb();
    $q = $a['question'][$a['question_num']];
    unset($a['request']['C1']);
    unset($a['request']['C2']);
    unset($a['request']['C3']);
    unset($a['request']['C4']);
    unset($a['request']['C5']);
    if ($a['request']['answer'] == $q['answer']) {
        $second_choice = $q['second_choice'];
    } else {
        $second_choice = $a['request']['answer'];
    }
    $db_statement = \Edu8\Sql::runStatement($connection, 'rationales', ['question' => $q['question_'], 'answer' => $second_choice]);
    $a['rationales2'] = chooseRationales($db_statement->fetchAll());
    $db_statement2 = \Edu8\Sql::runStatement($connection, 'rationales', ['question' => $q['question_'], 'answer' => $q['answer']]);
    $a['rationales'] = chooseRationales($db_statement2->fetchAll());
    $a['other'] = $second_choice;
    $a['swap'] = rand(0, 1);
}
Beispiel #8
0
function build(&$a)
{
    $connection = \Edu8\Config::initDb();
    $answered_questions = \Edu8\Sql::runStatement($connection, 'answered_questions');
    $a['answered_questions'] = $answered_questions->fetchAll();
    //Get the question id from the post var or from the top of the list of questions.
    $question_ = isset($a['request']['question_']) ? $a['request']['question_'] : $a['answered_questions'][0]['question_'];
    $question = \Edu8\Sql::runStatement($connection, 'question_graph', ['question_' => $question_]);
    $question_graph = $question->fetchAll()[0];
    $question_answers = \Edu8\Sql::runStatement($connection, 'question_answers_graph', ['question_' => $question_]);
    $question_answers_graph = $question_answers->fetchAll();
    $answers_tags = \Edu8\Sql::runStatement($connection, 'answers_tags_graph', ['question_' => $question_]);
    $answers_tags_graph = $answers_tags->fetchAll();
    $a['alpha'] = $question_graph['alpha'];
    $a['num_choice'] = $question_graph['num_choice'];
    $a['num_choice_col1'] = floor($question_graph['num_choice'] / 2);
    $a['correct_choices'] = $question_graph['answer'] . ', ' . $question_graph['second_choice'];
    $a['media1'] = $question_graph['media1'];
    $a['question_answers_graph'] = [];
    //Initialize the choices graph.
    for ($i = 0; $i < $question_graph['num_choice']; $i++) {
        $a['question_answers_graph'][$i] = 0;
    }
    //Populate the choices graph.
    for ($i = 0; $i < count($question_answers_graph); $i++) {
        $a['question_answers_graph'][$question_answers_graph[$i]['answer'] - 1] = $question_answers_graph[$i]['count'];
    }
    $a['question_answers_graph'] = implode($a['question_answers_graph'], ', ');
    $question_tag_graph = explode(',', $question_graph['concepts']);
    sort($question_tag_graph);
    $a['question_tag_graph'] = '"' . implode($question_tag_graph, '" ,"') . '"';
    //Initialize the tag graphs.
    $a['answers_tags_graphs'] = [];
    $answer_counter = [];
    for ($i = 0; $i < $question_graph['num_choice']; $i++) {
        $a['answers_tags_graphs'][$i] = [];
        $answer_counter[$i] = 0;
        for ($j = 0; $j < count($question_tag_graph); $j++) {
            $a['answers_tags_graphs'][$i][$j] = 0;
        }
    }
    //Populate the tag graphs.
    for ($i = 0; $i < count($answers_tags_graph); $i++) {
        $tags = explode(',', $answers_tags_graph[$i]['concepts']);
        $answer = $answers_tags_graph[$i]['answer'] - 1;
        $answer_counter[$answer]++;
        for ($j = 0; $j < count($question_tag_graph); $j++) {
            if (array_search($question_tag_graph[$j], $tags) !== false) {
                $a['answers_tags_graphs'][$answer][$j]++;
            }
        }
    }
    //Normalize the tag graphs.
    for ($i = 0; $i < count($a['answers_tags_graphs']); $i++) {
        for ($j = 0; $j < count($a['answers_tags_graphs'][$i]); $j++) {
            if ($answer_counter[$i] > 0) {
                $a['answers_tags_graphs'][$i][$j] *= 100 / $answer_counter[$i];
            }
        }
    }
    for ($i = 0; $i < $question_graph['num_choice']; $i++) {
        $a['answers_tags_graphs'][$i] = implode($a['answers_tags_graphs'][$i], ', ');
    }
}