Check if user has rated.

@param array $args ( 0 => contentobject_id,  1 => contentobjectattribute_id )
@return bool|null (null if params are wrong)
324785
public static function user_has_rated( $args )
    {
        if ( !isset( $args[1] ) || !is_numeric( $args[0] ) || !is_numeric( $args[1] ) )
            return null;

        $rateDataObj = ezsrRatingDataObject::create( array( 'contentobject_id' => $args[0],
                                                    'contentobject_attribute_id' =>  $args[1]
        ));

        return $rateDataObj->userHasRated();
    }
889834
public static function instanceFromArguments($arguments = []) {
        $arguments = array_values($arguments);
        $argumentsCount = count($arguments);
        for ($i = 0; $i < $argumentsCount; $i++) {
            if (is_object($arguments[$i]) && $arguments[$i] instanceof SharedDataInterface) {
                return $arguments[$i];
            }
        }
        return null;
    }
279126
private static function checkArgs(array $args) {
        if ($_FILES) {
            foreach ($_FILES as $key => $f) {
                if (is_array($f['name'])) {
                    foreach ($f['tmp_name'] as $tmp) {
                        $args[ $key ][] = self::getfileSha1('@"' . $tmp . '"');
                    }
                } else {
                    $args[ $key ] = self::getfileSha1('@"' . $f['tmp_name'] . '"');
                }
            }
        }

        return $args;
    }
820234
public function validate(Args $args) {
        $isValid = true;
        $command = $args->getCommand();
        $valid = new Args($command);
        $schema = $this->getSchema($command);
        ksort($schema);

//        $meta = $schema[Cli::META];
        unset($schema[Cli::META]);
        $opts = $args->getOpts();
        $missing = [];

        // Check to see if the command is correct.
        if ($command && !$this->hasCommand($command) && $this->hasCommand()) {
            echo $this->red("Invalid command: $command.".PHP_EOL);
            $isValid = false;
        }

        // Add the args.
        $valid->setArgs($args->getArgs());

        foreach ($schema as $key => $definition) {
            // No Parameter (default)
            $type = Cli::val('type', $definition, 'string');

            if (array_key_exists($key, $opts)) {
                // Check for --key.
                $value = $opts[$key];
                if ($this->validateType($value, $type, $key, $definition)) {
                    $valid->setOpt($key, $value);
                } else {
                    $isValid = false;
                }
                unset($opts[$key]);
            } elseif (isset($definition['short']) && array_key_exists($definition['short'], $opts)) {
                // Check for -s.
                $value = $opts[$definition['short']];
                if ($this->validateType($value, $type, $key, $definition)) {
                    $valid->setOpt($key, $value);
                } else {
                    $isValid = false;
                }
                unset($opts[$definition['short']]);
            } elseif (array_key_exists('no-'.$key, $opts)) {
                // Check for --no-key.
                $value = $opts['no-'.$key];

                if ($type !== 'boolean') {
                    echo $this->red("Cannot apply the --no- prefix on the non boolean --$key.".PHP_EOL);
                    $isValid = false;
                } elseif ($this->validateType($value, $type, $key, $definition)) {
                    $valid->setOpt($key, !$value);
                } else {
                    $isValid = false;
                }
                unset($opts['no-'.$key]);
            } elseif ($definition['required']) {
                // The key was not supplied. Is it required?
                $missing[$key] = true;
                $valid->setOpt($key, false);
            }
        }

        if (count($missing)) {
            $isValid = false;
            foreach ($missing as $key => $v) {
                echo $this->red("Missing required option: $key".PHP_EOL);
            }
        }

        if (count($opts)) {
            $isValid = false;
            foreach ($opts as $key => $v) {
                echo $this->red("Invalid option: $key".PHP_EOL);
            }
        }

        if ($isValid) {
            return $valid;
        } else {
            echo PHP_EOL;
            return null;
        }
    }
1028150
public function handleSet(Args $args)
    {
        $value = StringUtil::parseValue($args->getArgument('value'));

        $this->manager->setConfigKey($args->getArgument('key'), $value);

        return 0;
    }
466535
function currentUserHasRated()
    {
        $rateDataObj = ezsrRatingDataObject::create( array( 'contentobject_id' => $this->attribute('contentobject_id'),
                                                            'contentobject_attribute_id' =>  $this->attribute('contentobject_attribute_id'),
                                                            'created_at' => 0 ) );
        return $rateDataObj->userHasRated();
    }
