Quiz

 
 
Picture of ayan sasmal
Help needed to modify the logic how the processattempt.php works
 

Hi,

 

I am using Moodle 2.3.1. I would like to know that when a student clicks on "Check" button, and processattempt.php is invoked, can we modify the existing logic to get the correct answer?

 

Regards,

Ayan

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Yes, of course you can modify the logic. Open the PHP file in your editor and edit it wink

I realise you were after more specific help than that, but you question is too vague at the moment. Please explain what you are trying to do.

 
Average of ratings: -
Picture of ayan sasmal
Re: Help needed to modify the logic how the processattempt.php works
 

Hi,

 

I'm trying to add a logic for interative questions with multiple attempts. I have an application where i am asking the students to answer a question. on correct answer i am creating a code. this code is the correct answer. I want to push the correct answer into the db. now i want this processattempt.php to check, if the value in textbox is null and value in db for that question is null, then ask for input and to take the value from DB if the value is present in db n then proceed.

Let me know how to proceed with this.

Regards,

Ayan

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

You need to understand how the quiz works: http://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine

The quiz is built from questions, and each question is controlled by a separate question type plugin.

It sounds to me like you want to build a new question type.

 
Average of ratings: -
Picture of Ray Morris
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Particularly helpful Moodlers

That's an excellent explanation of HOW you're thinking about doing it, but I'm still a little unclear about WHAT you're trying to do.  Putting aside the talk about nulls and database values, what are you trying to accomplish, what should the student see?

 

If I'm understanding right, you want the existing feature called "feedback".

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

@ayan,

Like Tim and Ray I am finding it quite difficult to understand what you are wanting to do. It would make things clearer if you gave us a concrete example of a question, expected answers, and feedback message(s) that you have in mind.

Joseph

 
Average of ratings: -
Picture of ayan sasmal
Re: Help needed to modify the logic how the processattempt.php works
 

@Tim, Ray and Joseph

For eg.

Question: Which fruit fell on Newton's Head that lead to the discovery of Gravitational Force?

for answering we have a textbox and a check button.

Now the student has to write the answer in another of my application where this answer (i.e. Apple) will be verified.

Based on my requirements, the application will validate the answer given by the student. Now if, the student has entered Orange and verified, no code is given. Now when student enters Apple, a code is generated which the student needs to copy from the application and paste it in the textbox for anwser and click "Check".

Now i want to automate this process of copy pasting. The moment the user has entered the correct answer and verified in my application, i want to push the correct code in db in the column where the it would have gone if the student had pasted it in the textbox. 

Now on click of "Check", processattempt.php should check 2 things :

1. if value in textbox is empty

2. if value in db is empty

-if value in textbox(tb) is empty and value in db is empty, then dont proceed (display please enter a response)

-if there is a value in db, then use that value and proceed.

-else use the value from tb.

 

Now, guide me to find the location where i can add this logic in processattempt.php and the column in db where i need to save the data.

Regards,

Ayan

P.S. Dont ask about the logic of verification thoughtful using another application.

 
Average of ratings: -
Picture of Joseph Rézeau
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

ayan "Now the student has to write the answer in another of my application where this answer (i.e. Apple) will be verified."

Sorry, but I fail to understand why you need to do that.

Joseph

 
Average of ratings: -
Picture of ayan sasmal
Re: Help needed to modify the logic how the processattempt.php works
 
the application checks the answer in a varied way... we can say, we can have multiple correct answers... so that application checks n generates the code when the answers are correct... thats y we need the application...
 
Average of ratings: -
Picture of Joseph Rézeau
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Particularly helpful MoodlersGroup TestersGroup Translators

This still remains mysterious to me until you provide a concrete example.

 
Average of ratings: -
Picture of ayan sasmal
Re: Help needed to modify the logic how the processattempt.php works
 
the application checks the answer in a varied way... we can say, we can have multiple correct answers... so that application checks n generates the code when the answers are correct... thats y we need the application...
 
Average of ratings: -
Picture of Justin Hunt
Re: Help needed to modify the logic how the processattempt.php works
Group Particularly helpful Moodlers

You need the answer that gets saved as the student's response, to be the auto generated code(fetched from your application). 

Am I right?

In that case I would avoid trying to access the Moodle database directly. I think you should do it the Moodle way.  So write a new question type.

If you can put the code generating logic into your question type you can make the process pretty simple.

If not you will need some ajax like interaction with your app. In that case in your new question type, in place of a single textbox for the answer, put a javascript enabled form or flash widget.  That should then send the student's response to your application, and your app. should return the code. Your javascript/flash widget can save the code in a visible or hidden form field. When the question is posted it will get submitted and saved as the data does with any other question type.

That is how I would do it.

Justin

 

 

 
Average of ratings:Useful (1)
Tim at Lone Pine Koala Sanctuary
Re: Help needed to modify the logic how the processattempt.php works
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Justin is right that you should make a new question type (as I said a week ago. If you want us to go on helping you, then please give some indication that you have read and tried to understand what we said.)

However, doing it client-side is a bad solution. It is perfectly possible to get the server-side PHP code in the question type to make a call to another server to do the grading. I am afraid that the only examples of this that I can think of are both very complicated (qtype_stack and qtype_opaque).

You are probably better off looking at question/type/truefalse to get started on writing a new question type.

 
Average of ratings: -