<?php
function ms34_level_dropdown($name, $value = '') {
    ?>
    <select name="<?= $name ?>" class="ms29-level-select">
        <option value="">Select</option>

        <option value="Level 1" <?= ($value === 'Level 1') ? 'selected' : '' ?>>
            Level 1 – Needs a lot of support of teacher and peers.
        </option>

        <option value="Level 2" <?= ($value === 'Level 2') ? 'selected' : '' ?>>
            Level 2 – Able to do with support of teacher/peers.
        </option>

        <option value="Level 3" <?= ($value === 'Level 3') ? 'selected' : '' ?>>
            Level 3 – Able to perform expected skills.
        </option>
    </select>
    <?php
}

function gradeOutOf30($marks)
{
    // percentage with FULL round off
    $percent = round(($marks / 30) * 100);

    if ($percent >= 91) return 'A1';
    elseif ($percent >= 81) return 'A2';
    elseif ($percent >= 71) return 'B1';
    elseif ($percent >= 61) return 'B2';
    elseif ($percent >= 51) return 'C1';
    elseif ($percent >= 41) return 'C2';
    elseif ($percent >= 33) return 'D';
    elseif ($percent >= 21) return 'E1';
    else return 'E2';
}

function gradeOutOf50($marks)
{
    // percentage with FULL round off
    $percent = round(($marks / 50) * 100);

    if ($percent >= 91) return 'A1';
    elseif ($percent >= 81) return 'A2';
    elseif ($percent >= 71) return 'B1';
    elseif ($percent >= 61) return 'B2';
    elseif ($percent >= 51) return 'C1';
    elseif ($percent >= 41) return 'C2';
    elseif ($percent >= 33) return 'D';
    elseif ($percent >= 21) return 'E1';
    else return 'E2';
}