Calculate the progress of the current user in the lesson.

@return int the progress (scale 0-100)
@since  Moodle 3.3
509470
public function calculate_progress() {
        global $USER, $DB;

        // Check if the user is reviewing the attempt.
        if (isset($USER->modattempts[$this->properties->id])) {
            return 100;
        }

        // All of the lesson pages.
        $pages = $this->load_all_pages();
        foreach ($pages as $page) {
            if ($page->prevpageid == 0) {
                $pageid = $page->id;  // Find the first page id.
                break;
            }
        }

        // Current attempt number.
        if (!$ntries = $DB->count_records("lesson_grades", array("lessonid" => $this->properties->id, "userid" => $USER->id))) {
            $ntries = 0;  // May not be necessary.
        }

        $viewedpageids = array();
        if ($attempts = $this->get_attempts($ntries, false)) {
            foreach ($attempts as $attempt) {
                $viewedpageids[$attempt->pageid] = $attempt;
            }
        }

        $viewedbranches = array();
        // Collect all of the branch tables viewed.
        if ($branches = $this->get_content_pages_viewed($ntries, $USER->id, 'timeseen ASC', 'id, pageid')) {
            foreach ($branches as $branch) {
                $viewedbranches[$branch->pageid] = $branch;
            }
            $viewedpageids = array_merge($viewedpageids, $viewedbranches);
        }

        // Filter out the following pages:
        // - End of Cluster
        // - End of Branch
        // - Pages found inside of Clusters
        // Do not filter out Cluster Page(s) because we count a cluster as one.
        // By keeping the cluster page, we get our 1.
        $validpages = array();
        while ($pageid != 0) {
            $pageid = $pages[$pageid]->valid_page_and_view($validpages, $viewedpageids);
        }

        // Progress calculation as a percent.
        $progress = round(count($viewedpageids) / count($validpages), 2) * 100;
        return (int) $progress;
    }
1188760
public function getCurrentAccount()
    {
        $this->currentAccount || $this->currentAccount = wei()->wechatAccount()->cache()->curApp()->findOrInit(false);

        return $this->currentAccount;
    }
861193
public function getRemaining()
    {
        $speed = $this->getSpeed();
        $notHandledCount = $this->all - $this->handled;

        $remainingSeconds = $speed != 0 ? $notHandledCount / $speed : $notHandledCount;

        return round($remainingSeconds);
    }
165449
public function next_user() {
        if (!$this->users_rs) {
            return false; // no users present
        }

        if (!$this->users_rs->valid()) {
            if ($current = $this->_pop()) {
                // this is not good - user or grades updated between the two reads above :-(
            }

            return false; // no more users
        } else {
            $user = $this->users_rs->current();
            $this->users_rs->next();
        }

        // find grades of this user
        $grade_records = array();
        while (true) {
            if (!$current = $this->_pop()) {
                break; // no more grades
            }

            if (empty($current->userid)) {
                break;
            }

            if ($current->userid != $user->id) {
                // grade of the next user, we have all for this user
                $this->_push($current);
                break;
            }

            $grade_records[$current->itemid] = $current;
        }

        $grades = array();
        $feedbacks = array();

        if (!empty($this->grade_items)) {
            foreach ($this->grade_items as $grade_item) {
                if (!isset($feedbacks[$grade_item->id])) {
                    $feedbacks[$grade_item->id] = new stdClass();
                }
                if (array_key_exists($grade_item->id, $grade_records)) {
                    $feedbacks[$grade_item->id]->feedback       = $grade_records[$grade_item->id]->feedback;
                    $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat;
                    unset($grade_records[$grade_item->id]->feedback);
                    unset($grade_records[$grade_item->id]->feedbackformat);
                    $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false);
                } else {
                    $feedbacks[$grade_item->id]->feedback       = '';
                    $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE;
                    $grades[$grade_item->id] =
                        new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false);
                }
                $grades[$grade_item->id]->grade_item = $grade_item;
            }
        }

        // Set user suspended status.
        $user->suspendedenrolment = isset($this->suspendedusers[$user->id]);
        $result = new stdClass();
        $result->user      = $user;
        $result->grades    = $grades;
        $result->feedbacks = $feedbacks;
        return $result;
    }
906667
final public static function getUploadProgress($formName)
    {

        $key = ini_get("session.upload_progress.prefix") . $formName;
        if (!empty($_SESSION[$key])) {
            $current = $_SESSION[$key]["bytes_processed"];
            $total = $_SESSION[$key]["content_length"];
            return $current < $total ? ceil($current / $total * 100) : 100;
        } else {
            return 100;
        }
    }
