コード例 #1
0
    if (empty($groupexists)) {
        $group_id = 0;
    } else {
        $groupincourse = groups_get_group_by_name($course_id, $groupexists->name);
        if (empty($groupincourse)) {
            $group_id = 0;
        }
    }
    $pagetitle = $course->shortname;
    if (stripos($CFG->release, "2.") !== false) {
        $ucourses = enrol_get_users_courses($USER->id, false, NULL, 'shortname ASC');
    } else {
        $ucourses = $dbc->get_user_courses($USER->id);
    }
    $user_courses = array();
    foreach ($ucourses as $uc) {
        $coursecontext = get_context_instance(CONTEXT_COURSE, $uc->id);
        //if the user has the capability to view the course then add it to the array
        if (has_capability('block/ilp:viewotherilp', $coursecontext, $USER->id, false)) {
            $user_courses[] = $uc;
        }
    }
} else {
    //get the list of tutees for this user
    $student = $dbc->get_user_tutees($USER->id);
    $pagetitle = get_string('mytutees', 'block_ilp');
}
$status_items = $dbc->get_status_items(ILP_DEFAULT_USERSTATUS_RECORD);
$baseurl = $CFG->wwwroot . "/blocks/ilp/actions/view_studentlist.php";
//require the view_studentlist.html page
require_once $CFG->dirroot . '/blocks/ilp/views/view_studentlist.html';
コード例 #2
0
$flextable->collapsible(true);
//define the columns and the headers in the flextable
$flextable->define_columns($columns);
$flextable->define_headers($headers);
$flextable->column_nosort = $nosorting;
$flextable->sortable(true, 'lastname', 'DESC');
$flextable->set_attribute('summary', get_string('studentslist', 'block_ilp'));
$flextable->set_attribute('cellspacing', '0');
$flextable->set_attribute('class', 'generaltable fit');
$flextable->set_attribute('id', "student_listcourse_id={$course_id}tutor={$tutor}status_id={$status_id}");
$flextable->initialbars(true);
$flextable->setup();
if (!empty($course_id)) {
    $users = $dbc->get_course_users($course_id, $group_id);
} else {
    $users = $dbc->get_user_tutees($USER->id);
}
$students = array();
foreach ($users as $u) {
    $students[] = $u->id;
}
$notstatus_ids = false;
if (!empty($status_id)) {
    $defaultstatusid = get_config('block_ilp', 'defaultstatusitem');
    if ($defaultstatusid == $status_id) {
        $notstatus_ids = true;
    }
}
//we only want to get the student matrix if students have been provided
$studentslist = !empty($students) ? $dbc->get_students_matrix($flextable, $students, $status_id, $notstatus_ids) : false;
//get the default status item which will be used as the status for students who
コード例 #3
0
 /**
  * Sets up the content for the block.
  *
  * @return object The content object
  */
 function get_content()
 {
     global $CFG, $USER, $COURSE, $SITE;
     // include  db class
     require_once $CFG->dirroot . '/blocks/ilp/db/ilp_db.php';
     // include the parser class
     require_once $CFG->dirroot . '/blocks/ilp/classes/ilp_parser.class.php';
     // include the lib file
     require_once $CFG->dirroot . '/blocks/ilp/lib.php';
     // db class manager
     $dbc = new ilp_db();
     // get the course id
     $course_id = optional_param('id', $SITE->id, PARAM_INT);
     //this is to handle the /user/view.php page where id is reserved for the userid ...
     //allow the current course to be course=XX
     $current_course_id = optional_param('course', null, PARAM_INT);
     if (!$current_course_id) {
         $current_course_id = optional_param('id', null, PARAM_INT);
         //if there's no explicit course id, id might be a course id
     }
     // get the course
     $course = $dbc->get_course($course_id);
     // cache the content of the block
     if ($this->content !== null) {
         return $this->content;
     }
     //get all course that the current user is enrolled in
     $my_courses = $dbc->get_user_courses($USER->id);
     $access_viewilp = false;
     $access_viewotherilp = false;
     if (empty($my_courses)) {
         $c = new stdClass();
         $c->id = $course_id;
         $my_courses = array($c);
     }
     //we are going to loop through all the courses the user is enrolled in so that we can
     //choose which display they will see
     $found_current_course = false;
     foreach ($my_courses as $c) {
         $sitecontext = get_context_instance(CONTEXT_SYSTEM);
         $coursecontext = get_context_instance(CONTEXT_COURSE, $c->id);
         $set_course_groups_link = false;
         //we need to get the capabilites of the current user so we can deceide what to display in the block
         if (has_capability('block/ilp:viewilp', $coursecontext, $USER->id, false)) {
             $access_viewilp = true;
             //I have removed the var below as we dont want the my course groups link to contain
             //the id of a  course which the user is not a teacher in
             //$set_course_groups_link = true;
         }
         if (has_capability('block/ilp:viewotherilp', $coursecontext, $USER->id, false) || has_capability('block/ilp:ilpviewall', $sitecontext, $USER->id, false) || is_siteadmin($USER)) {
             $access_viewotherilp = true;
             $set_course_groups_link = true;
         }
         if ($set_course_groups_link) {
             if (!$found_current_course) {
                 $intial_course_id = $c->id;
                 if ($c->id == $current_course_id) {
                     //current course is part of my_courses, so this should be the preselection for the linked page
                     //so stop changing the value for the link
                     $found_current_course = true;
                 }
             }
         }
     }
     //
     $usertutees = $dbc->get_user_tutees($USER->id);
     $this->content = new stdClass();
     $this->content->footer = '';
     //check if the user has the viewotherilp capability
     if (!empty($access_viewotherilp) || !empty($usertutees)) {
         if (!empty($access_viewotherilp)) {
             $label = get_string('mycoursegroups', 'block_ilp');
             $url = "{$CFG->wwwroot}/blocks/ilp/actions/view_studentlist.php?tutor=0&course_id={$intial_course_id}";
             $this->content->items[] = "<a href='{$url}'>{$label}</a>";
             $this->content->icons[] = "";
         }
         if (!empty($usertutees)) {
             $label = get_string('mytutees', 'block_ilp');
             $url = "{$CFG->wwwroot}/blocks/ilp/actions/view_studentlist.php?tutor=1&course_id=0";
             $this->content->items[] = "<a href='{$url}'>{$label}</a>";
             $this->content->icons[] = "";
         }
     } else {
         //---
         //TODO all code for implementing percentage bars in the block is below it has been commented out so that it can be
         //implemented correctly
         /*
         			$percentagebars	=	array();
         
         			
         			//include the attendance 
         			$misclassfile	=	$CFG->dirroot.'/blocks/ilp/classes/dashboard/mis/ilp_mis_attendance_percentbar_plugin.php';
         			
         			if (file_exists($misclassfile)) {
         				
         				$pbstatus	=	get_config('block_ilp','ilp_mis_attendance_percentbar_plugin_pluginstatus');
         				
         				if ($pbstatus == ILP_ENABLED) {
         						//create an instance of the MIS class
         						$misclass	=	new ilp_mis_attendance_percentbar_plugin();
         						
         						//set the data for the student in question
         						$misclass->set_data($USER->idnumber);
         						
         						
         						$punch_method1 = array($misclass, 'get_student_punchuality');
         						$attend_method1 = array($misclass, 'get_student_attendance');
         		
         		        
         							        //check whether the necessary functions have been defined
         				        if (is_callable($punch_method1,true)) {
         				        	$misinfo	=	new stdClass();
         			    	        
         		
         			    	        if ($misclass->get_student_punctuality() != false) {
         				    	        //calculate the percentage
         				    	        
         				    	        $misinfo->percentage	=	$misclass->get_student_punctuality();	
         			    	        
         			    		        $misinfo->name	=	get_string('punctuality','block_ilp');
         			    	        	
         			    		        //pass the object to the percentage bars array
         			    	    	    $percentagebars[]	=	$misinfo;
         			    	        }
         			        	}
         		
         						//check whether the necessary functions have been defined
         				        if (is_callable($attend_method1,true) ) {
         				        	$misinfo	=	new stdClass();
         			    	        
         			    	        //if total_possible is empty then there will be nothing to report
         				        	if ($misclass->get_student_attendance() != false) {
         			    	        	//calculate the percentage
         			    	        	$misinfo->percentage	=	$misclass->get_student_attendance();
         			    	        
         			    	        	$misinfo->name	=	get_string('attendance','block_ilp');
         		
         			    	        	$percentagebars[]	=	$misinfo;
         			    	        }
         			    	        
         			        	}
         				}
         
         			}
         
         			
         			$misoverviewplugins	=	false;
         
         			if ($dbc->get_mis_plugins() !== false) {
         				
         				$misoverviewplugins	=	array();
         				
         				//get all plugins that mis plugins
         				$plugins = $CFG->dirroot.'/blocks/ilp/classes/dashboard/mis';
         				
         				$mis_plugins = ilp_records_to_menu($dbc->get_mis_plugins(), 'id', 'name');
         				
         				foreach ($mis_plugins as $plugin_file) {
         					
         				    require_once($plugins.'/'.$plugin_file.".php");
         				    
         				    // instantiate the object
         				    $class = basename($plugin_file, ".php");
         				    $pluginobj = new $class();
         				    $method = array($pluginobj, 'plugin_type');
         					
         				    if (is_callable($method,true)) {
         				    	//we only want mis plugins that are of type overview 
         				        if ($pluginobj->plugin_type() == 'overview') {
         				        	
         				        	//get the actual overview plugin
         				        	$misplug	=	$dbc->get_mis_plugin_by_name($plugin_file);
         				        	
         				        	//if the admin of the moodle has done there job properly then only one overview mis plugin will be enabled 
         				        	//otherwise there may be more and they will all be displayed 
         				        	
         				        	$status =	get_config('block_ilp',$plugin_file.'_pluginstatus');
         				        	
         				        	$status	=	(!empty($status)) ?  $status: ILP_DISABLED;
         				        	
         				        	if (!empty($misplug) & $status == ILP_ENABLED ) {
         								$misoverviewplugins[]	=	$pluginobj;
         				        	}
         				        }
         				    }
         			
         				}
         			}
         
         			
                 	//if the user has the capability to view others ilp and this ilp is not there own 
         			//then they may change the students status otherwise they can only view 
         			
         			//get all enabled reports in this ilp
         			$reports		=	$dbc->get_reports(ILP_ENABLED);
         			
         			
         			//we are going to output the add any reports that have state fields to the percentagebar array 
         			foreach ($reports as $r) {
         				if ($dbc->has_plugin_field($r->id,'ilp_element_plugin_state')) {
         
         					$reportinfo				=	new stdClass();
         					$reportinfo->total		=	$dbc->count_report_entries($r->id,$USER->id);
         					$reportinfo->actual		=	$dbc->count_report_entries_with_state($r->id,$USER->id,ILP_STATE_PASS);
         					
         					 //if total_possible is empty then there will be nothing to report
         	    	        if (!empty($reportinfo->total)) {
         	    	        	//calculate the percentage
         	    	        	$reportinfo->percentage	=	$reportinfo->actual/$reportinfo->total	* 100;
         	    	        
         	    	        	$reportinfo->name	=	$r->name;
         
         	    	        	$percentagebars[]	=	$reportinfo;
         	    	        }
         					
         				}
         			}
         			
         			require_once($CFG->dirroot.'/blocks/ilp/classes/ilp_percentage_bar.class.php');
         			
         			$pbar	=	new ilp_percentage_bar();
         			
         			
                 	
                 	if (!empty($percentagebars)) {  
         					foreach($percentagebars	as $p) {
                  				$this->content->items[]	=	$pbar->display_bar($p->percentage,$p->name);
                  			}
                 	}
         */
         //additional check to stop users from being able to access the ilp in course context
         //from the front page
         $courseurl = !empty($course_id) && $course_id != 1 ? "&course_id={$course_id}" : '';
         $this->content->text = "";
         $label = get_string('mypersonallearningplan', 'block_ilp');
         $url = "{$CFG->wwwroot}/blocks/ilp/actions/view_main.php?user_id={$USER->id}{$courseurl}";
         $this->content->items[] = "<p><a href='{$url}'>{$label}</a><p/>";
         $this->content->icons[] = "";
     }
     return $this->content;
 }