forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
toyomoyo
committed
Jul 11, 2007
1 parent
73f1e3b
commit 2054475
Showing
4 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,143 @@ | ||
<?php //$id:$ | ||
<?php //$Id$ | ||
|
||
//TODO: implement | ||
?> | ||
require_once '../../../config.php'; | ||
require_once $CFG->libdir.'/gradelib.php'; | ||
require_once 'edit_grade_form.php'; | ||
|
||
$courseid = required_param('courseid', PARAM_INT); | ||
$id = optional_param('id', 0, PARAM_INT); // grade_grades id | ||
$action = optional_param('action', 'view', PARAM_ALPHA); | ||
|
||
if (!$course = get_record('course', 'id', $courseid)) { | ||
print_error('nocourseid'); | ||
} | ||
|
||
// capabilities check | ||
require_login($course); | ||
$context = get_context_instance(CONTEXT_COURSE, $course->id); | ||
require_capability('gradereport/grader:manage', $context); | ||
|
||
// default return url | ||
$returnurl = $CFG->wwwroot.'/grade/report.php?report=grader&id='.$course->id; | ||
|
||
$mform = new edit_grade_form(qualified_me(), array('id'=>$id)); | ||
if ($grade_grades = get_record('grade_grades', 'id', $id)) { | ||
if ($grade_text = get_record('grade_grades_text', 'gradeid', $id)) { | ||
$mform->set_data($grade_text); | ||
} | ||
|
||
$mform->set_data($grade_grades); | ||
} else { | ||
$mform->set_data(array('courseid'=>$course->id, 'id' => $id)); | ||
} | ||
|
||
if ($mform->is_cancelled()) { | ||
redirect($returnurl); | ||
// form processing | ||
} else if ($data = $mform->get_data()) { | ||
$data->gradeid = $data->id; | ||
unset($data->id); | ||
|
||
$grade_text = new grade_grades_text(array('gradeid'=>$id)); | ||
grade_grades_text::set_properties($grade_text, $data); | ||
if (empty($grade_text->id)) { | ||
$grade_text->insert(); | ||
|
||
} else { | ||
$grade_text->update(); | ||
} | ||
|
||
redirect($returnurl, get_string('feedbacksaved', 'grades'), 1); | ||
} | ||
|
||
// Get extra data related to this feedback | ||
$query = "SELECT a.id AS userid, a.firstname, a.lastname, | ||
b.id AS itemid, b.itemname, b.grademin, b.grademax, b.iteminstance, b.itemmodule, b.scaleid, | ||
c.finalgrade | ||
FROM {$CFG->prefix}user a, | ||
{$CFG->prefix}grade_items b, | ||
{$CFG->prefix}grade_grades c | ||
WHERE c.id = $id | ||
AND b.id = c.itemid | ||
AND a.id = c.userid"; | ||
|
||
$extra_info = get_record_sql($query) ; | ||
$extra_info->grademin = round($extra_info->grademin); | ||
$extra_info->grademax = round($extra_info->grademax); | ||
$extra_info->finalgrade = round($extra_info->finalgrade); | ||
|
||
if (!empty($extra_info->itemmodule) && !empty($extra_info->iteminstance)) { | ||
$extra_info->course_module = get_coursemodule_from_instance($extra_info->itemmodule, $extra_info->iteminstance, $courseid); | ||
} | ||
|
||
$stronascaleof = get_string('onascaleof', 'grades', $extra_info); | ||
$strgrades = get_string('grades'); | ||
$strgrade = get_string('grade'); | ||
$strgraderreport = get_string('graderreport', 'grades'); | ||
$strfeedback = get_string('feedback', 'grades'); | ||
$strfeedbackedit = get_string('feedbackedit', 'grades'); | ||
$strfeedbackview = get_string('feedbackview', 'grades'); | ||
$strfeedbackadd = get_string('feedbackadd', 'grades'); | ||
$strstudent = get_string('student', 'grades'); | ||
$strgradeitem = get_string('gradeitem', 'grades'); | ||
|
||
$feedback = null; | ||
$heading = ${"strfeedback$action"}; | ||
if (!empty($action) && $action == 'view' && !empty($grade_text->feedback)) { | ||
$feedback = "<p><strong>$strfeedback</strong>:</p><p>$grade_text->feedback</p>"; | ||
} | ||
|
||
$nav = array(array('name'=>$strgrades,'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'), | ||
array('name'=>$strgraderreport, 'link'=>$CFG->wwwroot.'/grade/report.php?id='.$courseid.'&report=grader', 'type'=>'misc'), | ||
array('name'=>$heading, 'link'=>'', 'type'=>'misc')); | ||
|
||
$navigation = build_navigation($nav); | ||
|
||
/*********** BEGIN OUTPUT *************/ | ||
|
||
print_header_simple($strgrades . ': ' . $strgraderreport . ': ' . $heading, | ||
': ' . $heading , $navigation, '', '', true, '', navmenu($course)); | ||
|
||
print_heading($heading); | ||
|
||
print_simple_box_start("center"); | ||
|
||
// Student name and link | ||
echo "<p><strong>$strstudent:</strong> <a href=\"" . $CFG->wwwroot . '/user/view.php?id=' | ||
. $extra_info->userid . '">' . fullname($extra_info) . "</a></p>"; | ||
|
||
// Grade item name and link | ||
if (!empty($extra_info->course_module) && !empty($extra_info->itemmodule)) { | ||
echo "<p><strong>$strgradeitem:</strong> <a href=\"" . $CFG->wwwroot . '/mod/' . $extra_info->itemmodule | ||
. '/view.php?id=' . $extra_info->course_module->id . "&courseid=$courseid\">$extra_info->itemname</a></p>"; | ||
} | ||
|
||
// Final grade and link to scale if applicable | ||
if (!empty($extra_info->finalgrade)) { | ||
$openlink = ''; | ||
$closelink = ''; | ||
|
||
if (!empty($extra_info->scaleid)) { | ||
$openlink = '<a href="' . $CFG->wwwroot . '/course/scales.php?id=' . $courseid . '&scaleid=' | ||
. $extra_info->scaleid . '">'; | ||
$closelink = '</a>'; | ||
} | ||
echo "<p><strong>$strgrade:</strong> " . $extra_info->finalgrade . "$openlink $stronascaleof $closelink</p>"; | ||
} | ||
|
||
// Form if in edit or add modes | ||
$mform->display(); | ||
/* | ||
if ($action != 'view') { | ||
$mform->display(); | ||
} else { // Feedback string and Back button if in View mode | ||
echo $feedback; | ||
echo "<button onclick=\"window.location='" . $CFG->wwwroot . "/grade/report.php?report=grader&id=$courseid';\">" | ||
. get_string('back') . '</button>'; | ||
} | ||
*/ | ||
|
||
print_simple_box_end(); | ||
|
||
print_footer($course); | ||
die; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php //$Id$ | ||
|
||
require_once $CFG->libdir.'/formslib.php'; | ||
|
||
class edit_grade_form extends moodleform { | ||
function definition() { | ||
global $CFG, $USER; | ||
$mform =& $this->_form; | ||
|
||
$id = $this->_customdata['id']; | ||
$grade_grades = get_record('grade_grades', 'id', $id); | ||
$gradeitem = get_record('grade_items', 'id', $grade_grades->itemid); | ||
|
||
/// actual grade - numeric or scale | ||
if ($gradeitem->gradetype == 1) { | ||
// numeric grade | ||
$mform->addElement('text', 'finalgrade', get_string('finalgrade', 'grades')); | ||
} else if ($gradeitem->gradetype == 2) { | ||
// scale grade | ||
$scaleopt[-1] = get_string('nograde'); | ||
|
||
if ($scale = get_record('scale', 'id', $gradeitem->scaleid)) { | ||
foreach (split(",", $scale->scale) as $option) { | ||
$scaleopt[] = $option; | ||
} | ||
} | ||
|
||
$mform->addElement('select', 'finalgrade', get_string('finalgrade', 'grades'), $scaleopt); | ||
} | ||
/// hidden | ||
|
||
/// hidden | ||
$mform->addElement('advcheckbox', 'hidden', get_string('hidden', 'grades')); | ||
|
||
/// locked | ||
$mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'),'','',$grade_grades->locked); | ||
|
||
/// locktime | ||
$mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional'=>true)); | ||
$mform->disabledIf('locktime', 'gradetype', 'eq', GRADE_TYPE_NONE); | ||
/// hidden/visible | ||
|
||
/// feedback | ||
$feedbackformat = get_user_preferences('grade_report_feedbackformat', $CFG->grade_report_feedbackformat); | ||
|
||
// visible elements | ||
// User preference determines the format | ||
if ($CFG->htmleditor && $USER->htmleditor && $feedbackformat == GRADER_REPORT_FEEDBACK_FORMAT_HTML) { | ||
$mform->addElement('htmleditor', 'feedback', get_string('feedback', 'grades'), | ||
array('rows'=> '15', 'course' => optional_param('courseid', PARAM_INT), 'cols'=>'45')); | ||
} else { | ||
$mform->addElement('textarea', 'feedback', get_string('feedback', 'grades')); | ||
} | ||
|
||
//TODO: add other elements | ||
|
||
// hidden params | ||
$mform->addElement('hidden', 'id', 0); | ||
$mform->setType('gradeid', PARAM_INT); | ||
|
||
$mform->addElement('hidden', 'courseid', 0); | ||
$mform->setType('courseid', PARAM_INT); | ||
|
||
//------------------------------------------------------------------------------- | ||
// buttons | ||
$this->add_action_buttons(); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters