original_string: public function count_submissions_need_grading($currentgroup = null) {
          global $DB;
  
          if ($this->get_instance()->teamsubmission) {
              // This does not make sense for group assignment because the submission is shared.
              return 0;
          }
  
          if ($currentgroup === null) {
              $currentgroup = groups_get_activity_group($this->get_course_module(), true);
          }
          list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true);
  
          $params['assignid'] = $this->get_instance()->id;
          $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
          $sqlscalegrade = $this->get_instance()->grade < 0 ? ' OR g.grade = -1' : '';
  
          $sql = 'SELECT COUNT(s.userid)
                     FROM {assign_submission} s
                     LEFT JOIN {assign_grades} g ON
                          s.assignment = g.assignment AND
                          s.userid = g.userid AND
                          g.attemptnumber = s.attemptnumber
                     JOIN(' . $esql . ') e ON e.id = s.userid
                     WHERE
                          s.latest = 1 AND
                          s.assignment = :assignid AND
                          s.timemodified IS NOT NULL AND
                          s.status = :submitted AND
                          (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL '
                              . $sqlscalegrade . ')';
  
          return $DB->count_records_sql($sql, $params);
      }
code: public function count_submissions_need_grading($currentgroup = null) {
          global $DB;
  
          if ($this->get_instance()->teamsubmission) {
              // This does not make sense for group assignment because the submission is shared.
              return 0;
          }
  
          if ($currentgroup === null) {
              $currentgroup = groups_get_activity_group($this->get_course_module(), true);
          }
          list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true);
  
          $params['assignid'] = $this->get_instance()->id;
          $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
          $sqlscalegrade = $this->get_instance()->grade < 0 ? ' OR g.grade = -1' : '';
  
          $sql = 'SELECT COUNT(s.userid)
                     FROM {assign_submission} s
                     LEFT JOIN {assign_grades} g ON
                          s.assignment = g.assignment AND
                          s.userid = g.userid AND
                          g.attemptnumber = s.attemptnumber
                     JOIN(' . $esql . ') e ON e.id = s.userid
                     WHERE
                          s.latest = 1 AND
                          s.assignment = :assignid AND
                          s.timemodified IS NOT NULL AND
                          s.status = :submitted AND
                          (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL '
                              . $sqlscalegrade . ')';
  
          return $DB->count_records_sql($sql, $params);
      }
code_tokens: public function count_submissions_need_grading ( $ currentgroup = null ) { global $ DB ; if ( $ this -> get_instance ( ) -> teamsubmission ) { // This does not make sense for group assignment because the submission is shared. return 0 ; } if ( $ currentgroup === null ) { $ currentgroup = groups_get_activity_group ( $ this -> get_course_module ( ) , true ) ; } list ( $ esql , $ params ) = get_enrolled_sql ( $ this -> get_context ( ) , 'mod/assign:submit' , $ currentgroup , true ) ; $ params [ 'assignid' ] = $ this -> get_instance ( ) -> id ; $ params [ 'submitted' ] = ASSIGN_SUBMISSION_STATUS_SUBMITTED ; $ sqlscalegrade = $ this -> get_instance ( ) -> grade < 0 ? ' OR g.grade = -1' : '' ; $ sql = 'SELECT COUNT(s.userid)
                     FROM {assign_submission} s
                     LEFT JOIN {assign_grades} g ON
                          s.assignment = g.assignment AND
                          s.userid = g.userid AND
                          g.attemptnumber = s.attemptnumber
                     JOIN(' . $ esql . ') e ON e.id = s.userid
                     WHERE
                          s.latest = 1 AND
                          s.assignment = :assignid AND
                          s.timemodified IS NOT NULL AND
                          s.status = :submitted AND
                          (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL ' . $ sqlscalegrade . ')' ; return $ DB -> count_records_sql ( $ sql , $ params ) ; }
docstring: Load a count of active users submissions in the current module that require grading
  This means the submission modification time is more recent than the
  grading modification time and the status is SUBMITTED.
  
  @param mixed $currentgroup int|null the group for counting (if null the function will determine it)
  @return int number of matching submissions
docstring_tokens: Load a count of active users submissions in the current module that require grading This means the submission modification time is more recent than the grading modification time and the status is SUBMITTED .