error/An error occurred whilst communicating with the server

error/An error occurred whilst communicating with the server

by Aditya Dubay -
Number of replies: 7

Hi,

I am using Moodle 3.4.2

After upgrading my moodle from 3.1 to 3.4 I got below error. Before upgrade it works fine.

 

error/An error occurred whilst communicating with the server

Debug info: 
Error code: An error occurred whilst communicating with the server
$a contents:
Stack trace:
  • line 79 of /lib/classes/session/manager.php: core\session\exception thrown
  • line 785 of /lib/setup.php: call to core\session\manager::start()
  • line 26 of /config.php: call to require_once()
  • line 6 of /result_aisect.php: call to require_once()

 

 

Code on line 79 of /lib/classes/session/manager.php: core\session\exception thrown

throw new \core\session\exception(get_string('servererror'));

Code on line 785 of /lib/setup.php: call to core\session\manager::start()

\core\session\manager::start();

Code on line 26 of /config.php: call to require_once()

require_once(dirname(__FILE__) . '/lib/setup.php');

Code on line 6 of /result_aisect.php: call to require_once()

require_once('config.php');

 

Please help me how to get rid of this error.

Thanks in advance.

Average of ratings: -
In reply to Aditya Dubay

Re: error/An error occurred whilst communicating with the server

by Ken Task -
Picture of Particularly helpful Moodlers

What is function/purpose of the 'result_aisect.php' file?

That's not part of core code for any version of Moodle of which am aware.

Related to sessions manager ... which has to have the ability to not only create session files in moodledata/sessions/ but also change/destroy or remove session files located there.

Solution .... ?????

'spirit of sharing', Ken

In reply to Ken Task

Re: error/An error occurred whilst communicating with the server

by Aditya Dubay -

Hi Ken,

Thanks for reply.

Yes "result_aisect.php" is not a part of moodle and it is a custom file which was working fine before upgrade from 3.1 to 3.4

So problem is not in that file I feel.

Yes I need a solution of session too.

I hope Moodle can give solution of session at-least.

 

 

In reply to Aditya Dubay

Re: error/An error occurred whilst communicating with the server

by Ken Task -
Picture of Particularly helpful Moodlers

Well, debug is reporting that file ... may have  worked with 3.1, but obviously not working after your upgrade to 3.4.

Debug shows line numbers ... which you have provided ... but have you looked at those lines in the context of what encloses them.  Whatever that file does, it's related to sessions.

Since it's not part of core, how would anyone help you solve the issue if they don't know what it supposed to do and what it's relationship to sessions might be.

Check apache logs to see if there is any clue/hint.

'spirit of sharing', Ken



In reply to Ken Task

Re: error/An error occurred whilst communicating with the server

by Aditya Dubay -

Hi Ken,

Thanks for reply.

Here is what that custom file do:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<?php


// The number of lines in front of config file determine the // hierarchy of files.
require_once('config.php');


$PAGE->set_context(get_system_context());
$PAGE->set_pagelayout('admin');
$PAGE->set_title("Results");
$PAGE->set_heading("Results");
//$PAGE->set_url($CFG->wwwroot.'/blank_page.php');


echo $OUTPUT->header();


// Actual content goes here

 

 

 

$iud = $_POST['student_id'];
$ard=explode(",",$iud);
$id=$ard['0'];
$st_name= $ard['1'];

///////////////////////////////////////////////////////////db

$dbhost = $CFG->dbhost;
$dbname=$CFG->dbname;
$dbuser = $CFG->dbuser;
$dbpass = $CFG->dbpass;
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname);
///////////////////////////////////////////////////////////////////////////////db
$sql = "SELECT id,username
FROM `mdl_user` ";

$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
$cid=$row['quiz'];
$option .='<option value="'.$row['id'].','.$row['username'].'"> '.$row['username'].'</option>';
$op2.='<option value="'.$row['id'].'"> '.$row['username'].'</option>';

