/**
 * returns true if the user is teacher in the course
 * 
 * @param type $userid
 * @param type $courseid
 * @return boolean
 */
function isteacherincourse($userid, $courseid)
{
    if (!isuservalid($userid)) {
        return false;
    }
    $cntx = \context_course::instance($courseid);
    $haseditcap = has_capability('moodle/grade:edit', $cntx, $userid);
    if ($haseditcap) {
        return true;
    }
    return false;
}
Example #2
0
<?php

include 'db_connection.php';
include 'db.php';
$my_username = $_POST['reg_uname'];
$my_password = $_POST['reg_password'];
isuservalid($my_username, $my_password);