function createExam(){
      if(name===""){
          setErrorText("Name of Exam cannot be empty");
          return;
      }
      if(exam_link===""){
          setErrorText("Exam Link cannot be empty");
          return;
      }
      if(!isUrl(exam_link)){
          setErrorText("Exam Link must be a valid url");
          return;
      }
      if(duration === 0){
          setErrorText("Duration cannot be 0");
          return;
      }
      if(exam_code===""){
          setErrorText("Click Generate exam code to get an exam code first");
          return;
      }
      var current_date_time = new Date();
      if(date_time_start< current_date_time){
        setErrorText("Please select a date and time of the future");
        return;
      }
      axios.post('/api/exams/createExam', {
          name: name,
          exam_link: exam_link,
          date_time_start: date_time_start,
          duration: duration,
          exam_code: exam_code,
          prof_email: props.prof_email,
        })
        .then(function (response) {
          console.log(response);
          swal("Exam has been created. Your exam code has been copied to your clipboard, please share it with the students.");
        })
        .catch(function (error) {
          console.log(error);
          swal("Some error occoured in creating the exam");
        });
      
      closeExamDialog();
      
  }
/**
   * This function is called when Create Exam button is pressed
   * It first checks whether all fields are correct, if not it displays error
   * Then it sends data to server, closes the dialog and shows a notification
   * that exam has been created
   * 
   */
This function is called when Create Exam button is pressed
It first checks whether all fields are correct, if not it displays error
Then it sends data to server, closes the dialog and shows a notification
that exam has been created
This function is called when Create Exam button is pressed It first checks whether all fields are correct if not it displays error Then it sends data to server closes the dialog and shows a notification that exam has been created
function createExam(){
      if(name===""){
          setErrorText("Name of Exam cannot be empty");
          return;
      }
      if(exam_link===""){
          setErrorText("Exam Link cannot be empty");
          return;
      }
      if(!isUrl(exam_link)){
          setErrorText("Exam Link must be a valid url");
          return;
      }
      if(duration === 0){
          setErrorText("Duration cannot be 0");
          return;
      }
      if(exam_code===""){
          setErrorText("Click Generate exam code to get an exam code first");
          return;
      }
      var current_date_time = new Date();
      if(date_time_start< current_date_time){
        setErrorText("Please select a date and time of the future");
        return;
      }
      axios.post('/api/exams/createExam', {
          name: name,
          exam_link: exam_link,
          date_time_start: date_time_start,
          duration: duration,
          exam_code: exam_code,
          prof_email: props.prof_email,
        })
        .then(function (response) {
          console.log(response);
          swal("Exam has been created. Your exam code has been copied to your clipboard, please share it with the students.");
        })
        .catch(function (error) {
          console.log(error);
          swal("Some error occoured in creating the exam");
        });
      closeExamDialog();
  }
function createExam ( ) { if ( name === "" ) { setErrorText ( "Name of Exam cannot be empty" ) ; return ; } if ( exam_link === "" ) { setErrorText ( "Exam Link cannot be empty" ) ; return ; } if ( ! isUrl ( exam_link ) ) { setErrorText ( "Exam Link must be a valid url" ) ; return ; } if ( duration === 0 ) { setErrorText ( "Duration cannot be 0" ) ; return ; } if ( exam_code === "" ) { setErrorText ( "Click Generate exam code to get an exam code first" ) ; return ; } var current_date_time = new Date ( ) ; if ( date_time_start < current_date_time ) { setErrorText ( "Please select a date and time of the future" ) ; return ; } axios . post ( '/api/exams/createExam' , { name : name , exam_link : exam_link , date_time_start : date_time_start , duration : duration , exam_code : exam_code , prof_email : props . prof_email , } ) . then ( function ( response ) { console . log ( response ) ; swal ( "Exam has been created. Your exam code has been copied to your clipboard, please share it with the students." ) ; } ) . catch ( function ( error ) { console . log ( error ) ; swal ( "Some error occoured in creating the exam" ) ; } ) ; closeExamDialog ( ) ; }
This function is called when Create Exam button is pressed
 It first checks whether all fields are correct, if not it displays error
 Then it sends data to server, closes the dialog and shows a notification
 that exam has been created
This function is called when Create Exam button is pressed It first checks whether all fields are correct if not it displays error Then it sends data to server closes the dialog and shows a notification that exam has been created