Пример #1
0
require_once $CFG->dirroot . '/grade/lib.php';
require_once $CFG->libdir . '/gradelib.php';
$courseid = optional_param('id', SITEID, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
if (!($course = get_record('course', 'id', $courseid))) {
    print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
    error('Missing permission to view letter grades');
}
$gpr = new grade_plugin_return(array('type' => 'edit', 'plugin' => 'letter', 'courseid' => $courseid));
$strgrades = get_string('grades');
$pagename = get_string('letters', 'grades');
print_grade_page_head($courseid, 'letter', 'view', get_string('gradeletters', 'grades'));
$letters = grade_get_letters($context);
$data = array();
$max = 100;
foreach ($letters as $boundary => $letter) {
    $line = array();
    $line[] = format_float($max, 2) . ' %';
    $line[] = format_float($boundary, 2) . ' %';
    $line[] = format_string($letter);
    $data[] = $line;
    $max = $boundary - 0.01;
}
$table = new object();
$table->head = array(get_string('max', 'grades'), get_string('min', 'grades'), get_string('letter', 'grades'));
$table->size = array('30%', '30%', '40%');
$table->align = array('left', 'left', 'left');
Пример #2
0
    $buttons = '';
}
$gradeserror = array();
// Handle toggle change request
if (!is_null($toggle) && !empty($toggle_type)) {
    set_user_preferences(array('grade_report_show' . $toggle_type => $toggle));
}
//first make sure we have proper final grades - this must be done before constructing of the grade tree
grade_regrade_final_grades($courseid);
// Perform actions
if (!empty($target) && !empty($action) && confirm_sesskey()) {
    grade_report_grader::process_action($target, $action);
}
$reportname = get_string('pluginname', 'gradereport_grader');
/// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
//Initialise the grader report object that produces the table
//the class grade_report_grader_ajax was removed as part of MDL-21562
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
// make sure separate group does not prevent view
if ($report->currentgroup == -2) {
    echo $OUTPUT->heading(get_string("notingroup"));
    echo $OUTPUT->footer();
    exit;
}
/// processing posted grades & feedback here
if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) {
    $warnings = $report->process_data($data);
} else {
    $warnings = array();
}
Пример #3
0
            $aid = $matches[2];
            $value = clean_param($value, PARAM_BOOL);
            $grade_item = grade_item::fetch(array('id' => $aid, 'courseid' => $courseid));
            $grade_item->{$param} = $value;
            $grade_item->update();
            $recreatetree = true;
        }
    }
    $originalweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
    grade_regrade_final_grades($courseid);
    $alteredweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
    if (array_diff($originalweights, $alteredweights)) {
        $normalisationmessage = get_string('weightsadjusted', 'grades');
    }
}
print_grade_page_head($courseid, 'settings', 'setup', get_string('categoriesanditems', 'grades'));
// Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox');
echo '<form id="gradetreeform" method="post" action="' . $returnurl . '">';
echo '<div>';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
//did we update something in the db and thus invalidate $grade_edit_tree?
if ($recreatetree) {
    $grade_edit_tree = new grade_edit_tree($gtree, $movingeid, $gpr);
}
// Check to see if we have a normalisation message to send.
if (!empty($normalisationmessage)) {
    echo $OUTPUT->notification($normalisationmessage, 'notifymessage');
}
echo html_writer::table($grade_edit_tree->table);
echo '<div id="gradetreesubmit">';
Пример #4
0
        }
        $grade_item->outcomeid = null;
        // update hiding flag
        if ($hiddenuntil) {
            $grade_item->set_hidden($hiddenuntil, false);
        } else {
            $grade_item->set_hidden($hidden, false);
        }
        $grade_item->set_locktime($locktime);
        // locktime first - it might be removed when unlocking
        $grade_item->set_locked($locked, false, true);
        $grade_item->update();
        // We don't need to insert it, it's already created when the category is created
        // set parent if needed
        if (isset($data->parentcategory)) {
            $grade_category->set_parent($data->parentcategory, 'gradebook');
        }
        // update agg coef if needed
        if (isset($data->aggregationcoef)) {
            $data->aggregationcoef = unformat_float($data->aggregationcoef);
            $grade_item = $grade_category->load_grade_item();
            $grade_item->aggregationcoef = $data->aggregationcoef;
            $grade_item->update();
        }
        redirect($returnurl);
    }
}
print_grade_page_head($courseid, 'edittree', null, $heading);
$mform->display();
print_footer($course);
die;
Пример #5
0
            // If we are using natural weight and the weight has been un-overriden, force parent category to recalculate weights.
            $grade_category->force_regrading();
        }
        $grade_item->weightoverride = $itemdata->weightoverride;
        $grade_item->outcomeid = null;
        if (!empty($data->grade_item_rescalegrades) && $data->grade_item_rescalegrades == 'yes') {
            $grade_item->rescale_grades_keep_percentage($grade_item_copy->grademin, $grade_item_copy->grademax, $grade_item->grademin, $grade_item->grademax, 'gradebook');
        }
        // update hiding flag
        if ($hiddenuntil) {
            $grade_item->set_hidden($hiddenuntil, false);
        } else {
            $grade_item->set_hidden($hidden, false);
        }
        $grade_item->set_locktime($locktime);
        // locktime first - it might be removed when unlocking
        $grade_item->set_locked($locked, false, true);
        $grade_item->update();
        // We don't need to insert it, it's already created when the category is created
        // set parent if needed
        if (isset($data->parentcategory)) {
            $grade_category->set_parent($data->parentcategory, 'gradebook');
        }
        redirect($returnurl);
    }
}
$PAGE->navbar->add($heading);
print_grade_page_head($courseid, 'settings', null, $heading, false, false, false);
$mform->display();
echo $OUTPUT->footer();
die;
Пример #6
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
require_once '../../config.php';
require_once $CFG->dirroot . '/grade/lib.php';
$id = required_param('id', PARAM_INT);
// course id
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:import', $context);
print_grade_page_head($course->id, 'import', 'keymanager', get_string('keymanager', 'grades'));
$stredit = get_string('edit');
$strdelete = get_string('delete');
$data = array();
$params = array($course->id, $USER->id);
if ($keys = $DB->get_records_select('user_private_key', "script='grade/import' AND instance=? AND userid=?", $params)) {
    foreach ($keys as $key) {
        $line = array();
        $line[0] = format_string($key->value);
        $line[1] = $key->iprestriction;
        $line[2] = empty($key->validuntil) ? get_string('always') : userdate($key->validuntil);
        $buttons = "<a title=\"{$stredit}\" href=\"key.php?id={$key->id}\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"{$stredit}\" /></a> ";
        $buttons .= "<a title=\"{$strdelete}\" href=\"key.php?id={$key->id}&amp;delete=1\"><img" . " src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"{$strdelete}\" /></a> ";
        $line[3] = $buttons;
        $data[] = $line;
    }
Пример #7
0
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
require_once '../../../config.php';
require_once $CFG->dirroot . '/grade/export/lib.php';
require_once 'grade_export_ods.php';
$id = required_param('id', PARAM_INT);
// course id
$PAGE->set_url('/grade/export/ods/index.php', array('id' => $id));
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/ods:view', $context);
print_grade_page_head($COURSE->id, 'export', 'ods', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_ods'));
if (!empty($CFG->gradepublishing)) {
    $CFG->gradepublishing = has_capability('gradeexport/ods:publish', $context);
}
$mform = new grade_export_form(null, array('publishing' => true));
$groupmode = groups_get_course_groupmode($course);
// Groups are being used
$currentgroup = groups_get_course_group($course, true);
if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
    echo $OUTPUT->heading(get_string("notingroup"));
    echo $OUTPUT->footer();
    die;
}
// process post information
if ($data = $mform->get_data()) {
    $export = new grade_export_ods($course, $currentgroup, '', false, false, $data->display, $data->decimals);
        }
        $line[] = $buttons;
        $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->width = '90%';
    $table->data = $data;
    $return .= html_writer::table($table);
    $outcomes_tables[] = $return;
}
if ($courseid) {
    /// Print header
    print_grade_page_head($courseid, 'outcome', 'edit', $heading);
}
foreach ($outcomes_tables as $table) {
    echo $table;
}
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->single_button(new moodle_url('edit.php', array('courseid' => $courseid)), $strcreatenewoutcome);
if (!empty($outcomes_tables)) {
    echo $OUTPUT->single_button(new moodle_url('export.php', array('id' => $courseid, 'sesskey' => sesskey())), get_string('exportalloutcomes', 'grades'));
}
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
/**
 * Local shortcut function for creating a link to a scale.
 * @param int $courseid The Course ID
 * @param grade_scale $scale The Scale to link to
    $disabledEP = 'disabled';
}
if (!isset($toolAE) || !$toolAE) {
    $disabledAE = 'disabled';
}
if (!isset($toolEI) || !$toolEI) {
    $disabledEI = 'disabled';
}
//--------------------------------------------------------------------------------
global $OUTPUT;
$PAGE->set_url(new moodle_url('/blocks/evalcomix/assessment/activity_edit_form.php', array('id' => $courseid)));
$PAGE->navbar->add('evalcomix', new moodle_url('../assessment/index.php?id=' . $courseid));
$context = context_course::instance($course->id);
//require_capability('block/evalcomix:edit', $context);
require_capability('moodle/block:edit', $context);
print_grade_page_head($COURSE->id, 'report', 'grader', null, false, '', false);
//Ln 199 antes era así
//<input type="hidden" id="maxgrade" name="maxgrade" value='.$activity->grade.'>
echo '			
		<center>
			<div><img src="' . $CFG->wwwroot . EVXLOGOROOT . '" width="230" alt="EvalCOMIX"/></div>
			<div><input type="button" style="color:#333333" value="' . get_string('designsection', 'block_evalcomix') . '" onclick="location.href=\'' . $CFG->wwwroot . '/blocks/evalcomix/tool/index.php?id=' . $courseid . '\'"/></div>
		</center>
	';
//-----------------------------------------------------------------------------------------------
echo '
		<script>
			function disabling(element, slavetag){
				if(element.value != 0)
					document.getElementById(slavetag).disabled = false;				
				else
Пример #10
0
        }
        // Handle null decimals value - must be done before update!
        if (!property_exists($itemdata, 'decimals') or $itemdata->decimals < 0) {
            $grade_item->decimals = null;
        }
        $grade_item->outcomeid = null;
        // update hiding flag
        if ($hiddenuntil) {
            $grade_item->set_hidden($hiddenuntil, false);
        } else {
            $grade_item->set_hidden($hidden, false);
        }
        $grade_item->set_locktime($locktime);
        // locktime first - it might be removed when unlocking
        $grade_item->set_locked($locked, false, true);
        $grade_item->update();
        // We don't need to insert it, it's already created when the category is created
        // set parent if needed
        if (isset($data->parentcategory)) {
            $grade_category->set_parent($data->parentcategory, 'gradebook');
        }
        redirect($returnurl);
    }
}
$return = false;
$buttons = false;
$shownavigation = false;
print_grade_page_head($courseid, 'edittree', null, $heading, $return, $buttons, $shownavigation);
$mform->display();
echo $OUTPUT->footer();
die;
 * This is a one-line short description of the file
 *
 * You can have a rather longer description of the file as well,
 * if you like, and it can span multiple lines.
 *
 * @package    grade_report_newgradereport
 * @author     Daniel Neis Araujo <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
include '../../../config.php';
require $CFG->libdir . '/gradelib.php';
require $CFG->dirroot . '/grade/lib.php';
require $CFG->dirroot . '/grade/report/newgradereport/lib.php';
$courseid = required_param('id', PARAM_INT);
// course id
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('invalidcourseid');
}
$PAGE->set_url(new moodle_url('/grade/report/newgradereport/index.php', array('id' => $courseid)));
require_login($courseid);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('gradereport/newgradereport:view', $context);
print_grade_page_head($COURSE->id, 'report', 'newgradereport', get_string('pluginname', 'gradereport_newgradereport') . $OUTPUT->help_icon('pluginname', 'gradereport_newgradereport'));
grade_regrade_final_grades($courseid);
//first make sure we have proper final grades
$gpr = new grade_plugin_return(array('type' => 'report', 'plugin' => 'grader', 'courseid' => $courseid));
// return tracking object
$report = new grade_report_newgradereport($courseid, $gpr, $context);
// Initialise the grader report object
$report->show();
echo $OUTPUT->footer();
Пример #12
0
            $data->description = $data->description_editor['text'];
            $data->descriptionformat = $data->description_editor['format'];
            grade_scale::set_properties($scale, $data);
            if (!has_capability('moodle/grade:manage', $systemcontext)) {
                $data->standard = 0;
            }
            $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            $scale->insert();
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale->id);
            $DB->set_field($scale->table, 'description', $data->description, array('id' => $scale->id));
        } else {
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $id);
            grade_scale::set_properties($scale, $data);
            if (isset($data->standard)) {
                $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            } else {
                unset($scale->courseid);
                // keep previous
            }
            $scale->update();
        }
        redirect($returnurl);
    }
}
if ($courseid) {
    print_grade_page_head($course->id, 'scale', 'edit', $heading);
} else {
    echo $OUTPUT->header();
}
$mform->display();
echo $OUTPUT->footer();
Пример #13
0
        $importcode = import_xml_grades($text, $course, $error);
        if ($importcode) {
            grade_import_commit($id, $importcode, $data->feedback, true);
            echo $OUTPUT->footer();
            die;
        } else {
            echo $OUTPUT->notification($error);
            echo $OUTPUT->continue_button($CFG->wwwroot . '/grade/index.php?id=' . $course->id);
            echo $OUTPUT->footer();
            die;
        }
    } else {
        if (empty($data->key)) {
            redirect('import.php?id=' . $id . '&amp;feedback=' . (int) $data->feedback . '&url=' . urlencode($data->url));
        } else {
            if ($data->key == 1) {
                $data->key = create_user_key('grade/import', $USER->id, $course->id, $data->iprestriction, $data->validuntil);
            }
            print_grade_page_head($COURSE->id, 'import', 'xml', get_string('importxml', 'grades'));
            echo '<div class="gradeexportlink">';
            $link = $CFG->wwwroot . '/grade/import/xml/fetch.php?id=' . $id . '&amp;feedback=' . (int) $data->feedback . '&amp;url=' . urlencode($data->url) . '&amp;key=' . $data->key;
            echo get_string('import', 'grades') . ': <a href="' . $link . '">' . $link . '</a>';
            echo '</div>';
            echo $OUTPUT->footer();
            die;
        }
    }
}
print_grade_page_head($COURSE->id, 'import', 'xml', get_string('importxml', 'grades'));
$mform->display();
echo $OUTPUT->footer();
Пример #14
0
$importcode = optional_param('importcode', '', PARAM_FILE);
$url = new moodle_url('/grade/import/direct/index.php', array('id' => $id));
if ($verbosescales !== 1) {
    $url->param('verbosescales', $verbosescales);
}
$PAGE->set_url($url);
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/direct:view', $context);
$separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
$currentgroup = groups_get_course_group($course);
print_grade_page_head($course->id, 'import', 'direct', get_string('pluginname', 'gradeimport_direct'), false, false, true, 'userdata', 'gradeimport_direct');
$renderer = $PAGE->get_renderer('gradeimport_csv');
// Get the grade items to be matched with the import mapping columns.
$gradeitems = gradeimport_csv_load_data::fetch_grade_items($course->id);
// If the csv file hasn't been imported yet then look for a form submission or
// show the initial submission form.
if (!$iid) {
    // Set up the import form.
    $mform = new gradeimport_direct_import_form(null, array('includeseparator' => true, 'verbosescales' => true, 'acceptedtypes' => array('.csv', '.txt')));
    // If the import form has been submitted.
    if ($formdata = $mform->get_data()) {
        $text = $formdata->userdata;
        $csvimport = new gradeimport_csv_load_data();
        $csvimport->load_csv_content($text, $formdata->encoding, 'tab', $formdata->previewrows);
        $csvimporterror = $csvimport->get_error();
        if (!empty($csvimporterror)) {
Пример #15
0
            } else {
                $itemname = $grade_item->get_name();
            }
            $outcomedata['outcome']->sum += $item->avg;
            $gradehtml = $scale->get_nearest_item($item->avg);
            $items_html .= "<td class=\"cell c3\">{$itemname}</td>" . "<td class=\"cell c4\">{$gradehtml} ({$item->avg})</td>" . "<td class=\"cell c5\">{$item->count}</td></tr>\n";
            $print_tr = true;
        }
    } else {
        $items_html .= "<td class=\"cell c3\"> - </td><td class=\"cell c4\"> - </td><td class=\"cell c5\"> 0 </td></tr>\n";
    }
    // Calculate outcome average
    if (is_array($outcomedata['items'])) {
        $count = count($outcomedata['items']);
        if ($count > 0) {
            $avg = $outcomedata['outcome']->sum / $count;
        } else {
            $avg = $outcomedata['outcome']->sum;
        }
        $avg_html = $scale->get_nearest_item($avg) . " (" . round($avg, 2) . ")\n";
    } else {
        $avg_html = ' - ';
    }
    $outcomeavg_html = '<td class="cell c1" rowspan="' . $rowspan . '">' . $avg_html . "</td>\n";
    $html .= $shortname_html . $outcomeavg_html . $sitewide_html . $items_html;
    $row++;
}
$html .= '</table>';
print_grade_page_head($courseid, 'report', 'outcomes');
echo $html;
print_footer($course);
Пример #16
0
    if (isset($CFG->CSV_ENCODE)) {
        $csv_encode = '/\\&\\#' . $CFG->CSV_ENCODE . '/';
    }
} else {
    if ($separator == 'tab') {
        $csv_delimiter = "\t";
        $csv_delimiter2 = "";
        $csv_encode = "";
    } else {
        $csv_delimiter = "\\,";
        $csv_delimiter2 = ",";
        $csv_encode = '/\\&\\#44/';
    }
}
$actionstr = get_string('csv', 'grades');
print_grade_page_head($course->id, 'import', 'csv');
// set up import form
$mform = new grade_import_form(null, array('includeseparator' => !isset($CFG->CSV_DELIMITER), 'verbosescales' => true));
// set up grade import mapping form
$header = '';
$gradeitems = array();
if ($id) {
    if ($grade_items = grade_item::fetch_all(array('courseid' => $id))) {
        foreach ($grade_items as $grade_item) {
            // skip course type and category type
            if ($grade_item->itemtype == 'course' || $grade_item->itemtype == 'category') {
                continue;
            }
            // this was idnumber
            $gradeitems[$grade_item->id] = $grade_item->get_name();
        }
Пример #17
0
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
// If data submitted, then process and store.
if (!$mform->is_cancelled() && ($data = $mform->get_data())) {
    foreach ($data as $preference => $value) {
        if (substr($preference, 0, 6) !== 'grade_') {
            continue;
        }
        if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
            unset_user_preference($preference);
        } else {
            set_user_preference($preference, $value);
        }
    }
    redirect($CFG->wwwroot . '/grade/report/grader/index.php?id=' . $courseid);
    // message here breaks accessability and is sloooowww
    exit;
}
if ($mform->is_cancelled()) {
    redirect($CFG->wwwroot . '/grade/report/grader/index.php?id=' . $courseid);
}
print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader'));
// If USER has admin capability, print a link to the site config page for this report
if (has_capability('moodle/site:config', $systemcontext)) {
    echo '<div id="siteconfiglink"><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=gradereportgrader">';
    echo get_string('changereportdefaults', 'grades');
    echo "</a></div>\n";
}
print_simple_box_start("center");
$mform->display();
print_simple_box_end();
print_footer($course);
Пример #18
0
}
// Hide advanced columns if moving
if ($grade_edit_tree->moving) {
    $original_gradeediting = $USER->gradeediting[$course->id];
    $USER->gradeediting[$course->id] = 0;
}
$CFG->stylesheets[] = $CFG->wwwroot . '/grade/edit/tree/tree.css';
$current_view_str = '';
if ($current_view != '') {
    if ($current_view == 'simpleview') {
        $current_view_str = get_string('simpleview', 'grades');
    } elseif ($current_view == 'fullview') {
        $current_view_str = get_string('fullview', 'grades');
    }
}
print_grade_page_head($courseid, 'edittree', $current_view, get_string('categoriesedit', 'grades') . ': ' . $current_view_str);
$form_key = optional_param('sesskey', null, PARAM_ALPHANUM);
if ($form_key && ($data = data_submitted())) {
    // Perform bulk actions first
    if (!empty($data->bulkmove) && confirm_sesskey()) {
        $elements = array();
        foreach ($data as $key => $value) {
            if (preg_match('/select_(i[0-9]*)/', $key, $matches)) {
                $elements[] = $matches[1];
            }
        }
        $grade_edit_tree->move_elements($elements, $returnurl);
    }
    // Category and item field updates
    foreach ($data as $key => $value) {
        // Grade category text inputs
Пример #19
0
        $studentnamelink = html_writer::link(new moodle_url('/user/view.php', array('id' => $report->user->id, 'course' => $courseid)), fullname($report->user));
        print_grade_page_head($courseid, 'report', 'user', get_string('pluginname', 'gradereport_user') . ' - ' . $studentnamelink, false, false, true, null, null, $report->user);
        groups_print_course_menu($course, $gpr->get_return_url('index.php?id=' . $courseid, array('userid' => 0)));
        if ($user_selector) {
            $renderer = $PAGE->get_renderer('gradereport_user');
            $showallusersoptions = true;
            echo $renderer->graded_users_selector('user', $course, $userid, $currentgroup, $showallusersoptions);
        }
        if ($currentgroup and !groups_is_member($currentgroup, $userid)) {
            echo $OUTPUT->notification(get_string('groupusernotmember', 'error'));
        } else {
            if ($report->fill_table()) {
                echo '<br />' . $report->print_table(true, $userid, $courseid);
                //START BY @HARSHA
                //echo '<br />'.$report->print_table(true);
            }
        }
    }
} else {
    //Students will see just their own report
    // Create a report instance
    $report = new grade_report_user($courseid, $gpr, $context, $userid);
    // print the page
    print_grade_page_head($courseid, 'report', 'user', get_string('pluginname', 'gradereport_user') . ' - ' . fullname($report->user));
    if ($report->fill_table()) {
        echo '<br />' . $report->print_table(true);
    }
}
// Trigger report viewed event.
$report->viewed();
echo $OUTPUT->footer();
Пример #20
0
        $line = array();
        $line[] = format_string($scale->name) . '<div class="scale_options">' . str_replace(",", ", ", $scale->scale) . '</div>';
        $used = $scale->is_used();
        $line[] = $used ? get_string('yes') : get_string('no');
        $buttons = "";
        if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
            $buttons .= grade_button('edit', $courseid, $scale);
        }
        if (!$used and has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
            $buttons .= grade_button('delete', $courseid, $scale);
        }
        $line[] = $buttons;
        $data[] = $line;
    }
    $table2->head = array($strscale, $strused, $stredit);
    $table->attributes['class'] = 'scaletable globalscales generaltable';
    $table2->size = array('70%', '20%', '10%');
    $table2->align = array('left', 'center', 'center');
    $table2->data = $data;
}
if ($courseid) {
    print_grade_page_head($courseid, 'scale', 'scale', get_string('coursescales', 'grades'));
}
echo $OUTPUT->heading($strcustomscales, 3, 'main');
echo html_writer::table($table);
echo $OUTPUT->heading($strstandardscale, 3, 'main');
echo html_writer::table($table2);
echo $OUTPUT->container_start('buttons');
echo $OUTPUT->single_button(new moodle_url('edit.php', array('courseid' => $courseid)), $srtcreatenewscale);
echo $OUTPUT->container_end();
echo $OUTPUT->footer();
Пример #21
0
    $url->param('separator', $separator);
}
if ($verbosescales !== 1) {
    $url->param('verbosescales', $verbosescales);
}
$PAGE->set_url($url);
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/csv:view', $context);
$separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
$currentgroup = groups_get_course_group($course);
print_grade_page_head($course->id, 'import', 'csv', get_string('importcsv', 'grades'));
// Set up the grade import mapping form.
$gradeitems = array();
if ($id) {
    if ($grade_items = grade_item::fetch_all(array('courseid' => $id))) {
        foreach ($grade_items as $grade_item) {
            // Skip course type and category type.
            if ($grade_item->itemtype == 'course' || $grade_item->itemtype == 'category') {
                continue;
            }
            $displaystring = null;
            if (!empty($grade_item->itemmodule)) {
                $displaystring = get_string('modulename', $grade_item->itemmodule) . get_string('labelsep', 'langconfig') . $grade_item->get_name();
            } else {
                $displaystring = $grade_item->get_name();
            }
Пример #22
0
    if ($data = $mform->get_data()) {
        $scale = new grade_scale(array('id' => $id));
        $data->userid = $USER->id;
        if (empty($scale->id)) {
            $data->description = $data->description_editor['text'];
            $data->descriptionformat = $data->description_editor['format'];
            grade_scale::set_properties($scale, $data);
            if (!has_capability('moodle/grade:manage', $systemcontext)) {
                $data->standard = 0;
            }
            $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            $scale->insert();
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $scale->id);
            $DB->set_field($scale->table, 'description', $data->description, array('id' => $scale->id));
        } else {
            $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'scale', $id);
            grade_scale::set_properties($scale, $data);
            if (isset($data->standard)) {
                $scale->courseid = !empty($data->standard) ? 0 : $courseid;
            } else {
                unset($scale->courseid);
                // keep previous
            }
            $scale->update();
        }
        redirect($returnurl);
    }
}
print_grade_page_head($COURSE->id, 'scale', null, $heading, false, false, false);
$mform->display();
echo $OUTPUT->footer();
Пример #23
0
 * @param int $weightsadjusted Whether weights have been adjusted
 * @return moodle_url A URL to redirect to after regrading when a progress bar is displayed.
 */
