Checks whether this feedback is similar to another

@param FeedbackInterface $feedback
@return boolean
352386
public function isSimilarTo(FeedbackInterface $feedback)
    {
        if (!$feedback instanceof RemoveNode) {
            return false;
        }

        return $this->getNode()->getContextPath() === $feedback->getNode()->getContextPath();
    }
517487
public function mail(array $feedbackObject, $copyreporter = false) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings from config if not in copy mode
		$to = Configure::read('Feedback.methods.mail.to');
		$from = Configure::read('Feedback.methods.mail.from');

		// Change recipient if sending a copy
		if ($copyreporter) {
			$to = $feedbackObject['email'];
		}

		//Change the sender if any given
		if (!empty($feedbackObject['email']) && !empty($feedbackObject['name'])) {
			$from = [$feedbackObject['email'] => $feedbackObject['name']];
		}

		//Tmp store the screenshot:
		$tmpfile = APP . 'tmp' . DS . time() . '_' . rand(1000, 9999) . '.png';
		if (!file_put_contents($tmpfile, base64_decode($feedbackObject['screenshot']))) {
			//Need to save tmp file
			throw new NotFoundException('Could not save tmp file for attachment in mail');
		}

		$email = new Email();
		$email->from($from);
		$email->to($to);
		$email->subject($feedbackObject['subject']);
		$email->emailFormat('html');
		$email->attachments([
		    'screenshot.png' => [
		        'file' => $tmpfile,
		        'mimetype' => 'image/png',
		        'contentId' => 'id-screenshot'
		    ]
		]);

		//Mail specific: append browser, browser version, URL, etc to feedback :
		if ($copyreporter) {
			$feedbackObject['feedback'] = '<p>' . __d('feedback', 'A copy of your submitted feedback:') . '</p>' . $feedbackObject['feedback'];
		}
		$feedbackObject['feedback'] .= '<p>';
		$feedbackObject['feedback'] .= sprintf('Browser: %s %s<br/>', $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf('Url: %s<br/>', $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf('OS: %s<br/>', $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf('By: %s<br/>', $feedbackObject['name']);
		$feedbackObject['feedback'] .= 'Screenshot: <br/>';
		$feedbackObject['feedback'] .= '</p>';
		$feedbackObject['feedback'] .= '<img src="cid:id-screenshot">'; //Add inline screenshot

		if ($email->send($feedbackObject['feedback'])) {
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

			return $returnobject;
		}

		unlink($tmpfile);

		return $returnobject;
	}
1138937
protected function comparesTo(AmountInterface $amount) {
    $this->validateOtherAmount($amount);

    return bccomp($this->getAmount(), $amount->getAmount(), static::BC_MATH_SCALE);
  }
1212077
public function isEqualTo(EntityInterface $entity)
    {
        if ($entity->getType() !== $this->getType()) {
            return false;
        }

        if ($this->getType()->getAttributes()->getSize() !== $this->value_holder_map->getSize()) {
            return false;
        }

        foreach ($this->getType()->getAttributes()->getKeys() as $attribute_name) {
            $value_holder = $this->value_holder_map->getItem($attribute_name);
            if (!$value_holder->sameValueAs($entity->getValue($attribute_name))) {
                return false;
            }
        }

        return true;
    }
307825
public function isMatch($a, $b)
    {
        $percentage = null;

        // Strip tags and check similarity
        $aStripped = strip_tags($a);
        $bStripped = strip_tags($b);
        similar_text($aStripped, $bStripped, $percentage);

        if ($percentage >= $this->similarityThreshold) {
            return true;
        }

        // Check w/o stripped tags
        similar_text($a, $b, $percentage);
        if ($percentage >= $this->similarityThreshold) {
            return true;
        }

        // Check common prefix/ suffix length
        $aCleaned = trim($aStripped);
        $bCleaned = trim($bStripped);
        if ($this->stringUtil->strlen($aCleaned) === 0 || $this->stringUtil->strlen($bCleaned) === 0) {
            $aCleaned = $a;
            $bCleaned = $b;
        }
        if ($this->stringUtil->strlen($aCleaned) === 0 || $this->stringUtil->strlen($bCleaned) === 0) {
            return false;
        }
        $prefixIndex = Preprocessor::diffCommonPrefix($aCleaned, $bCleaned, $this->stringUtil);
        $suffixIndex = Preprocessor::diffCommonSuffix($aCleaned, $bCleaned, $this->stringUtil);

        // Use shorter string, and see how much of it is leftover
        $len = min($this->stringUtil->strlen($aCleaned), $this->stringUtil->strlen($bCleaned));
        $remaining = $len - ($prefixIndex + $suffixIndex);
        $strLengthPercent = $len / max($this->stringUtil->strlen($a), $this->stringUtil->strlen($b));

        if ($remaining === 0 && $strLengthPercent > $this->lengthRatioThreshold) {
            return true;
        }

        $percentCommon = ($prefixIndex + $suffixIndex) / $len;

        if ($strLengthPercent > 0.1 && $percentCommon > $this->commonTextRatioThreshold) {
            return true;
        }

        return false;
    }
202116
public function equals(self $other) : bool
    {
        if ($other === $this) {
            return true;
        }
        
        return $other->from->equals($this->from) && $other->until->equals($this->until);
    }
919230
public function process_feedback($feedbackset, &$feedbacks) {
        foreach ($feedbackset as $bbfeedback) {
            $feedback = new stdClass();
            $feedback->ident = $this->getpath($bbfeedback,
                    array('@', 'ident'), '', true);
            $feedback->text = '';
            if ($this->getpath($bbfeedback,
                    array('#', 'flow_mat', 0), false, false)) {
                $this->process_block($this->getpath($bbfeedback,
                        array('#', 'flow_mat', 0), false, false), $feedback);
            } else if ($this->getpath($bbfeedback,
                    array('#', 'solution', 0, '#', 'solutionmaterial', 0, '#', 'flow_mat', 0), false, false)) {
                $this->process_block($this->getpath($bbfeedback,
                        array('#', 'solution', 0, '#', 'solutionmaterial', 0, '#', 'flow_mat', 0), false, false), $feedback);
            }

            $feedbacks[$feedback->ident] = $feedback;
        }
    }
1086592
public function hasLink(Link $compared)
    {
        foreach ($this->links as $link) {
            if ($this->linksMatch($link, $compared)) {
                return true;
            }
        }

        return false;
    }
1120849
public function isCorrect()
    {
        if ($this->hasCorrectResponse() === true) {
            $correctResponse = $this->getCorrectResponse();

            if ($correctResponse instanceof Comparable) {
                return $correctResponse->equals($this->getValue());
            } else {
                return $correctResponse === $this->getValue();
            }
        }

        return false;
    }
850889
public function compareTo($other): bool {
        if(!($other instanceof $this)) {
            return FALSE;
        }
        if($this->getFileName() !== $other->getFileName()) {
            return FALSE;
        }
        return TRUE;
    }
1236682
public function removeFeedback(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Feedback\Feedback $feedback)
    {
        return $this->feedbacks->removeElement($feedback);
    }
402969
public function redmine(array $feedbackObject) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings
		$api_url			= Configure::read('Feedback.methods.redmine.api_url');
		$username			= Configure::read('Feedback.methods.redmine.username');
		$password			= Configure::read('Feedback.methods.redmine.password');
		$project_id			= Configure::read('Feedback.methods.redmine.project_id');
		$tracker_id			= Configure::read('Feedback.methods.redmine.tracker_id');

		//Redmine specific: append browser, browser version and URL to feedback:
		$feedbackObject['feedback'] .= "\n\n";
		$feedbackObject['feedback'] .= sprintf("**Browser**: %s %s\n\n", $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf("**Url**: %s\n\n", $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf("**OS**: %s\n\n", $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf("**By**: %s\n\n", $feedbackObject['name']);

		//Prepare data
		$data = [];
		$data['issue']['project_id'] = $project_id;
		$data['issue']['tracker_id'] = $tracker_id;
		$data['issue']['subject'] = $feedbackObject['subject'];
		$data['issue']['description'] = $feedbackObject['feedback'];
		$data_string = json_encode($data);

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $api_url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
		curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

		$result = curl_exec($ch);
		$curlstatuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

		if (!$result) {
			//Return curl error
			$returnobject['msg'] = curl_error($ch);

		} elseif ($curlstatuscode >= 400) {
			//Return http error and message
			$returnobject['msg'] = "Error in Redmine API call ($curlstatuscode)"; //Can contain linebreaks

		} else {
			//TODO: Update with image

			//Set return value to true and return message
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

		if (Configure::read('Feedback.returnlink')) {
				$returnobject['msg'] .= '<br/>';
				$returnobject['msg'] .= __d('feedback', 'View your feedback on: ');

				//Get response from jira api
				$answer = json_decode($result);

				//Create new url:
				//Replace api prefix with GitHub public domain:
				$url = str_replace('.json', '/', $api_url);

				//Append issue number
				$url .= $answer->issue->id;

				$returnobject['msg'] .= '<a target="_blank" href="' . $url . '">' . $url . '</a>';
			}

		}

		return $returnobject;
	}
1326044
public function equals($target): bool
    {
        if (
            ($this instanceof RoleInterface && $target instanceof RoleInterface) ||
            ($this instanceof SceneInterface && $target instanceof SceneInterface)
        ) {
            return $this->getType() === $target->getType() &&
                $this->getId() === $target->getId();
        }

        return false;
    }
242713
public function isEqualTo(ValueHolderInterface $other_value_holder)
    {
        if (get_class($this) !== get_class($other_value_holder)) {
            return false;
        }

        return $this->sameValueAs($other_value_holder->getValue());
    }
396988
public function github(array $feedbackObject) {
		$returnobject = [];
		$returnobject['result'] = false;
		$returnobject['msg'] = '';

		if (empty($feedbackObject)) {
			return $returnobject;
		}

		//Read settings
		$api_url			= Configure::read('Feedback.methods.github.api_url');
		$username			= Configure::read('Feedback.methods.github.username');
		$password			= Configure::read('Feedback.methods.github.password');
		$localimagestore = Configure::read('Feedback.methods.github.localimagestore');

		//Github specific: append browser, browser version and URL to feedback:
		$feedbackObject['feedback'] .= "\n\n";
		$feedbackObject['feedback'] .= sprintf("**Browser**: %s %s\n\n", $feedbackObject['browser'], $feedbackObject['browser_version']);
		$feedbackObject['feedback'] .= sprintf("**Url**: %s\n\n", $feedbackObject['url']);
		$feedbackObject['feedback'] .= sprintf("**OS**: %s\n\n", $feedbackObject['os']);
		$feedbackObject['feedback'] .= sprintf("**By**: %s\n\n", $feedbackObject['name']);

		// WARNING: This may not work for sites with different domains (or dev environments)
		//          If the given URL is not public, Github won't display the screenshot
		if ($localimagestore) {
			//Create filename based on timestamp and random number (to prevent collisions)
		if ($imagename = $this->saveScreenshot($feedbackObject)) {
				$viewimageUrl = Router::url("/img/screenshots/$imagename", true);

				$feedbackObject['feedback'] .= sprintf("**Screenshot**:\n![screenshot](%s)", $viewimageUrl);
			}
		}
		// Github still doesn't support this kind of image format in Markup Language
		// $content = '[screenshot]: data:image/png;base64,'. $feedbackObject['screenshot'] . " \n\n";

		//Prepare data
		$data = ['title' => $feedbackObject['subject'], 'body' => $feedbackObject['feedback']];
		$data_string = json_encode($data);

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $api_url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
		curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

		$result = curl_exec($ch);
		$curlstatuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

		if (!$result) {
			//Return curl error
			$returnobject['msg'] = curl_error($ch);

		} elseif ($curlstatuscode >= 400) {
			//Return http error and message
			$message = json_decode($result);
			$returnobject['msg'] = trim($message->message); //Can contain linebreaks

		} else {
			//Set return value to true and return message
			$returnobject['result'] = true;
			$returnobject['msg'] = __d('feedback', 'Thank you. Your feedback was saved.');

			if (Configure::read('Feedback.returnlink')) {
				$returnobject['msg'] .= '<br/>';
				$returnobject['msg'] .= __d('feedback', 'View your feedback on: ');

				//Get response from github api
				$answer = json_decode($result);

				//Create new url:
				//Replace api prefix with GitHub public domain:
				$url = str_replace('/api.', '/', $api_url);
				$url = str_replace('/repos/', '/', $url);

				//Append issue number
				$url .= '/' . $answer->number;

				$returnobject['msg'] .= '<a target="_blank" href="' . $url . '">' . $url . '</a>';
			}

		}

		return $returnobject;
	}
1322441
public function is_feedback_modified(stdClass $grade, stdClass $data) {
        $commenttext = '';
        if ($grade) {
            $feedbackcomments = $this->get_feedback_comments($grade->id);
            if ($feedbackcomments) {
                $commenttext = $feedbackcomments->commenttext;
            }
        }

        $formtext = $data->assignfeedbackcomments_editor['text'];

        // Need to convert the form text to use @@PLUGINFILE@@ and format it so we can compare it with what is stored in the DB.
        if (isset($data->assignfeedbackcomments_editor['itemid'])) {
            $formtext = file_rewrite_urls_to_pluginfile($formtext, $data->assignfeedbackcomments_editor['itemid']);
            $formtext = format_text($formtext, FORMAT_HTML);
        }

        if ($commenttext == $formtext) {
            return false;
        } else {
            return true;
        }
    }
947595
protected function feedback_submitted(\cm_info $cm, $contextid, $userid, $after = false) {
        if (empty($this->activitylogs[$contextid][$userid]) ||
                empty($this->activitylogs[$contextid][$userid]['\mod_lesson\event\lesson_ended'])) {
            return false;
        }

        // Multiple lesson attempts completed counts as submitted after feedback.
        return (2 >= count($this->activitylogs[$contextid][$userid]['\mod_lesson\event\lesson_ended']));
    }