WP data tables cpanel

Home Forums Legacy Support Support queries Other issues WP data tables cpanel

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #349278
    cenaura
    Participant
    This 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 ?
    #349808
    Anshuman Sahu
    Keymaster
    1 . 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 .
    #350572
    cenaura
    Participant
    This reply has been marked as private.
    #350947
    Veronica
    Moderator
    hi @cenaura @Alex is not available today so may I know here how and where to use that line of code? what is the code?
    #351840
    cenaura
    Participant
    Hi 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.
    #352175
    Anshuman Sahu
    Keymaster
    Well 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 :
    
    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);
                  }
    
    in $results you will get array .
    #352364
    cenaura
    Participant
    Hi alex, Should I run this as SQL query in my cpanel data table ?
    #352685
    Anshuman Sahu
    Keymaster
    Above is php code my friend. There is not direct query to fetch the user results .
    #352777
    cenaura
    Participant
    Where exactly can I deploy it can u tell me please !
    #352886
    Veronica
    Moderator
    hi 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 wrong
    #353501
    cenaura
    Participant
    Hi, 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.
    #353994
    Anshuman Sahu
    Keymaster
    To 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 .
    #354270
    cenaura
    Participant
    Hi 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.
    #354600
    Anshuman Sahu
    Keymaster
    Well 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.
    #354677
    cenaura
    Participant
    Hi 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 ?
Viewing 15 posts - 1 through 15 (of 18 total)
  • The topic ‘WP data tables cpanel’ is closed to new replies.