$grade_edit_tree_index_checkweights = function () use($courseid, $originalweights, &$weightsadjusted) {
    global $PAGE;
    $alteredweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
    if (array_diff($originalweights, $alteredweights)) {
        $weightsadjusted = 1;
        return new moodle_url($PAGE->url, array('weightsadjusted' => $weightsadjusted));
    }
    return $PAGE->url;
};
if (grade_regrade_final_grades_if_required($course, $grade_edit_tree_index_checkweights)) {
    $recreatetree = true;
}
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'));
// Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox');
echo '<form id="gradetreeform" method="post" action="' . $returnurl . '">';
echo '<div>';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
//did we update something in the db and thus invalidate $grade_edit_tree?
if ($recreatetree) {
    $grade_edit_tree = new grade_edit_tree($gtree, $movingeid, $gpr);
}
// Check to see if we have a normalisation message to send.
if ($weightsadjusted) {
    echo $OUTPUT->notification(get_string('weightsadjusted', 'grades'), 'notifymessage');
}
echo html_writer::table($grade_edit_tree->table);
echo '<div id="gradetreesubmit">';
Пример #24
0
        krsort($letters, SORT_NUMERIC);
        $old_ids = array();
        if ($records = get_records('grade_letters', 'contextid', $context->id, 'lowerboundary ASC', 'id')) {
            $old_ids = array_keys($records);
        }
        foreach ($letters as $boundary => $letter) {
            $record = new object();
            $record->letter = $letter;
            $record->lowerboundary = $boundary;
            $record->contextid = $context->id;
            if ($old_id = array_pop($old_ids)) {
                $record->id = $old_id;
                update_record('grade_letters', $record);
            } else {
                insert_record('grade_letters', $record);
            }
        }
        foreach ($old_ids as $old_id) {
            delete_records('grade_letters', 'id', $old_id);
        }
        redirect($returnurl);
    }
}
//page header
if ($admin) {
    admin_externalpage_print_header();
} else {
    print_grade_page_head($COURSE->id, 'letter', 'edit', get_string('editgradeletters', 'grades'));
}
$mform->display();
print_footer($COURSE);
Пример #25
0
    $result = $report->process_data($data);
    if (!empty($result->warnings)) {
        foreach ($result->warnings as $warning) {
            echo $OUTPUT->notification($warning);
        }
    }
    echo $OUTPUT->notification(get_string('savegradessuccess', 'gradereport_singleview', count((array) $result->changecount)));
    echo $OUTPUT->continue_button($currentpage);
    echo $OUTPUT->footer();
    die;
}
$PAGE->set_pagelayout('report');
if ($itemtype == 'user') {
    print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false, true, null, null, $report->screen->item);
} else {
    print_grade_page_head($course->id, 'report', 'singleview', $reportname);
}
$graderrightnav = $graderleftnav = null;
$options = $report->screen->options();
if (!empty($options)) {
    $optionkeys = array_keys($options);
    $optionitemid = array_shift($optionkeys);
    $relreport = new gradereport_singleview($courseid, $gpr, $context, $report->screen->item_type(), $optionitemid);
    $reloptions = $relreport->screen->options();
    $reloptionssorting = array_keys($relreport->screen->options());
    $i = array_search($itemid, $reloptionssorting);
    $navparams = array('item' => $itemtype, 'id' => $courseid, 'group' => $groupid);
    if ($i > 0) {
        $navparams['itemid'] = $reloptionssorting[$i - 1];
        $link = new moodle_url('/grade/report/singleview/index.php', $navparams);
        $navprev = html_writer::link($link, $OUTPUT->larrow() . ' ' . $reloptions[$reloptionssorting[$i - 1]]);
Пример #26
0
$strgrades = get_string('grades');
$pagename = get_string('coursesettings', 'grades');
$navigation = grade_build_nav(__FILE__, $pagename, $courseid);
$returnurl = $CFG->wwwroot . '/grade/index.php?id=' . $course->id;
$mform = new course_settings_form();
$settings = grade_get_settings($course->id);
$mform->set_data($settings);
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $mform->get_data()) {
        $data = (array) $data;
        $general = array('displaytype', 'decimalpoints', 'aggregationposition');
        foreach ($data as $key => $value) {
            if (!in_array($key, $general) and strpos($key, 'report_') !== 0 and strpos($key, 'import_') !== 0 and strpos($key, 'export_') !== 0) {
                continue;
            }
            if ($value == -1) {
                $value = null;
            }
            grade_set_setting($course->id, $key, $value);
        }
        redirect($returnurl);
    }
}
print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursesettings', 'grades'));
print_box_start('generalbox boxaligncenter boxwidthnormal centerpara');
echo get_string('coursesettingsexplanation', 'grades');
print_box_end();
$mform->display();
print_footer($course);
Пример #27
0
} else {
    require_once $CFG->libdir . '/adminlib.php';
    admin_externalpage_setup('outcomes');
    $context = context_system::instance();
}
require_capability('moodle/grade:manageoutcomes', $context);
$navigation = grade_build_nav(__FILE__, get_string('outcomes', 'grades'), $courseid);
$upload_form = new import_outcomes_form();
// display import form
if (!$upload_form->get_data()) {
    print_grade_page_head($courseid, 'outcome', 'import', get_string('importoutcomes', 'grades'));
    $upload_form->display();
    echo $OUTPUT->footer();
    die;
}
print_grade_page_head($courseid, 'outcome', 'import', get_string('importoutcomes', 'grades'));
$imported_file = $CFG->tempdir . '/outcomeimport/importedfile_' . time() . '.csv';
make_temp_directory('outcomeimport');
// copying imported file
if (!$upload_form->save_file('userfile', $imported_file, true)) {
    redirect('import.php' . ($courseid ? "?courseid={$courseid}" : ''), get_string('importfilemissing', 'grades'));
}
/// which scope are we importing the outcomes in?
if (isset($courseid) && $scope == 'custom') {
    // custom scale
    $local_scope = true;
} elseif ($scope == 'global' && has_capability('moodle/grade:manage', context_system::instance())) {
    // global scale
    $local_scope = false;
} else {
    // shouldn't happen .. user might be trying to access this script without the right permissions.
Пример #28
0
//          http://www.gnu.org/copyleft/gpl.html                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
require_once '../../../config.php';
require_once $CFG->dirroot . '/grade/export/lib.php';
require_once 'grade_export_xml.php';
$id = required_param('id', PARAM_INT);
// course id
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/xml:view', $context);
print_grade_page_head($COURSE->id, 'export', 'xml', get_string('exportto', 'grades') . ' ' . get_string('modulename', 'gradeexport_xml'));
if (!empty($CFG->gradepublishing)) {
    $CFG->gradepublishing = has_capability('gradeexport/xml:publish', $context);
}
$mform = new grade_export_form(null, array('idnumberrequired' => true, 'publishing' => true, 'updategradesonly' => true));
$groupmode = groups_get_course_groupmode($course);
// Groups are being used
$currentgroup = groups_get_course_group($course, true);
if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
    print_heading(get_string("notingroup"));
    print_footer($course);
    die;
}
// process post information
if ($data = $mform->get_data()) {
    $export = new grade_export_xml($course, $currentgroup, '', false, $data->updatedgradesonly, $data->display, $data->decimals);
Пример #29
0
        /// add all selected to course list
        foreach ($data->addoutcomes as $add) {
            $add = clean_param($add, PARAM_INT);
            if (!array_key_exists($add, $standardoutcomes)) {
                continue;
            }
            $goc = new object();
            $goc->courseid = $courseid;
            $goc->outcomeid = $add;
            $DB->insert_record('grade_outcomes_courses', $goc);
        }
    } else {
        if (!empty($data->remove) && !empty($data->removeoutcomes)) {
            /// remove all selected from course outcomes list
            foreach ($data->removeoutcomes as $remove) {
                $remove = clean_param($remove, PARAM_INT);
                if (!array_key_exists($remove, $co_standard_notused)) {
                    continue;
                }
                $DB->delete_records('grade_outcomes_courses', array('courseid' => $courseid, 'outcomeid' => $remove));
            }
        }
    }
    redirect('course.php?id=' . $courseid);
    // we must redirect to get fresh data
}
/// Print header
print_grade_page_head($COURSE->id, 'outcome', 'course');
check_theme_arrows();
require 'course_form.html';
print_footer($course);
Пример #30
0
    $url->param('separator', $separator);
}
if ($verbosescales !== 1) {
    $url->param('verbosescales', $verbosescales);
}
$PAGE->set_url($url);
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/csv:view', $context);
$separatemode = (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context));
$currentgroup = groups_get_course_group($course);
print_grade_page_head($course->id, 'import', 'csv', get_string('importcsv', 'grades'), false, false, true, 'importcsv', 'grades');
$renderer = $PAGE->get_renderer('gradeimport_csv');
// Get the grade items to be matched with the import mapping columns.
$gradeitems = gradeimport_csv_load_data::fetch_grade_items($course->id);
// If the csv file hasn't been imported yet then look for a form submission or
// show the initial submission form.
if (!$iid) {
    // Set up the import form.
    $mform = new grade_import_form(null, array('includeseparator' => true, 'verbosescales' => $verbosescales, 'acceptedtypes' => array('.csv', '.txt')));
    // If the import form has been submitted.
    if ($formdata = $mform->get_data()) {
        $text = $mform->get_file_content('userfile');
        $csvimport = new gradeimport_csv_load_data();
        $csvimport->load_csv_content($text, $formdata->encoding, $separator, $formdata->previewrows);
        $csvimporterror = $csvimport->get_error();
        if (!empty($csvimporterror)) {