Home › Forums › Legacy Support › Support queries › Other issues › WP data tables cpanel
- This topic has 17 replies, 3 voices, and was last updated 3 years, 6 months ago by Anshuman Sahu.
-
AuthorPosts
-
March 30, 2021 at 6:25 am #349278cenauraParticipantThis is a continuation of the topic from the following thread. https://wplms.io/support/forums/topic/wordpress-backend-datatables/ I saw the quiz results stored in the activity_meta table but they are not in a readable format. All the responses are stored in a single cell like "a:31:{i:0;a:8:{s:7:"content";s:265:"<p>Two distinct straight lines are said to be ______ when they have one common point and are said to be ______ when they have no common point.</p> <p> </p> <p>Options</p> <p> </p> <p>a) Parallel</p> <p> </p> <p>b) Intersecting</p>" 1) How to extract data from this and correspond it to a particular student_id ? 2) Also in the previous thread it is written " You will get the whole quiz results from there with responses marks , statement etc.and is shown in quiz statistics already". This is available in the frontend but I wish to know how to get it in the backend database tables ?March 31, 2021 at 1:56 pm #349808Anshuman SahuKeymaster1 . use unserialize({quiz data}) to check this in form of an array . 2 . join this with activity_id and id with "bp_activity" table , in activity table it has user_id .April 5, 2021 at 5:09 am #350572cenauraParticipantThis reply has been marked as private.April 6, 2021 at 12:42 pm #350947VeronicaModeratorhi @cenaura @Alex is not available today so may I know here how and where to use that line of code? what is the code?April 12, 2021 at 4:45 am #351840cenauraParticipantHi Veronica, Alex has mentioned to use "unserialize({quiz data})" this to check the array, which I have originally posted in the first question thread. Can you please tell me how to use this to get quiz results serially.April 13, 2021 at 1:31 pm #352175Anshuman SahuKeymasterWell the data you are getting is. in in serialized format to unserialze please use unserialize function :
unserialize({quiz data})
and the same table row should have user id column for the quiz . to get results with given user id and quiz id :
in $results you will get array .global $wpdb; $activity_id = $wpdb->get_var($wpdb->prepare( " SELECT id FROM {$bp->activity->table_name} WHERE secondary_item_id = %d AND type = 'quiz_evaluated' AND user_id = %d ORDER BY date_recorded DESC LIMIT 0,1 " ,$item_id,$user_id)); if(!empty($activity_id)){ $results = bp_course_get_quiz_results_meta($item_id,$user_id,$activity_id); } if(is_serialized($results)){ $results = unserialize($results); }
April 14, 2021 at 10:58 am #352364cenauraParticipantHi alex, Should I run this as SQL query in my cpanel data table ?April 15, 2021 at 1:56 pm #352685Anshuman SahuKeymasterAbove is php code my friend. There is not direct query to fetch the user results .April 16, 2021 at 5:33 am #352777cenauraParticipantWhere exactly can I deploy it can u tell me please !April 16, 2021 at 12:12 pm #352886VeronicaModeratorhi this is the PHP code you can add where you want to show the results above code is fetching the results from the database let me know if you are talking about something else you can explain your query in detail if i am getting it wrongApril 20, 2021 at 5:06 am #353501cenauraParticipantHi, I am attaching a screenshot of my datatables( https://prnt.sc/11qdab0). I am pointing the cell in which the quiz data is stored in a serialized format(https://prnt.sc/11qdmww). I want to ask how do I use this php code in the datatables to unserialize the quiz data.April 22, 2021 at 2:13 pm #353994Anshuman SahuKeymasterTo be able to tell you how to use it we need the whole picture what exactly you are trying to do ? Can you please elaborate in detail exactly what do you want ? Also tell if you are using any other programming language or something? the above code is a php code to fetch result in php from database and convert it to array which you can process or understand .April 24, 2021 at 6:24 am #354270cenauraParticipantHi alex, the quiz results data is stored in activity_meta table in my database. But all the quiz questions and answers are in a serialized format and are stored in a single cell in one row in the activity_meta table under meta_value column. https://prnt.sc/11ygaku , please see these screenshots for better understanding of my problem. https://prnt.sc/11ygd9r. I am unable to unserialize the data and understand as to which student answered what question and the answer provided by them. I want data in a structured format in my backend to understand which answer is given by which student and what is the corresponding answer given for a question. You have provided a php code as to how to unserialize the data but where should I run this code to get the results in an array. Is there a functionality in wplms where the quiz data is stored in a table with multiple rows and each row corresponding to each question and answer given by student.April 26, 2021 at 1:31 pm #354600Anshuman SahuKeymasterWell im sorry what you are asking is not possible due to quiz architecture limitation saving each response differently in database table . Suppose a 50 question quiz take by 100 students , how much data will be stored and ultimately the quizzess will become slow ,this is why we save the whole result itself . Believe me we have this architecture you say and we received many complaints database and quizzes going slow , this is the prime reason we switched to this new architecture. . You have the data in php array you can process it easily . You have the data just need to fetch it out.April 27, 2021 at 7:14 am #354677cenauraParticipantHi Alex, so the key challenge is how do I fetch it or unserialize it ? Please help here as It is a critical component in analyzing the quiz results for our students and providing a dynamic adaptive model of LMS . You gave a Php code but where should I use it to ensure that data is unserialized and available in the form of a readeable array ? Is the format JSON doc file ? Does Mysql provide a way a query it and make it into an array for better clarity ? -
AuthorPosts
- The topic ‘WP data tables cpanel’ is closed to new replies.