/**
 * This function will create a new form for the teachers to use to register student information.
 *
 * This function is responsible for creating and adding all of the associated fields
 * that are necessary for music teachers to enter data about their students that are competing.
 *
 * @param   String    $competition_name   The name of the newly created music competition
 *
 * @since 1.0.0
 * @author KREW
 */
function aria_create_teacher_form($competition_name)
{
    $teacher_form = new GF_Form("{$competition_name} Teacher Registration", "");
    $field_id_arr = aria_teacher_field_id_array();
    // teacher name
    $teacher_name_field = new GF_Field_Name();
    $teacher_name_field->label = "Name";
    $teacher_name_field->id = $field_id_arr['name'];
    $teacher_name_field->isRequired = true;
    $teacher_form->fields[] = $teacher_name_field;
    // teacher email
    $teacher_email_field = new GF_Field_Email();
    $teacher_email_field->label = "Email";
    $teacher_email_field->id = $field_id_arr['email'];
    $teacher_email_field->isRequired = true;
    $teacher_form->fields[] = $teacher_email_field;
    // teacher phone
    $teacher_phone_field = new GF_Field_Phone();
    $teacher_phone_field->label = "Phone";
    $teacher_phone_field->id = $field_id_arr['phone'];
    $teacher_phone_field->isRequired = true;
    $teacher_form->fields[] = $teacher_phone_field;
    // teacher volunteer preference
    $volunteer_preference_field = new GF_Field_Checkbox();
    $volunteer_preference_field->label = "Volunteer Preference";
    $volunteer_preference_field->id = $field_id_arr['volunteer_preference'];
    $volunteer_preference_field->isRequired = true;
    $volunteer_preference_field->choices = array(array('text' => 'Section Proctor', 'value' => 'Section Proctor', 'isSelected' => false), array('text' => 'Posting Results', 'value' => 'Posting Results', 'isSelected' => false), array('text' => 'Information Table', 'value' => 'Information Table', 'isSelected' => false), array('text' => 'Greeting and Assisting with Locating Rooms', 'value' => 'Greeting', 'isSelected' => false), array('text' => 'Hospitality (managing food in judges rooms)', 'value' => 'Hospitality', 'isSelected' => false));
    $volunteer_preference_field->description = "Please check 1 time slot if you" . " have 1-3 students competing, 2 time slots if you have 4-6 students" . " competing, and 3 time slots if you have more than 6 students competing.";
    $teacher_form->fields[] = $volunteer_preference_field;
    // volunteer time
    $volunteer_time_field = new GF_Field_Checkbox();
    $volunteer_time_field->label = "Times Available for Volunteering";
    $volunteer_time_field->id = $field_id_arr['volunteer_time'];
    $volunteer_time_field->isRequired = false;
    $teacher_form->fields[] = $volunteer_time_field;
    // student name
    $student_name_field = new GF_Field_Name();
    $student_name_field->label = "Student Name";
    $student_name_field->id = $field_id_arr['student_name'];
    $student_name_field->isRequired = true;
    $teacher_form->fields[] = $student_name_field;
    // student's first song period
    $song_one_period_field = new GF_Field_Select();
    $song_one_period_field->label = "Song 1 Period";
    $song_one_period_field->id = $field_id_arr['song_1_period'];
    $song_one_period_field->isRequired = true;
    $teacher->form->fields[] = $song_one_period_field;
    // student's first song composer
    $song_one_composer_field = new GF_Field_Select();
    $song_one_composer_field->label = "Song 1 Composer";
    $song_one_composer_field->id = $field_id_arr['song_1_composer'];
    $song_one_composer_field->isRequired = true;
    $teacher->form->fields[] = $song_one_composer_field;
    // student's first song selection
    $song_one_selection_field = new GF_Field_Select();
    $song_one_selection_field->label = "Song 1 Selection";
    $song_one_selection_field->id = $field_id_arr['song_1_selection'];
    $song_one_selection_field->isRequired = true;
    $teacher->form->fields[] = $song_one_selection_field;
    // student's second song period
    $song_two_period_field = new GF_Field_Select();
    $song_two_period_field->label = "Song 2 Period";
    $song_two_period_field->id = $field_id_arr['song_2_period'];
    $song_two_period_field->isRequired = true;
    $teacher->form->fields[] = $song_two_period_field;
    // student's second song composer
    $song_two_composer_field = new GF_Field_Select();
    $song_two_composer_field->label = "Song 2 Composer";
    $song_two_composer_field->id = $field_id_arr['song_2_composer'];
    $song_two_composer_field->isRequired = true;
    $teacher->form->fields[] = $song_two_composer_field;
    // student's second song selection
    $song_two_selection_field = new GF_Field_Select();
    $song_two_selection_field->label = "Song 2 Selection";
    $song_two_selection_field->id = $field_id_arr['song_2_selection'];
    $song_two_selection_field->isRequired = true;
    $teacher->form->fields[] = $song_two_selection_field;
    // student's theory score
    $student_theory_score = new GF_Field_Number();
    $student_theory_score->label = "Theory Score (percentage)";
    $student_theory_score->id = $field_id_arr['theory_score'];
    $student_theory_score->isRequired = false;
    $student_theory_score->numberFormat = "decimal_dot";
    $student_theory_score->rangeMin = 0;
    $student_theory_score->rangeMax = 100;
    $teacher_form->fields[] = $student_theory_score;
    // student's alternate theory
    $alternate_theory_field = new GF_Field_Checkbox();
    $alternate_theory_field->label = "Check if alternate theory exam was completed.";
    $alternate_theory_field->id = $field_id_arr['alternate_theory'];
    $alternate_theory_field->isRequired = false;
    $alternate_theory_field->choices = array(array('text' => 'Alternate theory exam completed', 'value' => 'Alternate theory exam completed', 'isSelected' => false));
    $teacher_form->fields[] = $alternate_theory_field;
    // competition format
    $competition_format_field = new GF_Field_Radio();
    $competition_format_field->label = "Format of Competition";
    $competition_format_field->id = $field_id_arr['competition_format'];
    $competition_format_field->isRequired = false;
    $competition_format_field->choices = $volunteer_preference_field->choices = array(array('text' => 'Traditional', 'value' => 'Traditional', 'isSelected' => false), array('text' => 'Competitive', 'value' => 'Competitive', 'isSelected' => false), array('text' => 'Master Class (if upper level)', 'value' => 'Master Class', 'isSelected' => false));
    $teacher_form->fields[] = $competition_format_field;
    // timing field
    $timing_of_pieces_field = new GF_Field_Number();
    $timing_of_pieces_field->label = "Timing of pieces (minutes)";
    $timing_of_pieces_field->id = $field_id_arr['timing_of_pieces'];
    $timing_of_pieces_field->isRequired = false;
    $timing_of_pieces_field->numberFormat = "decimal_dot";
    $teacher_form->fields[] = $timing_of_pieces_field;
    // add the new form to the festival chairman's dashboard
    $new_form_id = GFAPI::add_form($teacher_form->createFormArray());
    // make sure the new form was added without error
    if (is_wp_error($new_form_id)) {
        wp_die($new_form_id->get_error_message());
    }
    /*
    add a customized confirmation message
    
    this is done after the form has been added so that the initial confirmation
    hash has been added to the object
    */
    $added_teacher_form = GFAPI::get_form(intval($new_form_id));
    $successful_submission_message = 'Congratulations! You have just successfully registered';
    $successful_submission_message .= ' one your students.';
    GFAPI::update_form($added_teacher_form);
}
function aria_create_teacher_form($competition_name)
{
    $teacher_form = new GF_Form("{$competition_name} Teacher Registration", "");
    $field_id_arr = aria_teacher_field_id_array();
    $teacher_name_field = new GF_Field_Name();
    $teacher_name_field->label = "Name";
    $teacher_name_field->id = $field_id_arr['name'];
    $teacher_name_field->isRequired = true;
    $teacher_form->fields[] = $teacher_name_field;
    $teacher_email_field = new GF_Field_Email();
    $teacher_email_field->label = "Email";
    $teacher_email_field->id = $field_id_arr['email'];
    $teacher_email_field->isRequired = true;
    $teacher_form->fields[] = $teacher_email_field;
    $teacher_phone_field = new GF_Field_Phone();
    $teacher_phone_field->label = "Phone";
    $teacher_phone_field->id = $field_id_arr['phone'];
    $teacher_phone_field->isRequired = true;
    $teacher_form->fields[] = $teacher_phone_field;
    $volunteer_preference_field = new GF_Field_Checkbox();
    $volunteer_preference_field->label = "Volunteer Preference";
    $volunteer_preference_field->id = $field_id_arr['volunteer_preference'];
    $volunteer_preference_field->isRequired = true;
    $volunteer_preference_field->choices = array(array('text' => 'Section Proctor', 'value' => 'Section Proctor', 'isSelected' => false), array('text' => 'Posting Results', 'value' => 'Posting Results', 'isSelected' => false), array('text' => 'Information Table', 'value' => 'Information Table', 'isSelected' => false), array('text' => 'Greeting and Assisting with Locating Rooms', 'value' => 'Greeting', 'isSelected' => false), array('text' => 'Hospitality (managing food in judges rooms)', 'value' => 'Hospitality', 'isSelected' => false));
    $volunteer_preference_field->description = "Please check 1 time slot if you" . " have 1-3 students competing, 2 time slots if you have 4-6 students" . " competing, and 3 time slots if you have more than 6 students competing.";
    $teacher_form->fields[] = $volunteer_preference_field;
    $volunteer_time_field = new GF_Field_Checkbox();
    $volunteer_time_field->label = "Times Available for Volunteering";
    $volunteer_time_field->id = $field_id_arr['volunteer_time'];
    $volunteer_time_field->isRequired = false;
    $teacher_form->fields[] = $volunteer_time_field;
    $student_name_field = new GF_Field_Name();
    $student_name_field->label = "Student Name";
    $student_name_field->id = $field_id_arr['student_name'];
    $student_name_field->isRequired = true;
    $teacher_form->fields[] = $student_name_field;
    $student_level_field = new GF_Field_Select();
    $student_level_field->label = 'Student Level';
    $student_level_field->id = $field_id_arr['student_level'];
    $student_level_field->isRequired = true;
    $teacher->form->fields[] = $student_level_field;
    $song_one_period_field = new GF_Field_Select();
    $song_one_period_field->label = "Song 1 Period";
    $song_one_period_field->id = $field_id_arr['song_1_period'];
    $song_one_period_field->isRequired = true;
    $teacher->form->fields[] = $song_one_period_field;
    $song_one_composer_field = new GF_Field_Select();
    $song_one_composer_field->label = "Song 1 Composer";
    $song_one_composer_field->id = $field_id_arr['song_1_composer'];
    $song_one_composer_field->isRequired = true;
    $teacher->form->fields[] = $song_one_composer_field;
    $song_one_selection_field = new GF_Field_Select();
    $song_one_selection_field->label = "Song 1 Selection";
    $song_one_selection_field->id = $field_id_arr['song_1_selection'];
    $song_one_selection_field->isRequired = true;
    $teacher->form->fields[] = $song_one_selection_field;
    $song_two_period_field = new GF_Field_Select();
    $song_two_period_field->label = "Song 2 Period";
    $song_two_period_field->id = $field_id_arr['song_2_period'];
    $song_two_period_field->isRequired = true;
    $teacher->form->fields[] = $song_two_period_field;
    $song_two_composer_field = new GF_Field_Select();
    $song_two_composer_field->label = "Song 2 Composer";
    $song_two_composer_field->id = $field_id_arr['song_2_composer'];
    $song_two_composer_field->isRequired = true;
    $teacher->form->fields[] = $song_two_composer_field;
    $song_two_selection_field = new GF_Field_Select();
    $song_two_selection_field->label = "Song 2 Selection";
    $song_two_selection_field->id = $field_id_arr['song_2_selection'];
    $song_two_selection_field->isRequired = true;
    $teacher->form->fields[] = $song_two_selection_field;
    $student_theory_score = new GF_Field_Number();
    $student_theory_score->label = "Theory Score (percentage)";
    $student_theory_score->id = $field_id_arr['theory_score'];
    $student_theory_score->isRequired = false;
    $student_theory_score->numberFormat = "decimal_dot";
    $student_theory_score->rangeMin = 0;
    $student_theory_score->rangeMax = 100;
    $teacher_form->fields[] = $student_theory_score;
    $alternate_theory_field = new GF_Field_Checkbox();
    $alternate_theory_field->label = "Check if alternate theory exam was completed.";
    $alternate_theory_field->id = $field_id_arr['alternate_theory'];
    $alternate_theory_field->isRequired = false;
    $alternate_theory_field->choices = array(array('text' => 'Alternate theory exam completed', 'value' => 'Alternate theory exam completed', 'isSelected' => false));
    $teacher_form->fields[] = $alternate_theory_field;
    $competition_format_field = new GF_Field_Radio();
    $competition_format_field->label = "Format of Competition";
    $competition_format_field->id = $field_id_arr['competition_format'];
    $competition_format_field->isRequired = false;
    $competition_format_field->choices = $volunteer_preference_field->choices = array(array('text' => 'Traditional', 'value' => 'Traditional', 'isSelected' => false), array('text' => 'Competitive', 'value' => 'Competitive', 'isSelected' => false), array('text' => 'Master Class (if upper level)', 'value' => 'Master Class', 'isSelected' => false));
    $teacher_form->fields[] = $competition_format_field;
    $timing_of_pieces_field = new GF_Field_Number();
    $timing_of_pieces_field->label = "Timing of pieces (minutes)";
    $timing_of_pieces_field->id = $field_id_arr['timing_of_pieces'];
    $timing_of_pieces_field->isRequired = false;
    $timing_of_pieces_field->numberFormat = "decimal_dot";
    $teacher_form->fields[] = $timing_of_pieces_field;
    $result = GFAPI::add_form($teacher_form->createFormArray());
    aria_initialize_confirmation($result);
}
Example #3
0
<?php

