Exemplo n.º 1
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 public function __construct($userid, $gpr, $context)
 {
     global $CFG, $COURSE, $DB;
     parent::__construct($COURSE->id, $gpr, $context);
     // Get the user (for full name).
     $this->user = $DB->get_record('user', array('id' => $userid));
     // Load the user's courses.
     $this->courses = enrol_get_users_courses($this->user->id, false, 'id, shortname, showgrades');
     $this->showrank = array();
     $this->showrank['any'] = false;
     $this->showtotalsifcontainhidden = array();
     if ($this->courses) {
         foreach ($this->courses as $course) {
             $this->showrank[$course->id] = grade_get_setting($course->id, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
             if ($this->showrank[$course->id]) {
                 $this->showrank['any'] = true;
             }
             $this->showtotalsifcontainhidden[$course->id] = grade_get_setting($course->id, 'report_overview_showtotalsifcontainhidden', $CFG->grade_report_overview_showtotalsifcontainhidden);
         }
     }
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
Exemplo n.º 2
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 function grade_report_grader($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::grade_report($courseid, $gpr, $context, $page);
     // load collapsed settings for this report
     if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
         $this->collapsed = unserialize($collapsed);
     } else {
         $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
     }
     if (empty($CFG->enableoutcomes)) {
         $nooutcomes = false;
     } else {
         $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
     }
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, true, $this->get_pref('aggregationposition'), $this->collapsed, $nooutcomes);
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $studentsperpage = $this->get_pref('studentsperpage');
     $perpage = '';
     $curpage = '';
     if (!empty($studentsperpage)) {
         $perpage = '&perpage=' . $studentsperpage;
         $curpage = '&page=' . $this->page;
     }
     $this->baseurl = 'index.php?id=' . $this->courseid . $perpage . $curpage . '&';
     $this->pbarurl = 'index.php?id=' . $this->courseid . $perpage . '&';
     // Setup groups if requested
     if ($this->get_pref('showgroups')) {
         $this->setup_groups();
     }
     $this->setup_sortitemid();
 }
Exemplo n.º 3
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $userid The id of the user
  */
 public function __construct($courseid, $gpr, $context, $userid)
 {
     global $CFG, $DB;
     parent::__construct($courseid, $gpr, $context);
     $this->showrank = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
     $this->showpercentage = grade_get_setting($this->courseid, 'report_user_showpercentage', $CFG->grade_report_user_showpercentage);
     $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
     $this->showtotalsifcontainhidden = grade_get_setting($this->courseid, 'report_user_showtotalsifcontainhidden', $CFG->grade_report_user_showtotalsifcontainhidden);
     $this->switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, false, $this->switch, null, !$CFG->enableoutcomes);
     // Determine the number of rows and indentation
     $this->maxdepth = 1;
     $this->inject_rowspans($this->gtree->top_element);
     $this->maxdepth++;
     // Need to account for the lead column that spans all children
     for ($i = 1; $i <= $this->maxdepth; $i++) {
         $this->evenodd[$i] = 0;
     }
     $this->tabledata = array();
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->courseid));
     // get the user (for full name)
     $this->user = $DB->get_record('user', array('id' => $userid));
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/report?id=' . $courseid . '&amp;userid=' . $userid;
     $this->pbarurl = $this->baseurl;
     // no groups on this report - rank is from all course users
     $this->setup_table();
 }
Exemplo n.º 4
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 function grade_report_overview($userid, $gpr, $context)
 {
     global $CFG, $COURSE;
     parent::grade_report($COURSE->id, $gpr, $context);
     // get the user (for full name)
     $this->user = get_record('user', 'id', $userid);
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
Exemplo n.º 5
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 public function __construct($userid, $gpr, $context)
 {
     global $CFG, $COURSE, $DB;
     parent::__construct($COURSE->id, $gpr, $context);
     $this->showrank = grade_get_setting($this->courseid, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
     // get the user (for full name)
     $this->user = $DB->get_record('user', array('id' => $userid));
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
Exemplo n.º 6
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 function grade_report_overview($userid, $gpr, $context)
 {
     global $CFG, $COURSE;
     parent::grade_report($COURSE->id, $gpr, $context);
     $this->showrank = grade_get_setting($this->courseid, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
     $this->showtotalsifcontainhidden = grade_get_setting($this->courseid, 'report_overview_showtotalsifcontainhidden', $CFG->grade_report_overview_showtotalsifcontainhidden);
     // get the user (for full name)
     $this->user = get_record('user', 'id', $userid);
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
Exemplo n.º 7
0
 /**
  * Constructor for this report. Creates the appropriate screen class based on itemtype.
  *
  * @param int $courseid The course id.
  * @param object $gpr grade plugin return tracking object
  * @param context_course $context
  * @param string $itemtype Should be user, select or grade
  * @param int $itemid The id of the user or grade item
  * @param int $groupid (optional) The current groupid.
  */
 public function __construct($courseid, $gpr, $context, $itemtype, $itemid, $groupid = null)
 {
     parent::__construct($courseid, $gpr, $context);
     $screenclass = "\\gradereport_singleview\\local\\screen\\{$itemtype}";
     $this->screen = new $screenclass($courseid, $itemid, $groupid);
     // Load custom or predifined js.
     $this->screen->js();
     $base = '/grade/report/singleview/index.php';
     $idparams = array('id' => $courseid);
     $this->baseurl = new moodle_url($base, $idparams);
     $this->pbarurl = new moodle_url($base, $idparams + array('item' => $itemtype, 'itemid' => $itemid));
     $this->setup_groups();
 }
Exemplo n.º 8
0
 /**
  * Constructor for this report. Creates the appropriate screen class based on itemtype.
  *
  * @param int $courseid The course id.
  * @param object $gpr grade plugin return tracking object
  * @param context_course $context
  * @param string $itemtype Should be user, select or grade
  * @param int $itemid The id of the user or grade item
  * @param string $unused Used to be group id but that was removed and this is now unused.
  */
 public function __construct($courseid, $gpr, $context, $itemtype, $itemid, $unused = null)
 {
     parent::__construct($courseid, $gpr, $context);
     $base = '/grade/report/singleview/index.php';
     $idparams = array('id' => $courseid);
     $this->baseurl = new moodle_url($base, $idparams);
     $this->pbarurl = new moodle_url($base, $idparams + array('item' => $itemtype, 'itemid' => $itemid));
     //  The setup_group method is used to validate group mode and permissions and define the currentgroup value.
     $this->setup_groups();
     $screenclass = "\\gradereport_singleview\\local\\screen\\{$itemtype}";
     $this->screen = new $screenclass($courseid, $itemid, $this->currentgroup);
     // Load custom or predifined js.
     $this->screen->js();
 }
Exemplo n.º 9
0
Arquivo: lib.php Projeto: r007/PMoodle
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $userid The id of the user
  */
 function grade_report_user($courseid, $gpr, $context, $userid)
 {
     global $CFG;
     parent::grade_report($courseid, $gpr, $context);
     $this->showrank = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
     $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
     $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     // Grab the grade_seq for this course
     $this->gseq = new grade_seq($this->courseid, $switch);
     // get the user (for full name)
     $this->user = get_record('user', 'id', $userid);
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/report?id=' . $courseid . '&amp;userid=' . $userid;
     $this->pbarurl = $this->baseurl;
     // no groups on this report - rank is from all course users
     $this->setup_table();
 }
Exemplo n.º 10
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $userid The id of the user
  */
 function grade_report_user($courseid, $gpr, $context, $userid)
 {
     global $CFG;
     parent::grade_report($courseid, $gpr, $context);
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, true, $this->get_pref('aggregationposition'));
     // get the user (for full name)
     $this->user = get_record('user', 'id', $userid);
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/report?id=' . $courseid . '&amp;userid=' . $userid;
     $this->pbarurl = $this->baseurl;
     // Setup groups if requested
     if ($this->get_pref('showgroups')) {
         $this->setup_groups();
     }
     $this->setup_table();
 }
Exemplo n.º 11
0
Arquivo: lib.php Projeto: grug/moodle
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $userid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  */
 public function __construct($userid, $gpr, $context)
 {
     global $CFG, $COURSE, $DB;
     parent::__construct($COURSE->id, $gpr, $context);
     // Get the user (for full name).
     $this->user = $DB->get_record('user', array('id' => $userid));
     // Load the user's courses.
     $this->courses = enrol_get_users_courses($this->user->id, false, 'id, shortname, showgrades');
     $this->showrank = array();
     $this->showrank['any'] = false;
     $this->showtotalsifcontainhidden = array();
     $this->studentcourseids = array();
     $this->teachercourses = array();
     $roleids = explode(',', get_config('moodle', 'gradebookroles'));
     if ($this->courses) {
         foreach ($this->courses as $course) {
             $this->showrank[$course->id] = grade_get_setting($course->id, 'report_overview_showrank', !empty($CFG->grade_report_overview_showrank));
             if ($this->showrank[$course->id]) {
                 $this->showrank['any'] = true;
             }
             $this->showtotalsifcontainhidden[$course->id] = grade_get_setting($course->id, 'report_overview_showtotalsifcontainhidden', $CFG->grade_report_overview_showtotalsifcontainhidden);
             $coursecontext = context_course::instance($course->id);
             foreach ($roleids as $roleid) {
                 if (user_has_role_assignment($userid, $roleid, $coursecontext->id)) {
                     $this->studentcourseids[$course->id] = $course->id;
                     // We only need to check if one of the roleids has been assigned.
                     break;
                 }
             }
             if (has_capability('moodle/grade:viewall', $coursecontext, $userid)) {
                 $this->teachercourses[$course->id] = $course;
             }
         }
     }
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/overview/index.php?id=' . $userid;
     $this->pbarurl = $this->baseurl;
     $this->setup_table();
 }
Exemplo n.º 12
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 function grade_report_grader($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::grade_report($courseid, $gpr, $context, $page);
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
     $this->canviewuserreport = has_capability('gradereport/' . $CFG->grade_profilereport . ':view', $this->context);
     // load collapsed settings for this report
     if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
         $this->collapsed = unserialize($collapsed);
     } else {
         $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
     }
     if (empty($CFG->enableoutcomes)) {
         $nooutcomes = false;
     } else {
         $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
     }
     // if user report preference set or site report setting set use it, otherwise use course or site setting
     $switch = $this->get_pref('aggregationposition');
     if ($switch == '') {
         $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     }
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, true, $switch, $this->collapsed, $nooutcomes);
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $studentsperpage = $this->get_pref('studentsperpage');
     $perpage = '';
     $curpage = '';
     if (!empty($studentsperpage)) {
         $perpage = '&amp;perpage=' . $studentsperpage;
         $curpage = '&amp;page=' . $this->page;
     }
     $this->baseurl = 'index.php?id=' . $this->courseid . $perpage . $curpage . '&amp;';
     $this->pbarurl = 'index.php?id=' . $this->courseid . $perpage . '&amp;';
     $this->setup_groups();
     $this->setup_sortitemid();
 }
Exemplo n.º 13
0
 /**
  * A wrapper around blank_hidden_total_and_adjust_bounds() to allow test code to call it directly
  */
 public function blank_hidden_total_and_adjust_bounds($courseid, $courseitem, $finalgrade)
 {
     return parent::blank_hidden_total_and_adjust_bounds($courseid, $courseitem, $finalgrade);
 }
Exemplo n.º 14
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 public function __construct($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::__construct($courseid, $gpr, $context, $page);
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->course->id));
     // load collapsed settings for this report
     $this->collapsed = static::get_collapsed_preferences($this->course->id);
     if (empty($CFG->enableoutcomes)) {
         $nooutcomes = false;
     } else {
         $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
     }
     // if user report preference set or site report setting set use it, otherwise use course or site setting
     $switch = $this->get_pref('aggregationposition');
     if ($switch == '') {
         $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     }
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, true, $switch, $this->collapsed, $nooutcomes);
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
     $studentsperpage = $this->get_students_per_page();
     if (!empty($this->page) && !empty($studentsperpage)) {
         $this->baseurl->params(array('perpage' => $studentsperpage, 'page' => $this->page));
     }
     $this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid));
     $this->setup_groups();
     $this->setup_users();
     $this->setup_sortitemid();
     $this->overridecat = (bool) get_config('moodle', 'grade_overridecat');
 }
