Execute some logic before and after quiz attempt - moodle

I am using "\mod_quiz\event\attempt_started" Event observers but i am not getting any result, php error messages or logs.
I am creating own local plugin for leader board functionality but I am stuck in Event observers call.
In events.php file
$observers = array(
array('eventname' => '\mod_quiz\event\attempt_started',
'includefile'=> '/local/leaderboard/locallib.php',
'callback' => 'quiz_attempt_started',
'internal' => 1
),
array('eventname' => '\mod_quiz\event\attempt_submitted',
'includefile' => '/local/leaderboard/locallib.php',
'callback' => 'quiz_submitted_start'
),
);
In locallib.php
function quiz_attempt_started($event) {
file_put_contents('/local/leaderboard/log.txt', $event);
//Logic Here
}
function quiz_submitted_start($event) {
file_put_contents('/local/leaderboard/log.txt', $event);
// Logic Here
}
With debugging on this is the error that moodle shows.
PHP Notice: Exception encountered in event observer 'quiz_attempt_submitted': Coding error detected, it must be fixed by a programmer: PHP catchable fatal error
- line 20 of \local\leaderboard\lib.php: call to default_error_handler()
- line ? of unknownfile: call to quiz_attempt_submitted()
- line 155 of \lib\classes\event\manager.php: call to call_user_func()
- line 89 of \lib\classes\event\manager.php: call to -
core\event\manager::process_buffers()
- line 2489 of \lib\dml\moodle_database.php: call to core\event\manager::database_transaction_commited()
- line 92 of \lib\dml\moodle_transaction.php: call to moodle_database->commit_delegated_transaction()
- line 2221 of \mod\quiz\attemptlib.php: call to moodle_transaction->allow_commit()
- line 88 of \mod\quiz\processattempt.php: call to quiz_attempt->process_attempt()
in E:\Moodle_Boost\03_Execution\04_Tech\03_Source Code\lms\lib\weblib.php on line 3096
Here noting to get error or result. Am I forgetting or doing something wrong here?

Related

Laravel Mail::Send works on local apache but complains about mime on nginx

I have installed a laravel package for user verification
https://github.com/jrean/laravel-user-verification
Register Controller needs to be changed to work like below.
public function register(Request $request)
{
$this->validator($request->all())->validate();
$user = $this->create($request->all());
$this->guard()->login($user);
UserVerification::generate($user);
UserVerification::send($user, 'Verification Mail from example.com');
return redirect()->intended('/home');
}
Used mailgun to send mails.It worked fine on local apache. sent mails successfully to gmail and others.
Installed on nginx production(ubuntu 16.04 VPS ). It throws following error.
FatalThrowableError in SimpleMessage.php line 33:
Type error: Argument 1 passed to Swift_Mime_SimpleMessage::__construct() must
be an instance of Swift_Mime_HeaderSet, none given, called in /var/www/example.com/
html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php on line 48
To check if it is a package problem I have also done the following which works on local apache but throws the same error on nginx.
Route::get('/mailsend', function() {
$data = [
'title' => 'hello user',
'content' => 'Thanks for joining us'
];
Mail::send('mails.test', $data , function($message) {
$message->to('example#gmail.com','example')->subject('Testing from example');
});
});
The code as shown in error /Swift/Message.php in line 48 as follows
call_user_func_array(
array($this, 'Swift_Mime_SimpleMessage::__construct'),
Swift_DependencyContainer::getInstance()
->createDependenciesFor('mime.message')
);
Could not figure out the problem with nginx. Any help would be greatly appreciated.
Try uncomment line: extension=php_openssl.dll on php.ini
and check this https://laravel.io/forum/05-13-2014-smtp-mail-not-working-in-live-server

How to pass an object dynamically in the define function of Ext object in Sencha ExtJS 6.0.2?

