original_string: public function count_submissions($includenew = false) {
          global $DB;
  
          if (!$this->has_instance()) {
              return 0;
          }
  
          $params = array();
          $sqlnew = '';
  
          if (!$includenew) {
              $sqlnew = ' AND s.status <> :status ';
              $params['status'] = ASSIGN_SUBMISSION_STATUS_NEW;
          }
  
          if ($this->get_instance()->teamsubmission) {
              // We cannot join on the enrolment tables for group submissions (no userid).
              $sql = 'SELECT COUNT(DISTINCT s.groupid)
                          FROM {assign_submission} s
                          WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL AND
                              s.userid = :groupuserid' .
                              $sqlnew;
  
              $params['assignid'] = $this->get_instance()->id;
              $params['groupuserid'] = 0;
          } else {
              $currentgroup = groups_get_activity_group($this->get_course_module(), true);
              list($esql, $enrolparams) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true);
  
              $params = array_merge($params, $enrolparams);
              $params['assignid'] = $this->get_instance()->id;
  
              $sql = 'SELECT COUNT(DISTINCT s.userid)
                         FROM {assign_submission} s
                         JOIN(' . $esql . ') e ON e.id = s.userid
                         WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL ' .
                              $sqlnew;
  
          }
  
          return $DB->count_records_sql($sql, $params);
      }
code: public function count_submissions($includenew = false) {
          global $DB;
  
          if (!$this->has_instance()) {
              return 0;
          }
  
          $params = array();
          $sqlnew = '';
  
          if (!$includenew) {
              $sqlnew = ' AND s.status <> :status ';
              $params['status'] = ASSIGN_SUBMISSION_STATUS_NEW;
          }
  
          if ($this->get_instance()->teamsubmission) {
              // We cannot join on the enrolment tables for group submissions (no userid).
              $sql = 'SELECT COUNT(DISTINCT s.groupid)
                          FROM {assign_submission} s
                          WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL AND
                              s.userid = :groupuserid' .
                              $sqlnew;
  
              $params['assignid'] = $this->get_instance()->id;
              $params['groupuserid'] = 0;
          } else {
              $currentgroup = groups_get_activity_group($this->get_course_module(), true);
              list($esql, $enrolparams) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true);
  
              $params = array_merge($params, $enrolparams);
              $params['assignid'] = $this->get_instance()->id;
  
              $sql = 'SELECT COUNT(DISTINCT s.userid)
                         FROM {assign_submission} s
                         JOIN(' . $esql . ') e ON e.id = s.userid
                         WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL ' .
                              $sqlnew;
  
          }
  
          return $DB->count_records_sql($sql, $params);
      }
code_tokens: public function count_submissions ( $ includenew = false ) { global $ DB ; if ( ! $ this -> has_instance ( ) ) { return 0 ; } $ params = array ( ) ; $ sqlnew = '' ; if ( ! $ includenew ) { $ sqlnew = ' AND s.status <> :status ' ; $ params [ 'status' ] = ASSIGN_SUBMISSION_STATUS_NEW ; } if ( $ this -> get_instance ( ) -> teamsubmission ) { // We cannot join on the enrolment tables for group submissions (no userid). $ sql = 'SELECT COUNT(DISTINCT s.groupid)
                          FROM {assign_submission} s
                          WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL AND
                              s.userid = :groupuserid' . $ sqlnew ; $ params [ 'assignid' ] = $ this -> get_instance ( ) -> id ; $ params [ 'groupuserid' ] = 0 ; } else { $ currentgroup = groups_get_activity_group ( $ this -> get_course_module ( ) , true ) ; list ( $ esql , $ enrolparams ) = get_enrolled_sql ( $ this -> get_context ( ) , 'mod/assign:submit' , $ currentgroup , true ) ; $ params = array_merge ( $ params , $ enrolparams ) ; $ params [ 'assignid' ] = $ this -> get_instance ( ) -> id ; $ sql = 'SELECT COUNT(DISTINCT s.userid)
                         FROM {assign_submission} s
                         JOIN(' . $ esql . ') e ON e.id = s.userid
                         WHERE
                              s.assignment = :assignid AND
                              s.timemodified IS NOT NULL ' . $ sqlnew ; } return $ DB -> count_records_sql ( $ sql , $ params ) ; }
docstring: Load a count of submissions.
  
  @param bool $includenew When true, also counts the submissions with status 'new'.
  @return int number of submissions
docstring_tokens: Load a count of submissions .