Exemplo n.º 15
0
 /**
  * Given the name of a user preference (without grade_report_ prefix), locally saves then returns
  * the value of that preference. If the preference has already been fetched before,
  * the saved value is returned. If the preference is not set at the User level, the $CFG equivalent
  * is given (site default).
  * @static (Can be called statically, but then doesn't benefit from caching)
  * @param string $pref The name of the preference (do not include the grade_report_ prefix)
  * @param int $objectid An optional itemid or categoryid to check for a more fine-grained preference
  * @return mixed The value of the preference
  */
 public function get_pref($pref, $objectid = null)
 {
     global $CFG;
     $fullprefname = 'grade_report_' . $pref;
     $shortprefname = 'grade_' . $pref;
     $retval = null;
     if (!isset($this) or get_class($this) != 'grade_report') {
         if (!empty($objectid)) {
             $retval = get_user_preferences($fullprefname . $objectid, grade_report::get_pref($pref));
         } elseif (isset($CFG->{$fullprefname})) {
             $retval = get_user_preferences($fullprefname, $CFG->{$fullprefname});
         } elseif (isset($CFG->{$shortprefname})) {
             $retval = get_user_preferences($fullprefname, $CFG->{$shortprefname});
         } else {
             $retval = null;
         }
     } else {
         if (empty($this->prefs[$pref . $objectid])) {
             if (!empty($objectid)) {
                 $retval = get_user_preferences($fullprefname . $objectid);
                 if (empty($retval)) {
                     // No item pref found, we are returning the global preference
                     $retval = $this->get_pref($pref);
                     $objectid = null;
                 }
             } else {
                 $retval = get_user_preferences($fullprefname, $CFG->{$fullprefname});
             }
             $this->prefs[$pref . $objectid] = $retval;
         } else {
             $retval = $this->prefs[$pref . $objectid];
         }
     }
     return $retval;
 }