Taking a look at the following segment of code you will see two cases where the sencha cmd return an error and one case that it doesn't
var memoryStore = new MemoryStore<Individual>("personnel", [
'name', 'email', 'phone'
], [
new Individual("Batman", "etsigoustaro#thefirm.com", "+306969696969"),
new Individual("Jean Luc", "jeanluc.picard#enterprise.com", "555-111-1111"),
new Individual("Worf", "worf.moghsson#enterprise.com", "+30 696 969 6969"),
new Individual("Deanna", "mr.data#enterprise.com", "+30 6969696969"),
new Individual("Data", "deanna.troi#enterprise.com", "+30-6969696969"),
])
//memoryStore.toExtJS()
Ext.define('extTestTs.store.Personnel', (function(){
//return JSON.stringify(memoryStore.toExtJS()) //fails
//return Ext.Object.merge({},{}) //fails
return {} //succeeds
})());
As you see we have removed everything, even extends is missing but as long as you are typing an object by hand it works. When this object is returned from a function it stops to work!
What does the sencha cmd does behind the scenes? Is it parsing the plain javascript as a text file?..
Because if it was javascript it would run without an issue.
This is the error from sencha cmd console output:
[ERR] C2008: Requirement had no matching files (extTestTs.store.Personnel) -- /home/student/Desktop/Typescript/extTestTs/classic/src/view/main/List.js:8:10
[ERR]
[ERR] BUILD FAILED
[ERR] com.sencha.exceptions.ExBuild: Failed to find any files for /home/student/Desktop/Typescript/extTestTs/classic/src/view/main/List.js::ClassRequire::extTestTs.store.Personnel
[ERR]
[ERR] Total time: 3 seconds
[ERR] The following error occurred while executing this line:
/home/student/bin/Sencha/Cmd/6.1.2.15/plugins/ext/current/plugin.xml:425: The following error occurred while executing this line:
/home/student/Desktop/Typescript/extTestTs/.sencha/app/build-impl.xml:380: The following error occurred while executing this line:
/home/student/Desktop/Typescript/extTestTs/.sencha/app/init-impl.xml:382: com.sencha.exceptions.ExBuild: Failed to find any files for /home/student/Desktop/Typescript/extTestTs/classic/src/view/main/List.js::ClassRequire::extTestTs.store.Personnel
How could we overcome this restriction of explicitly defining the object and rather define it more dynamically?
The goal is to make typescript work with ExtJS but not with the extreme unconventional solutions others propose, like forking typescript itself
Found a workaround
First allow unreachable code in typescript
Here is a screenshot from the IntelliJ settings:
And the code in the questions transforms into that
var memoryStore = new MemoryStore<Individual>("personnel", [
'name', 'email', 'phone'
], [
new Individual("Batman", "etsigoustaro#thefirm.com", "+306969696969"),
new Individual("Jean Luc", "jeanluc.picard#enterprise.com", "555-111-1111"),
new Individual("Worf", "worf.moghsson#enterprise.com", "+30 696 969 6969"),
new Individual("Deanna", "mr.data#enterprise.com", "+30 6969696969"),
new Individual("Data", "deanna.troi#enterprise.com", "+30-6969696969"),
])
//memoryStore.toExtJS()
Ext.define('extTestTs.store.Personnel', function (Personnel) {
return memoryStore.toExtJS()
return {} //do not erase this line
});
Yeah the line return {} might seem totally redundant but (obviously) the sencha cmd is trying to parse the file before it includes it in the requires
Now sencha cmd gives a success and executing sencha app web start the sample app works ok

Codeigniter A PHP Error was encountered, Filename: mysqli/mysqli_driver.php

