Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add parent child aspect for outcomes

  • Loading branch information...
commit 159bb63b4c5594babcbb9fb8e6acc60581398a26 1 parent 1035169
@zhendi zhendi authored
View
4 grade/edit/outcome/edit.php
@@ -126,6 +126,7 @@
} else if ($data = $mform->get_data()) {
$outcome = new grade_outcome(array('id'=>$id));
$data->usermodified = $USER->id;
+ $outcome->parent = $data->parent;
if (empty($outcome->id)) {
$data->description = $data->description_editor['text'];
@@ -138,7 +139,8 @@
$outcome->courseid = null;
}
$outcome->insert();
-
+
+ $DB->set_field($outcome->table, 'parent', $data->parent, array('id'=>$outcome->id));
$data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome->id);
$DB->set_field($outcome->table, 'description', $data->description, array('id'=>$outcome->id));
} else {
View
9 grade/edit/outcome/edit_form.php
@@ -30,7 +30,7 @@
class edit_outcome_form extends moodleform {
public function definition() {
- global $CFG, $COURSE;
+ global $CFG, $COURSE, $DB;
$mform =& $this->_form;
// visible elements
@@ -49,6 +49,13 @@ public function definition() {
$options = array();
+ $out_array = $DB->get_records_menu('grade_outcomes', array(), '', 'id, fullname');
+ foreach($out_array as $id => $fullname) {
+ $out_array[$id] = strip_tags(format_string($fullname));
+ }
+
+ $mform->addElement('select', 'parent', 'Parent', $out_array);
+
$mform->addElement('selectwithlink', 'scaleid', get_string('scale'), $options, null,
array('link' => $CFG->wwwroot.'/grade/edit/scale/edit.php?courseid='.$COURSE->id, 'label' => get_string('scalescustomcreate')));
$mform->addHelpButton('scaleid', 'typescale', 'grades');
View
26 grade/edit/outcome/index.php
@@ -57,6 +57,7 @@
$strshortname = get_string('outcomeshortname', 'grades');
$strfullname = get_string('outcomefullname', 'grades');
+$strparent = "Parent";
$strscale = get_string('scale');
$strstandardoutcome = get_string('outcomesstandard', 'grades');
$strcustomoutcomes = get_string('outcomescustom', 'grades');
@@ -128,6 +129,12 @@
$line = array();
$line[] = $outcome->get_name();
$line[] = $outcome->get_shortname();
+ $parent = $DB->get_record('grade_outcomes', array('id' => $outcome->parent))
+ if ($parent) {
+ $line[] = $parent->fullname;
+ } else {
+ $line[] = '-'
+ }
$scale = $outcome->load_scale();
if (empty($scale->id)) { // hopefully never happens
@@ -160,9 +167,9 @@
$data[] = $line;
}
$table = new html_table();
- $table->head = array($strfullname, $strshortname, $strscale, $stritems, $stredit);
- $table->size = array('30%', '20%', '20%', '20%', '10%' );
- $table->align = array('left', 'left', 'left', 'center', 'center');
+ $table->head = array($strfullname, $strshortname, $strparent, $strscale, $stritems, $stredit);
+ $table->size = array('30%', '20%', '20%', '10%', '10%', '10%' );
+ $table->align = array('left', 'left', 'left', 'left', 'center', 'center');
$table->width = '90%';
$table->data = $data;
$return .= html_writer::table($table);
@@ -178,6 +185,13 @@
$line[] = $outcome->get_name();
$line[] = $outcome->get_shortname();
+ $parent = $DB->get_record('grade_outcomes', array('id' => $outcome->parent))
+ if ($parent) {
+ $line[] = $parent->fullname;
+ } else {
+ $line[] = '-'
+ }
+
$scale = $outcome->load_scale();
if (empty($scale->id)) { // hopefully never happens
$line[] = $scale->get_name();
@@ -212,9 +226,9 @@
$data[] = $line;
}
$table = new html_table();
- $table->head = array($strfullname, $strshortname, $strscale, $strcourses, $stritems, $stredit);
- $table->size = array('30%', '20%', '20%', '10%', '10%', '10%');
- $table->align = array('left', 'left', 'left', 'center', 'center', 'center');
+ $table->head = array($strfullname, $strshortname, $strparent, $strscale, $strcourses, $stritems, $stredit);
+ $table->size = array('30%', '20%', '10%', '10%', '10%', '10%', '10%' );
+ $table->align = array('left', 'left', 'left', 'left', 'center', 'center');
$table->width = '90%';
$table->data = $data;
$return .= html_writer::table($table);
View
5 lib/grade/grade_outcome.php
@@ -49,7 +49,7 @@ class grade_outcome extends grade_object {
* @var array $required_fields
*/
public $required_fields = array('id', 'courseid', 'shortname', 'fullname', 'scaleid','description',
- 'descriptionformat', 'timecreated', 'timemodified', 'usermodified');
+ 'descriptionformat', 'timecreated', 'timemodified', 'usermodified', 'parent');
/**
* The course this outcome belongs to.
@@ -100,6 +100,9 @@ class grade_outcome extends grade_object {
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return bool success
*/
+
+ public $parent;
+
public function delete($source=null) {
global $DB;
if (!empty($this->courseid)) {
Please sign in to comment.
Something went wrong with that request. Please try again.