Exemplo n.º 16
0
 /**
  * Constructor. Initialises grade_tree, sets up group, baseurl
  * and pbarurl.
  * @param int $courseid the coures id for the report
  * @param object $gpr grade plugin tracking object
  * @context string $context
  */
 public function __construct($courseid, $gpr, $context, $visid = null)
 {
     global $CFG;
     parent::__construct($courseid, $gpr, $context, null);
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
     /// Set up urls
     $this->baseurl = 'index.php?id=' . $this->courseid;
     $this->pbarurl = 'index.php?id=' . $this->courseid;
     /// Set the position of the aggregation categorie based on pref
     $switch = $this->get_pref('visual', 'aggregationposition');
     if ($switch == '' && isset($CFG->grade_aggregationposition)) {
         $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     }
     /// Build grade tree
     $this->gtree = new grade_tree($this->courseid, false, $switch);
     $this->load_visualizations();
     if (!is_null($visid) && !empty($visid) && array_key_exists($visid, grade_report_visual::$visualizations)) {
         $this->visid = $visid;
     } else {
         $keys = array_keys(grade_report_visual::$visualizations);
         $this->visid = $keys[0];
     }
     $this->set_up_flashvars();
     /// Set up Groups
     if ($this->visid && grade_report_visual::get_visualization($this->visid)->usegroups) {
         $this->setup_groups();
     }
 }
Exemplo n.º 17
0
 /**
  * A wrapper around blank_hidden_total() to allow test code to call it directly
  */
 public function blank_hidden_total($courseid, $courseitem, $finalgrade)
 {
     return parent::blank_hidden_total($courseid, $courseitem, $finalgrade);
 }