// $option .= "<tr>".get_quiz_name($conn,$row['quiz'],$row['grade'])."<td><a href='".$CFG->wwwroot."/mod/quiz/grade.php?id=".$cid."&userid=".$id."'>Detail Report</a><td></tr>";
//$det_rr.="<iframe width='100%' height='100%' src='".$CFG->wwwroot."/mod/quiz/grade.php?id=".$cid."&userid=".$id."'/>";
// //echo "Tutorial ID :{$row['id']} <br> ".
// //"Title: {$row['username']} <br> ".
// "Author: {$row['tutorial_author']} <br> ".
// "Submission Date : {$row['submission_date']} <br> ".
"--------------------------------<br>";
}

echo '<form id="myform" action="" method="post" class="hide_from_print" >
<h1>Select Student</h1> <select name="student_id">'.$option.'</select> <input class="ajj"value="Get Result" type="submit"></form>';
//echo "Fetched data successfully\n";

echo '<div class="result"></div>';

echo '<form id="form2" action="'.$CFG->wwwroot.'/void_attempt.php" method="get" class="hide_from_print" ><select name="userid">'.$op2.'</select> <input value="Delete Attempt" type="submit"></form>';
echo $OUTPUT->footer();
?>

 

<script>
$(document).ready(function(){

$( ".ajj" ).click(function(){


var formData = $("#myform").serializeArray();
$.ajax({
url : "<?php echo $CFG->wwwroot;?>/get_marks.php",
type: "POST",
data : formData,
success: function(data, textStatus, jqXHR)
{
$(".result").html(data);
//data - response from server
},
error: function (jqXHR, textStatus, errorThrown)
{

}
});
return false;
});
});


function capture() {

window.print();

}
</script>

<style type="text/css" media="print">

@media print {
/*.header, .hide { visibility: hidden }*/
.hide_from_print{display:none;}

.block_navigation{ visibility: hidden ;}
.block_settings{ visibility: hidden; }
.block_navigation{ display:none;}
.block_settings{ display:none;}
.history{ display:none;}
.comment{ display:none;}
.othernav{ visibility: hidden; }
.othernav{ display:none;}


.editquestion{ display:none; }
body {

font-size: 10px;
line-height: 1.428571429;

}

.outcome {
padding: 0px;
margin-bottom: 0px;
border: 1px solid transparent;
border-radius: 0px;
}

.que .ablock {
margin:1px;
}
.que .qtext {
margin-bottom: 1px;
}
.formulation {
padding: 1px;
margin-bottom: 1px;

}

#page-footer{display:none;}
}</style>

 

 

 

In Moodle 3.4 it looks like:

 

In Moodle 3.1 it looks like:

In reply to Aditya Dubay

Re: error/An error occurred whilst communicating with the server

by Ken Task -
Picture of Particularly helpful Moodlers

Obviously, this belongs in the Developer forum cause it's not 'General Help', me thinks.

I, myself, am not a programmer ... more a hacker ... but if one were to develop their own local plugin would assume that the proper location for it would be in /local/ of code directory ... not at code root (there does appear to be other files at code root related).

One could download something from: https://moodle.org/plugins/browse.php?list=category&id=18

and inspect how those were done.

Or read about developing a local plugin

https://docs.moodle.org/dev/Local_plugins

Can't read the 'warning lines' in the image (text would have been better - but am not asking for you to do that) ... so a suggestion ... find something already part of moodle code, that presents to the user a form similar to yours.   See how that connected to the DB ... think that's really a place to start.

Good luck!

'spirit of sharing', Ken


In reply to Aditya Dubay

Re: error/An error occurred whilst communicating with the server

by Jerry Lau -

I would contact the developer and short of that, hope you can roll back to version 3.1. Hope this is not in production

In reply to Aditya Dubay

Re: error/An error occurred whilst communicating with the server

by José Luis García Mañas -

Hello,

I had the same problem, and I solved it placing the require_once lines on top of the script, before any other code.

I hope this help you.

See you,

JL

Average of ratings: Useful (1)