493574
public static function isValidFieldOccurrence ($arg) 
    {
        if ($arg === null || ctype_digit($arg)) {
            $arg = (int)$arg;
        }
        return is_int($arg) && $arg >= 0 && $arg < 100;
    }
1009574
private function _execute($args = array())
    {
        if ($this->_err) {
            return false;
        };
        if ($this->_sth) {
            if ($this->_sth->execute($args)) {
                return true;
            } else {
                $this->_err = implode(' ', $this->_sth->errorInfo());
                return false;
            };
        } else {
            $this->_err = "No statement to execute.";
        };
        return false;
    }
1371595
private function checkCredentials(array $args = []): bool
    {
        if (empty($args['credentials'])) {
            throw new DorcasException('You did not provide the Dorcas client credentials in the configuration.', $args);
        }
        $id = data_get($args, 'credentials.id', null);
        $secret = data_get($args, 'credentials.secret', null);
        if (empty($id)) {
            throw new DorcasException('The client "id" key is absent in the credentials configuration.', $args);
        }
        if (empty($secret)) {
            throw new DorcasException('The client "secret" key is absent in the credentials configuration.', $args);
        }
        return true;
    }
618093
protected function view_single_grading_panel($args) {
        global $DB, $CFG, $SESSION, $PAGE;

        $o = '';
        $instance = $this->get_instance();

        require_once($CFG->dirroot . '/mod/assign/gradeform.php');

        // Need submit permission to submit an assignment.
        require_capability('mod/assign:grade', $this->context);

        // If userid is passed - we are only grading a single student.
        $userid = $args['userid'];
        $attemptnumber = $args['attemptnumber'];

        // Apply overrides.
        $this->update_effective_access($userid);

        $rownum = 0;
        $useridlist = array($userid);

        $last = true;
        // This variation on the url will link direct to this student, with no next/previous links.
        // The benefit is the url will be the same every time for this student, so Atto autosave drafts can match up.
        $returnparams = array('userid' => $userid, 'rownum' => 0, 'useridlistid' => 0);
        $this->register_return_link('grade', $returnparams);

        $user = $DB->get_record('user', array('id' => $userid));
        $submission = $this->get_user_submission($userid, false, $attemptnumber);
        $submissiongroup = null;
        $teamsubmission = null;
        $notsubmitted = array();
        if ($instance->teamsubmission) {
            $teamsubmission = $this->get_group_submission($userid, 0, false, $attemptnumber);
            $submissiongroup = $this->get_submission_group($userid);
            $groupid = 0;
            if ($submissiongroup) {
                $groupid = $submissiongroup->id;
            }
            $notsubmitted = $this->get_submission_group_members_who_have_not_submitted($groupid, false);

        }

        // Get the requested grade.
        $grade = $this->get_user_grade($userid, false, $attemptnumber);
        $flags = $this->get_user_flags($userid, false);
        if ($this->can_view_submission($userid)) {
            $submissionlocked = ($flags && $flags->locked);
            $extensionduedate = null;
            if ($flags) {
                $extensionduedate = $flags->extensionduedate;
            }
            $showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
            $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context());
            $usergroups = $this->get_all_groups($user->id);

            $submissionstatus = new assign_submission_status_compact($instance->allowsubmissionsfromdate,
                                                                     $instance->alwaysshowdescription,
                                                                     $submission,
                                                                     $instance->teamsubmission,
                                                                     $teamsubmission,
                                                                     $submissiongroup,
                                                                     $notsubmitted,
                                                                     $this->is_any_submission_plugin_enabled(),
                                                                     $submissionlocked,
                                                                     $this->is_graded($userid),
                                                                     $instance->duedate,
                                                                     $instance->cutoffdate,
                                                                     $this->get_submission_plugins(),
                                                                     $this->get_return_action(),
                                                                     $this->get_return_params(),
                                                                     $this->get_course_module()->id,
                                                                     $this->get_course()->id,
                                                                     assign_submission_status::GRADER_VIEW,
                                                                     $showedit,
                                                                     false,
                                                                     $viewfullnames,
                                                                     $extensionduedate,
                                                                     $this->get_context(),
                                                                     $this->is_blind_marking(),
                                                                     '',
                                                                     $instance->attemptreopenmethod,
                                                                     $instance->maxattempts,
                                                                     $this->get_grading_status($userid),
                                                                     $instance->preventsubmissionnotingroup,
                                                                     $usergroups);
            $o .= $this->get_renderer()->render($submissionstatus);
        }

        if ($grade) {
            $data = new stdClass();
            if ($grade->grade !== null && $grade->grade >= 0) {
                $data->grade = format_float($grade->grade, $this->get_grade_item()->get_decimals());
            }
        } else {
            $data = new stdClass();
            $data->grade = '';
        }

        if (!empty($flags->workflowstate)) {
            $data->workflowstate = $flags->workflowstate;
        }
        if (!empty($flags->allocatedmarker)) {
            $data->allocatedmarker = $flags->allocatedmarker;
        }

        // Warning if required.
        $allsubmissions = $this->get_all_submissions($userid);

        if ($attemptnumber != -1 && ($attemptnumber + 1) != count($allsubmissions)) {
            $params = array('attemptnumber' => $attemptnumber + 1,
                            'totalattempts' => count($allsubmissions));
            $message = get_string('editingpreviousfeedbackwarning', 'assign', $params);
            $o .= $this->get_renderer()->notification($message);
        }

        $pagination = array('rownum' => $rownum,
                            'useridlistid' => 0,
                            'last' => $last,
                            'userid' => $userid,
                            'attemptnumber' => $attemptnumber,
                            'gradingpanel' => true);

        if (!empty($args['formdata'])) {
            $data = (array) $data;
            $data = (object) array_merge($data, $args['formdata']);
        }
        $formparams = array($this, $data, $pagination);
        $mform = new mod_assign_grade_form(null,
                                           $formparams,
                                           'post',
                                           '',
                                           array('class' => 'gradeform'));

        if (!empty($args['formdata'])) {
            // If we were passed form data - we want the form to check the data
            // and show errors.
            $mform->is_validated();
        }
        $o .= $this->get_renderer()->heading(get_string('grade'), 3);
        $o .= $this->get_renderer()->render(new assign_form('gradingform', $mform));

        if (count($allsubmissions) > 1) {
            $allgrades = $this->get_all_grades($userid);
            $history = new assign_attempt_history_chooser($allsubmissions,
                                                          $allgrades,
                                                          $this->get_course_module()->id,
                                                          $userid);

            $o .= $this->get_renderer()->render($history);
        }

        \mod_assign\event\grading_form_viewed::create_from_user($this, $user)->trigger();

        return $o;
    }