Exemplo n.º 18
0
$returnurl = $gpr->get_return_url(null);
//first make sure we have proper final grades - we need it for locking changes
grade_regrade_final_grades($courseid);
// get the grading tree object
// note: total must be first for moving to work correctly, if you want it last moving code must be rewritten!
$gtree = new grade_tree($courseid, false, false);
if (empty($eid)) {
    $element = null;
    $object = null;
} else {
    if (!($element = $gtree->locate_element($eid))) {
        error('Incorrect element id!', $returnurl);
    }
    $object = $element['object'];
}
$switch = grade_report::get_pref('aggregationposition');
$strgrades = get_string('grades');
$strgraderreport = get_string('graderreport', 'grades');
$strcategoriesedit = get_string('categoriesedit', 'grades');
$strcategoriesanditems = get_string('categoriesanditems', 'grades');
$navigation = grade_build_nav(__FILE__, $strcategoriesanditems, array('courseid' => $courseid));
$moving = false;
switch ($action) {
    case 'delete':
        if ($eid) {
            $confirm = optional_param('confirm', 0, PARAM_BOOL);
            if ($confirm and confirm_sesskey()) {
                $object->delete('grade/report/grader/category');
                redirect($returnurl);
            } else {
                print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strcategoriesedit, $navigation, '', '', true, '', navmenu($course));
Exemplo n.º 19
0
 }
 if (!isset($data->aggregateonlygraded)) {
     $data->aggregateonlygraded = 0;
 }
 if (!isset($data->aggregateoutcomes)) {
     $data->aggregateoutcomes = 0;
 }
 grade_category::set_properties($grade_category, $data);
 if (empty($grade_category->id)) {
     $grade_category->insert();
 } else {
     $grade_category->update();
 }
 // Handle user preferences
 if (isset($data->pref_aggregationview)) {
     if (!grade_report::set_pref('aggregationview', $data->pref_aggregationview, $grade_category->id)) {
         error("Could not set preference aggregationview to {$value} for this grade category");
     }
 }
 // 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);
 function __construct($courseid, $gpr, $context, $page = null)
 {
     parent::__construct($courseid, $gpr, $context, $page);
     $this->course_grade_item = grade_item::fetch_course_item($this->courseid);
 }
Exemplo n.º 21
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $userid The id of the user
  * @param boolean $hidereport Hide all report only show assessments
  */
 public function __construct($courseid, $gpr, $context, $userid, $hidereport)
 {
     global $DB, $CFG;
     parent::__construct($courseid, $gpr, $context);
     if (isset($hidereport)) {
         $this->hidereport = $hidereport;
     }
     $this->showhiddenactivity = grade_get_setting($this->courseid, 'report_marksheet_showhiddenactivity', $CFG->grade_report_marksheet_showhiddenactivity);
     $this->showrank = grade_get_setting($this->courseid, 'report_marksheet_showrank', $CFG->grade_report_marksheet_showrank);
     $this->showpercentage = grade_get_setting($this->courseid, 'report_marksheet_showpercentage', $CFG->grade_report_marksheet_showpercentage);
     $this->showhiddenitems = grade_get_setting($this->courseid, 'report_marksheet_showhiddenitems', $CFG->grade_report_marksheet_showhiddenitems);
     $this->showtotalsifcontainhidden = array($this->courseid => grade_get_setting($this->courseid, 'report_marksheet_showtotalsifcontainhidden', $CFG->grade_report_marksheet_showtotalsifcontainhidden));
     $this->showgrade = grade_get_setting($this->courseid, 'report_marksheet_showgrade', !empty($CFG->grade_report_marksheet_showgrade));
     $this->showrange = grade_get_setting($this->courseid, 'report_marksheet_showrange', !empty($CFG->grade_report_marksheet_showrange));
     $this->showfeedback = grade_get_setting($this->courseid, 'report_marksheet_showfeedback', !empty($CFG->grade_report_marksheet_showfeedback));
     $this->showweight = grade_get_setting($this->courseid, 'report_marksheet_showweight', !empty($CFG->grade_report_marksheet_showweight));
     $this->showlettergrade = grade_get_setting($this->courseid, 'report_marksheet_showlettergrade', !empty($CFG->grade_report_marksheet_showlettergrade));
     $this->showaverage = grade_get_setting($this->courseid, 'report_marksheet_showaverage', !empty($CFG->grade_report_marksheet_showaverage));
     $this->showtimeupdate = grade_get_setting($this->courseid, 'report_marksheet_showtimeupdate', !empty($CFG->grade_report_marksheet_showtimeupdate));
     $this->showstartdate = grade_get_setting($this->courseid, 'report_marksheet_showstartdate', !empty($CFG->grade_report_marksheet_showstartdate));
     $this->grade_category_modids = array();
     $this->grade_category_start_dates = array();
     // The default grade decimals is 2
     $defaultdecimals = 2;
     date_default_timezone_set('Australia/Victoria');
     if (property_exists($CFG, 'grade_decimalpoints')) {
         $defaultdecimals = $CFG->grade_decimalpoints;
     }
     $this->decimals = grade_get_setting($this->courseid, 'decimalpoints', $defaultdecimals);
     // The default range decimals is 0
     $defaultrangedecimals = 0;
     if (property_exists($CFG, 'grade_report_marksheet_rangedecimals')) {
         $defaultrangedecimals = $CFG->grade_report_marksheet_rangedecimals;
     }
     $this->rangedecimals = grade_get_setting($this->courseid, 'report_marksheet_rangedecimals', $defaultrangedecimals);
     $this->switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, false, $this->switch, null, !$CFG->enableoutcomes);
     // Determine the number of rows and indentation
     $this->maxdepth = 1;
     $this->inject_rowspans($this->gtree->top_element);
     $this->maxdepth++;
     // Need to account for the lead column that spans all children
     for ($i = 1; $i <= $this->maxdepth; $i++) {
         $this->evenodd[$i] = 0;
     }
     $this->tabledata = array();
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->courseid));
     // get the user (for full name)
     $this->user = $DB->get_record('user', array('id' => $userid));
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/report?id=' . $courseid . '&amp;userid=' . $userid;
     $this->pbarurl = $this->baseurl;
     // no groups on this report - rank is from all course users
     $this->setup_table();
     //optionally calculate grade item averages
     $this->calculate_averages();
     // //Set Marksheet Categoryid
     // $cat = grade_category::fetch(array('courseid'=>$this->courseid,'fullname'=>'Marksheet'));
     // if (isset($cat)) {
     //     $this->marksheet_category_id = $cat->id;
     // }else
     // {
     //     $this->marksheet_category_id = nil;
     // }
 }
