Author Message

Posted: Tue May 10, 2016 2:22 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

Okay you'll have to pick over this, its the main index.php file that takes the data and passes it to MySQL DB, remembering I've got some extra $Var in use.

Code:
<?php
// Make sure that a POST is asked for

   header('Access-Control-Allow-Origin: *');
   if ($_SERVER['REQUEST_METHOD'] != 'POST')
   {
        echo "POST request expected";
        return;
   }
   
 //Errors catching for closed flash file   
   error_reporting(E_ALL && E_WARNING && E_NOTICE);
   ini_set('display_errors', 0);
   ini_set('log_errors', 1);

// include scripts to handle different questions types in iSpring QuizMaker (produced by iSpring team and available in their forum)
   require_once 'includes/common.inc.php';
   $requestParameters = RequestParametersParser::getRequestParameters($_POST, !empty($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : null);
   _log($requestParameters);

//set Database access in you server (mine is localhost)
   $servername = "localhost";
   $user = "XXXXXX";
   $password = "XXXXXXX";
   $dbname = "XXXXXXXX";
// Create connection
   $conn = new mysqli($servername, $user, $password, $dbname);
// Check connection (this echos will not work since the flash quiz produced by iSpring does not display regular echo)
    if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
   }

//Get Results from Quiz POST to server
 try
    {
//Get Results and parse then
        $quizResults = new QuizResults();
        $quizResults->InitFromRequest($requestParameters);
        $generator = QuizReportFactory::CreateGenerator($quizResults, $requestParameters);
        $report = $generator->createReport();
         $studentname = $_POST['USER_NAME'];
         $studentname = stripappo($studentname);//  $usernameold= $_POST['sn'];
         $studentname = mb_convert_case($studentname, MB_CASE_TITLE, "UTF-8");
         $userid = $_POST['sid'];
         $userid = stripappo($userid);
         $percentpass =$_POST['psp'];
        $earnedpoints= $_POST['sp'];
        $gainedpoints= $_POST['tp'];                                  
      $email= $_POST['se'];
         $email= stripappo($email);                         
        //$dateTime = date('d-m-y'); 
        $dateTime = date('Y-m-d_H-i-s'); // for txt filename only
        $quiztitle= $_POST['qt'];
         $quiztitle= stripappo($quiztitle);              
        $quiztype= $_POST['t'];
       $passscore= $_POST['ps'];      
        //$resultsxml = $_POST['dr'];
         //$resultsxml = stripappo($resultsxml);               
          $dob = $_POST['DOB'];
          $dob = stripappo($dob);          
          $speciality = $_POST['SPECIALITY'];
          $speciality = stripappo($speciality);
         $speciality = mb_convert_case($speciality, MB_CASE_TITLE, "UTF-8");                      
          $dept = $_POST['DEPARTMENT'];
          $dept = stripappo($dept);   
         $dept = mb_convert_case($dept, MB_CASE_TITLE, "UTF-8");                  
          $job = $_POST['JOBTITLE'];
          $job = stripappo($job);
          $job = mb_convert_case($job, MB_CASE_TITLE, "UTF-8");                     
          $contactno = $_POST['CONTACTNUMBER'];
          $contactno = stripappo($contactno);           
          $manager = $_POST['LINEMANAGER'];
          $manager = stripappo($manager);
          $manager = mb_convert_case($manager, MB_CASE_TITLE, "UTF-8");                     
          $postgrad = $_POST['POSTGRAD'];
         $trust = $_POST['TRUST'];
         $trust = stripappo($trust);
             
                       
       if($earnedpoints>=$passscore){ //test for pass or failure & update either with real text
            $passorfail ="Pass";
        }           
        else{
            $passorfail ="Fail";
        }
   
//write complete results to txt file
        $resultFilename = dirname(__FILE__) . "/result/quiz_result__{$quiztitle}_{$studentname}_{$userid}_{$dateTime}.txt"; //$qt used as quiz id
        @file_put_contents($resultFilename, $report); 
        $quizresult =  "/result/quiz_result__{$quiztitle}_{$studentname}_{$userid}_{$dateTime}.txt";//------testing
        $report= stripappo($report);
       
      //write selected results to MySQL Database
     // query with xml feed
     // $sql = "INSERT INTO results (`studentname`, `userid`, `percentpass`, `earnedpoints`, `gainedpoints`, `email`, `quiztitle`, `quiztype`, `passscore`, `passorfail`, `quizresult`, `report`, `resultsxml`, `datetime`, `dob`, `speciality`, `dept`, `job`, `contactno`, `manager`, `postgrad`, `trust`)
     // VALUES ('$studentname','$userid','$percentpass','$earnedpoints','$gainedpoints','$email','$quiztitle','$quiztype','$passscore','$passorfail', '$quizresult', '$report','$resultsxml', NOW(),'$dob', '$speciality', '$dept', '$job', '$contactno', '$manager', '$postgrad', '$trust')";

// query without xml feed, variable turned off above $_POST['dr']
      $sql = "INSERT INTO results (`studentname`, `userid`, `percentpass`, `earnedpoints`, `gainedpoints`, `email`, `quiztitle`, `quiztype`, `passscore`, `passorfail`, `quizresult`, `report`, `datetime`, `dob`, `speciality`, `dept`, `job`, `contactno`, `manager`, `postgrad`, `trust`)
      VALUES ('$studentname','$userid','$percentpass','$earnedpoints','$gainedpoints','$email','$quiztitle','$quiztype','$passscore','$passorfail', '$quizresult', '$report', NOW(),'$dob', '$speciality', '$dept', '$job', '$contactno', '$manager', '$postgrad', '$trust')";


      if ($conn->query($sql) === TRUE) {
             echo "New record created successfully";
      } else {
             echo "Error: " . $sql . "<br>" . $conn->error;
      }
     
// if everything went fine, the flash quiz will need to receive this echo "OK". Otherwise it will say "cannot send results to server"...   
       echo "OK";
      }
   
//Write type of error if something failed in a log file
    catch (Exception $e)
    {
        error_log($e);
        echo "******************** Error ****************: " . $e->getMessage();
    }
//========================================================= Functions from here on ================================================================


    function _log($requestParameters)//------------------------------------------------------------------------------------------------ _log create log file
    {
        $logFilename = dirname(__FILE__) . '/log/quiz_results.log';
        $event       = array('ts' => date('Y-m-d H:i:s'), 'request_parameters' => $requestParameters, 'ts_' => time());
        $logMessage  = json_encode($event);
        $logMessage .= ',' . PHP_EOL;
        @file_put_contents($logFilename, $logMessage, FILE_APPEND);
    }//-------------------------------------------------------------------------------------------------------------------------------- _log
   
    function stripappo($word)
    {//-------------------------------------------------------------------------------------------------------------------------------- stripappo strip apostrophe & clean
         
      if(get_magic_quotes_gpc())
      {
         $word = stripslashes($word );
      }
      $word = trim($word );
      $word =  str_replace("'", "", $word);
      return $word;
    }//-------------------------------------------------------------------------------------------------------------------------------- stripappo

$conn->close();
?>



Profile profile test

Posted: Tue May 10, 2016 4:10 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

Thanks Dave,
I see your script is for a fixed quiz. I develop different quizzes for different classes, so I want to make a script that will loop through the 'dr' XML and creates a different MySQL table for each quiz, just like the txt that the iSpring quiz generates.
Its a bit more complicated.
I will keep you posted of the progress.
Cheers,


Profile profile test

Posted: Tue May 10, 2016 4:19 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

I have different quizzes using different question formats, we just store all results in the one table and then pull data as needed per Quiz Title.

One thing we have not achieved is taking the detailed text file output and parsing the content it into a readable format within the DB or on a php page


Profile profile test

Posted: Fri May 27, 2016 4:07 am   Post subject: Re: Help Please - Results to Server (QuizMaker)

OK I don't know much about mySQL but it seems like a lot of work.

I am an individual teacher (AP Physics) using quizmaker quite a lot. I have posted an easy method for using an automated e-mail parser to collect and organize the data I need.

This might be a round about way, but couldn't you use this method and have the e-mail parser send results directly to your database?


Profile profile test

Posted: Fri May 27, 2016 12:20 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

xyoureyes wrote:
OK I don't know much about mySQL but it seems like a lot of work.

I am an individual teacher (AP Physics) using quizmaker quite a lot. I have posted an easy method for using an automated e-mail parser to collect and organize the data I need.

This might be a round about way, but couldn't you use this method and have the e-mail parser send results directly to your database?


Hello xyoureyes,
Yes, we got this working with Php, but any simpler solution would be welcome. Can you please share?
Best Regards,
João


Profile profile test

Posted: Fri May 27, 2016 12:56 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

See my posts:

"Extract your data from e-mails automatically for free"
and
"Organizing questions for easier data analysis"


Profile profile test

Posted: Sat May 28, 2016 11:37 am   Post subject: Re: Help Please - Results to Server (QuizMaker)

Thanks xyoureyes. I will look into the email parser.
It is still some more clicks than just having a script saving the results automatically to the database. But it is definitevely a good solution if you don't want or don't have the time to learn php and mysql or can pay development fees to a programmer.

I also use QuizMaker to give automatic tests to my students, and although I am college teacher, I face the same problem as you (money and access to programmers developers). The IT guys are always *busy* connecting cables and keeping email servers running and have no time to program (I guess, most, don't know how and don't want to learn). So, we have to find a way ourselves. iSPring, of course, wants to sell their services, not custom develop a solution that most teachers would need - to have a local datbase with results!...

My last problem to solve is this one: What happens when I am testing 200+ students and the internet breaks down. There's no email sent, right?. So I use the iSpring script to write the test results in a txt file in the USB stick. But now, I have to upload the answers (+200) by hand to my database.