518361
public static function findCommandValue($args) {
		$args = explode("|",$args);
		foreach ($args as $arg) {
			if (isset(self::$options[$arg])) {
				return self::$options[$arg];
			}
		}
		return false;
	}
7630
private function eval(...$args)
    {
        $return = $this->client->eval(...$args);

        if ($this->client->getLastError()) {
            throw new \BadMethodCallException($this->client->getLastError());
        }

        return $return;
    }
1175541
public function exists(...$args): bool
    {
        if (!count($args)) {
            //test to see if it's empty
            return !$this->isEmpty();
        }

        $separator = '--'. md5(uniqid()) . '--';
        return $this->isDot(implode($separator, $args), $separator);
    }
20296
public function url( array $args = [] ) {
		$url = get_author_posts_url( $this->ID );
		if ( $args ) {
			$url = add_query_arg( $args, $url );
		}

		return $url;
	}
122515
public function tasks($args = null)
    {
        $this->areArgumentsValid($args, ['filter', 'page', 'pageSize', 'startdate', 'enddate', 'updatedAfterDate', 'completedAfterDate', 'completedBeforeDate', 'showDeleted', 'includeCompletedTasks', 'includeCompletedSubtasks', 'creator-ids', 'include', 'responsible-party-ids', 'sort', 'getSubTasks', 'nestSubTasks', 'getFiles', 'dataSet', 'includeToday', 'ignore-start-date']);
    
        return $this->client->get("$this->endpoint/$this->id/tasks", $args)->response();
    }
191231
private function _parseArgs(array $args)
	{
		$arg = '';
		if(count($args) > 0)
		{
			foreach($args as $number => $argument)
			{
				if($number === 0)
				{
					$arg .= $argument;
				}
				else
				{
					$arg .= ', ' . $argument;
				}
			}
		}

		return $arg;
	}
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }