Add feedback

@param FeedbackInterface $feedback
@return void
192294
public function add(FeedbackInterface $feedback)
    {
        foreach ($this->feedbacks as $value) {
            if ($value->isSimilarTo($feedback)) {
                return;
            }
        }

        $this->feedbacks[] = $feedback;
    }
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;
	}
1059431
public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_feedback $feedbackplugin) {
        $o = '';

        if ($feedbackplugin->view == assign_feedback_plugin_feedback::SUMMARY) {
            $showviewlink = false;
            $summary = $feedbackplugin->plugin->view_summary($feedbackplugin->grade, $showviewlink);

            $classsuffix = $feedbackplugin->plugin->get_subtype() .
                           '_' .
                           $feedbackplugin->plugin->get_type() .
                           '_' .
                           $feedbackplugin->grade->id;
            $o .= $this->output->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix);

            $link = '';
            if ($showviewlink) {
                $previewstr = get_string('viewfeedback', 'assign');
                $icon = $this->output->pix_icon('t/preview', $previewstr);

                $expandstr = get_string('viewfull', 'assign');
                $options = array('class'=>'expandsummaryicon expand_' . $classsuffix);
                $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, $options);

                $jsparams = array($feedbackplugin->plugin->get_subtype(),
                                  $feedbackplugin->plugin->get_type(),
                                  $feedbackplugin->grade->id);
                $this->page->requires->js_init_call('M.mod_assign.init_plugin_summary', $jsparams);

                $urlparams = array('id' => $feedbackplugin->coursemoduleid,
                                   'gid'=>$feedbackplugin->grade->id,
                                   'plugin'=>$feedbackplugin->plugin->get_type(),
                                   'action'=>'viewplugin' . $feedbackplugin->plugin->get_subtype(),
                                   'returnaction'=>$feedbackplugin->returnaction,
                                   'returnparams'=>http_build_query($feedbackplugin->returnparams));
                $url = new moodle_url('/mod/assign/view.php', $urlparams);
                $link .= '<noscript>';
                $link .= $this->output->action_link($url, $icon);
                $link .= '</noscript>';

                $link .= $this->output->spacer(array('width'=>15));
            }

            $o .= $link . $summary;
            $o .= $this->output->box_end();
            if ($showviewlink) {
                $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix);
                $classes = 'expandsummaryicon contract_' . $classsuffix;
                $o .= $this->output->pix_icon('t/switch_minus',
                                              get_string('viewsummary', 'assign'),
                                              null,
                                              array('class'=>$classes));
                $o .= $feedbackplugin->plugin->view($feedbackplugin->grade);
                $o .= $this->output->box_end();
            }
        } else if ($feedbackplugin->view == assign_feedback_plugin_feedback::FULL) {
            $o .= $this->output->box_start('boxaligncenter feedbackfull');
            $o .= $feedbackplugin->plugin->view($feedbackplugin->grade);
            $o .= $this->output->box_end();
        }

        return $o;
    }
824
protected function addReview()
    {
        if (!$this->isError()) {
            $id = $this->review->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
32506
public function addInput($input)
    {
        $inputs = $this->getInputs();
        array_push($inputs, $input);
        $this->setInputs($inputs);
    }
101882
public void setFeedback(final SpecTopic feedback) {
        if (feedback == null && this.feedback == null) {
            return;
        } else if (feedback == null) {
            removeChild(this.feedback);
            this.feedback = null;
        } else if (this.feedback == null) {
            feedback.setTopicType(TopicType.FEEDBACK);
            this.feedback = new KeyValueNode<SpecTopic>(CommonConstants.CS_FEEDBACK_TITLE, feedback);
            appendChild(this.feedback, false);
        } else {
            feedback.setTopicType(TopicType.FEEDBACK);
            this.feedback.setValue(feedback);
        }
    }
1327207
public function addAddress(AddressInterface $address): void
    {
        if (!$this->hasAddress($address)) {
            if ($this->isIndividual()) {
                if ($address->getFirstName() === null || $address->getLastName() === null) {
                    $address->setFirstName($this->getFirstName());
                    $address->setLastName($this->getLastName());
                }
            } else {
                if ($address->getLastName() === null) {
                    $address->setLastName($this->getName());
                }
            }

            $this->addresses->add($address);
            $address->setCustomer($this);

            if (!$this->getDefaultAddress()) {
                $this->setDefaultAddress($address);
            }
        }
    }
1332151
public function feedbackFormAction(Request $request)
    {
        $feedback = new Feedback();

        $form = $this->getFeedbackFormProvider()->getFeedbackForm($feedback);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);

            $return = json_encode(
                array('messagesent' => false)
            );

            if ($form->isValid()) {
                $message = \Swift_Message::newInstance();

                $message->setSubject('[Website] - Feedback Form has been submitted!')
                    ->setFrom($this->container->getParameter('mailer_user'))
                    ->setTo($request->request->get('recipient'))
                    ->setBody($this->renderView(
                        'YuzuPipelineBundle:mail:feedback_form.html.twig',
                        array(
                            'name' => $form->get('name')->getData(),
                            'email' => $form->get('email')->getData(),
                            'message' => $form->get('message')->getData(),
                        )
                    ));

                $this->get('mailer')->send($message);

                $return = json_encode(
                    array('messagesent' => true)
                );
            }

            return new Response(
                $return,
                200,
                array('Content-Type' => 'application/json')
            );
        }
    }
749150
public function add(ElementInterface $element)
    {
        $id = $element->id;

        if ($id === null) $id = $this->generateId();

        $this->checkId($id);

        $this->objects[$id] = $element;
    }
1205125
public function get_feedback() {
        global $DB;
        if (!isset($this->feedback->publish_stats) || !isset($this->feedback->name)) {
            // Make sure the full object is retrieved.
            $this->feedback = $DB->get_record('feedback', ['id' => $this->feedback->id], '*', MUST_EXIST);
        }
        return $this->feedback;
    }
980462
public function index() {
		$savepath = Configure::read('Feedback.configuration.Filesystem.location');

		//Check dir
		if (!is_dir($savepath)) {
			throw new NotFoundException('savepath not exists');
		}

		//Creat feedback array in a cake-like way
		$feedbacks = [];

		//Loop through files
		if (!$this->request->getSession()->started()) {
			$this->request->getSession()->start();
		}
		foreach (glob($savepath . '*-' . $this->request->getSession()->id() . '.feedback') as $feedbackfile) {
			$feedbackObject = unserialize(file_get_contents($feedbackfile));
			$feedbacks[$feedbackObject['time']] = $feedbackObject;
		}

		//Sort by time
		krsort($feedbacks);

		$this->set('feedbacks', $feedbacks);
	}
669822
private function helper_render_feedback($feedback) {

        $o  = '';    // output HTML code
        $o .= $this->output->container_start('feedback feedbackforauthor');
        $o .= $this->output->container_start('header');
        $o .= $this->output->heading(get_string('feedbackby', 'workshop', s(fullname($feedback->get_provider()))), 3, 'title');

        $userpic = $this->output->user_picture($feedback->get_provider(), array('courseid' => $this->page->course->id, 'size' => 32));
        $o .= $this->output->container($userpic, 'picture');
        $o .= $this->output->container_end(); // end of header

        $content = format_text($feedback->get_content(), $feedback->get_format(), array('overflowdiv' => true));
        $o .= $this->output->container($content, 'content');

        $o .= $this->output->container_end();

        return $o;
    }
299221
public function addListener(ListenerInterface $listener)
    {
        if (!in_array($listener, $this->collection_listeners, true)) {
            $this->collection_listeners[] = $listener;
        }
    }
853581
def send_feedback(cls, type=FeedbackType.IDEA, referrer=None, text=None,
                      api=None):
        
        api = api if api else cls._API
        data = {'type': type,
                'text': text,
                'referrer': referrer if referrer else six.text_type(
                    client_info
                )}

        extra = {
            'resource': cls.__name__,
            'query': data
        }
        logger.info('Sending feedback', extra=extra)
        api.post(url=cls._URL['send_feedback'], data=data)
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']));
    }
422564
def write_feedback(self, feedback, cr=True):
		
		self.__previous_data += feedback
		if cr is True:
			self.__previous_data += '\n'
410406
public function format_feedback($feedback, $grade = null) {
        $string = $feedback->feedback;
        if (!empty($grade)) {
            // Rewrite links to get the export working for 36, refer MDL-63488.
            $string = file_rewrite_pluginfile_urls(
                $feedback->feedback,
                'pluginfile.php',
                $grade->get_context()->id,
                GRADE_FILE_COMPONENT,
                GRADE_FEEDBACK_FILEAREA,
                $grade->id
            );
        }

        return strip_tags(format_text($string, $feedback->feedbackformat));
    }