/**
  * Returns an array of available roles
  * @return array of availble roles
  */
 function get_roles() {
     global $DB;
     $myuser = users::getInstance();
     $context = context_system::instance();
     $rs = $DB->get_records_sql("SELECT * FROM {role} WHERE archetype = 'student'");
     $role = array();
     foreach ($rs as $r) {
         $role[$r->id] = ucwords($r->shortname);
     }
     $systemroles = $myuser->systemroles_custom();
     $roles = array(0 => get_string('anyrole', 'filters')) + $systemroles + $role;
     return $roles;
 }
Beispiel #2
0
function user_download_xls($fields) {
    $hier = new hierarchy();
    $schools = $hier->get_assignedschools();

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename('Users.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $sheetrow = 1;
    $myuser = users::getInstance();

    $users = $DB->get_records_sql("SELECT u.id, u.username, u.email, u.firstname, u.lastname, u.city, u.country,
                                            u.lastaccess, u.confirmed, u.mnethostid, u.suspended FROM {user} u, {local_users} lu
                                            WHERE lu.userid = u.id ");

    foreach ($users as $user) {
        $rid = $myuser->get_rolename($user->id);
        $post = new stdclass();
        $post->firstname = $user->firstname;
        $post->lastname = $user->lastname;
        $post->email = $user->email;

        $post->schoolname = $myuser->get_schoolnames($user);
        $post->roleid = $myuser->get_rolename($user->id);
        $col = 0;
        foreach ($fields as $fieldname) {
            $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
            $col++;
        }
        $sheetrow++;
    }

    $workbook->close();
    die;
}
Beispiel #3
0
$currentcss = '/local/courseregistration/css/styles.css';
$PAGE->requires->css($currentcss);
$PAGE->requires->js('/local/courseregistration/js/expand.js');
/* ---check the context level of the user and check weather the user is login to the system or not--- */
$PAGE->set_context($systemcontext);
if ($CFG->forcelogin) {
    require_login();
} else {
    user_accesstime_log();
}
$PAGE->set_url('/local/courseregistration/mycur.php');

/* ---Header and the navigation bar--- */
$PAGE->set_heading($SITE->fullname);
$PAGE->navbar->add(get_string('mycurriculum', 'local_curriculum'));
$users = users::getInstance();
echo $OUTPUT->header();
/* ---Heading of the page--- */
echo $OUTPUT->heading(get_string('mycurriculum', 'local_curriculum'));

/* ---Moodle 2.2 and onwards--- */
$currenttab = 'myplan';
/* ---adding tabs--- */
$exams->studentside_tabs($currenttab);
if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('mycurriculumdec', 'local_curriculum'));
}

// -----used get to cuurent active semesterid--------------------------------
$hier = new hierarchy();
$semesterid = $hier->get_allmyactivesemester($USER->id);
Beispiel #4
0
//require_once($CFG->dirroot . '/local/admission/lib.php');
require_once($CFG->dirroot . '/local/users/user_form.php');
require_once($CFG->dirroot . '/local/costcenter/lib.php');
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->dirroot . '/user/profile/lib.php');
require_once($CFG->libdir . '/gdlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/local/positions/lib.php');

