Example #1
0
echo form_name($form);
?>
          <h4></h4>
        </h3>
        <hr>
        
 <?php 
//if they want to enable the form you must update the basic qualifying questions.
if ($_GET['enable'] == 'enable') {
    update_basic_form($form);
}
//if safety form check for answered questions then give warning
if ($_GET['begin_safety']) {
    $begin_safety = 1;
} else {
    $begin_safety = count_single_form_answered($form, $tax_id);
}
if ($_GET['disabled'] == 'disabled') {
    echo '<div class="alert alert-info">
          <h3>
            This section has been marked as not relevant for your App
          </h3>
          <p>
            This is because you declared that the App can cause no harm to a user,
            even in the case of a fault with the App. If this is not the case then
            you must enable this section and answer the questions.
          </p>
          <div>
            <br>
            <a href="' . get_permalink($post->ID) . '?form=' . $form . '&enable=enable"  class="btn btn-default">Enable this section</a>
          </div>
Example #2
0
function count_questions($app_id, $page)
{
    // first test for what forms need filling out from basic answers
    // get form basic answer results
    if (!$_SESSION['app_id']) {
        $tax_id = $app_id;
    } else {
        $tax_id = $_SESSION['app_id'];
    }
    $answers = get_posts(array('post_type' => 'basic_form', 'numberposts' => -1, 'tax_query' => array(array('taxonomy' => 'app_name', 'field' => 'id', 'terms' => $tax_id))));
    $tax_id = $_SESSION['app_id'];
    // get term slug for overview link
    $term = get_term_by('id', $tax_id, 'app_name');
    //$i is the total questions answered
    // $k is total questions answered or unanswered
    $i = count_single_form_answered('ps_form', $app_id) + count_single_form_answered('qu_form', $app_id) + count_single_form_answered('safety_form', $app_id) + count_single_form_answered('io_form', $app_id) + count_single_form_answered('od_form', $app_id) + count_single_form_answered('eff_form', $app_id) + count_single_form_answered('ts_form', $app_id) + count_single_form_answered('equality_form', $app_id);
    $k = single_form_question_count('ts_form', $app_id) + single_form_question_count('equality_form', $app_id) + single_form_question_count('qu_form', $app_id) + single_form_question_count('eff_form', $app_id);
    //The Safety Form
    if (get_field('basics_q2', $answers[0]->ID) == 'YES') {
        $k = $k + single_form_question_count('safety_form', $app_id);
    }
    //The Interoperability Form
    if (get_field('basics_q4', $answers[0]->ID) == 'YES') {
        $k = $k + single_form_question_count('io_form', $app_id);
    }
    //The Open Data Form
    if (get_field('basics_q5', $answers[0]->ID) == 'YES') {
        $k = $k + single_form_question_count('od_form', $app_id);
    }
    //The Privacy & Security Form
    if (get_field('basics_q3', $answers[0]->ID) == 'YES') {
        $k = $k + single_form_question_count('ps_form', $app_id);
    }
    //echo get_field('basics_q2',  $answers[0]->ID);
    if ($page == 'single-app') {
        echo '<div class="col-md-4"><h3>Your progress:</h3>';
        echo '<h3> ' . $i . ' / ' . $k . '</h3>';
        echo '<div class="progress"><div class="progress-bar" style="width: ' . number_format($i / $k * 100, 0) . '%"></div></div>';
        echo '<a href="/ie-design/app_name/' . $term->slug . '" class="btn btn-primary">See overview</a></div>';
    } elseif ($page == 'all-apps') {
        return $i . ' / ' . $k;
    } elseif ($page == 'total-alert') {
        $level = create_level();
        if ($level == 'f' and $i == $k) {
            echo '<div class="alert alert-danger">
        <h3>
          <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
          This has failed for one or more reasons.
        </h3>
        <p>
          Please review and correct sections before attempting to submit.
        </p>
        <div>
          
        </div>
        <p>
        </p>
      </div>';
        } elseif ($i == $k) {
            echo '<div class="alert alert-success">
        <h3>
          <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
          This assessment is complete and ready to be submitted
        </h3>
        <p>
          You should ensure that the declarations you have made in answering the
          questions are true and complete before submitting this assessment. You
          can revisit the assessment in the future to enhance your scores or to reflect
          changes in your application.
        </p>
        <div>
          <br>
          <div>
            <a href="#" class="btn btn-default">Submit this assessment to be endorsed</a>
            <br>
          </div>
        </div>
        <p>
        </p>
      </div>';
        } elseif ($i < $k) {
            echo ' <div class="alert alert-danger">
        <h3>
          <i class="fa fa-exclamation-circle"></i>
          This assessment is incomplete so can not be submitted for endorsement
        </h3>
        <p>
          Check the essential items to resolve list below - everything here must
          be completed before you can submit you application for endorsement.
        </p>
      </div>
';
        }
    } elseif ($page == 'total-pass-fail') {
        if ($i == $k) {
            return '<span class="label label-success">Completed</span>';
        } elseif ($i < $k) {
            return '<span class="label label-info">In progress</span>';
        }
    } else {
        echo 'there was a counting error';
    }
}