mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
minor scale related changes, added fixed update() into grade_outcome class
This commit is contained in:
parent
3818937e4a
commit
4c2402b2f8
@ -52,7 +52,7 @@ class edit_scale_form extends moodleform {
|
||||
|
||||
if ($id = $mform->getElementValue('id')) {
|
||||
$scale = grade_scale::fetch(array('id'=>$id));
|
||||
$count = $scale->get_uses_count();
|
||||
$count = $scale->get_item_uses_count();
|
||||
|
||||
if ($count) {
|
||||
$mform->hardFreeze('scale');
|
||||
|
@ -39,7 +39,7 @@ $strname = get_string('name');
|
||||
$strdelete = get_string('delete');
|
||||
$stredit = get_string('edit');
|
||||
$srtcreatenewscale = get_string('scalescustomcreate');
|
||||
$stractivities = get_string('activities');
|
||||
$stritems = get_string('items', 'grades');
|
||||
$stredit = get_string('edit');
|
||||
|
||||
switch ($action) {
|
||||
@ -84,7 +84,7 @@ if ($courseid and $scales = grade_scale::fetch_all_local($courseid)) {
|
||||
$line = array();
|
||||
$line[] = format_string($scale->name).'<div class="scale_options">'.str_replace(",",", ",$scale->scale).'</div>';
|
||||
|
||||
$scales_uses = $scale->get_uses_count();
|
||||
$scales_uses = $scale->get_item_uses_count();
|
||||
$line[] = $scales_uses;
|
||||
|
||||
$buttons = "";
|
||||
@ -97,7 +97,7 @@ if ($courseid and $scales = grade_scale::fetch_all_local($courseid)) {
|
||||
$line[] = $buttons;
|
||||
$data[] = $line;
|
||||
}
|
||||
$table->head = array($strscale, $stractivities, $stredit);
|
||||
$table->head = array($strscale, $stritems, $stredit);
|
||||
$table->size = array('70%', '20%', '10%');
|
||||
$table->align = array('left', 'center', 'center');
|
||||
$table->width = '90%';
|
||||
@ -112,7 +112,7 @@ if ($scales = grade_scale::fetch_all_global()) {
|
||||
$line = array();
|
||||
$line[] = format_string($scale->name).'<div class="scale_options">'.str_replace(",",", ",$scale->scale).'</div>';
|
||||
|
||||
$scales_uses = $scale->get_uses_count();
|
||||
$scales_uses = $scale->get_item_uses_count();
|
||||
$line[] = $scales_uses;
|
||||
|
||||
$buttons = "";
|
||||
@ -127,7 +127,7 @@ if ($scales = grade_scale::fetch_all_global()) {
|
||||
$line[] = $buttons;
|
||||
$data[] = $line;
|
||||
}
|
||||
$table->head = array($strscale, $stractivities, $stredit);
|
||||
$table->head = array($strscale, $stritems, $stredit);
|
||||
$table->size = array('70%', '20%', '10%');
|
||||
$table->align = array('left', 'center', 'center');
|
||||
$table->width = '90%';
|
||||
|
@ -107,6 +107,25 @@ class grade_outcome extends grade_object {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* In addition to update() it also updates grade_outcomes_courses if needed
|
||||
* @param string $source from where was the object inserted
|
||||
* @return boolean success
|
||||
*/
|
||||
function update($source=null) {
|
||||
if ($result = parent::update($source)) {
|
||||
if (!empty($this->courseid)) {
|
||||
if (!get_records('grade_outcomes_courses', 'courseid', $this->courseid, 'outcomeid', $this->id)) {
|
||||
$goc = new object();
|
||||
$goc->courseid = $this->courseid;
|
||||
$goc->outcomeid = $this->id;
|
||||
insert_record('grade_outcomes_courses', $goc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and returns a grade_outcome instance based on params.
|
||||
* @static
|
||||
|
@ -200,7 +200,7 @@ class grade_scale extends grade_object {
|
||||
* @return boolean
|
||||
*/
|
||||
function can_delete() {
|
||||
$count = $this->get_uses_count();
|
||||
$count = $this->get_item_uses_count();
|
||||
return empty($count);
|
||||
}
|
||||
|
||||
@ -208,9 +208,10 @@ class grade_scale extends grade_object {
|
||||
* Returns the number of places where scale is used - activities, grade items, outcomes, etc.
|
||||
* @return int
|
||||
*/
|
||||
function get_uses_count() {
|
||||
function get_item_uses_count() {
|
||||
global $CFG;
|
||||
|
||||
//TODO: fix me - this methods does some duplicate counting in grade items and activities
|
||||
$count = 0;
|
||||
if (!empty($this->courseid)) {
|
||||
if ($scales_uses = course_scale_used($this->courseid,$this->id)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user