I wonder if the emailparser could do that for a txt file, or if you know of some other solution.

Thanks a lot. I appreciate you stepping in.


Profile profile test

Posted: Sun May 29, 2016 5:46 am   Post subject: Re: Help Please - Results to Server (QuizMaker)

Hello jo,

I believe you could copy the text into an e-mail and have the parser do its thing.

I generally don't have the students use the quizzes or tests made with Quizmaker at school. Its hard to get laptops on the days I need them and by the end of the day I run into battery problems because I don't have an easy way to plug them in.

When they complete the quizzes or tests at home I generally advise them to print the results if they have any suspicion the results didn't get sent. I lose some detailed data, but at least I have their score.

I try to flip my classroom as much as possible, so most of the content delivery is done at home and the quizzes are used to ensure they are reading their book, watching the videos, and performing interactive simulations. So, I use the quizzes sort of like gateways. I won't accept a score less than 80%, but they can repeat the quizzes as much as they want. Because I have about a 4 to 1 ratio of questions to questions used per session and they are randomized, its more inconvenient to cheat than it is to actually do the work.

Some students don't want me to know how many attempts they have made to pass so if they know they aren't going to pass the quiz they will simply close the browser and exit early so no results are sent. I would like the option of having an e-mail sent at the beginning of the quiz (right after they fill in their name) to let me know the student started the quiz.

Keep me updated on your attempts at using the parser. I can help if you run into problems. It took me a few attempts to get the workflow right but now it runs very smoothly.

Barney


Profile profile test

Posted: Mon May 30, 2016 4:39 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

Thanks a lot Barney,

I am also using Quizmaker in a Statistics and Math courses and I read your solutions inf the forum (I also use the text options in white color when giving figures as response options, so that I can have the answers saved into my database). I will try now the emailparser. If you can send me one of your scripts, I would appreciate. It seems to me that I will have a few trial and errors to get it working as it should.

Warm regards,
João
P.S. my email is jpmaroco at gmail.com


Profile profile test

Posted: Tue May 31, 2016 3:11 am   Post subject: Re: Help Please - Results to Server (QuizMaker)

I sent an example to your e-mail. Check for it to make sure it didn't get stuck in spam.


Profile profile test

Posted: Fri Jun 17, 2016 9:50 am   Post subject: Re: Help Please - Results to Server (QuizMaker)

xyoureyes wrote:
I sent an example to your e-mail. Check for it to make sure it didn't get stuck in spam.


Hi Barney,

I am afraid this email did not get through. I've been able to use the emailparser (thanks for the tip) to recover most questions. However, I can't recover the survey type question since the email ends with text that is variable from student to student. I used the option "and continues to: following position" (using up to line 500...) but nothing is returned. I wonder if you have a similar exprience?

Best regards,
João


Profile profile test

Posted: Fri Nov 18, 2016 10:55 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

@jpmaroco THANK YOU GREATLY FOR YOUR SCRIPTS

Please I have done exactly what you instructed but the only thing working fine is the XML format from the request posted. that of .txt file and mysql database always appears blank. kindly walk me through the process one- by- one.

THANK YOU


Profile profile test

Posted: Fri Nov 18, 2016 11:08 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

@jpmaroco THANK YOU GREATLY FOR YOUR SCRIPTS

Please I have done exactly what you instructed but the only thing working fine is the XML format from the request posted. that of .txt file and mysql database always appears blank. kindly walk me through the process one- by- one.

THANK YOU


Profile profile test

Posted: Sat Nov 19, 2016 2:30 pm   Post subject: Re: Help Please - Results to Server (QuizMaker)

kwesilorgor wrote:
@jpmaroco THANK YOU GREATLY FOR YOUR SCRIPTS

Please I have done exactly what you instructed but the only thing working fine is the XML format from the request posted. that of .txt file and mysql database always appears blank. kindly walk me through the process one- by- one.

THANK YOU


... make sure you are using the correct links to the files. The .txt file should be writtend on the same directory as the xml file.
For the MySql make sure you have writting privileges in the folder where the database will be created and stored. Also, that you have php and mysql running on your server...

There's a .log file being created in your working directory. Open it and see the error messages... probably it will be saying something like "can't write in the DB"...
Good luck.


Profile profile test

Posted: Sat Dec 17, 2016 4:36 pm   Post subject: Re: Help Please - Results to Server (QuizMaker) @jpmaroco

HELLO SIR

i have been working on sending the results to my server for months now but every effort comes out to be nothing
can you please send the codes to my email... maybe there is something else am missing out. thanks
email:mrlorgor419@gmail.com


Profile profile test
Display posts from previous:  Sort by  

   Page: 1, 2, 3, 4, 5


Who is online
Who is online In total there are 11 users online :: 0 registered, 0 hidden and 11 guests (based on users active over the past 5 minutes)
Most users ever online was 803 on Sat Dec 12, 2020 9:21 am

Registered users: No registered users