How to check how many certificates and the quiz score in database?

Home Forums Legacy Support Support queries How-to & Troubleshooting How to check how many certificates and the quiz score in database?

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #50981
    mind_expert
    Spectator
    Hello, I'd like to know how many certificates where generated and the course quiz score, could you please point me where in database those information are stored?   Thanks!
    #51068
    H.K. Latiyan
    Participant
    The certificate is saved in the user_meta, you can get it like this:  $certis=vibe_sanitize(get_user_meta($user_id,'certificates',false)); The quiz score is st0red in the post_meta, use user id to get it.
    #51216
    rafirocz
    Spectator
    can we display "quiz score" in "quiz passing message"
    #51288
    mind_expert
    Spectator
    Thanks Latiyan, About certificates: 1 - how may I know that it's a certificate in the wp_usermeta database 2 - how may I know which course is it from? Same for quiz scores: 1 - how may I know that it's a quiz score in the wp_postmeta database 2 - how may I know which course is it from?  
    #51492
    Anshuman Sahu
    Keymaster
    Hi @ rafirocs, Please create a new topic in relevant forum for this . hi@mind_expert, 1. & 2.  You have the meta_key to be " certificates " in usermeta table for this to search and its meta_value is the course id . Quiz scores 1. Well for that you have to match the meta_key with regex expression as for integer value be'coz marks are stored as / meta_key = user id meta_value = marks in post_meta table . To know the course you have to use this function . $course_id = get_post_meta($quiz_id,'vibe_quiz_course',true); there is a meta called " vibe_quiz_course " set which gives the course id of that quiz .  
    #51528
    mind_expert
    Spectator
    Thank you so much Alex, I've accomplished a lot with your explication. The only thing I'm missing here is the $quiz_id. All I got from the unserialized array is $quizData['ques'] and $quizData['marks']. I tried to get the course_id with the $quizData['ques'] values, but all of them returned me an empty string. I guess that's the question id and not the quiz id.   Could you please explain how may I get the course id with that unserialized array from database?
    #51686
    mind_expert
    Spectator
    Please, also correct if I'm wrong: Am I getting the correct value of the serialized array of the database to check the course id that the certificate is from? Raw: string(51) "a:3:{i:0;s:4:"2740";i:1;s:4:"2968";i:2;s:4:"2968";}" Unserialized: array(3) { [0]=> string(4) "2740" [1]=> string(4) "2968" [2]=> string(4) "2968" } [0]: string(4) "2740"  <------ Is this the course id?
    #51792
    Anshuman Sahu
    Keymaster
    Yep these are course ids in the user meta of the user .with meta_key = certificates and for the quiz_id please share more information on which page do you want the quiz id or from ? Is it from course id you want to fetch all quizzes from course id or something else ?
    #51815
    mind_expert
    Spectator
    I'd like to have all quiz scores of a particular instructor to put the average score on the instructors profile page (dashboard). The instructor can choose to view only his average quiz score or from all the instructors. The idea is to filter by date, but that I think I need only to add a timestamp field in the database and filter from there. I have a way of geting all the courses id of the instructors so having the course id will help a lot! Thanks!
    #51937
    Anshuman Sahu
    Keymaster
    a. Assuming that the Quiz is craeted by the instructor, we maintain the average quiz score in quiz post meta, so this is possible. b. We're already recording the timestamp values in the activity table, however we will need further clarification on what is required here, are you suggestion average score of users in quizzes within certain timestamps ?
    #51968
    mind_expert
    Spectator
      I guess I got it now, please confirm If I'm doing it right:   $checkQuizzes = $conn->prepare(" SELECT activity.item_id as course_id, postmeta.meta_value as quiz_data, activity.date_recorded as date_recorded FROM wp_bp_activity as activity JOIN wp_postmeta as postmeta ON activity.secondary_item_id = postmeta.post_id WHERE activity.type = 'submit_quiz' AND postmeta.meta_key LIKE 'quiz_question%' "); $checkQuizzes->execute(); $quizzes = $checkQuizzes->fetchAll();   $quizAverageArray = array(); $quizAverage = 0; foreach ($quizzes as $quiz) {   if (!is_null($quiz['quiz_data'])) {   unset($mark); $result = 0; $quizCourseId = $quiz['course_id']; $quizData = unserialize(stripcslashes($quiz['quiz_data'])); $quizTimestamp = date("Y-m-d", strtotime($quiz['date_recorded']));   // Quiz marks if($quizTimestamp >= $minDate AND $quizTimestamp <= $maxDate AND !empty($quizData['marks']) ) {   if (isset($quizScoreList[$quizCourseId])) {   array_push($quizScoreList[$quizCourseId], array_sum($quizData['marks']) / count($quizData['marks']));   } else {   $quizScoreList[$quizCourseId] = array(array_sum($quizData['marks']) / count($quizData['marks']));   }   } } }   foreach ($quizScoreList as $key => $score) { $quizScore[$key]['score'] = array_sum($score) / count($score); }   // Checks the average score of the course and push to the array $quizAverageArray if (array_key_exists($unit['course_id'], $quizScore)) { array_push($quizAverageArray, $quizScore[$unit['course_id']]['score']); }   // Quiz Average $quizAverage = array_sum($quizAverageArray) / count($quizAverageArray);
    #52093
    Anshuman Sahu
    Keymaster
    I guess there is a slight mistake in the above code . you are not fetching user marks to get the average . You are fetching question marks as far as i can see . You have to track he "quiz_evaluated" activity in the activity table and then you will find user id in the activity . For this user ids you need to fetch the marks of that user for that quiz . Remember marks of user are saved in postmeta with meta_key as user id and meta_value are marks . You will get the quiz id from the same "quiz_evaluated" activity . If quiz is connected to the course then quiz id will be in the secondary_item_id and course_id will be in primary_item_id otherwise quiz id will be in primary_item_id .  
    #52130
    mind_expert
    Spectator
    Thanks Alex, I got it, but what I'm trying to do is to get the average score of each course here. Later, I'll check each course and assign to it's instructor to then calculate the average score of each instructor or a set of courses.   After your last consideration I saw an error, and now I'm lost again... I need to link these 2 tables to have the course_id, date_recorded and meta_value(the unserialized array with the question scores). With this information I think I'll be able to filter all the quizzes according to date_recorded
    #52261
    mind_expert
    Spectator
    Please confirm if I'm doing it right to get all the quiz scores:   SELECT activity.item_id as course_id, postmeta.meta_value as quiz_data, activity.date_recorded as date_recorded FROM wp_bp_activity as activity JOIN wp_postmeta as postmeta ON postmeta.post_id = activity.secondary_item_id WHERE activity.type = 'quiz_evaluated' AND CONCAT('quiz_questions', activity.user_id) = postmeta.meta_key  
    #52472
    Anshuman Sahu
    Keymaster
    I am also little confused here now . Do you want the total marks of the quiz or the mark scored by the users in a quiz ? I am not able to understand why are your fetching unserialzed question array .I am assuming now that your are trying to get the total marks of a quiz not the marks that users have scored in that quiz ? The above reply was for user marks in quiz coz the quiz_evaluated type activity recorded when marks are given to student .
Viewing 15 posts - 1 through 15 (of 18 total)
  • The topic ‘How to check how many certificates and the quiz score in database?’ is closed to new replies.