diff -Naurw moodle-clean/moodle/user/tabs.php moodle-dev/user/tabs.php
--- moodle-clean/moodle/user/tabs.php 2008-04-19 01:15:49.000000000 +0100
+++ moodle-dev/user/tabs.php 2009-05-12 12:33:45.000000000 +0100
@@ -97,6 +97,19 @@
$toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id, get_string('profile'));
}
+ if((((has_capability('gradereport/user:view', $personalcontext) and $user->id==$USER->id) or has_capability('gradereport/allgrade:view', $personalcontext)))or(((has_capability('mod/attforblock:view', $personalcontext) and $user->id==$USER->id) or (has_capability('mod/attforblock:viewreports', $personalcontext))))or((has_capability('mod/termreview:view', $systemcontext) and $user->id==$USER->id) or has_capability('mod/termreview:viewall', $systemcontext))) {
+ $toprow[] = new tabobject('tutor', $CFG->wwwroot.'/course/user.php?id=1&mode=allgrade&user='.$user->id,get_string('tutor'));
+ if (($currenttab=='allgrade')or($currenttab=='allatt')or($currenttab=='termreview')){
+ $inactive = array('tutor');
+ $activetwo = array('tutor');
+
+ $secondrow = array();
+ if (((has_capability('gradereport/user:view', $personalcontext) and $user->id==$USER->id) or has_capability('gradereport/allgrade:view', $personalcontext))) $secondrow[] = new tabobject('allgrade', $CFG->wwwroot.'/course/user.php?id=1&mode=allgrade&user='.$user->id, get_string('allgrade'));
+ if (((has_capability('mod/attforblock:view', $personalcontext) and $user->id==$USER->id) or (has_capability('mod/attforblock:viewreports', $personalcontext)))) $secondrow[] = new tabobject('allatt', $CFG->wwwroot.'/course/user.php?id=1&mode=allatt&user='.$user->id, get_string('allatt'));
+ if ((has_capability('mod/termreview:view', $systemcontext) and $user->id==$USER->id) or has_capability('mod/termreview:viewall', $systemcontext)) $secondrow[] = new tabobject('termreview', $CFG->wwwroot.'/course/user.php?id=1&mode=termreview&user='.$user->id, get_string('termreview'));
+ }
+
+ }
/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
diff -Naurw moodle-clean/moodle/course/user.php moodle-dev/course/user.php
--- moodle-clean/moodle/course/user.php 2008-04-03 01:14:16.000000000 +0100
+++ moodle-dev/course/user.php 2009-05-12 12:35:50.000000000 +0100
@@ -12,6 +12,7 @@
$mode = optional_param('mode', "todaylogs", PARAM_ALPHA);
$page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', 100, PARAM_INT);
+ $termreview = optional_param('termreview',0,PARAM_INT);
if (! $course = get_record("course", "id", $id)) {
error("Course id is incorrect.");
@@ -26,11 +27,15 @@
$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
+ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
// if in either context, we can read report, then we can proceed
if (!(has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext))) {
+ //permission for these is checked specifically later
+ if($mode!='allatt' and $mode !='allgrade' and $mode !='termreview'){
error("You are not allowed to look at this page");
}
+ }
add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
@@ -69,6 +74,33 @@
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
switch ($mode) {
+ case 'termreview';
+ if ((has_capability('mod/termreview:view', $systemcontext) and $user->id==$USER->id) or has_capability('mod/termreview:viewall', $systemcontext)){
+ require_once $CFG->dirroot.'/mod/termreview/usertab.php';
+ }else{
+ error("You are not allowed to look at this page (termreview)");
+ }
+
+ break;
+ case "allgrade":
+ if (((has_capability('gradereport/user:view', $usercontext) and $user->id==$USER->id) or has_capability('gradereport/allgrade:view', $usercontext))){
+ require_once $CFG->dirroot.'/grade/lib.php';
+ require_once $CFG->dirroot.'/grade/report/allgrade/lib.php';
+ grade_report_user_profilereport_allgrade($user);
+ }else{
+ error("You are not allowed to look at this page (allgrade)");
+ }
+ break;
+
+ case "allatt":
+ if (((has_capability('mod/attforblock:view', $usercontext) and $user->id==$USER->id) or (has_capability('mod/attforblock:viewreports', $usercontext)))){
+ echo "
Please bear in mind that these marks are only updated once a day so changes will take a day to appear
";
+ require_once $CFG->dirroot.'/mod/attforblock/allattlib.php';
+ print_all_user_attendaces($user);
+ }else{
+ error("You are not allowed to look at this page (allatt)");
+ }
+ break;
case "grade":
if (empty($CFG->grade_profilereport) or !file_exists($CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php')) {
$CFG->grade_profilereport = 'user';
diff -Naurw moodle-clean/moodle/grade/report/allgrade/lib.php moodle-dev/grade/report/allgrade/lib.php
--- moodle-clean/moodle/grade/report/allgrade/lib.php 1970-01-01 01:00:00.000000000 +0100
+++ moodle-dev/grade/report/allgrade/lib.php 2009-01-29 12:47:19.000000000 +0000
@@ -0,0 +1,402 @@
+dirroot . '/grade/report/lib.php');
+require_once($CFG->libdir.'/tablelib.php');
+
+/**
+ * Class providing an API for the user report building and displaying.
+ * @uses grade_report
+ * @package gradebook
+ */
+class grade_report_user_allgrade extends grade_report {
+
+ /**
+ * The user.
+ * @var object $user
+ */
+ var $user;
+
+ /**
+ * A flexitable to hold the data.
+ * @var object $table
+ */
+ var $table;
+
+ /**
+ * Flat structure similar to grade tree
+ */
+ var $gseq;
+
+ /**
+ * show student ranks
+ */
+ var $showrank;
+
+ /**
+ * Show hidden items even when user does not have required cap
+ */
+ var $showhiddenitems;
+
+ /**
+ * Constructor. Sets local copies of user preferences and initialises grade_tree.
+ * @param int $courseid
+ * @param object $gpr grade plugin return tracking object
+ * @param string $context
+ * @param int $userid The id of the user
+ */
+ function grade_report_user_allgrade($userid) {
+
+global $USER;
+global $CFG;
+
+$this->setup_table();
+// print the page
+echo ''; // css fix to share styles with real report page
+// print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
+
+if ($mycourses = get_my_courses($userid, null, null, false, 21)) {
+
+ print_course_totals($userid);
+
+
+
+ foreach ($mycourses as $mycourse) {
+
+ //if the user has permission to be marking in the course, and the viewer has permission to view gradebooks, display link to gradebook
+
+ $coursecontext=get_context_instance(CONTEXT_COURSE,$mycourse->id);
+ if (has_capability('gradereport/grader:view',$coursecontext,$USER->id) and has_capability('moodle/grade:edit',$coursecontext,$userid)){
+ echo '
';
+ }
+
+ $course = get_record('course', 'id', $mycourse->id);
+ $courseid = $course->id;
+ if (!empty($course->showgrades)) {
+
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ //first make sure we have proper final grades - this must be done before constructing of the grade tree
+ grade_regrade_final_grades($course->id);
+ /// return tracking object
+ //$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$user->id));
+ $gpr='';
+ global $CFG;
+ parent::grade_report($courseid, $gpr, $context);
+
+ $this->showrank = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
+ $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
+
+ $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
+
+ // Grab the grade_seq for this course
+ $this->gseq = new grade_seq($this->courseid, $switch);
+
+ // get the user (for full name)
+ $this->user = get_record('user', 'id', $userid);
+
+ // base url for sorting by first/last name
+ $this->baseurl = $CFG->wwwroot.'/grade/report?id='.$courseid.'&userid='.$userid;
+ $this->pbarurl = $this->baseurl;
+
+
+
+
+ $this->fill_table();
+ }
+ }
+echo $this->print_table(true);
+echo '
';
+ }
+
+
+
+ // no groups on this report - rank is from all course users
+
+ }
+
+
+
+ /**
+ * Prepares the headers and attributes of the flexitable.
+ */
+ function setup_table() {
+ global $CFG;
+ /*
+ * Table has 5-6 columns
+ *| itemname/description | final grade | percentage final grade | rank (optional) | feedback |
+ * HAVE REMOVED PERCENTAGE COLUMN- percentage of 1 is pointless
+ */
+
+ // setting up table headers
+ if ($this->showrank) {
+ // TODO: this is broken if hidden grades present!!
+ $tablecolumns = array('itemname', 'course', 'grade', /*'percentage',*/ 'rank', 'feedback');
+ $tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('course'), $this->get_lang_string('grade'),
+ /*$this->get_lang_string('percent', 'grades'),*/ $this->get_lang_string('rank', 'grades'),
+ $this->get_lang_string('feedback'));
+ } else {
+ $tablecolumns = array('itemname', 'course', 'grade', /*'percentage',*/ 'feedback');
+ $tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('course'), $this->get_lang_string('grade'),
+ /*$this->get_lang_string('percent', 'grades'),*/ $this->get_lang_string('feedback'));
+ }
+
+ $this->table = new flexible_table('grade-report-user-'.$this->courseid);
+
+ $this->table->define_columns($tablecolumns);
+ $this->table->define_headers($tableheaders);
+ $this->table->define_baseurl($this->baseurl);
+
+ $this->table->set_attribute('cellspacing', '0');
+ $this->table->set_attribute('id', 'user-grade');
+ $this->table->set_attribute('class', 'boxaligncenter generaltable');
+
+ // not sure tables should be sortable or not, because if we allow it then sorted results distort grade category structure and sortorder
+ $this->table->set_control_variables(array(
+ TABLE_VAR_SORT => 'ssort',
+ TABLE_VAR_HIDE => 'shide',
+ TABLE_VAR_SHOW => 'sshow',
+ TABLE_VAR_IFIRST => 'sifirst',
+ TABLE_VAR_ILAST => 'silast',
+ TABLE_VAR_PAGE => 'spage'
+ ));
+
+ $this->table->setup();
+ }
+
+
+
+ /**
+ * Prints or returns the HTML from the flexitable.
+ * @param bool $return Whether or not to return the data instead of printing it directly.
+ * @return string
+ */
+ function print_table($return=false) {
+ ob_start();
+ $this->table->print_html();
+ $html = ob_get_clean();
+ if ($return) {
+ return $html;
+ } else {
+ echo $html;
+ }
+ }
+
+
+
+ function fill_table() {
+ global $CFG;
+ $numusers = $this->get_numusers(false); // total course users
+ $items =& $this->gseq->items;
+ $grades = array();
+
+ $canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->courseid));
+
+ // fetch or create all grades
+ foreach ($items as $key=>$unused) {
+ if (!$grade_grade = grade_grade::fetch(array('itemid'=>$items[$key]->id, 'userid'=>$this->user->id))) {
+ $grade_grade = new grade_grade();
+ $grade_grade->userid = $this->user->id;
+ $grade_grade->itemid = $items[$key]->id;
+ }
+ $grades[$key] = $grade_grade;
+ $grades[$key]->grade_item =& $items[$key];
+ }
+
+ if ($canviewhidden) {
+ $altered = array();
+ $unknown = array();
+ } else {
+ $hiding_affected = grade_grade::get_hiding_affected($grades, $items);
+ $altered = $hiding_affected['altered'];
+ $unknown = $hiding_affected['unknown'];
+ unset($hiding_affected);
+ }
+
+ foreach ($items as $itemid=>$unused) {
+ $grade_item =& $items[$itemid];
+ $grade_grade =& $grades[$itemid];
+
+ if (!$canviewhidden and $grade_item->is_hidden()) {
+ if ($this->showhiddenitems == 0) {
+ // no hidden items at all
+ continue;
+ } else if ($this->showhiddenitems == 1 and !$grade_item->is_hiddenuntil()) {
+ // hidden until that are still hidden are visible
+ continue;
+ }
+ }
+
+ $class = 'gradeitem';
+ if ($grade_item->is_course_item()) {
+ $class = 'courseitem';
+ } else if ($grade_item->is_category_item()) {
+ $class = 'categoryitem';
+ }
+
+ if (in_array($itemid, $unknown)) {
+ $gradeval = null;
+ } else if (array_key_exists($itemid, $altered)) {
+ $gradeval = $altered[$itemid];
+ } else {
+ $gradeval = $grade_grade->finalgrade;
+ }
+
+ $data = array();
+
+ // all users should know which items are still hidden
+ $hidden = '';
+ if ($grade_item->is_hidden()) {
+ $hidden = ' hidden ';
+ }
+
+ $element = $this->gseq->locate_element($this->gseq->get_item_eid($grade_item));
+ $header = $this->gseq->get_element_header($element, true, true, true);
+
+ //No need to continue with category totals
+ if($grade_item->itemtype == 'category' ){
+ continue;
+ }
+
+
+ /// prints grade item name
+ $data[] = ''.$header.'';
+
+ /// prints course
+ $course=get_record('course','id',$grade_item->courseid);
+ $data[] = ''.$course->fullname.'';
+
+ $hidden = '';
+ if ($grade_item->is_hidden()) {
+ // can not see grades in hidden items
+ $hidden = ' hidden ';
+ } else if ($canviewhidden and $grade_grade->is_hidden()) {
+ // if user can see hidden grades, indicate which ones are hidden
+ $hidden = ' hidden ';
+ }
+
+ /// prints the grade
+ if ($grade_grade->is_excluded()) {
+ $excluded = get_string('excluded', 'grades').' ';
+ } else {
+ $excluded = '';
+ }
+
+ if ($grade_item->needsupdate) {
+ $data[] = ''.get_string('error').'';
+
+ } else if (!empty($CFG->grade_hiddenasdate) and $grade_grade->get_datesubmitted() and !$canviewhidden and $grade_grade->is_hidden()
+ and !$grade_item->is_category_item() and !$grade_item->is_course_item()) {
+ // the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
+ $data[] = ''.$excluded.get_string('submittedon', 'grades', userdate($grade_grade->get_datesubmitted(), get_string('strftimedatetimeshort'))).'';
+
+ } else {
+ $data[] = ''.$excluded.grade_format_gradevalue($gradeval, $grade_item, true).'';
+ }
+
+
+
+ /// prints percentage
+/* Percentage of 1 is a silly column
+ if ($grade_item->needsupdate) {
+ $data[] = ''.get_string('error').'';
+
+ } else {
+ $data[] = ''.grade_format_gradevalue($gradeval, $grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE).'';
+ }
+*/
+
+
+
+ /// prints feedback
+ if (empty($grade_grade->feedback) or (!$canviewhidden and $grade_grade->is_hidden())) {
+ $data[] = '
';
+
+ } else {
+ $data[] = ''.format_text($grade_grade->feedback, $grade_grade->feedbackformat).'
';
+ }
+
+ $this->table->add_data($data);
+ }
+ return true;
+ }
+
+
+
+}
+
+/*function grade_report_user_settings_definition(&$mform) {
+ global $CFG;
+
+ $options = array(-1 => get_string('default', 'grades'),
+ 0 => get_string('hide'),
+ 1 => get_string('show'));
+
+ if (empty($CFG->grade_report_user_showrank)) {
+ $options[-1] = get_string('defaultprev', 'grades', $options[0]);
+ } else {
+ $options[-1] = get_string('defaultprev', 'grades', $options[1]);
+ }
+
+ $mform->addElement('select', 'report_user_showrank', get_string('showrank', 'grades'), $options);
+ $mform->setHelpButton('report_user_showrank', array('showrank', get_string('showrank', 'grades'), 'grade'));
+
+ $options = array(-1 => get_string('default', 'grades'),
+ 0 => get_string('hide'),
+ 1 => get_string('showhiddenuntilonly', 'grades'),
+ 2 => get_string('show'));
+
+ if (empty($CFG->grade_report_user_showhiddenitems)) {
+ $options[-1] = get_string('defaultprev', 'grades', $options[0]);
+ } else {
+ $options[-1] = get_string('defaultprev', 'grades', $options[1]);
+ }
+
+ $mform->addElement('select', 'report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), $options);
+ $mform->setHelpButton('report_user_showhiddenitems', array('showhiddenitems', get_string('showhiddenitems', 'grades'), 'grade'));
+}*/
+
+
+
+function grade_report_user_profilereport_allgrade($user) {
+ $report = new grade_report_user_allgrade($user->id);
+}
+
+function print_course_totals($user){
+ $sql = "select fullname,userid,finalgrade,courseid from mdl_grade_grades join mdl_grade_items on mdl_grade_grades.itemid=mdl_grade_items.id join mdl_course on mdl_course.id=courseid where itemtype='course' and !isnull(finalgrade) and userid=$user";
+ if ($records = get_records_sql($sql)) {
+ echo '';
+ foreach ($records as $record) {
+ // do something with $record
+ echo "$record->fullname | ".intval(100 * $record->finalgrade)."% |
";
+ }
+ echo'
';
+ }
+}
+
+?>
diff -Naurw moodle-clean/moodle/mod/attforblock/allattlib.php moodle-dev/mod/attforblock/allattlib.php
--- moodle-clean/moodle/mod/attforblock/allattlib.php 1970-01-01 01:00:00.000000000 +0100
+++ moodle-dev/mod/attforblock/allattlib.php 2008-11-25 10:01:56.000000000 +0000
@@ -0,0 +1,45 @@
+dirroot.'/mod/attforblock/locallib.php';
+
+function print_all_user_attendaces($user) {
+ global $CFG;
+
+ if ($mycourses = get_my_courses($user->id, null, null, false, 21)) {
+ echo'';
+ foreach ($mycourses as $course) {
+ $cm = get_record("course_modules", "id", $course->id);
+ $att = array_pop(get_all_instances_in_course('attforblock', $course, NULL, true));
+
+ //get attendance taken days for this course
+ $complete = count_records_select('attendance_sessions', "courseid = $course->id AND sessdate >= $course->startdate AND takenby != 0");
+ if(!($complete == 0)and($tutor==FALSE)) {
+ $percent = sprintf("%0.2f", get_percent($user->id, $course)).' %';
+
+
+ echo ''.$course->fullname.' ';
+
+ echo "$percent ";
+
+ //print each type of mark and how many of each type
+ $settings = get_settings($course->id);
+ foreach($settings as $set) {
+ echo $set->description.': ', ''.get_attendance($user->id, $course, $set->status).' ';
+ }
+ echo' | ';
+
+
+
+
+
+
+ }
+ }
+ echo'
';
+ }
+}
+
+
+
+
+?>
diff -Naurw moodle-clean/moodle/lang/en_utf8/moodle.php moodle-dev/lang/en_utf8/moodle.php
--- moodle-clean/moodle/lang/en_utf8/moodle.php 2009-04-23 13:32:15.000000000 +0100
+++ moodle-dev/lang/en_utf8/moodle.php 2008-11-17 11:05:30.000000000 +0000
@@ -91,6 +91,7 @@
$string['ajaxuse'] = 'AJAX and Javascript';
$string['ajaxyes'] = 'Yes: use advanced web features';
$string['all'] = 'All';
+$string['allatt'] = 'All Attendance';
$string['allactions'] = 'All actions';
$string['allactivities'] = 'All activities';
$string['allchanges'] = 'All changes';
@@ -704,6 +705,7 @@
See the Moodle License information page for full details:
http://docs.moodle.org/en/License';
$string['grade'] = 'Grade';
+$string['allgrade'] = 'All Grades';
$string['grades'] = 'Grades';
$string['group'] = 'Group';
$string['groupadd'] = 'Add new group';
@@ -1467,6 +1469,7 @@
$string['teacheronly'] = 'for the $a only';
$string['teacherroles'] = '$a roles';
$string['teachers'] = 'Teachers';
+$string['termreview'] = 'Term Reviews';
$string['textediting'] = 'When editing text';
$string['texteditor'] = 'Use standard web forms';
$string['textformat'] = 'Plain text format';
@@ -1493,6 +1496,7 @@
$string['topicoutline'] = 'Topic outline';
$string['topicshow'] = 'Show this topic to $a';
$string['total'] = 'Total';
+$string['tutor'] = 'Tutor';
$string['trackforums'] = 'Forum tracking';
$string['trackforumsno'] = 'No: don\'t keep track of posts I have seen';
$string['trackforumsyes'] = 'Yes: highlight new posts for me';