mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
grade edit form, and adding set_locktime for grade_grades and grade_item
This commit is contained in:
parent
df2c2310e5
commit
7e3c9767db
@ -24,8 +24,9 @@ $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);
|
||||
}
|
||||
}
|
||||
|
||||
$grade_grades->courseid = $courseid;
|
||||
$mform->set_data($grade_grades);
|
||||
} else {
|
||||
$mform->set_data(array('courseid'=>$course->id, 'id' => $id));
|
||||
@ -35,17 +36,18 @@ 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();
|
||||
}
|
||||
|
||||
$grade_grades = new grade_grades(array('id'=>$id));
|
||||
$grade_item = new grade_item(array('id'=>$grade_grades->itemid));
|
||||
$grade_item->update_final_grade($grade_grades->userid, $data->finalgrade, NULL, NULL, $data->feedback);
|
||||
|
||||
// set locked
|
||||
$grade_grades->set_locked($data->locked);
|
||||
// set hidden
|
||||
$grade_grades->set_hidden($data->hidden);
|
||||
|
||||
// set locktime
|
||||
$grade_grades->set_locktime($data->locktime);
|
||||
|
||||
redirect($returnurl, get_string('feedbacksaved', 'grades'), 1);
|
||||
}
|
||||
@ -112,30 +114,8 @@ if (!empty($extra_info->course_module) && !empty($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();
|
||||
|
||||
|
@ -19,9 +19,11 @@ class edit_grade_form extends moodleform {
|
||||
// scale grade
|
||||
$scaleopt[-1] = get_string('nograde');
|
||||
|
||||
$i = 1;
|
||||
if ($scale = get_record('scale', 'id', $gradeitem->scaleid)) {
|
||||
foreach (split(",", $scale->scale) as $option) {
|
||||
$scaleopt[] = $option;
|
||||
$scaleopt[$i] = $option;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,45 @@ class grade_grades extends grade_object {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the locktime for this grade.
|
||||
*
|
||||
* @param int $locktime timestamp for lock to activate
|
||||
* @return boolean true if sucessful, false if can not set new lock state for grade
|
||||
*/
|
||||
function set_locktime($locktime) {
|
||||
|
||||
if ($locktime) {
|
||||
// if current locktime is before, no need to reset
|
||||
|
||||
if ($this->locktime && $this->locktime <= $locktime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->grade_item->needsupdate) {
|
||||
//can not lock grade if final not calculated!
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
$this->locktime = $locktime;
|
||||
$this->update();
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
// remove the locktime timestamp
|
||||
$this->locktime = 0;
|
||||
|
||||
$this->update();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check grade lock status. Uses both grade item lock and grade lock.
|
||||
* Internally any date in hidden field (including future ones) means hidden,
|
||||
|
@ -457,6 +457,44 @@ class grade_item extends grade_object {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the locktime for this grade.
|
||||
*
|
||||
* @param int $locktime timestamp for lock to activate
|
||||
* @return boolean true if sucessful, false if can not set new lock state for grade
|
||||
*/
|
||||
function set_locktime($locktime) {
|
||||
|
||||
if ($locktime) {
|
||||
// if current locktime is before, no need to reset
|
||||
|
||||
if ($this->locktime && $this->locktime <= $locktime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
if ($this->grade_item->needsupdate) {
|
||||
//can not lock grade if final not calculated!
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
$this->locktime = $locktime;
|
||||
$this->update();
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
// remove the locktime timestamp
|
||||
$this->locktime = 0;
|
||||
|
||||
$this->update();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hidden state of this grade_item (if the grade_item is hidden OR no specific
|
||||
|
Loading…
x
Reference in New Issue
Block a user