http://studentmoodle.accelerateu.org/student/portal/studentindex.php?action=staff
I did build into the page logic that presents edit buttons to privileged accounts. This allows my customer to add/update a photo and a brief bio. What the page does not do is allow for the addition or removal of new records. Opps, a little lazy I suppose. Consequently, my customer contacts me with removals, "they do not work for us anymore" and "we just hired so and so".
When it is time to add or remove a teacher, I go to the DB table that is feeding the page and add/remove the records.
This is a look at the table in its DB and the fields that I created in it.
I use a little SQL to create a statement to read this table and then a little PHP to display it on the page.
A little PHP on the view page that outputs the teachers info.
include_once('../config.php');A little SQL to get the teacher recs from DB. $DB is defined and made avail by the moodle framework.
include_once('DAO.php');
$teachers = getTeachers(); //this method is defined in the DAO.php file.
$isadmin = false; //set the condition to false - so no one can see the edit buttons
if(....'some condition that I just removed is true'... ){
$isadmin = true; // update variable
}
$path = 'http://'.$_SERVER['SERVER_NAME'].'/student/portal/pathtophotos.../';
//var_dump($path);
foreach($teachers as $rec){ //loop over records
$rpath = $path.$rec->pic;
echo '<div id="col1">
<img src='.$rpath.' width="150" height="150">'; // set the photo dimensions
if($isadmin){
echo " <br/>
<form action='somepage.php?action=someaction' method='POST'>
<input type='submit' value='Edit'>
<input type='hidden' name='id' value=".$rec->id.">
</form>
";
}
echo '</div>';
echo '<div id="col2">';
echo '<b>'.$rec->fname.' '.$rec->lname.'</b>';
echo '<br/><a href="mailto:'.$rec->email.'">'.$rec->email.'</a>';
echo '<br/>'.$rec->subjects;
echo '<p></p>'.$rec->bio;
echo '<hr>';
echo '</div>';
echo '<div style="clear: both;"></div>';
}//foreach
function getTeachers(){
global $DB;
//echo "test";
return
$DB->get_records_sql('
SELECT id, fname, lname, subjects, email, pic, bio
FROM geniusintegration.teachers
ORDER BY subjects, lname
');
}

No comments:
Post a Comment