original_string: public function get_submissions($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) {
          global $DB;
  
          $authorfields      = user_picture::fields('u', null, 'authoridx', 'author');
          $gradeoverbyfields = user_picture::fields('t', null, 'gradeoverbyx', 'over');
          $params            = array('workshopid' => $this->id);
          $sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
                         s.title, s.grade, s.gradeover, s.gradeoverby, s.published,
                         $authorfields, $gradeoverbyfields
                    FROM {workshop_submissions} s
                    JOIN {user} u ON (s.authorid = u.id)";
          if ($groupid) {
              $sql .= " JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)";
              $params['groupid'] = $groupid;
          }
          $sql .= " LEFT JOIN {user} t ON (s.gradeoverby = t.id)
                   WHERE s.example = 0 AND s.workshopid = :workshopid";
  
          if ('all' === $authorid) {
              // no additional conditions
          } elseif (!empty($authorid)) {
              list($usql, $uparams) = $DB->get_in_or_equal($authorid, SQL_PARAMS_NAMED);
              $sql .= " AND authorid $usql";
              $params = array_merge($params, $uparams);
          } else {
              // $authorid is empty
              return array();
          }
          list($sort, $sortparams) = users_order_by_sql('u');
          $sql .= " ORDER BY $sort";
  
          return $DB->get_records_sql($sql, array_merge($params, $sortparams), $limitfrom, $limitnum);
      }
code: public function get_submissions($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) {
          global $DB;
  
          $authorfields      = user_picture::fields('u', null, 'authoridx', 'author');
          $gradeoverbyfields = user_picture::fields('t', null, 'gradeoverbyx', 'over');
          $params            = array('workshopid' => $this->id);
          $sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
                         s.title, s.grade, s.gradeover, s.gradeoverby, s.published,
                         $authorfields, $gradeoverbyfields
                    FROM {workshop_submissions} s
                    JOIN {user} u ON (s.authorid = u.id)";
          if ($groupid) {
              $sql .= " JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)";
              $params['groupid'] = $groupid;
          }
          $sql .= " LEFT JOIN {user} t ON (s.gradeoverby = t.id)
                   WHERE s.example = 0 AND s.workshopid = :workshopid";
  
          if ('all' === $authorid) {
              // no additional conditions
          } elseif (!empty($authorid)) {
              list($usql, $uparams) = $DB->get_in_or_equal($authorid, SQL_PARAMS_NAMED);
              $sql .= " AND authorid $usql";
              $params = array_merge($params, $uparams);
          } else {
              // $authorid is empty
              return array();
          }
          list($sort, $sortparams) = users_order_by_sql('u');
          $sql .= " ORDER BY $sort";
  
          return $DB->get_records_sql($sql, array_merge($params, $sortparams), $limitfrom, $limitnum);
      }
code_tokens: public function get_submissions ( $ authorid = 'all' , $ groupid = 0 , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; $ authorfields = user_picture :: fields ( 'u' , null , 'authoridx' , 'author' ) ; $ gradeoverbyfields = user_picture :: fields ( 't' , null , 'gradeoverbyx' , 'over' ) ; $ params = array ( 'workshopid' => $ this -> id ) ; $ sql = "SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
                         s.title, s.grade, s.gradeover, s.gradeoverby, s.published,
                         $authorfields, $gradeoverbyfields
                    FROM {workshop_submissions} s
                    JOIN {user} u ON (s.authorid = u.id)" ; if ( $ groupid ) { $ sql .= " JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)" ; $ params [ 'groupid' ] = $ groupid ; } $ sql .= " LEFT JOIN {user} t ON (s.gradeoverby = t.id)
                   WHERE s.example = 0 AND s.workshopid = :workshopid" ; if ( 'all' === $ authorid ) { // no additional conditions } elseif ( ! empty ( $ authorid ) ) { list ( $ usql , $ uparams ) = $ DB -> get_in_or_equal ( $ authorid , SQL_PARAMS_NAMED ) ; $ sql .= " AND authorid $usql" ; $ params = array_merge ( $ params , $ uparams ) ; } else { // $authorid is empty return array ( ) ; } list ( $ sort , $ sortparams ) = users_order_by_sql ( 'u' ) ; $ sql .= " ORDER BY $sort" ; return $ DB -> get_records_sql ( $ sql , array_merge ( $ params , $ sortparams ) , $ limitfrom , $ limitnum ) ; }
docstring: Returns submissions from this workshop
  
  Fetches data from {workshop_submissions} and adds some useful information from other
  tables. Does not return textual fields to prevent possible memory lack issues.
  
  @see self::count_submissions()
  @param mixed $authorid int|array|'all' If set to [array of] integer, return submission[s] of the given user[s] only
  @param int $groupid If non-zero, return only submissions by authors in the specified group
  @param int $limitfrom Return a subset of records, starting at this point (optional)
  @param int $limitnum Return a subset containing this many records in total (optional, required if $limitfrom is set)
  @return array of records or an empty array
docstring_tokens: Returns submissions from this workshop