Exemplo n.º 22
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 public function __construct($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::__construct($courseid, $gpr, $context, $page);
     //Basado en el constructor de la clase grade_report_grader
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, false, false);
     $this->add_activities_to_gtree();
     $this->grade_viewer = new grade_expert_db_block();
     $this->calculator = new calculator_average();
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
     $this->studentsperpage = $this->get_pref('studentsperpage');
     $studentsperpage = $this->studentsperpage;
     if (!empty($studentsperpage)) {
         $this->baseurl->params(array('perpage' => $studentsperpage, 'page' => $this->page));
     }
     $this->pbarurl = new moodle_url('/blocks/evalcomix/assessment/index.php', array('id' => $this->courseid, 'perpage' => $studentsperpage));
     $this->setup_groups();
     $this->setup_sortitemid();
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->course->id));
 }
Exemplo n.º 23
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $userid The id of the user
  * @param bool $viewasuser Set this to true when the current user is a mentor/parent of the targetted user.
  */
 public function __construct($courseid, $gpr, $context, $userid, $viewasuser = null)
 {
     global $DB, $CFG;
     parent::__construct($courseid, $gpr, $context);
     $this->showrank = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
     $this->showpercentage = grade_get_setting($this->courseid, 'report_user_showpercentage', $CFG->grade_report_user_showpercentage);
     $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
     $this->showtotalsifcontainhidden = array($this->courseid => grade_get_setting($this->courseid, 'report_user_showtotalsifcontainhidden', $CFG->grade_report_user_showtotalsifcontainhidden));
     $this->showgrade = grade_get_setting($this->courseid, 'report_user_showgrade', !empty($CFG->grade_report_user_showgrade));
     $this->showrange = grade_get_setting($this->courseid, 'report_user_showrange', !empty($CFG->grade_report_user_showrange));
     $this->showfeedback = grade_get_setting($this->courseid, 'report_user_showfeedback', !empty($CFG->grade_report_user_showfeedback));
     $this->showweight = grade_get_setting($this->courseid, 'report_user_showweight', !empty($CFG->grade_report_user_showweight));
     $this->showlettergrade = grade_get_setting($this->courseid, 'report_user_showlettergrade', !empty($CFG->grade_report_user_showlettergrade));
     $this->showaverage = grade_get_setting($this->courseid, 'report_user_showaverage', !empty($CFG->grade_report_user_showaverage));
     $this->viewasuser = $viewasuser;
     // The default grade decimals is 2
     $defaultdecimals = 2;
     if (property_exists($CFG, 'grade_decimalpoints')) {
         $defaultdecimals = $CFG->grade_decimalpoints;
     }
     $this->decimals = grade_get_setting($this->courseid, 'decimalpoints', $defaultdecimals);
     // The default range decimals is 0
     $defaultrangedecimals = 0;
     if (property_exists($CFG, 'grade_report_user_rangedecimals')) {
         $defaultrangedecimals = $CFG->grade_report_user_rangedecimals;
     }
     $this->rangedecimals = grade_get_setting($this->courseid, 'report_user_rangedecimals', $defaultrangedecimals);
     $this->switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, false, $this->switch, null, !$CFG->enableoutcomes);
     // Get the user (for full name).
     $this->user = $DB->get_record('user', array('id' => $userid));
     // What user are we viewing this as?
     $coursecontext = context_course::instance($this->courseid);
     if ($viewasuser) {
         $this->modinfo = new course_modinfo($this->course, $this->user->id);
         $this->canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext, $this->user->id);
     } else {
         $this->modinfo = $this->gtree->modinfo;
         $this->canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext);
     }
     // Determine the number of rows and indentation.
     $this->maxdepth = 1;
     $this->inject_rowspans($this->gtree->top_element);
     $this->maxdepth++;
     // Need to account for the lead column that spans all children.
     for ($i = 1; $i <= $this->maxdepth; $i++) {
         $this->evenodd[$i] = 0;
     }
     $this->tabledata = array();
     // base url for sorting by first/last name
     $this->baseurl = $CFG->wwwroot . '/grade/report?id=' . $courseid . '&amp;userid=' . $userid;
     $this->pbarurl = $this->baseurl;
     // no groups on this report - rank is from all course users
     $this->setup_table();
     //optionally calculate grade item averages
     $this->calculate_averages();
 }