I am using Codeigniter 3.0.0 and have just tested the program live online. The website is www.theloven.com.
The problem is like below
I could not fix the error.I need some help on this case
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (42000/1203): User ... already has more than 'max_user_connections' active connections
Filename: mysqli/mysqli_driver.php
Line Number: 135
Backtrace:
File: /home/.../public_html/index.php
Line: 292
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/theloven8/public_html/system/core/Exceptions.php:272)
Filename: Session/Session.php
Line Number: 140
Backtrace:
File: /home/.../public_html/index.php
Line: 292
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/theloven8/public_html/system/core/Exceptions.php:272)
Filename: Session/Session.php
Line Number: 168
Backtrace:
File: /home/.../public_html/index.php
Line: 292
Function: require_once
First you have specify local host user name and passwords in config > database.php
'hostname' => 'localhost',
'username' => 'uname',
'password' => 'password',
'database' => 'project',
'dbdriver' => 'mysqli',

Magento SOAP 2 API Fatal error: Procedure 'login' not present

I am getting: Fatal error: Procedure 'login' not present in /chroot/home/mystore/mystore.com/html/lib/Zend/Soap/Server.php on line 832
This is where the error is coming from
$soap = $this->_getSoap();
ob_start();
if($setRequestException instanceof Exception) {
// Send SOAP fault message if we've catched exception
$soap->fault("Sender", $setRequestException->getMessage());
} else {
try {
$soap->handle($request);
} catch (Exception $e) {
$fault = $this->fault($e);
$soap->fault($fault->faultcode, $fault->faultstring);
Any Ideas on how to fix the error?
I had the same issue, and which I did to fix it was to go to System/Configuration/Magento Core API and set the value WS-I Compliance as 'No'.
I'm working with a WebService which consumes the Magento V2 API, I don't recall if I generate the web reference using this value as 'Yes'; I'm working with a WS C# using VS 2010.
I had similar problem and I did not want to change the API version. Deleting the WSDL cache helped me.
Run this to get the WSDL cache folder:
php -i | grep soap
From the result you can see that the WDSL cache is enabled and stored in /tmp:
soap
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Remove the cache and run it again:
sudo rm -rf /tmp/*
I found the clue in this article - http://artur.ejsmont.org/blog/content/php-soap-error-procedure-xxx-not-present

mblox soap api - php soap Payment Request not working

mblox soap api - php soap Payment Request not working and gives error.
I use as below code in subscribe.php file...
$client = new SoapClient("https://ngp.us.mblox.com/client-gateway/services?wsdl", array('trace' => 1, 'encoding' => 'UTF-8', 'soap_version' => SOAP_1_2));
$array = array(
'SecurityContext'=>array('userId'=>'aaaaaaaa','password'=>'bbbbbbbb'),
'ClientDetails'=>array('shortcode'=>'234242', 'brandName'=>'aaaaaaaaaa.com', 'programSponsor'=>'aaaaaaaaaa', 'originatingUrl'=>'www.aaaaaaaaaa.com', 'minPageUrl'=>'www.aaaaaaaaaa.com', 'successUrl'=>'www.aaaaaaaaaa.com/subscribConfirm.php', 'cancelUrl'=>'www.aaaaaaaaaa.com', 'tcUrl'=>'www.aaaaaaaaaa.com/terms.html', 'postBackUrl'=>'http://aaaaaaaaaa/subscribe.php'),
'paymentDetails'=>array('paymentType'=>'PSMS', 'amount'=>'9.99', 'currency'=>'USD', 'billingFrequency'=>'MONTHLY'),
'msisdn'=>'243233232',
'serviceId'=>'332',
'operatorId'=>'33343',
'productDescription'=>'Text test',
'optInBody'=>'aaaaaaaaaa',
'browserSessionId'=>'123456',
);
$result = $client->initiatePayment($array);
It shows error as below on last line => $result = $client->initiatePayment($array);
Fatal error: Uncaught SoapFault exception: [(null)] in
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php:97 Stack trace:
0 /aaaaaaaa/Source/developement/PHP/ver1/subscribe.php(97): SoapClient->__call('initiatePayment', Array) #1
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php(97):
SoapClient->initiatePayment(Array) #2 {main} thrown in
/aaaaaaaa/Source/developement/PHP/ver1/subscribe.php on line 97
I got things working using curl,
I use This
as a reference and code working.
Thankx