adding some new files for grade outcomes

This commit is contained in:
toyomoyo 2007-07-24 07:43:46 +00:00
parent c3bc8c6a23
commit 5d71ece008
5 changed files with 193 additions and 5 deletions

View File

@ -0,0 +1,30 @@
<table style="margin-left:auto;margin-right:auto">
<tr>
<td>
<select id="addoutcomes" size="20" name="addoutcomes[]" multiple="multiple">
<?php
foreach ($outcomes as $outcome) {
echo '<option value="'.$outcome->id.'">'.$outcome->shortname.'</option>';
}
?>
</select>
</td>
<td>
<p class="arrow_button">
<input name="add" id="add" type="submit" value="<?php echo '&nbsp;'.$THEME->larrow.' &nbsp; &nbsp; '.get_string('add'); ?>" title="<?php print_string('add'); ?>" />
<br />
<input name="remove" id="remove" type="submit" value="<?php echo '&nbsp; '.$THEME->rarrow.' &nbsp; &nbsp; '.get_string('remove'); ?>" title="<?php print_string('remove'); ?>" />
</p>
</td>
<td>
<select id="removeoutcomes" size="20" name="removeoutcomes[]" multiple="multiple">
<?php
foreach ($courseoutcomes as $courseoutcome) {
echo '<option value="'.$courseoutcome->id.'">'.$courseoutcome->shortname.'</option>';
}
?>
</select>
</td>
</tr>
</table>

View File

@ -0,0 +1,25 @@
<?php
/*********************************
* Course outcomes editting page *
*********************************/
include_once('../../../config.php');
$courseid = required_param('id', SITEID, PARAM_INT); // course id
/// form processing
print_header();
// Add tabs
$currenttab = 'outcomesettings';
include('tabs.php');
/// listing of all site outcomes + this course specific outcomes
$outcomes = get_records_sql('SELECT * FROM '.$CFG->prefix.'grade_outcomes
WHERE ISNULL(courseid)');
get_records('grade_outcomes', 'courseid', $courseid);
check_theme_arrows();
include_once('course.html');
print_footer();
?>

View File

@ -2,6 +2,8 @@
include_once('../../../config.php');
require_once $CFG->libdir.'/formslib.php';
// courseid needs to be passed in to know whether this should be tied to a course
class edit_outcomes_form extends moodleform {
function definition() {
@ -30,6 +32,8 @@ class edit_outcomes_form extends moodleform {
$mform->setType('scaleid', PARAM_INT);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
@ -39,9 +43,10 @@ class edit_outcomes_form extends moodleform {
$id = optional_param('id', 0, PARAM_INT); // id of the outcome
if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
// optional course id, if set, editting from course
$returnurl = $CFG->wwwroot."/grade/report/outcomes/course.php";
} else {
// admin editting site level outcomes
$returnurl = $CFG->wwwroot."/grade/report/outcomes/settings.php";
$returnurl = $CFG->wwwroot."/grade/report/outcomes/site.php";
}
// form processing
@ -50,6 +55,11 @@ if ($id) {
// form set data
$mform->set_data(get_record('grade_outcomes', 'id', $id));
}
// if courseid is provided, set it in the form
if ($courseid) {
$data->courseid = $courseid;
$mform->set_data($data);
}
if ($mform->is_cancelled()) {
redirect($returnurl);
@ -70,4 +80,4 @@ include('tabs.php');
print_header();
$mform->display();
print_footer();
?>
?>

117
grade/report/outcomes/site.php Executable file
View File

@ -0,0 +1,117 @@
<?php
/*********************************
* Global outcomes editting page *
*********************************/
include_once('../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
// setting up params
$courseid = optional_param('id', SITEID, PARAM_INT); // course id
/// check capability
$page = optional_param('page', 0, PARAM_INT); // current page
$search = optional_param('search', 0, PARAM_TEXT);
$deleteid = optional_param('deleteid', 0, PARAM_INT); // which outcome to delete
$confirm = optional_param('confirm', 0, PARAM_INT);
$perpage = 30;
// form processing
if ($deleteid && confirm_sesskey()) {
if ($confirm) {
// delete all outcomes used in courses
// delete all outcomes used in grade items
delete_records('grade_outcomes_courses', 'outcomeid', $deleteid);
delete_records('grade_outcomes', 'id', $deleteid);
} else {
// prints confirmation
print_header('');
echo '<form action="settings.php">';
echo '<div>';
echo '<input type="hidden" name="confirm" value="1" />';
echo '<input type="hidden" name="deleteid" value="'.$deleteid.'" />';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo 'Are you sure you want to delete this outcome?';
echo '<input type="submit" value="yes" />';
echo '</div>';
echo '</form>';
print_footer();
exit;
}
}
/// display information
admin_externalpage_setup('gradereportoutcomes');
admin_externalpage_print_header();
// Add tabs
$currenttab = 'outcomesettings';
include('tabs.php');
$totalcount = count_records('grade_outcomes');
$baseurl = "settings.php";
print_paging_bar($totalcount, $page, $perpage, $baseurl);
if ($outcomes = get_recordset('grade_outcomes', '', '', '', '*', $page * $perpage, $perpage)) {
$tablecolumns = array('outcome', 'scale', 'course', 'edit', 'usedgradeitems', 'usedcourses');
$tableheaders = array(get_string('outcomes'),
get_string('scale'),
get_string('course'),
get_string('operations'),
get_string('usedgradeitem'),
get_string('usedcourses'));
$table = new flexible_table('outcomes');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'user-grade');
$table->set_attribute('class', 'boxaligncenter generaltable');
$table->setup();
foreach ($outcomes as $outcome) {
$data = array();
// full name of the outcome
$data[] = $outcome['fullname'];
// full name of the scale used by this outcomes
$scale= get_record('scale', 'id', $outcome['scaleid']);
$data[] = $scale->name;
// get course
if ($outcome['courseid']) {
$course = get_record('course', 'id', $outcome['courseid']);
$data[] = $course->shortname;
} else {
$data[] = get_string('site');
}
// add operations
$data[] = '<a href="editoutcomes.php?id='.$outcome['id'].'&amp;sesskey='.sesskey().'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
<a href="settings.php?deleteid='.$outcome['id'].'&amp;sesskey='.sesskey().'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/delete.gif"/></a>'; // icons and links
// num of gradeitems using this
$num = count_records('grade_outcomes_courses', 'outcomeid' ,$outcome['id']);
$data[] = (int) $num;
// num of courses using this outcome
$num = count_records('grade_items', 'outcomeid', $outcome['id']);
$data[] = (int) $num;
$table->add_data($data);
}
$table->print_html();
}
echo '<a href="editoutcomes.php">Add a new outcome</a>';
// print the footer, end of page
admin_externalpage_print_footer();
?>

View File

@ -4,9 +4,15 @@
$CFG->wwwroot.'/grade/report/outcomes/index.php?id='.$courseid,
get_string('outcomereport', 'grades'));
$row[] = new tabobject('outcomesettings',
$CFG->wwwroot.'/grade/report/outcomes/settings.php?id='.$courseid,
get_string('settings'));
if ($courseid != SITEID) {
$row[] = new tabobject('outcomesettings',
$CFG->wwwroot.'/grade/report/outcomes/course.php?id='.$courseid,
get_string('settings'));
} else {
$row[] = new tabobject('outcomesettings',
$CFG->wwwroot.'/grade/report/outcomes/site.php?id='.$courseid,
get_string('settings'));
}
$row[] = new tabobject('editoutcomes',
$CFG->wwwroot.'/grade/report/outcomes/editoutcomes.php?courseid='.$courseid,