Exemplo n.º 1
0
function inCurrentCourse($moodleId)
{
    //  Checks to see if the currently logged in student is in courses that are in the current term.
    global $CFG;
    $moodledb = mysql_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass);
    if (!$moodledb) {
        die('Could not connect to moodle: ' . mysql_error());
    }
    mysql_select_db($CFG->dbname, $moodledb);
    $filter = getCurrentCourseFilter();
    $query = 'select 
			*
			from mdl_user_enrolments ue
			join mdl_enrol e on ue.enrolid = e.id
			join mdl_course c on c.id = e.courseid
			where c.shortname like "' . $filter . '"
			and ue.userid = ' . $moodleId . ';';
    //echo $query;
    $res = mysql_query($query);
    $num = mysql_num_rows($res);
    mysql_close();
    if ($num > 0) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 2
0
function checkSurveyStatus($stdid)
{
    // Checks to see if the current user has alreay completed the survey for the semester.
    global $LIME;
    $lime = mysql_connect($LIME->dbhost, $LIME->dbuser, $LIME->dbpass);
    if (!$lime) {
        die('Could not connect: ' . mysql_error());
    }
    $query = 'select * from lime_survey_' . $LIME->surveyid . ' where ((' . $LIME->surveyid . 'X' . $LIME->surveygroup . 'X' . $LIME->surveyquestion . ' = "' . $stdid . '") and (submitdate is not null));';
    mysql_select_db($LIME->db, $lime);
    $res = mysql_query($query);
    $num = mysql_num_rows($res);
    mysql_close();
    if ($num == 0) {
        if ($stdid != "") {
            $tc = getCurrentCourseFilter();
            $tc = substr($tc, 2);
            $json = '{ "studentid":"' . $stdid . '","termcode":"' . $tc . '"}';
            $result = $json;
        } else {
            $result = "0";
        }
    } else {
        $result = "0";
    }
    return $result;
}