$id = optional_param('id', -1, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$visible = optional_param('visible', -1, PARAM_INT);
$confirm = optional_param('confirm', 0, PARAM_INT);
global $CFG;

$myuser = users::getInstance();
$costcenter = new costcenter();
$conf = new object();

$systemcontext = context_system::instance();
//get the admin layout
$PAGE->set_pagelayout('admin');
//check the context level of the user and check weather the user is login to the system or not
$PAGE->set_context($systemcontext);

require_login();

//if (!has_capability('local/costcenter:manage', $systemcontext)) {
//    print_error('You dont have permissions');
//}
$PAGE->set_url('/local/users/user.php');
Beispiel #5
0
/**
 * @method student_currculum_progress
 * @todo to print student curriculum progress bar
 * @param int $curid curriculum id, int $schoid schoolid
 * @return- print progress bar
 */
function student_currculum_progress($curid, $schoid) {

    global $CFG, $DB, $USER;
    $myuser = users::getInstance();
    $courses = $DB->get_records('local_curriculum_plancourses', array('curriculumid' => $curid));
    $course_count = sizeof($courses);
    $enrolled = 0;
    $completed = 0;
    foreach ($courses as $course) {
        $status = $myuser->get_coursestatus($course->courseid, $USER->id);
        if ($status != 'Not Enrolled') {
            $enrolled++;
            if ($status != 'Enrolled (Inprogress)')
                $completed++;
        }
    }

    $curculum = $DB->get_record('local_curriculum', array('id' => $curid));
    $program = $DB->get_record('local_program', array('id' => $curculum->programid));
    $grades = $DB->get_record('local_cobalt_gpasettings', array('schoolid' => $schoid, 'sub_entityid' => $program->programlevel));
    $cgpa = $DB->get_field('local_graduation', 'finalcgpa', array('userid' => $USER->id, 'schoolid' => $schoid, 'curriculumid' => $curid));
    if (empty($cgpa)) {
        $cgpa = 'Not Graded';
    }
    $totalcredit = $DB->get_field('local_level_settings', 'mincredithours', array('schoolid' => $schoid, 'levelid' => $curculum->programid, 'level' => 'PL'));
    if (empty($totalcredit)) {
        $totalcredit = 'Not Applicable';
    }
    $usercredits = "SELECT sum(totcredithours) as total FROM {local_user_sem_details} WHERE userid={$USER->id} AND curriculumid={$curid}";
    $usercredit = $DB->get_record_sql($usercredits);
    $gpasql = "SELECT * FROM {local_user_sem_details} WHERE userid={$USER->id} AND curriculumid={$curid}";
    $gpaqry = $DB->get_records_sql($gpasql);
    $gpacount = sizeof($gpaqry);
    if ($completed < $enrolled || $enrolled == 0) {
        $one = "<img src='pix/unsuccess.png'>";
    } else {
        $one = "<img src='pix/success.png'>";
    }
    if ($totalcredit <= $usercredit->total) {
        $two = "<img src='pix/success.png'>";
    } else {
        $two = "<img src='pix/unsuccess.png'>";
    }
    /*
     * ###Bugreport#181-Curriculum
     * @author Naveen Kumar<*****@*****.**>
     * (Resolved) checking both empty and less than or equal to cgpa 
     */
    if (round($grades->cgpa) <= $cgpa && !empty($grades->cgpa)) {
        $three = "<img src='pix/success.png'>";
    } else {
        $three = "<img src='pix/unsuccess.png'>";
    }
    
    $string .= html_writer::start_tag('div', array('style'=>'border: 1px solid #E8E8E8; background: #EAEAEA; padding: 10px; width: 97%; margin: 25px 0 25px; font-weight: bold; overflow: auto;'));
    $string .= html_writer::tag('div', $program->fullname, array('style'=>'float: left;'));
    $string .= html_writer::tag('div', $curculum->fullname, array('style'=>'float: right;'));
    $string .= html_writer::end_tag('div');
    
    echo $string;
    
    //========By Vinod for DYPatil
//    $table = new html_table();
//    $table->align = array('left', 'left', 'left', 'left');
//    $table->size = array('20%', '36%', '32%', '12%');
//    $table->width = '100%';
//    $cell = new html_table_cell();
//    $cell->text = 'Graduation will be given if following conditions are met<br> ' . $one . ' Need to complete all enrolled courses in curriculum .<br> ' . $two . ' Credithours should be greater than or equal to required credit hours.<br> 
//		' . $three . ' CGPA achieved is equal or greater than to required CGPA.<br>  ';
//    $cell->colspan = 3;
//    $table->data[] = array('Program Name', '<b>' . $program->fullname . '</b>', 'Total Number of Courses', '<b>' . $course_count . '</b>');
//    $table->data[] = array('Curriculum Name', '<b>' . $curculum->fullname . '</b>', 'Total Number of Enroled Courses', '<b>' . $enrolled . '</b>');
//    $table->data[] = array('Required Credithours', '<b>' . $totalcredit . '</b>', 'Total Number of Completed Courses', '<b>' . $completed . '</b>');
//    $table->data[] = array('Credithours Achieved', '<b>' . $usercredit->total . '</b>', 'Required CGPA', '<b>' . round($grades->cgpa) . '</b>');
//
//    $table->data[] = array('Progress', get_my_progress($USER->id, 0, $curid), 'CGPA Achieved', '<b>' . round($cgpa) . '</b>');
//    $table->data[] = array('Description', $cell);
//
//    echo html_writer::table($table);
}