public static function page_number_for_attempt($assignment, $userid, $attemptnumber, $readonly = false) {
        global $CFG;

        require_once($CFG->libdir . '/pdflib.php');

        $assignment = self::get_assignment_from_param($assignment);

        if (!$assignment->can_view_submission($userid)) {
            print_error('nopermission');
        }

        // When in readonly we can return the number of images in the DB because they should already exist,
        // if for some reason they do not, then we proceed as for the normal version.
        if ($readonly) {
            $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
            $fs = get_file_storage();
            $files = $fs->get_directory_files($assignment->get_context()->id, 'assignfeedback_editpdf',
                self::PAGE_IMAGE_READONLY_FILEAREA, $grade->id, '/');
            $pagecount = count($files);
            if ($pagecount > 0) {
                return $pagecount;
            }
        }

        // Get a combined pdf file from all submitted pdf files.
        $document = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
        return $document->get_page_count();
    }
public static function page_number_for_attempt($assignment, $userid, $attemptnumber, $readonly = false) {
        global $CFG;

        require_once($CFG->libdir . '/pdflib.php');

        $assignment = self::get_assignment_from_param($assignment);

        if (!$assignment->can_view_submission($userid)) {
            print_error('nopermission');
        }

        // When in readonly we can return the number of images in the DB because they should already exist,
        // if for some reason they do not, then we proceed as for the normal version.
        if ($readonly) {
            $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
            $fs = get_file_storage();
            $files = $fs->get_directory_files($assignment->get_context()->id, 'assignfeedback_editpdf',
                self::PAGE_IMAGE_READONLY_FILEAREA, $grade->id, '/');
            $pagecount = count($files);
            if ($pagecount > 0) {
                return $pagecount;
            }
        }

        // Get a combined pdf file from all submitted pdf files.
        $document = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
        return $document->get_page_count();
    }
public static function page_number_for_attempt ( $ assignment , $ userid , $ attemptnumber , $ readonly = false ) { global $ CFG ; require_once ( $ CFG -> libdir . '/pdflib.php' ) ; $ assignment = self :: get_assignment_from_param ( $ assignment ) ; if ( ! $ assignment -> can_view_submission ( $ userid ) ) { print_error ( 'nopermission' ) ; } // When in readonly we can return the number of images in the DB because they should already exist, // if for some reason they do not, then we proceed as for the normal version. if ( $ readonly ) { $ grade = $ assignment -> get_user_grade ( $ userid , true , $ attemptnumber ) ; $ fs = get_file_storage ( ) ; $ files = $ fs -> get_directory_files ( $ assignment -> get_context ( ) -> id , 'assignfeedback_editpdf' , self :: PAGE_IMAGE_READONLY_FILEAREA , $ grade -> id , '/' ) ; $ pagecount = count ( $ files ) ; if ( $ pagecount > 0 ) { return $ pagecount ; } } // Get a combined pdf file from all submitted pdf files. $ document = self :: get_combined_pdf_for_attempt ( $ assignment , $ userid , $ attemptnumber ) ; return $ document -> get_page_count ( ) ; }
This function will return the number of pages of a pdf.

@param int|\assign $assignment
@param int $userid
@param int $attemptnumber (-1 means latest attempt)
@param bool $readonly When true we get the number of pages for the readonly version.
@return int number of pages
This function will return the number of pages of a pdf .