This topic is locked
[SOLVED]

 Lock Record After Answer

12/23/2013 4:32:29 PM
PHPRunner General questions
A
Abbas author

(PHPRunner 7.0 build 19454, MySQL Database)
I have a questions, answers, students and teachers tables in my database
Students can add questions and teachers answers this question.
I want to make the question record locked (Student can not edit question record) after the teacher's answer the question
I have a Boolean field named IsLocked in questions table which will be set to '0' when record is created and i think it need to make Event to change it to '1' after the teacher's answer the question and lock the record
How to make it by Event?
Thanks

Abbas

Sergey Kornilov admin 12/24/2013

Here is the code you can use in BeforeAdd or in BeforeEdit event to set the value of IsLocked field:

$values["IsLocked"]=1;


I guess you need to add some logic here so set the value of IsLocked field only when teacher is replying.

A
Abbas author 12/26/2013



Here is the code you can use in BeforeAdd or in BeforeEdit event to set the value of IsLocked field:

$values["IsLocked"]=1;


I guess you need to add some logic here so set the value of IsLocked field only when teacher is replying.


Thanks for your replay
OK the IsLocked value is (1)
I think I need to add in a code in Before record updated

like

if (

$values["IsLocked"]=1

{

Desable or remove save button;



$message = "Sorry, you can not modify the question";

}


Thanks

Abbas

A
Abbas author 12/29/2013

I've written this event in "Before Record Updated"

if ($values["IsLocked"]=1)

{

echo '<script>alert("Sorry, you can not modify the question.");</script>';

$message = "Sorry, you can not modify the question";
return false;

}

else

{

return true;

}


But there is something wrong, I can not be modified any record even if the value of IsLocled = 0
Always I get the message "Sorry, you can not modify the question"
What's wrong?

Sergey Kornilov admin 12/29/2013

The following line is incorrect:

if ($values["IsLocked"]=1)


Use the following:

if ($values["IsLocked"]==1)
A
Abbas author 12/30/2013

Thank you