<?php

get_header();
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
// if(!isset($_SESSION['app_id'])) {
$_SESSION['app_id'] = $term->term_id;
//	 }
?>
 <?php 
// check all forms for level of pass fail take lowest common and create.
$type = create_level();
switch ($type) {
    case "f":
        $failed = 'alert-danger';
        $text = "Failed";
        break;
    case "i":
        $incomplete = 'alert-warning';
        $text = "Unacceptable";
        break;
    case "b":
        $basic = 'alert-info';
        break;
    case "e":
        $enhanced = 'alert-info';
        break;
    case "bp":
        $best = 'alert-info';
        break;
}
?>
示例#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';
    }
}