original_string: public function get_user_flags($userid, $create) {
          global $DB, $USER;
  
          // If the userid is not null then use userid.
          if (!$userid) {
              $userid = $USER->id;
          }
  
          $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid);
  
          $flags = $DB->get_record('assign_user_flags', $params);
  
          if ($flags) {
              return $flags;
          }
          if ($create) {
              $flags = new stdClass();
              $flags->assignment = $this->get_instance()->id;
              $flags->userid = $userid;
              $flags->locked = 0;
              $flags->extensionduedate = 0;
              $flags->workflowstate = '';
              $flags->allocatedmarker = 0;
  
              // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet.
              // This is because students only want to be notified about certain types of update (grades and feedback).
              $flags->mailed = 2;
  
              $fid = $DB->insert_record('assign_user_flags', $flags);
              $flags->id = $fid;
              return $flags;
          }
          return false;
      }
code: public function get_user_flags($userid, $create) {
          global $DB, $USER;
  
          // If the userid is not null then use userid.
          if (!$userid) {
              $userid = $USER->id;
          }
  
          $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid);
  
          $flags = $DB->get_record('assign_user_flags', $params);
  
          if ($flags) {
              return $flags;
          }
          if ($create) {
              $flags = new stdClass();
              $flags->assignment = $this->get_instance()->id;
              $flags->userid = $userid;
              $flags->locked = 0;
              $flags->extensionduedate = 0;
              $flags->workflowstate = '';
              $flags->allocatedmarker = 0;
  
              // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet.
              // This is because students only want to be notified about certain types of update (grades and feedback).
              $flags->mailed = 2;
  
              $fid = $DB->insert_record('assign_user_flags', $flags);
              $flags->id = $fid;
              return $flags;
          }
          return false;
      }
code_tokens: public function get_user_flags ( $ userid , $ create ) { global $ DB , $ USER ; // If the userid is not null then use userid. if ( ! $ userid ) { $ userid = $ USER -> id ; } $ params = array ( 'assignment' => $ this -> get_instance ( ) -> id , 'userid' => $ userid ) ; $ flags = $ DB -> get_record ( 'assign_user_flags' , $ params ) ; if ( $ flags ) { return $ flags ; } if ( $ create ) { $ flags = new stdClass ( ) ; $ flags -> assignment = $ this -> get_instance ( ) -> id ; $ flags -> userid = $ userid ; $ flags -> locked = 0 ; $ flags -> extensionduedate = 0 ; $ flags -> workflowstate = '' ; $ flags -> allocatedmarker = 0 ; // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet. // This is because students only want to be notified about certain types of update (grades and feedback). $ flags -> mailed = 2 ; $ fid = $ DB -> insert_record ( 'assign_user_flags' , $ flags ) ; $ flags -> id = $ fid ; return $ flags ; } return false ; }
docstring: This will retrieve a user flags object from the db optionally creating it if required.
  The user flags was split from the user_grades table in 2.5.
  
  @param int $userid The user we are getting the flags for.
  @param bool $create If true the flags record will be created if it does not exist
  @return stdClass The flags record
docstring_tokens: This will retrieve a user flags object from the db optionally creating it if required . The user flags was split from the user_grades table in 2 . 5 .