MDL-10544 placeholder for outcome edit forms grade/edit/outcome/
MDL-10650 scales code moved to grade/edit/scale/ refactoring in grade/edit/
This commit is contained in:
@@ -131,7 +131,7 @@ class block_admin extends block_list {
|
||||
|
||||
/// Manage scales
|
||||
if (has_capability('moodle/course:managescales', $context) && ($course->id!==SITEID)) {
|
||||
$this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/edit/scale/index.php?id='.$this->instance->pageid.'">'.get_string('scales').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" class="icon" alt="" />';
|
||||
}
|
||||
|
||||
|
||||
+42
-434
@@ -4,19 +4,15 @@
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$scaleid = optional_param('scaleid', 0, PARAM_INT); // scale id
|
||||
$action = optional_param('action', 'undefined', PARAM_ALPHA); // action to execute
|
||||
$name = optional_param('name', '', PARAM_CLEAN); // scale name
|
||||
$description = optional_param('description', '', PARAM_CLEAN);// scale description
|
||||
$list = optional_param('list', 0, PARAM_BOOL); // show listing in help window
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:viewscales', $context);
|
||||
|
||||
$strscale = get_string("scale");
|
||||
$strscales = get_string("scales");
|
||||
@@ -26,447 +22,59 @@
|
||||
$strstandardscales = get_string("scalesstandard");
|
||||
$strname = get_string("name");
|
||||
$strdescription = get_string("description");
|
||||
$strsavechanges = get_string("savechanges");
|
||||
$strchangessaved = get_string("changessaved");
|
||||
$strdeleted = get_string("deleted");
|
||||
$strdelete = get_string("delete");
|
||||
$stredit = get_string("edit");
|
||||
$strdown = get_string("movedown");
|
||||
$strup = get_string("moveup");
|
||||
$strmoved = get_string("changessaved");
|
||||
$srtcreatenewscale = get_string("scalescustomcreate");
|
||||
$strhelptext = get_string("helptext");
|
||||
$stractivities = get_string("activities");
|
||||
$stroptions = get_string("action");
|
||||
$strtype = get_string("group");
|
||||
|
||||
/// init this here so we can pass it by reference to every call to site_scale_used to avoid getting the courses out of the db over and over again
|
||||
$courses = array();
|
||||
|
||||
/// If scale data is being submitted, then save it and continue
|
||||
$focus = "";
|
||||
$errors = NULL;
|
||||
print_header($strscales);
|
||||
|
||||
if ($action == 'sendform' and confirm_sesskey()) {
|
||||
if ($form = data_submitted()) {
|
||||
if (empty($form->name)) {
|
||||
$errors[$scaleid]->name = true;
|
||||
$focus = "form$scaleid.save";
|
||||
}
|
||||
if (empty($form->scalescale)) {
|
||||
$errors[$scaleid]->scalescale = true;
|
||||
$focus = "form$scaleid.save";
|
||||
}
|
||||
if ($scales = get_records("scale", "courseid", "$course->id", "name ASC")) {
|
||||
print_heading($strcustomscales);
|
||||
|
||||
if (!$errors) {
|
||||
$newscale=NULL;
|
||||
$newscale->name = $form->name;
|
||||
$newscale->scale = $form->scalescale;
|
||||
$newscale->description = $form->description;
|
||||
$newscale->courseid = $form->courseid;
|
||||
$newscale->userid = $USER->id;
|
||||
$newscale->timemodified = time();
|
||||
if (has_capability('moodle/course:managescales', $context)) {
|
||||
echo "<p align=\"center\">(";
|
||||
print_string("scalestip");
|
||||
echo ")</p>";
|
||||
}
|
||||
|
||||
if (empty($scaleid)) {
|
||||
$newscale->courseid = $course->id;
|
||||
if (!insert_record("scale", $newscale)) {
|
||||
error("Could not insert the new scale!");
|
||||
}
|
||||
} else {
|
||||
$newscale->id = $scaleid;
|
||||
if (!update_record("scale", $newscale)) {
|
||||
error("Could not update that scale!");
|
||||
}
|
||||
}
|
||||
foreach ($scales as $scale) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
$notify = "$newscale->name: $strchangessaved";
|
||||
$focus = "form$scaleid.save";
|
||||
} else {
|
||||
if (!empty($scaleid)) {
|
||||
$action = "edit";
|
||||
} else {
|
||||
$action = "new";
|
||||
}
|
||||
}
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
echo "<hr />";
|
||||
}
|
||||
|
||||
} else {
|
||||
if (has_capability('moodle/course:managescales', $context)) {
|
||||
echo "<p align=\"center\">(";
|
||||
print_string("scalestip");
|
||||
echo ")</p>";
|
||||
}
|
||||
}
|
||||
|
||||
//If action is details, show the popup info
|
||||
if ($action == "details") {
|
||||
//Check for teacher edit
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
//Check for scale
|
||||
if (! $scale = get_record("scale", "id", $scaleid)) {
|
||||
error("Scale ID was incorrect");
|
||||
}
|
||||
if ($scales = get_records("scale", "courseid", "0", "name ASC")) {
|
||||
print_heading($strstandardscales);
|
||||
foreach ($scales as $scale) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
// $scales_course_uses = course_scale_used($course->id,$scale->id);
|
||||
// $scales_site_uses = site_scale_used($scale->id,$courses);
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
print_header("$course->shortname: $strscales", $course->fullname,
|
||||
"$course->shortname -> $strscales -> $scale->name", "", "", true, " ", " ");
|
||||
|
||||
close_window_button();
|
||||
|
||||
echo "<p/>";
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
echo "<p/>";
|
||||
|
||||
close_window_button();
|
||||
print_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
//If action is edit or new, show the form
|
||||
if ($action == "edit" || $action == "new") {
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
//Check for scale if action = edit
|
||||
if ($action == "edit") {
|
||||
if (! $scale = get_record("scale", "id", $scaleid)) {
|
||||
error("Scale ID was incorrect");
|
||||
}
|
||||
} else {
|
||||
$scale = new object();
|
||||
$scale->id = 0;
|
||||
$scale->courseid = $course->id;
|
||||
$scale->name = "";
|
||||
$scale->scale = "";
|
||||
$scale->description = "";
|
||||
}
|
||||
|
||||
//Calculate the uses
|
||||
if ($scale->courseid == 0) {
|
||||
$scale_uses = site_scale_used($scale->id,$courses);
|
||||
} else {
|
||||
$scale_uses = course_scale_used($course->id,$scale->id);
|
||||
}
|
||||
|
||||
//Check for scale_uses
|
||||
if (!empty($scale_uses)) {
|
||||
error("Scale is in use and cannot be modified",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
|
||||
}
|
||||
|
||||
//Check for standard scales
|
||||
if ($scale->courseid == 0 and !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
error("Only administrators can edit this scale",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
|
||||
}
|
||||
|
||||
//Print out the headers
|
||||
print_header("$course->shortname: $strscales", $course->fullname,
|
||||
"<a href=\"view.php?id=$course->id\">$course->shortname</a>".
|
||||
" -> <a href=\"scales.php?id=$course->id\">$strscales</a>".
|
||||
" -> ".get_string("editinga","",$strscale), $focus);
|
||||
|
||||
//Title
|
||||
print_heading_with_help($strscales, "scales");
|
||||
|
||||
if (!empty($errors) and ($form->scaleid == $scale->id)) {
|
||||
$scale->name = $form->name;
|
||||
$scale->scale = $form->scalescale;
|
||||
$scale->description = $form->description;
|
||||
}
|
||||
echo "<form method=\"post\" action=\"scales.php\" id=\"form$scale->id\">";
|
||||
echo "<table cellpadding=\"9\" cellspacing=\"0\" align=\"center\" class=\"generalbox\">";
|
||||
echo "<tr valign=\"top\">";
|
||||
if (!empty($errors[$scale->id]->name)) {
|
||||
$class = "class=\"highlight\"";
|
||||
} else {
|
||||
$class = "";
|
||||
}
|
||||
echo "<td align=\"right\"><b>$strname:</b></td>";
|
||||
echo "<td $class><input type=\"text\" name=\"name\" size=\"50\" value=\"".s($scale->name)."\" />";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "<tr valign=\"top\">";
|
||||
if (!empty($errors[$scale->id]->scalescale)) {
|
||||
$class = "class=\"highlight\"";
|
||||
} else {
|
||||
$class = "";
|
||||
}
|
||||
echo "<td align=\"right\"><b>$strscale:</b></td>";
|
||||
echo "<td $class><textarea name=\"scalescale\" cols=\"50\" rows=\"2\" wrap=\"virtual\">".s($scale->scale)."</textarea>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\"><b>$strdescription:</b>";
|
||||
helpbutton("text", $strhelptext);
|
||||
echo "</td>";
|
||||
echo "<td><textarea name=\"description\" cols=\"50\" rows=\"8\" wrap=\"virtual\">".s($scale->description)."</textarea>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
if ($scale->id) {
|
||||
echo "<tr valign=\"top\">";
|
||||
echo "<td align=\"right\">";
|
||||
echo "</td>";
|
||||
echo "<td>".get_string("usedinnplaces","",$scale_uses);
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\" align=\"center\">";
|
||||
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$sesskey\" />";
|
||||
echo "<input type=\"hidden\" name=\"courseid\" value=\"$scale->courseid\" />";
|
||||
echo "<input type=\"hidden\" name=\"scaleid\" value=\"$scale->id\" />";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"sendform\" />";
|
||||
echo "<input type=\"submit\" name=\"save\" value=\"$strsavechanges\" />";
|
||||
echo "</td></tr></table>";
|
||||
echo "</form>";
|
||||
echo "<br />";
|
||||
|
||||
print_footer($course);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
//If action is delete, do it
|
||||
if ($action == "delete" and confirm_sesskey()) {
|
||||
//Check for teacher edit
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
//Check for scale if action = edit
|
||||
if (! $scale = get_record("scale", "id", $scaleid)) {
|
||||
error("Scale ID was incorrect");
|
||||
}
|
||||
|
||||
//Calculate the uses
|
||||
if ($scale->courseid == 0) {
|
||||
$scale_uses = site_scale_used($scale->id,$courses);
|
||||
} else {
|
||||
$scale_uses = course_scale_used($course->id,$scale->id);
|
||||
}
|
||||
|
||||
//Check for scale_uses
|
||||
if (!empty($scale_uses)) {
|
||||
error("Scale is in use and cannot be deleted",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
|
||||
}
|
||||
|
||||
//Check for standard scales
|
||||
if ($scale->courseid == 0 and !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
error("Only administrators can delete this scale",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
|
||||
}
|
||||
|
||||
if (delete_records("scale", "id", $scaleid)) {
|
||||
$notify = "$scale->name: $strdeleted";
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
echo "<hr />";
|
||||
}
|
||||
}
|
||||
|
||||
//If action is down or up, do it
|
||||
if (($action == "down" || $action == "up") and confirm_sesskey()) {
|
||||
//Check for teacher edit
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
//Check for scale if action = edit
|
||||
if (! $scale = get_record("scale", "id", $scaleid)) {
|
||||
error("Scale ID was incorrect");
|
||||
}
|
||||
|
||||
//Calculate the uses
|
||||
if ($scale->courseid == 0) {
|
||||
$scale_uses = site_scale_used($scale->id,$courses);
|
||||
} else {
|
||||
$scale_uses = course_scale_used($course->id,$scale->id);
|
||||
}
|
||||
|
||||
//Check for scale_uses
|
||||
if (!empty($scale_uses)) {
|
||||
error("Scale is in use and cannot be moved",$CFG->wwwroot.'/course/scales.php?id='.$course->id);
|
||||
}
|
||||
|
||||
if ($action == "down") {
|
||||
$scale->courseid = 0;
|
||||
} else {
|
||||
$scale->courseid = $course->id;
|
||||
}
|
||||
|
||||
if (set_field("scale", "courseid", $scale->courseid, "id", $scale->id)) {
|
||||
$notify = "$scale->name: $strmoved";
|
||||
}
|
||||
}
|
||||
|
||||
if ($list) { /// Just list the scales (in a helpwindow)
|
||||
require_capability('moodle/course:viewscales', $context);
|
||||
print_header($strscales);
|
||||
|
||||
if (!empty($scaleid)) {
|
||||
if ($scale = get_record("scale", "id", "$scaleid")) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
}
|
||||
echo "<br />";
|
||||
close_window_button();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($scales = get_records("scale", "courseid", "$course->id", "name ASC")) {
|
||||
print_heading($strcustomscales);
|
||||
|
||||
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo "<p align=\"center\">(";
|
||||
print_string("scalestip");
|
||||
echo ")</p>";
|
||||
}
|
||||
|
||||
foreach ($scales as $scale) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
echo "<hr />";
|
||||
}
|
||||
|
||||
} else {
|
||||
if (has_capability('moodle/course:managescales', $context)) {
|
||||
echo "<p align=\"center\">(";
|
||||
print_string("scalestip");
|
||||
echo ")</p>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($scales = get_records("scale", "courseid", "0", "name ASC")) {
|
||||
print_heading($strstandardscales);
|
||||
foreach ($scales as $scale) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
print_simple_box_start("center");
|
||||
print_heading($scale->name);
|
||||
echo "<center>";
|
||||
choose_from_menu($scalemenu, "", "", "");
|
||||
echo "</center>";
|
||||
echo text_to_html($scale->description);
|
||||
print_simple_box_end();
|
||||
echo "<hr />";
|
||||
}
|
||||
}
|
||||
|
||||
close_window_button();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/// The rest is all about editing the scales
|
||||
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
/// Print out the main page
|
||||
|
||||
print_header("$course->shortname: $strscales", $course->fullname,
|
||||
"<a href=\"view.php?id=$course->id\">$course->shortname</a>
|
||||
-> $strscales");
|
||||
|
||||
print_heading_with_help($strscales, "scales");
|
||||
|
||||
$options = array();
|
||||
$options['id'] = $course->id;
|
||||
$options['scaleid'] = 0;
|
||||
$options['action'] = 'new';
|
||||
|
||||
print_simple_box_start('center');
|
||||
print_single_button($CFG->wwwroot.'/course/scales.php',$options,$srtcreatenewscale,'POST');
|
||||
print_simple_box_end();
|
||||
echo "<p />";
|
||||
|
||||
if (!empty($notify)) {
|
||||
notify($notify, "green");
|
||||
}
|
||||
|
||||
$scales = array();
|
||||
$customscales = get_records("scale", "courseid", "$course->id", "name ASC");
|
||||
$standardscales = get_records("scale", "courseid", "0", "name ASC");
|
||||
|
||||
if ($customscales) {
|
||||
foreach($customscales as $scale) {
|
||||
$scales[] = $scale;
|
||||
}
|
||||
}
|
||||
|
||||
if ($standardscales) {
|
||||
foreach($standardscales as $scale) {
|
||||
$scales[] = $scale;
|
||||
}
|
||||
}
|
||||
|
||||
if ($scales) {
|
||||
//Calculate the base path
|
||||
$path = "$CFG->wwwroot/course";
|
||||
|
||||
$data = array();
|
||||
$incustom = true;
|
||||
foreach($scales as $scale) {
|
||||
//Check the separator
|
||||
if (empty($scale->courseid) && $incustom) {
|
||||
$incustom = false;
|
||||
$line = "hr";
|
||||
$data[] = $line;
|
||||
}
|
||||
$line = array();
|
||||
$line[] = "<a target=\"scale\" title=\"$scale->name\" href=\"$CFG->wwwroot/course/scales.php?id=$course->id&scaleid=$scale->id&action=details\" "."onclick=\"return openpopup('/course/scales.php?id=$course->id\&scaleid=$scale->id&action=details', 'scale', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">".$scale->name."</a><br /><font size=\"-1\">".str_replace(",",", ",$scale->scale)."</font>";
|
||||
if (!empty($scale->courseid)) {
|
||||
$scales_uses = course_scale_used($course->id,$scale->id);
|
||||
} else {
|
||||
$scales_uses = site_scale_used($scale->id,$courses);
|
||||
}
|
||||
$line[] = $scales_uses;
|
||||
if ($incustom) {
|
||||
$line[] = $strcustomscale;
|
||||
} else {
|
||||
$line[] = $strstandardscale;
|
||||
}
|
||||
$buttons = "";
|
||||
if (empty($scales_uses) && ($incustom || has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID)))) {
|
||||
$buttons .= "<a title=\"$stredit\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=edit\"><img".
|
||||
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
|
||||
if ($incustom && has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$buttons .= "<a title=\"$strdown\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=down&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/down.gif\" class=\"iconsmall\" alt=\"$strdown\" /></a> ";
|
||||
}
|
||||
if (!$incustom && has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$buttons .= "<a title=\"$strup\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=up&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/up.gif\" class=\"iconsmall\" alt=\"$strup\" /></a> ";
|
||||
}
|
||||
$buttons .= "<a title=\"$strdelete\" href=\"$path/scales.php?id=$course->id&scaleid=$scale->id&action=delete&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
|
||||
}
|
||||
$line[] = $buttons;
|
||||
|
||||
$data[] = $line;
|
||||
}
|
||||
$head = $strscale.",".$stractivities.",".$strtype.",".$stroptions;
|
||||
$table->head = explode(",",$head);
|
||||
$size = "50%,20%,20%,10%";
|
||||
$table->size = explode(",",$size);
|
||||
$align = "left,center,center,center";
|
||||
$table->align = explode(",",$align);
|
||||
$wrap = ",nowrap,nowrap,nowrap";
|
||||
$table->wrap = explode(",",$wrap);
|
||||
$table->width = "90%";
|
||||
$table->data = $data;
|
||||
print_table ($table);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
close_window_button();
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
TODO
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php';
|
||||
require_once 'edit_form.php';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
|
||||
|
||||
$mform = new edit_scale_form(null, array('gpr'=>$gpr));
|
||||
if ($scale = get_record('scale', 'id', $id)) {
|
||||
$scale->custom = (int)(!empty($scale->courseid));
|
||||
if (!empty($scale->courseid)) {
|
||||
require_capability('moodle/course:managescales', $systemcontext);
|
||||
}
|
||||
$scale->courseid = $courseid;
|
||||
$options = new object();
|
||||
$options->smiley = false;
|
||||
$options->filter = false;
|
||||
$options->noclean = false;
|
||||
$scale->description = format_text($scale->description, FORMAT_MOODLE, $options);
|
||||
$mform->set_data($scale);
|
||||
|
||||
} else {
|
||||
$mform->set_data(array('courseid'=>$courseid, 'custom'=>1));
|
||||
}
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($data = $mform->get_data(false)) {
|
||||
$scale = new grade_scale(array('id'=>$id));
|
||||
$data->userid = $USER->id;
|
||||
grade_scale::set_properties($scale, $data);
|
||||
|
||||
if (empty($scale->id)) {
|
||||
$scale->courseid = $courseid;
|
||||
if (empty($data->custom) and has_capability('moodle/course:managescales', $systemcontext)) {
|
||||
$scale->courseid = 0;
|
||||
}
|
||||
$scale->insert();
|
||||
|
||||
} else {
|
||||
if (isset($data->custom)) {
|
||||
$scale->courseid = $data->custom ? $courseid : 0;
|
||||
} else {
|
||||
unset($scale->couseid);
|
||||
}
|
||||
$scale->update();
|
||||
}
|
||||
|
||||
redirect($returnurl, 'temp debug delay', 3);
|
||||
}
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$strgraderreport = get_string('graderreport', 'grades');
|
||||
$strscaleedit = get_string('scale');
|
||||
|
||||
$nav = array(array('name'=>$strgrades,'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$strscaleedit, 'link'=>'', 'type'=>'misc'));
|
||||
|
||||
$navigation = build_navigation($nav);
|
||||
|
||||
|
||||
print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strscaleedit, $navigation, '', '', true, '', navmenu($course));
|
||||
|
||||
$mform->display();
|
||||
|
||||
print_footer($course);
|
||||
die;
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class edit_scale_form extends moodleform {
|
||||
function definition() {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
// visible elements
|
||||
$mform->addElement('header', 'general', get_string('scale'));
|
||||
|
||||
$mform->addElement('text', 'name', get_string('name'));
|
||||
$mform->addRule('name', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('advcheckbox', 'custom', get_string('coursescale', 'grades'));
|
||||
|
||||
$mform->addElement('static', 'activities', get_string('activities'));
|
||||
|
||||
$mform->addElement('textarea', 'scale', get_string('scale'), array('cols'=>50, 'rows'=>2));
|
||||
$mform->addRule('scale', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('scale', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('htmleditor', 'description', get_string('description'), array('cols'=>80, 'rows'=>20));
|
||||
|
||||
|
||||
// hidden params
|
||||
$mform->addElement('hidden', 'id', 0);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'courseid', 0);
|
||||
$mform->setType('courseid', PARAM_INT);
|
||||
|
||||
/// add return tracking info
|
||||
$gpr = $this->_customdata['gpr'];
|
||||
$gpr->add_mform_elements($mform);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// buttons
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
|
||||
/// tweak the form - depending on existing data
|
||||
function definition_after_data() {
|
||||
global $CFG;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if ($id = $mform->getElementValue('id')) {
|
||||
$scale = grade_scale::fetch(array('id'=>$id));
|
||||
if ($count = $scale->get_uses_count()) {
|
||||
if (empty($scale->courseid)) {
|
||||
$mform->hardFreeze('custom');
|
||||
}
|
||||
$mform->hardFreeze('scale');
|
||||
}
|
||||
$activities_el =& $mform->getElement('activities');
|
||||
$activities_el->setValue(get_string('usedinnplaces', '', $count));
|
||||
|
||||
} else {
|
||||
$mform->removeElement('activities');
|
||||
if (!has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$mform->hardFreeze('custom');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// perform extra validation before submission
|
||||
function validation($data){
|
||||
$errors= array();
|
||||
|
||||
$options = explode(',', $data['scale']);
|
||||
if (count($options) < 2) {
|
||||
$errors['scale'] = get_string('error');
|
||||
}
|
||||
|
||||
if (0 == count($errors)){
|
||||
return true;
|
||||
} else {
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php // $Id$
|
||||
// Allows a creator to edit custom scales, and also display help about scales
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
/// Make sure they can even access this course
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'scale', 'courseid'=>$courseid));
|
||||
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$pagename = get_string('scales');
|
||||
|
||||
$navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$pagename, 'link'=>'', 'type'=>'misc'));
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
$strscale = get_string('scale');
|
||||
$strstandardscale = get_string('scalesstandard');
|
||||
$strcustomscales = get_string('coursescales', 'grades');
|
||||
$strname = get_string('name');
|
||||
$strdelete = get_string('delete');
|
||||
$stredit = get_string('edit');
|
||||
$srtcreatenewscale = get_string('scalescustomcreate');
|
||||
$stractivities = get_string('activities');
|
||||
$stroptions = get_string('action');
|
||||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (!confirm_sesskey()) {
|
||||
break;
|
||||
}
|
||||
$scaleid = required_param('scaleid', PARAM_INT);
|
||||
if (!$scale = grade_scale::fetch(array('id'=>$scaleid))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($scale->courseid)) {
|
||||
require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
|
||||
}
|
||||
|
||||
if (!$scale->can_delete()) {
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO: add confirmation
|
||||
$scale->delete();
|
||||
break;
|
||||
}
|
||||
|
||||
/// Print header
|
||||
print_header_simple($strgrades.': '.$pagename, ': '.$strgrades, $navigation,
|
||||
'', '', true, '', navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'edit', 'scale');
|
||||
|
||||
|
||||
print_heading($strstandardscale);
|
||||
if ($scales = grade_scale::fetch_all(array('courseid'=>0))) {
|
||||
$data = array();
|
||||
foreach($scales as $scale) {
|
||||
$line = array();
|
||||
$line[] = format_string($scale->name).'<div class="scale_options">'.str_replace(",",", ",$scale->scale).'</div>';
|
||||
|
||||
$scales_uses = $scale->get_uses_count();
|
||||
$line[] = $scales_uses;
|
||||
|
||||
$buttons = "";
|
||||
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$buttons .= "<a title=\"$stredit\" href=\"edit.php?courseid=$course->id&id=$scale->id\"><img".
|
||||
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
|
||||
}
|
||||
if (empty($scales_uses) and has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
$buttons .= "<a title=\"$strdelete\" href=\"index.php?id=$course->id&scaleid=$scale->id&action=delete&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
|
||||
}
|
||||
$line[] = $buttons;
|
||||
$data[] = $line;
|
||||
}
|
||||
$table->head = array($strscale, $stractivities, $stroptions);
|
||||
$table->size = array('70%', '20%', '10%');
|
||||
$table->align = array('left', 'center', 'center');
|
||||
$table->width = '90%';
|
||||
$table->data = $data;
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
print_heading($strcustomscales);
|
||||
if ($scales = grade_scale::fetch_all(array('courseid'=>$courseid))) {
|
||||
$data = array();
|
||||
foreach($scales as $scale) {
|
||||
$line = array();
|
||||
$line[] = format_string($scale->name).'<div class="scale_options">'.str_replace(",",", ",$scale->scale).'</div>';
|
||||
|
||||
$scales_uses = $scale->get_uses_count();
|
||||
$line[] = $scales_uses;
|
||||
|
||||
$buttons = "";
|
||||
$buttons .= "<a title=\"$stredit\" href=\"edit.php?courseid=$course->id&id=$scale->id\"><img".
|
||||
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
|
||||
if (empty($scales_uses)) {
|
||||
$buttons .= "<a title=\"$strdelete\" href=\"index.php?id=$course->id&scaleid=$scale->id&action=delete&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
|
||||
}
|
||||
$line[] = $buttons;
|
||||
$data[] = $line;
|
||||
}
|
||||
$table->head = array($strscale, $stractivities, $stroptions);
|
||||
$table->size = array('70%', '20%', '10%');
|
||||
$table->align = array('left', 'center', 'center');
|
||||
$table->width = '90%';
|
||||
$table->data = $data;
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
echo '<div class="buttons">';
|
||||
print_single_button('edit.php', array('courseid'=>$courseid), $srtcreatenewscale);
|
||||
echo '</div>';
|
||||
|
||||
print_footer($course);
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
@@ -16,7 +16,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/edit/tree.php?id='.$course->id);
|
||||
$returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/edit/tree/index.php?id='.$course->id);
|
||||
|
||||
// get the grading tree object
|
||||
$gtree = new grade_tree($courseid, false, false);
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once 'calculation_form.php';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php';
|
||||
require_once 'category_form.php';
|
||||
@@ -18,7 +18,7 @@ require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('tree.php?id='.$course->id);
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
|
||||
|
||||
|
||||
$mform = new edit_category_form(null, array('gpr'=>$gpr));
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once 'grade_form.php';
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
@@ -42,7 +42,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'courseid'=>$courseid));
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'tree', 'courseid'=>$courseid));
|
||||
$returnurl = $gpr->get_return_url(null);
|
||||
|
||||
//first make sure we have proper final grades - we need it for locking changes
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php';
|
||||
require_once 'item_form.php';
|
||||
@@ -18,7 +18,7 @@ require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('tree.php?id='.$course->id);
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
|
||||
|
||||
$mform = new edit_item_form(null, array('gpr'=>$gpr));
|
||||
|
||||
@@ -29,7 +29,7 @@ if ($mform->is_cancelled()) {
|
||||
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
||||
// redirect if outcomeid present
|
||||
if (!empty($item->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ if ($data = $mform->get_data()) {
|
||||
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
|
||||
grade_item::set_properties($grade_item, $data);
|
||||
|
||||
$grade_item->outcomeid = null;
|
||||
|
||||
if (empty($grade_item->id)) {
|
||||
$grade_item->itemtype = 'manual'; // all new items to be manual only
|
||||
$grade_item->insert();
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php';
|
||||
require_once 'outcomeitem_form.php';
|
||||
@@ -18,7 +18,7 @@ require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('tree.php?id='.$course->id);
|
||||
$returnurl = $gpr->get_return_url('index.php?id='.$course->id);
|
||||
|
||||
$mform = new edit_outcomeitem_form(null, array('gpr'=>$gpr));
|
||||
|
||||
@@ -29,7 +29,7 @@ if ($mform->is_cancelled()) {
|
||||
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
||||
// redirect if outcomeid present
|
||||
if (empty($item->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
|
||||
+34
-18
@@ -93,13 +93,33 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
|
||||
}
|
||||
|
||||
/// editing scripts - not real plugins
|
||||
if (has_capability('moodle/grade:manage', $context)) {
|
||||
if (has_capability('moodle/grade:manage', $context)
|
||||
or has_capability('moodle/course:managescales', $context)) {
|
||||
$menu['edit']='--'.get_string('edit');
|
||||
$url = 'edit/tree.php?id='.$courseid;
|
||||
if ($active_type == 'edit' and $active_plugin == 'tree' ) {
|
||||
$active = $url;
|
||||
|
||||
if (has_capability('moodle/grade:manage', $context)) {
|
||||
$url = 'edit/tree/index.php?id='.$courseid;
|
||||
if ($active_type == 'edit' and $active_plugin == 'tree' ) {
|
||||
$active = $url;
|
||||
}
|
||||
$menu[$url] = get_string('edittree', 'grades');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:managescales', $context)) {
|
||||
$url = 'edit/scale/index.php?id='.$courseid;
|
||||
if ($active_type == 'edit' and $active_plugin == 'scale' ) {
|
||||
$active = $url;
|
||||
}
|
||||
$menu[$url] = get_string('scales');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/grade:manage', $context)) { // TODO: add outcome cap
|
||||
$url = 'edit/outcome/index.php?id='.$courseid;
|
||||
if ($active_type == 'edit' and $active_plugin == 'outcome' ) {
|
||||
$active = $url;
|
||||
}
|
||||
$menu[$url] = get_string('outcomes', 'grades');
|
||||
}
|
||||
$menu[$url] = get_string('edittree', 'grades');
|
||||
}
|
||||
|
||||
/// finally print/return the popup form
|
||||
@@ -175,10 +195,6 @@ class grade_plugin_return {
|
||||
function get_return_url($default, $extras=null) {
|
||||
global $CFG;
|
||||
|
||||
if ($this->type == 'edit') {
|
||||
return $CFG->wwwroot.'/grade/edit/tree.php?id='.$this->courseid;
|
||||
}
|
||||
|
||||
if (empty($this->type) or empty($this->plugin)) {
|
||||
return $default;
|
||||
}
|
||||
@@ -581,21 +597,21 @@ class grade_tree {
|
||||
case 'categoryitem':
|
||||
case 'courseitem':
|
||||
if (empty($object->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/item.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/item.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcomeitem.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/outcomeitem.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
}
|
||||
$url = $gpr->add_url_params($url);
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$url = $CFG->wwwroot.'/grade/edit/category.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/category.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $gpr->add_url_params($url);
|
||||
break;
|
||||
|
||||
case 'grade':
|
||||
//TODO: improve dealing with new grades
|
||||
$url = $CFG->wwwroot.'/grade/edit/grade.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/grade.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $gpr->add_url_params($url);
|
||||
if (!empty($object->feedback)) {
|
||||
$feedback = format_text($object->feedback, $object->feedbackformat);
|
||||
@@ -636,12 +652,12 @@ class grade_tree {
|
||||
}
|
||||
|
||||
if ($element['object']->is_hidden()) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/action.php?id='.$this->courseid.'&action=show&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.$this->courseid.'&action=show&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/show.gif" class="iconsmall" alt="'.$strshow.'" title="'.$strshow.'"/></a>';
|
||||
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/action.php?id='.$this->courseid.'&action=hide&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.$this->courseid.'&action=hide&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/hide.gif" class="iconsmall" alt="'.$strhide.'" title="'.$strhide.'"/></a>';
|
||||
}
|
||||
@@ -667,7 +683,7 @@ class grade_tree {
|
||||
if (!has_capability('moodle/grade:manage', $this->context) and !has_capability('moodle/grade:unlock', $this->context)) {
|
||||
return '';
|
||||
}
|
||||
$url = $CFG->wwwroot.'/grade/edit/action.php?id='.$this->courseid.'&action=unlock&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.$this->courseid.'&action=unlock&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/unlock.gif" class="iconsmall" alt="'.$strunlock.'" title="'.$strunlock.'"/></a>';
|
||||
|
||||
@@ -675,7 +691,7 @@ class grade_tree {
|
||||
if (!has_capability('moodle/grade:manage', $this->context) and !has_capability('moodle/grade:lock', $this->context)) {
|
||||
return '';
|
||||
}
|
||||
$url = $CFG->wwwroot.'/grade/edit/action.php?id='.$this->courseid.'&action=lock&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.$this->courseid.'&action=lock&sesskey='.sesskey().'&eid='.$element['eid'];
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'"><img src="'.$CFG->pixpath.'/t/lock.gif" class="iconsmall" alt="'.$strlock.'" title="'.$strlock.'"/></a>';
|
||||
}
|
||||
@@ -703,7 +719,7 @@ class grade_tree {
|
||||
|
||||
// show calculation icon only when calculation possible
|
||||
if (!$object->is_normal_item() and ($object->gradetype == GRADE_TYPE_SCALE or $object->gradetype == GRADE_TYPE_VALUE)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/calculation.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/calculation.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
$url = $gpr->add_url_params($url);
|
||||
$calculation_icon = '<a href="'. $url.'"><img src="'.$CFG->pixpath.'/t/calc.gif" class="iconsmall" alt="'
|
||||
. $streditcalculation.'" title="'.$streditcalculation.'" /></a>'. "\n";
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
$string['addoutcome'] = 'Add an outcome';
|
||||
$string['courseoutcomes'] = 'Course outcomes';
|
||||
$string['coursespecoutcome'] = 'Course outcomes';
|
||||
$string['modulename'] = 'Outcomes';
|
||||
$string['modulename'] = 'Outcomes report';
|
||||
$string['usedgradeitem'] = 'Number of grade items';
|
||||
?>
|
||||
|
||||
@@ -91,7 +91,7 @@ $string['editcalculation'] = 'Edit Calculation';
|
||||
$string['editfeedback'] = 'Edit Feedback';
|
||||
$string['editgrade'] = 'Edit Grade';
|
||||
$string['editoutcomes'] = 'Edit outcomes';
|
||||
$string['edittree'] = 'Categories';
|
||||
$string['edittree'] = 'Categories and items';
|
||||
$string['enableajax'] = 'Enable AJAX';
|
||||
$string['enableoutcomes'] = 'Enable outcomes';
|
||||
$string['encoding'] = 'Encoding';
|
||||
|
||||
@@ -169,5 +169,48 @@ class grade_scale extends grade_object {
|
||||
|
||||
return $scales[$grade-1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if scale can be deleted.
|
||||
* @return boolean
|
||||
*/
|
||||
function can_delete() {
|
||||
$count = $this->get_uses_count();
|
||||
return empty($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of places where scale is used - activities, grade items, outcomes, etc.
|
||||
* @return int
|
||||
*/
|
||||
function get_uses_count() {
|
||||
global $CFG;
|
||||
|
||||
$count = 0;
|
||||
if (!empty($this->courseid)) {
|
||||
if ($scales_uses = course_scale_used($this->courseid,$this->id)) {
|
||||
$count += count($scales_uses);
|
||||
}
|
||||
} else {
|
||||
$courses = array();
|
||||
if ($scales_uses = site_scale_used($this->id,$courses)) {
|
||||
$count += count($scales_uses);
|
||||
}
|
||||
}
|
||||
|
||||
// count grade items
|
||||
$sql = "SELECT COUNT(id) FROM {$CFG->prefix}grade_items WHERE scaleid = {$this->id} AND outcomeid IS NULL";
|
||||
if ($scales_uses = count_records_sql($sql)) {
|
||||
$count += $scales_uses;
|
||||
}
|
||||
|
||||
// count outcomes
|
||||
$sql = "SELECT COUNT(id) FROM {$CFG->prefix}grade_outcomes WHERE scaleid = {$this->id}";
|
||||
if ($scales_uses = count_records_sql($sql)) {
|
||||
$count += $scales_uses;
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -481,6 +481,10 @@ body#grade-index .grades .header {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
.grade-edit-scale .scale_options {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** Login
|
||||
|
||||
@@ -2145,9 +2145,22 @@ body#doc-contents ul {
|
||||
display: inline;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* scales edit */
|
||||
|
||||
.grade-edit-scale .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.grade-edit-scale .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
/* gradebook edit tree */
|
||||
|
||||
#grade-edit-edit_tree .gradetreebox {
|
||||
.grade-edit-tree .gradetreebox {
|
||||
width:70%;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
@@ -2155,40 +2168,39 @@ body#doc-contents ul {
|
||||
padding-bottom:15px;
|
||||
}
|
||||
|
||||
#grade-edit-tree .buttons {
|
||||
.grade-edit-tree .buttons {
|
||||
margin: 20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#grade-edit-tree .buttons .singlebutton {
|
||||
.grade-edit-tree .buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
|
||||
#grade-edit-tree .movetarget {
|
||||
.grade-edit-tree .movetarget {
|
||||
position: relative;
|
||||
width: 80px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
#grade-edit-tree ul#grade_tree {
|
||||
.grade-edit-tree ul#grade_tree {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#grade-edit-tree ul#grade_tree li {
|
||||
.grade-edit-tree ul#grade_tree li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#grade-edit-tree ul#grade_tree li.category {
|
||||
.grade-edit-tree ul#grade_tree li.category {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
#grade-edit-tree .moving {
|
||||
.grade-edit-tree .moving {
|
||||
background-color: #E8EEF7;
|
||||
}
|
||||
|
||||
#grade-edit-tree .iconsmall {
|
||||
.grade-edit-tree .iconsmall {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user