MDL-10210 Added the user preferences, using moodleform.

This commit is contained in:
nicolasconnault 2007-07-04 15:23:36 +00:00
parent 82b4da8649
commit 6e1d5e046c
4 changed files with 72 additions and 31 deletions

View File

@ -5,10 +5,6 @@
require_once($CFG->libdir.'/tablelib.php');
include_once($CFG->libdir.'/gradelib.php');
// Prepare language strings
$strsortasc = get_string('sortasc', 'grades');
$strsortdesc = get_string('sortasc', 'grades');
/// processing posted grades here
if ($data = data_submitted()) {
@ -65,6 +61,15 @@ if ($perpageurl = optional_param('perpage', 0, PARAM_INT)) {
$perpage = $perpageurl;
}
// Prepare language strings
$strsortasc = get_string('sortasc', 'grades');
$strsortdesc = get_string('sortasc', 'grades');
// base url for sorting by first/last name
$baseurl = 'report.php?id='.$courseid.'&report=grader&page='.$page;
// base url for paging
$pbarurl = 'report.php?id='.$courseid.'&report=grader&';
// Grab the grade_tree for this course
$gtree = new grade_tree($courseid);
@ -166,12 +171,13 @@ grade_update_final_grades($courseid);
// roles to be displaye in the gradebook
$gradebookroles = $CFG->gradebookroles;
// pulls out the userids of the users to be display, and sort them
// the right outer join is needed because potentially, it is possible not
// to have the corresponding entry in grade_grades table for some users
// this is check for user roles because there could be some users with grades
// but not supposed to be displayed
/*
* pulls out the userids of the users to be display, and sort them
* the right outer join is needed because potentially, it is possible not
* to have the corresponding entry in grade_grades table for some users
* this is check for user roles because there could be some users with grades
* but not supposed to be displayed
*/
if (is_numeric($sortitemid)) {
$sql = "SELECT u.id, u.firstname, u.lastname
FROM {$CFG->prefix}grade_grades g RIGHT OUTER JOIN
@ -227,19 +233,6 @@ if ($grades = get_records_sql($sql)) {
}
}
print_heading('Grader Report');
// Add tabs
$currenttab = 'graderreport';
include('tabs.php');
// base url for sorting by first/last name
$baseurl = 'report.php?id='.$courseid.'&report=grader&page='.$page;
// base url for paging
$pbarurl = 'report.php?id='.$courseid.'&report=grader&';
print_paging_bar($numusers, $page, $perpage, $pbarurl);
/// With the users in an sorted array and grades fetched, we can not print the main html table
// 1. Fetch all top-level categories for this course, with all children preloaded, sorted by sortorder
@ -270,13 +263,23 @@ if ($sortitemid === 'firstname') {
$firstarrow = '';
}
// first name/last name column
/********* BEGIN OUTPUT *********/
print_heading('Grader Report');
// Add tabs
$currenttab = 'graderreport';
include('tabs.php');
print_paging_bar($numusers, $page, $perpage, $pbarurl);
$items = array();
// Prepare Table Headers
$headerhtml = '';
$numrows = count($gtree->levels);
foreach ($gtree->levels as $key=>$row) {
if ($key == 0) {
// do not diplay course grade category
@ -286,7 +289,8 @@ foreach ($gtree->levels as $key=>$row) {
$headerhtml .= '<tr class="heading">';
if ($key == $numrows - 1) {
$headerhtml .= '<th class="user"><a href="'.$baseurl.'&amp;sortitemid=firstname">Firstname</a> '. $firstarrow. '/ <a href="'.$baseurl.'&amp;sortitemid=lastname">Lastname </a>'. $lastarrow .'</th>';
$headerhtml .= '<th class="user"><a href="'.$baseurl.'&amp;sortitemid=firstname">Firstname</a> '
. $firstarrow. '/ <a href="'.$baseurl.'&amp;sortitemid=lastname">Lastname </a>'. $lastarrow .'</th>';
} else {
$headerhtml .= '<td class="topleft">&nbsp;</td>';
}
@ -339,10 +343,12 @@ foreach ($gtree->levels as $key=>$row) {
}
if ($object->itemtype == 'mod') {
$icon = '<img src="'.$CFG->modpixpath.'/'.$object->itemmodule.'/icon.gif" class="icon" alt="'.get_string('modulename', $object->itemmodule).'"/>';
$icon = '<img src="'.$CFG->modpixpath.'/'.$object->itemmodule.'/icon.gif" class="icon" alt="'
.get_string('modulename', $object->itemmodule).'"/>';
} else if ($object->itemtype == 'manual') {
//TODO: add manual grading icon
$icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'.get_string('manualgrade', 'grades').'"/>'; // TODO: localize
$icon = '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon" alt="'.get_string('manualgrade', 'grades')
.'"/>'; // TODO: localize
}
@ -359,7 +365,8 @@ foreach ($gtree->levels as $key=>$row) {
$headerhtml .= '</tr>';
}
$studentshtml = '';
// Prepare Table Rows
$studentshtml = '';
foreach ($users as $userid => $user) {
$studentshtml .= '<tr><th class="user">' . $user->firstname . ' ' . $user->lastname . '</th>';
@ -407,7 +414,8 @@ foreach ($users as $userid => $user) {
$i++;
$scaleopt[$i] = $scaleoption;
}
$studentshtml .= choose_from_menu ($scaleopt, 'grade_'.$userid.'_'.$item->id, $gradeval, get_string('nograde'), '', -1, true);
$studentshtml .= choose_from_menu($scaleopt, 'grade_'.$userid.'_'.$item->id,
$gradeval, get_string('nograde'), '', -1, true);
}
} else {
$studentshtml .= '<input size="6" type="text" name="grade_'.$userid.'_'.$item->id.'" value="'.$gradeval.'"/>';

View File

@ -26,7 +26,7 @@ set_time_limit(0);
require_once '../../../config.php';
require_once $CFG->libdir . '/gradelib.php';
$courseid = optional_param('id', 0 , PARAM_INT);
$courseid = required_param('id', PARAM_INT);
/// Make sure they can even access this course
@ -37,6 +37,23 @@ if (!$course = get_record('course', 'id', $courseid)) {
require_login($course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('gradereport/grader:manage', $context);
// If data submitted, then process and store.
if ($form = data_submitted()) {
foreach ($form as $preference => $value) {
switch ($preference) {
case 'persistflt':
set_user_preference('calendar_persistflt', intval($value));
break;
default:
set_user_preference($preference, $value);
break;
}
}
redirect($CFG->wwwroot . '/grade/report.php?report=grader&amp;id='.$courseid, get_string('changessaved'), 1);
exit;
}
$strgrades = get_string('grades');
$strgraderreport = get_string('graderreport', 'grades');
@ -49,12 +66,19 @@ $crumbs[] = array('name' => $strgradepreferences, 'link' => '', 'type' => 'misc'
$navigation = build_navigation($crumbs);
print_header_simple($strgrades.': '.$strgraderreport,': '.$strgradepreferences, $navigation,
print_header_simple($strgrades.': '.$strgraderreport . ': ' . $strgradepreferences,': '.$strgradepreferences, $navigation,
'', '', true, '', navmenu($course));
print_heading(get_string('preferences'));
// Add tabs
$currenttab = 'preferences';
include('tabs.php');
print_simple_box_start("center");
include('./preferences_form.php');
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
echo $mform->display();
print_simple_box_end();
print_footer($course);
?>

View File

@ -41,4 +41,5 @@ $settings->add(new admin_setting_configselect('grade_report_decimalpoints', get_
'3' => '3',
'4' => '4',
'5' => '5')));
?>

View File

@ -24,6 +24,7 @@ $string['category'] = 'Category';
$string['categoriesedit'] = 'Edit Categories';
$string['categoryname'] = 'Category name';
$string['choosecategory'] = 'Select Category';
$string['compact'] = 'Compact';
$string['configaggregationposition'] = 'The position of the aggregation column in the grader report table, in reference to the raw grades.';
$string['configaggregationview'] = 'The way aggregations are displayed: either alongside the raw grades, or in a compact form in which only one type is shown in the table at once: the raw grades OR the aggregated grades.';
$string['configbulkcheckboxes'] = 'Checkboxes near each grade for Bulk grade operations.';
@ -71,6 +72,7 @@ $string['feedbackedit'] = 'Edit feedback';
$string['feedbackformat'] = 'Feedback format';
$string['forelementtypes'] = ' for the selected $a';
$string['forstudents'] = 'For Students';
$string['full'] = 'Full';
$string['grade'] = 'Grade';
$string['gradebook'] = 'Gradebook';
$string['gradebookhiddenerror'] = 'The gradebook is currently set to hide everything from students.';
@ -108,6 +110,7 @@ $string['hidecategory'] = 'Hidden';
$string['highgradeascending'] = 'Sort by high grade ascending';
$string['highgradedescending'] = 'Sort by high grade descending';
$string['highgradeletter'] = 'High';
$string['html'] = 'HTML';
$string['identifier'] = 'Identify user by';
$string['importcsv'] = 'Import CSV';
$string['importfailed'] = 'Import failed';
@ -120,6 +123,7 @@ $string['item'] = 'Item';
$string['iteminfo'] = 'Item info';
$string['itemname'] = 'Item name';
$string['items'] = 'Items';
$string['left'] = 'Left';
$string['lettergrade'] = 'Letter Grade';
$string['lettergradenonnumber'] = 'Low and/or High grade were non-numeric for';
$string['letters'] = 'Letters';
@ -155,6 +159,7 @@ $string['onascaleof'] = ' on a scale of $a->grademin to $a->grademax';
$string['outcome'] = 'Outcome';
$string['pctoftotalgrade'] = '%% of total grade';
$string['percent'] = 'Percent';
$string['percentage'] = 'Percentage';
$string['percentascending'] = 'Sort by percent ascending';
$string['percentdescending'] = 'Sort by percent descending';
$string['percentshort'] = '%%';
@ -163,8 +168,10 @@ $string['pointsascending'] = 'Sort by points ascending';
$string['pointsdescending'] = 'Sort by points descdending';
$string['preferences'] = 'Preferences';
$string['rank'] = 'Rank';
$string['raw'] = 'Raw';
$string['rawpct'] = 'Raw %%';
$string['reprintheaders'] = 'Reprint Headers';
$string['right'] = 'Right';
$string['savechanges'] = 'Save Changes';
$string['savepreferences'] = 'Save Preferences';
$string['scaledpct'] = 'Scaled %%';
@ -198,6 +205,7 @@ $string['student'] = 'Student';
$string['studentsperpage'] = 'Students per page';
$string['subcategory'] = 'Normal Category';
$string['synclegacygrades'] = 'Synchronise legacy grades';
$string['text'] = 'Text';
$string['topcategory'] = 'Super Category';
$string['total'] = 'Total';
$string['totalweight100'] = 'The total weight is equal to 100';