function aria_teacher_field_id_array()
{
    // CAUTION, This array is used as a source of truth. Changing these values may
    // result in catastrophic failure. If you do not want to feel the bern,
    // consult an aria developer before making changes to this portion of code.
    $arr = array('name' => 1, 'email' => 2, 'phone' => 3, 'volunteer_preference' => 4, 'volunteer_time' => 5, 'student_name' => 6, 'song_1_period' => 7, 'song_1_composer' => 8, 'song_1_selection' => 9, 'song_2_period' => 10, 'song_2_composer' => 11, 'song_2_selection' => 12, 'theory_score' => 13, 'alternate_theory' => 14, 'competition_format' => 15, 'timing_of_pieces' => 16);
    return $arr;
}
function aria_get_music_database_form_id()
{
    $nnmta_music_database_form_name = 'NNMTA Music Database';
    $nnmta_music_database_form_id = NULL;
    $all_active_forms = GFAPI::get_forms();
    foreach ($all_active_forms as $form) {
        if ($form['title'] === $nnmta_music_database_form_name) {
            $nnmta_music_database_form_id = $form['id'];
        }
    }
    if (!isset($nnmta_music_database_form_id)) {
        wp_die('Form ' . $nnmta_music_database_form_name . ' does not exist. Please create it and try again.');
    }
    return $nnmta_music_database_form_id;
}
$arr = aria_teacher_field_id_array();
$data = isset($_POST['data']) ? $arr[$_POST['data']] : '';
$data = aria_get_music_database_form_id();
echo $data;