original_string: protected function validate_duedate($value) {
  
          // We do not check duedate when plan is draft, complete, unset, or based on a template.
          if ($this->is_based_on_template()
                  || $this->is_draft()
                  || $this->get('status') == self::STATUS_COMPLETE
                  || empty($value)) {
              return true;
          }
  
          // During update.
          if ($this->get('id')) {
              $before = $this->beforeupdate->get('duedate');
              $beforestatus = $this->beforeupdate->get('status');
  
              // The value has not changed, then it's always OK. Though if we're going
              // from draft to active it has to has to be validated.
              if ($before == $value && !in_array($beforestatus, self::get_draft_statuses())) {
                  return true;
              }
          }
  
          if ($value <= time()) {
              // We cannot set the date in the past.
              return new lang_string('errorcannotsetduedateinthepast', 'core_competency');
          }
  
          if ($value <= time() + self::DUEDATE_THRESHOLD) {
              // We cannot set the date too soon, but we can leave it empty.
              return new lang_string('errorcannotsetduedatetoosoon', 'core_competency');
          }
  
          return true;
      }
code: protected function validate_duedate($value) {
  
          // We do not check duedate when plan is draft, complete, unset, or based on a template.
          if ($this->is_based_on_template()
                  || $this->is_draft()
                  || $this->get('status') == self::STATUS_COMPLETE
                  || empty($value)) {
              return true;
          }
  
          // During update.
          if ($this->get('id')) {
              $before = $this->beforeupdate->get('duedate');
              $beforestatus = $this->beforeupdate->get('status');
  
              // The value has not changed, then it's always OK. Though if we're going
              // from draft to active it has to has to be validated.
              if ($before == $value && !in_array($beforestatus, self::get_draft_statuses())) {
                  return true;
              }
          }
  
          if ($value <= time()) {
              // We cannot set the date in the past.
              return new lang_string('errorcannotsetduedateinthepast', 'core_competency');
          }
  
          if ($value <= time() + self::DUEDATE_THRESHOLD) {
              // We cannot set the date too soon, but we can leave it empty.
              return new lang_string('errorcannotsetduedatetoosoon', 'core_competency');
          }
  
          return true;
      }
code_tokens: protected function validate_duedate ( $ value ) { // We do not check duedate when plan is draft, complete, unset, or based on a template. if ( $ this -> is_based_on_template ( ) || $ this -> is_draft ( ) || $ this -> get ( 'status' ) == self :: STATUS_COMPLETE || empty ( $ value ) ) { return true ; } // During update. if ( $ this -> get ( 'id' ) ) { $ before = $ this -> beforeupdate -> get ( 'duedate' ) ; $ beforestatus = $ this -> beforeupdate -> get ( 'status' ) ; // The value has not changed, then it's always OK. Though if we're going // from draft to active it has to has to be validated. if ( $ before == $ value && ! in_array ( $ beforestatus , self :: get_draft_statuses ( ) ) ) { return true ; } } if ( $ value <= time ( ) ) { // We cannot set the date in the past. return new lang_string ( 'errorcannotsetduedateinthepast' , 'core_competency' ) ; } if ( $ value <= time ( ) + self :: DUEDATE_THRESHOLD ) { // We cannot set the date too soon, but we can leave it empty. return new lang_string ( 'errorcannotsetduedatetoosoon' , 'core_competency' ) ; } return true ; }
docstring: Validate the due date.
  When setting a due date it must not exceed the DUEDATE_THRESHOLD.
  
  @param  int $value The due date.
  @return bool|lang_string
docstring_tokens: Validate the due date . When setting a due date it must not exceed the DUEDATE_THRESHOLD .