function check_user_progress($pano_id) { // Check the user's progress before allowing // the user to see the pano $allowed = true; $flag_not_set = true; $accumulated_points = 0; $bonus_points = 0; $total_points = 0; $user_id = get_current_user_id(); // Check if the pano has a prereq $prereqs = get_pano_prereq($pano_id); // if it does make sure the user has completed // enough skills and missions if (count($prereqs) > 0) { if (is_null(v) || $prereqs->prereq_domain_id == 0) { // Get the accumulated points $accumulated_points = get_user_accumulated_points($user_id); // Get the bonus points $bonus_points = get_user_accumulated_bonus_pts($user_id); } else { // Get the accumulated points based on the prereq domain $accumulated_points = get_user_accumulated_points_for_prereq($user_id, $prereqs->prereq_domain_id); // Get the bonus points $bonus_points = get_user_accumulated_bonus_pts_for_prereq($user_id, $prereqs->prereq_domain_id); } $items = get_prereq_items($prereqs->id); $user_items_count = 0; $prereq_items_count = sizeof($items); foreach ($items as $item) { if (check_if_user_has_item(get_current_user_id(), $item->item_id)) { $user_items_count++; } } // Ensures the values are not null $accumulated_points = $accumulated_points ? $accumulated_points : 0; $bonus_points = $bonus_points ? $bonus_points : 0; // Add up the points $total_points = $accumulated_points->points + $bonus_points->bonus_points; // check if they are enough for the prereq if ($total_points > $prereqs->prereq_pts && $user_items_count == $prereq_items_count) { $allowed = true; $flag_not_set = true; } else { if ($flag_not_set) { $allowed = false; $flag_not_set = false; } } } // If they have, return the pano else return default id if ($allowed) { return true; } else { return false; } }
echo $prereq->prereq_pts . " " . $currency . " and the following items:"; ?> </p> <div class="ui form"> <div class="field"> <ul> <?php if ($items_size > 0) { ?> <?php foreach ($items as $item) { ?> <li class="games_form"> <?php if (check_if_user_has_item($user_id, $item->item_id)) { ?> <input id="1" class="cat0" type="checkbox" value="1" name="words[]" checked disabled></input> <?php } else { ?> <input id="1" class="cat0" type="checkbox" value="1" name="words[]" disabled></input> <?php } ?> <label class="cat0" for="1"> <?php echo get_item($item->item_id)->name; ?>