Custom API To store marks

Home Forums Legacy Support Support queries Other issues Custom API To store marks

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #372263
    impacttogether
    Participant
    I am writing custom APIs for my native app. I am almost done with most of the part. I am facing challenge in saving the quiz marks and marking quiz as complete. As of now, I am able to save the answers for the quiz and save marks, but the saved marks is not appearing in instructor statistics. Can you please help me with sequence of functions to be called to save quiz marks and make it appear in instructor course statistics? Following is my current function.: `function set_marks(WP_REST_Request $request){ $body = json_decode($request->get_body(),true); $user_id = apply_filters('vibebp_api_get_user_from_token','',$body['token'])->id; $quiz_id = $body['quiz_id']; $question_id = $body['question_id']; $marks = $body['marks']; $course_id = $body['course_id']; $answer = $body['answer']; bp_course_save_question_quiz_answer($quiz_id,$question_id,$user_id,$answer); bp_course_save_user_answer_marks($quiz_id,$question_id,$user_id,$marks); bp_course_update_user_quiz_status($user_id,$quiz_id,1); $test = bp_course_get_user_question_marks($quiz_id,$question_id,$user_id); return new WP_REST_Response( [$user_id, $test], 200 ); }
    #372361
    Anshuman Sahu
    Keymaster
    To set marks and complete the quiz you will need to do this :
    update_post_meta( $quiz_id,$user_id,$marks);
    					bp_course_update_user_quiz_status($user_id, $quiz_id,4);
    					update_user_meta($user_id,$quiz_id,time());
    					do_action('wplms_submit_quiz',$quiz_id,$user_id,$results,$course_id);
    
    #372367
    impacttogether
    Participant
    Thank you for the update. What should we pass in results?
    #372408
    impacttogether
    Participant
    I don't want to send complete quiz in results. I have course id, quiz id, question id, marked answer, marks obtained. What should I pass in result?
    #372831
    impacttogether
    Participant
    Any update?
    #372920
    Anshuman Sahu
    Keymaster
    You can pass blank array as an alternative then : do_action('wplms_submit_quiz',$quiz_id,$user_id,array(),$course_id);
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Custom API To store marks’ is closed to new replies.