Esempio n. 1
0
     $number_of_saved_categories = count($pool_categories);
     if ($number_of_saved_categories > 0) {
         $return_value = Update_Category_List($pool_categories, $multiple_choice);
         echo $return_value;
     }
 }
 if (isset($_GET['remove_category_choice'])) {
     //if we are removing a given category choice from DB:
     $category_id = $_GET['category_id'];
     $removal_choice = $_GET['remove_category_choice'];
     $pool = new Pool();
     $pool->RemoveCategoryChoice($removal_choice);
     $category_choices = $pool->GetCategoryChoices($category_id);
     $number_categories_choices = count($category_choices);
     if ($number_categories_choices > 0) {
         $return_value = Update_Category_Choice_List($category_choices, $category_id);
         echo $return_value;
     }
 }
 //SUBMIT THE POOL - MAKE IT READY FOR INVITEES
 if (isset($_GET['submit_pool'])) {
     $pool = new Pool();
     $result_array_test = $pool->MakePoolReadyForInvitees($pool_id);
     if ($result_array_test == 0) {
         //IF WE GET A 0 BACK FROM MakePoolReadyForInvitees FUNCTION, IT MEANS POOL IS ALREADY SUBMITTED
         echo "Pool is already submitted!";
         //note, as of 11/13, this text will not be shown anywhere
     } else {
         //IF WE GET A 1 BACK FROM MakePoolReadyForInvitees FUNCTION, IT MEANS POOL WAS NOT PREVIOUSLY READY FOR INVITES
         echo "Pool has been submitted!";
         //note, as of 11/13, this text will not be shown anywhere
function Update_Category_List($pool_categories, $multiple_choice)
{
    $pool = new Pool();
    $category_counter = 1;
    $return_array = array();
    foreach ($pool_categories as $category_id => $category_info) {
        if ($multiple_choice == 1) {
            //if this is a multiple choice pool (NOTE: AS OF 3/26/14, THIS UPDATE_CATEGORY_LIST FUNCTION CANNOT DIFFERENTIATE BETWEEN MC CATEGORIES AND NON MC CATEGORIES FOR THE SAME POOL - I.e., THE MC ARGUMENT IS STATIC ACROSS ALL CATEGORIES)
            $category_choices = $pool->GetCategoryChoices($category_id);
            $choice_list = Update_Category_Choice_List($category_choices, $category_id);
            $choice_return_value = <<<HTML
                <div id="category_choices_container">
                    <h4 class="edit_category_choices_label"> Category Choices: &nbsp; </h4>
                    <div id="category{$category_id}_choice_space">
                        {$choice_list}
                    </div>
                     <div id="new_category{$category_id}_choice_goes_here" class="new_category_choice_goes_here_div">
                        <h4><span id="add_choice_button_for_category_{$category_id}" class="add_category_choice_button"><input type="button" onclick="add_category_choice({$category_id})" value="Add new choice"></span></h4>
                    </div>
                </div> <!--END OF CATEGORY_CHOICE_CONTAINER DIV-->
HTML;
        } else {
            //if given pool is NOT multiple choice, choice_return_value should just be blank
            $choice_return_value = "";
        }
        $return_array[$category_counter] = <<<HTML
            <div id="category_{$category_counter}">
                <div style="margin-left:50px" class="well well-sm"> 
                    <div class="row">
                        <div class="col-md-2">
                            <h4> 
                            \t<span class="category_name_label">Category name: &nbsp; </span>
                            </h4>
                        </div>
                        <div class="col-md-6">
                            <h3>
                                <span class="label label-info"><span class="edit_pool_field" id="category_n_span{$category_info['Category ID']}" style="margin-left:0px; white-space:normal;">{$category_info['Category Name']}</span></span>
                            </h3>
                        </div>
                        <div class="col-md-2">
                            <h4>
                                Point Value: <span class="label label-info">&nbsp;<span class="edit_pool_field" id="category_p_span{$category_info['Category ID']}">&nbsp;{$category_info['Category Point Value']}&nbsp; </span>&nbsp;</span>
                            </h4>  
                        </div>
                        <div class="col-md-2"> 
                            <h5> 
                                <span class="remove_category_button"><input type="button" onclick="remove_category({$category_counter}, {$category_info['Category ID']}, {$multiple_choice})" value=" Remove 
Category"></span>
                            </h5>
                        </div>
                    </div>
                    {$choice_return_value}
                </div>
            </div>
HTML;
        $category_counter++;
    }
    foreach ($return_array as $category_number => $category_html_content) {
        //concatenate each category's html section together into one long string of html text
        $return_value = $return_value . $category_html_content;
    }
    return $return_value;
}