当前位置: 首页>>代码示例>>PHP>>正文


PHP grade_item::set_hidden方法代码示例

本文整理汇总了PHP中grade_item::set_hidden方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::set_hidden方法的具体用法?PHP grade_item::set_hidden怎么用?PHP grade_item::set_hidden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grade_item的用法示例。


在下文中一共展示了grade_item::set_hidden方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_hidden

 /**
  * Sets the grade_item's hidden variable and updates the grade_item.
  *
  * Overrides grade_item::set_hidden() to add cascading of the hidden value to grade items in this grade category
  *
  * @param int $hidden 0 mean always visible, 1 means always hidden and a number > 1 is a timestamp to hide until
  * @param bool $cascade apply to child objects too
  */
 public function set_hidden($hidden, $cascade = false)
 {
     $this->load_grade_item();
     //this hides the associated grade item (the course total)
     $this->grade_item->set_hidden($hidden, $cascade);
     //this hides the category itself and everything it contains
     parent::set_hidden($hidden, $cascade);
     if ($cascade) {
         if ($children = grade_item::fetch_all(array('categoryid' => $this->id))) {
             foreach ($children as $child) {
                 if ($child->can_control_visibility()) {
                     $child->set_hidden($hidden, $cascade);
                 }
             }
         }
         if ($children = grade_category::fetch_all(array('parent' => $this->id))) {
             foreach ($children as $child) {
                 $child->set_hidden($hidden, $cascade);
             }
         }
     }
     //if marking category visible make sure parent category is visible MDL-21367
     if (!$hidden) {
         $category_array = grade_category::fetch_all(array('id' => $this->parent));
         if ($category_array && array_key_exists($this->parent, $category_array)) {
             $category = $category_array[$this->parent];
             //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden
             //if($category->is_hidden()) {
             $category->set_hidden($hidden, false);
             //}
         }
     }
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:41,代码来源:grade_category.php

示例2: test_show_student_summary

 public function test_show_student_summary()
 {
     global $CFG, $PAGE;
     $this->setUser($this->editingteachers[0]);
     $assign = $this->create_instance();
     $PAGE->set_url(new moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
     // No feedback should be available because this student has not been graded.
     $this->setUser($this->students[0]);
     $output = $assign->view_student_summary($this->students[0], true);
     $this->assertEquals(false, strpos($output, 'Feedback'), 'Do not show feedback if there is no grade');
     // Simulate adding a grade.
     $this->setUser($this->teachers[0]);
     $data = new stdClass();
     $data->grade = '50.0';
     $assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
     // Now we should see the feedback.
     $this->setUser($this->students[0]);
     $output = $assign->view_student_summary($this->students[0], true);
     $this->assertNotEquals(false, strpos($output, 'Feedback'), 'Show feedback if there is a grade');
     // Now hide the grade in gradebook.
     $this->setUser($this->teachers[0]);
     require_once $CFG->libdir . '/gradelib.php';
     $gradeitem = new grade_item(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assign->get_instance()->id, 'courseid' => $this->course->id));
     $gradeitem->set_hidden(1, false);
     // No feedback should be available because the grade is hidden.
     $this->setUser($this->students[0]);
     $output = $assign->view_student_summary($this->students[0], true);
     $this->assertEquals(false, strpos($output, 'Feedback'), 'Do not show feedback if the grade is hidden in the gradebook');
     // Do the same but add feedback.
     $assign = $this->create_instance(array('assignfeedback_comments_enabled' => 1));
     $this->setUser($this->teachers[0]);
     $grade = $assign->get_user_grade($this->students[0]->id, true);
     $data = new stdClass();
     $data->assignfeedbackcomments_editor = array('text' => 'Tomato sauce', 'format' => FORMAT_MOODLE);
     $plugin = $assign->get_feedback_plugin_by_type('comments');
     $plugin->save($grade, $data);
     // Should have feedback but no grade.
     $this->setUser($this->students[0]);
     $output = $assign->view_student_summary($this->students[0], true);
     $this->assertNotEquals(false, strpos($output, 'Feedback'), 'Show feedback even if there is no grade');
     $this->assertEquals(false, strpos($output, 'Grade'), 'Do not show grade when there is no grade.');
     $this->assertEquals(false, strpos($output, 'Graded on'), 'Do not show graded date when there is no grade.');
     // Now hide the grade in gradebook.
     $this->setUser($this->teachers[0]);
     $gradeitem = new grade_item(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assign->get_instance()->id, 'courseid' => $this->course->id));
     $gradeitem->set_hidden(1, false);
     // No feedback should be available because the grade is hidden.
     $this->setUser($this->students[0]);
     $output = $assign->view_student_summary($this->students[0], true);
     $this->assertEquals(false, strpos($output, 'Feedback'), 'Do not show feedback if the grade is hidden in the gradebook');
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:51,代码来源:locallib_test.php


注:本文中的grade_item::set_hidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。