1073852
public function progress(): AchievementCriteriaProgress
    {
        if (!is_null($this->progress)) {
            return $this->progress;
        }

        return $this->progress = new AchievementCriteriaProgress(
            $this->data['progress']['value'] ?? 0,
            $this->data['progress']['changed'] ?? false,
            $this->data['progress']['completed'] ?? false,
            $this->data['progress']['data'] ?? []
        );
    }
733884
protected function getProgress(): string
    {
        return sprintf(
            ' %' . $this->numTestsWidth . 'd / %' . $this->numTestsWidth . 'd (%3s%%)',
            $this->casesProcessed,
            $this->totalCases,
            floor(($this->totalCases ? $this->casesProcessed / $this->totalCases : 0) * 100)
        );
    }
863010
protected function load_users() {
        global $CFG;

        // Create a graded_users_iterator because it will properly check the groups etc.
        $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
        $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
        $showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $this->context);

        require_once($CFG->dirroot.'/grade/lib.php');
        $gui = new \graded_users_iterator($this->course, null, $this->groupid);
        $gui->require_active_enrolment($showonlyactiveenrol);
        $gui->init();

        // Flatten the users.
        $users = array();
        while ($user = $gui->next_user()) {
            $users[$user->user->id] = $user->user;
        }
        $gui->close();
        return $users;
    }
1167045
public function getSubTotal()
    {
        $total = 0;

        // Calculate total from items in the list
        foreach ($this->Items() as $item) {
            $total += $item->SubTotal;
        }
        
        $this->extend("updateSubTotal", $total);

        return $total;
    }
520330
protected function getProgressBar(): ProgressBar
    {
        if ($this->progressBar === null) {
            $this->progressBar = new ProgressBar($this->output);
        }
        return $this->progressBar;
    }
173597
function progressText()
    {
        if ( $this->Progress == self::PROGRESS_UNKNOWN )
        {
            return ezpI18n::tr( 'ezscriptmonitor', 'Unknown' );
        }

        if ( $this->Progress < 0 )
        {
            return '0%';
        }

        if ( $this->Progress > 100 )
        {
            return '100%';
        }

        return $this->Progress . '%';
    }
227703
protected function get_progress() : \progress_trace {
        if (null === $this->progresstracer) {
            $this->set_progress(new \text_progress_trace());
        }

        return $this->progresstracer;
    }
1113880
public function draw()
    {
        $numberLen = strlen(' 100%');
        $complete = round($this->_progress / $this->_total, 2);
        $barLen = ($this->_width - $numberLen) * ($this->_progress / $this->_total);
        $bar = '';
        if ($barLen > 1) {
            $bar = str_repeat('=', $barLen - 1) . '>';
        }

        $pad = ceil($this->_width - $numberLen - $barLen);
        if ($pad > 0) {
            $bar .= str_repeat(' ', $pad);
        }
        $percent = ($complete * 100) . '%';
        $bar .= str_pad($percent, $numberLen, ' ', STR_PAD_LEFT);

        $this->_io->overwrite($bar, 0);

        return $this;
    }
694420
public function get_end() {
        global $DB;

        if ($this->endtime !== null) {
            return $this->endtime;
        }

        // The enddate field is only available from Moodle 3.2 (MDL-22078).
        if (!empty($this->get_course_data()->enddate)) {
            $this->endtime = (int)$this->get_course_data()->enddate;
            return $this->endtime;
        }

        return 0;
    }
595326
public function getProgress()
    {
        $site = $this->getSite();
        if (is_null($site)) {
            return 0.0;
        }

        /** @var $indexService \ApacheSolrForTypo3\Solr\Domain\Index\IndexService */
        $indexService = $this->getInitializedIndexService($site);

        return $indexService->getProgress();
    }
101722
public function getPreviousStep()
    {
        $steps = MultiFormStep::get()->filter('SessionID', $this->SessionID)->sort('LastEdited', 'DESC');

        if ($steps) {
            foreach ($steps as $step) {
                $step->setForm($this->form);

                if ($step->getNextStep()) {
                    if ($step->getNextStep() == static::class) {
                        return get_class($step);
                    }
                }
            }
        }
    }
899090
public function next()
    {
        $cls  = $this->_cls;
        $data = $this->_getCurrentData();

        if (!$data) {
            $this->_curval = null;
            return $this->_curval;
        } else {
            ++$this->_count;
            $this->_curval = $data;
            return new $this->_cls($this->_curval);
        }
    }