Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › How to check how many certificates and the quiz score in database?
Tagged: certificate, database, quiz
- This topic has 17 replies, 4 voices, and was last updated 8 years, 6 months ago by mind_expert.
-
AuthorPosts
-
May 30, 2016 at 4:45 pm #50981mind_expertSpectatorHello, 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!May 31, 2016 at 10:00 am #51068H.K. LatiyanParticipantThe 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.June 1, 2016 at 9:27 am #51216rafiroczSpectatorcan we display "quiz score" in "quiz passing message"June 1, 2016 at 8:12 pm #51288mind_expertSpectatorThanks 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?June 2, 2016 at 2:00 pm #51492Anshuman SahuKeymasterHi @ 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 .June 2, 2016 at 7:06 pm #51528mind_expertSpectatorThank 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?June 3, 2016 at 1:04 pm #51686mind_expertSpectatorPlease, 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?June 4, 2016 at 11:11 am #51792Anshuman SahuKeymasterYep 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 ?June 5, 2016 at 3:09 am #51815mind_expertSpectatorI'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!June 6, 2016 at 1:22 pm #51937Anshuman SahuKeymastera. 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 ?June 6, 2016 at 6:48 pm #51968mind_expertSpectatorI 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);June 7, 2016 at 12:30 pm #52093Anshuman SahuKeymasterI 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 .June 7, 2016 at 6:25 pm #52130mind_expertSpectatorThanks 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_recordedJune 8, 2016 at 12:49 pm #52261mind_expertSpectatorPlease 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_keyJune 9, 2016 at 10:39 am #52472Anshuman SahuKeymasterI 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 . -
AuthorPosts
- The topic ‘How to check how many certificates and the quiz score in database?’ is closed to new replies.