Exemplo n.º 24
0
 /**
  * Constructor. Sets local copies of user preferences and initialises grade_tree.
  * @param int $courseid
  * @param object $gpr grade plugin return tracking object
  * @param string $context
  * @param int $page The current page being viewed (when report is paged)
  * @param int $sortitemid The id of the grade_item by which to sort the table
  */
 public function __construct($courseid, $gpr, $context, $page = null, $sortitemid = null)
 {
     global $CFG;
     parent::__construct($courseid, $gpr, $context, $page);
     $this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
     // load collapsed settings for this report
     if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
         $this->collapsed = unserialize($collapsed);
     } else {
         $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
     }
     if (empty($CFG->enableoutcomes)) {
         $nooutcomes = false;
     } else {
         $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
     }
     // if user report preference set or site report setting set use it, otherwise use course or site setting
     $switch = $this->get_pref('aggregationposition');
     if ($switch == '') {
         $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
     }
     // Grab the grade_tree for this course
     $this->gtree = new grade_tree($this->courseid, true, $switch, $this->collapsed, $nooutcomes);
     $this->sortitemid = $sortitemid;
     // base url for sorting by first/last name
     $this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
     if (!empty($this->page)) {
         $this->baseurl->params(array('page' => $this->page));
     }
     $this->pbarurl = new moodle_url('/grade/report/grader/index.php', array('id' => $this->courseid));
     $this->setup_groups();
     $this->setup_sortitemid();
 }