php-general Digest 28 Apr 2010 06:39:57 -0000 Issue 6716

Topics (messages 304680 through 304694):

Re: Error handling strategies (db related)
        304680 by: Gary .
        304682 by: Andrew Ballard

Re: php quiz script/tutorial
        304681 by: Dotan Cohen
        304683 by: Adam Richardson

auto indentation
        304684 by: David McGlone
        304685 by: shiplu
        304686 by: Ashley Sheridan
        304687 by: D. Dante Lorenso
        304688 by: Programming Guides
        304689 by: Paul M Foster
        304690 by: David McGlone
        304691 by: David McGlone
        304692 by: Programming Guides
        304693 by: Paul M Foster

What is wrong with this code?
        304694 by: Gary .

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 4/27/10, tedd wrote:
> At 4:23 PM +0100 4/27/10, Nathan Rixham wrote:
>>
>>I'm still shocked you guys are still writing code that has errors in it,
>>what's worse is you know about the errors, and instead of fixing them
>>you're just telling the user about it!
>>
>>:p
>
> Here's my code that doesn't contain errors:
>
> <?php
>
> ?>

Wow! What license are you applying to that? Can I re-use it without
fear or being sued for copyright infringement?

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 12:23 PM, tedd <tedd.sperl...@gmail.com> wrote:
> At 4:23 PM +0100 4/27/10, Nathan Rixham wrote:
>>
>> I'm still shocked you guys are still writing code that has errors in it,
>> what's worse is you know about the errors, and instead of fixing them
>> you're just telling the user about it!
>>
>> :p
>
> Here's my code that doesn't contain errors:
>
> <?php
>
> ?>
>
> Cheers,
>
> ted
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Watch out for that new warning message:

<br />
<b>Warning</b>:  Deadbeat script. Your code does not do anything
useful in <b>teddscript.php</b> on line <b>1</b><br />


:-)

Andrew

--- End Message ---
--- Begin Message ---
On 26 April 2010 18:12, Paul Jinks <p...@pauljinks.co.uk> wrote:
> I'm considering my options for making quizzes mostly multiple choice
> type of thing, but also 'filling in the gaps'. This is in support of
> educational materials I'm working on. So far I've looked at Flash and
> javascript but have concerns about accessibility for both of these.
>
> Does anyone have any experience of writing quizzes with php and if so,
> can you recommend any resources to get me started?
>
> TIA
>
> Paul

HTML has a <form> element with radio buttons, text fields, and more. Use that.


-- 
Dotan Cohen

http://bido.com
http://what-is-what.com

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 12:55 PM, tedd <tedd.sperl...@gmail.com> wrote:

> At 4:12 PM +0100 4/26/10, Paul Jinks wrote:
>
>> I'm considering my options for making quizzes mostly multiple choice
>> type of thing, but also 'filling in the gaps'. This is in support of
>> educational materials I'm working on. So far I've looked at Flash and
>> javascript but have concerns about accessibility for both of these.
>>
>> Does anyone have any experience of writing quizzes with php and if so,
>> can you recommend any resources to get me started?
>>
>> TIA
>>
>> Paul
>>
>
> Paul:
>
> I have written surveys/quizzes, but have not found a lot of resources for
> it.
>
> I use javascript usually to handle minor user things, such as "Please
> answer the question before moving on" or "Rank these items in order of
> importance", or other such immediate demands of the user, but still the user
> input not to be trusted. IOW, you still have to scrub everything.
>
> While I could use Flash, I choose not for it would simply make my work-load
> harder.
>
> Quizzes and such are just a long cascade of forms.
>
> I usually use one form and populate it with questions (content and type)
> from a database. Then when the user submits their data, I then save the
> answer as a independent record with ties to the "test", "question" and
> responder. The database design takes some thought to set up correctly.
>
> In the end, there is not really anything that hard about this, it's just
> collecting information from the user via a form and storing that information
> in a database.
>
> Cheers,
>
> tedd
>
>
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If you were going to use Flash, I'd go the Flex route as it makes short work
of this kind of view.

Ted already mentioned the DB route using PHP, but you could also use PHP to
set up an XML schema that represents quizes (e.g., <quiz><question
id="1"><text>Will this work?</text><options><option>Yes this
will.</option><option>No it won't.</option></options></question><email>
respon...@msu.edu</email></quiz>)  With this type of scheme (one in which
the html form is automatically built up from an XML document), you could
just have the results emailed to an account as individual TSV file
attachments (that's why I included the email tag in the example above),
making it easy for anyone to tally the results after dragging the documents
into Excel.

Last, you can also leverage existing technologies.  In addition to quiz
generators available online, Google Docs allows you to create forms that
store responses in spreadsheets (Create New -> Form).  You can choose from a
variety of response types (text, multiple choice, etc.), and it works quite
well.

Just tossing out ideas ;)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
Hi everyone.

I got a quickie LOL

is there a way to auto indent code. I'm using Kate and I have it set so the 
tab is only 4 spaces, but I was wondering if there was an easier way than to 
have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice laid 
out code like this:

-----
 -----
  -----
   -----
    -----
   -----
  -----
 -----
-----

or:

function() {

        function here
}

-- 
Blessings,
David M.

--- End Message ---
--- Begin Message ---
There is a command "indent" in your kde.
Check the manual

Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--- End Message ---
--- Begin Message ---
On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:

> Hi everyone.
> 
> I got a quickie LOL
> 
> is there a way to auto indent code. I'm using Kate and I have it set so the 
> tab is only 4 spaces, but I was wondering if there was an easier way than to 
> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice 
> laid 
> out code like this:
> 
> -----
>  -----
>   -----
>    -----
>     -----
>    -----
>   -----
>  -----
> -----
> 
> or:
> 
> function() {
> 
>       function here
> }
> 
> -- 
> Blessings,
> David M.
> 


I use Kate too, and the indentation changed slightly in KDE 4. In the
configure dialogue window, go down to the Editing section in the left
menu and set the number of spaces to use in both the General tab (under
Tabulators) and the Indentation tab (under Indentation Properties. If
they are both different then you have to hit the tab key 4 times in
order for your spaces to be replaced by a tab character.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
Hi everyone.
I got a quickie LOL
is there a way to auto indent code. I'm using Kate and I have it set so the
tab is only 4 spaces, but I was wondering if there was an easier way than to
have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice laid
out code like this:

I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:

http://www.phpeclipse.com/

The code formatter built into that formats my code when I hit Ctrl+Shift+F. No other code formatter works as well for what I've found. Many formatters just indent, this one will reformatt by putting brackets up or down, and reindent all the code to fit my coding standards.

Project is getting a little old, though and doesn't yet support PHP 5.3 syntax, but it's still the best I've found.

-- Dante

----------
D. Dante Lorenso
da...@lorenso.com
972-333-4139

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso <da...@lorenso.com> wrote:

> On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
>
>> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
>>
>>> Hi everyone.
>>> I got a quickie LOL
>>> is there a way to auto indent code. I'm using Kate and I have it set so
>>> the
>>> tab is only 4 spaces, but I was wondering if there was an easier way than
>>> to
>>> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice
>>> laid
>>> out code like this:
>>>
>>
> I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
>
> http://www.phpeclipse.com/
>
> The code formatter built into that formats my code when I hit Ctrl+Shift+F.
>  No other code formatter works as well for what I've found.  Many formatters
> just indent, this one will reformatt by putting brackets up or down, and
> reindent all the code to fit my coding standards.
>
> Project is getting a little old, though and doesn't yet support PHP 5.3
> syntax, but it's still the best I've found.
>
> -- Dante
>
> ----------
> D. Dante Lorenso
> da...@lorenso.com
> 972-333-4139
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
vim ftw:

1. select the piece of code you want to indent (or select all with "ggVG")
2. Hit =
3. profit!

-- 
http://programming-guides.com

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 08:52:09PM -0500, Programming Guides wrote:

> On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso <da...@lorenso.com> wrote:
> 
> > On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
> >
> >> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> >>
> >>> Hi everyone.
> >>> I got a quickie LOL
> >>> is there a way to auto indent code. I'm using Kate and I have it set so
> >>> the
> >>> tab is only 4 spaces, but I was wondering if there was an easier way than
> >>> to
> >>> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create nice
> >>> laid
> >>> out code like this:
> >>>
> >>

<snip>

> vim ftw:
> 
> 1. select the piece of code you want to indent (or select all with "ggVG")
> 2. Hit =
> 3. profit!

+1 for vim

I use a limited number of "g" commands, like gg, G and gwap, but I use
them rotely; I've never understood the variations. Can you point me to
some sort of tutorial on these?

Paul


-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Tuesday 27 April 2010 16:55:45 Ashley Sheridan wrote:
> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> > Hi everyone.
> >
> > I got a quickie LOL
> >
> > is there a way to auto indent code. I'm using Kate and I have it set so
> > the tab is only 4 spaces, but I was wondering if there was an easier way
> > than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
> > create nice laid out code like this:
> >
> > -----
> >  -----
> >   -----
> >    -----
> >     -----
> >    -----
> >   -----
> >  -----
> > -----
> >
> > or:
> >
> > function() {
> >
> >     function here
> > }
> 
> I use Kate too, and the indentation changed slightly in KDE 4. In the
> configure dialogue window, go down to the Editing section in the left
> menu and set the number of spaces to use in both the General tab (under
> Tabulators) and the Indentation tab (under Indentation Properties. If
> they are both different then you have to hit the tab key 4 times in
> order for your spaces to be replaced by a tab character.

Thanks Ash. What is your preferences  for indenting code? Do you have it set 
so you don't have to hit the tab key at all? I set my numbers in kate to 4 
what about you?

-- 
Blessings,
David M.

--- End Message ---
--- Begin Message ---
On Tuesday 27 April 2010 19:00:29 D. Dante Lorenso wrote:
> On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
> > On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> >> Hi everyone.
> >> I got a quickie LOL
> >> is there a way to auto indent code. I'm using Kate and I have it set so
> >> the tab is only 4 spaces, but I was wondering if there was an easier way
> >> than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
> >> create nice laid out code like this:
> 
> I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
> 
> http://www.phpeclipse.com/
> 
> The code formatter built into that formats my code when I hit
> Ctrl+Shift+F.  No other code formatter works as well for what I've
> found.  Many formatters just indent, this one will reformatt by putting
> brackets up or down, and reindent all the code to fit my coding standards.
> 
> Project is getting a little old, though and doesn't yet support PHP 5.3
> syntax, but it's still the best I've found.

I haven't tried this one. I am just so stuck on Kate. I've tried a ton of 
editors and Kate is simply the best one for me hands down.

I'll check out php Eclipse. Never know I may be impressed with it.

After about 10 or more years of using KDE, I am have been running Gnome for 
about a year now, but I always always install Kontact and kate.

-- 
Blessings,
David M.

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 9:15 PM, Paul M Foster <pa...@quillandmouse.com>wrote:

> On Tue, Apr 27, 2010 at 08:52:09PM -0500, Programming Guides wrote:
>
> > On Tue, Apr 27, 2010 at 6:00 PM, D. Dante Lorenso <da...@lorenso.com>
> wrote:
> >
> > > On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
> > >
> > >> On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> > >>
> > >>> Hi everyone.
> > >>> I got a quickie LOL
> > >>> is there a way to auto indent code. I'm using Kate and I have it set
> so
> > >>> the
> > >>> tab is only 4 spaces, but I was wondering if there was an easier way
> than
> > >>> to
> > >>> have to hit the tab key 1x then 2x then 3x then 2x then 1x to create
> nice
> > >>> laid
> > >>> out code like this:
> > >>>
> > >>
>
> <snip>
>
> > vim ftw:
> >
> > 1. select the piece of code you want to indent (or select all with
> "ggVG")
> > 2. Hit =
> > 3. profit!
>
> +1 for vim
>
> I use a limited number of "g" commands, like gg, G and gwap, but I use
> them rotely; I've never understood the variations. Can you point me to
> some sort of tutorial on these?
>
> Paul
>
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I gotta say I dont understand the "g" commands very well either. They dont
seem to have much in common, and I, like yourself know a handful that I am
comfortable using. In any case, this cheat sheet has several "g" commands
(although I commonly use some that are not listed):

http://www.fprintf.net/vimCheatSheet.html

-- 
Viktor
http://programming-guides.com

--- End Message ---
--- Begin Message ---
On Tue, Apr 27, 2010 at 10:29:33PM -0400, David McGlone wrote:

> On Tuesday 27 April 2010 19:00:29 D. Dante Lorenso wrote:
> > On 4/27/2010 3:55 PM, Ashley Sheridan wrote:
> > > On Tue, 2010-04-27 at 16:33 -0400, David McGlone wrote:
> > >> Hi everyone.
> > >> I got a quickie LOL
> > >> is there a way to auto indent code. I'm using Kate and I have it set so
> > >> the tab is only 4 spaces, but I was wondering if there was an easier way
> > >> than to have to hit the tab key 1x then 2x then 3x then 2x then 1x to
> > >> create nice laid out code like this:
> >
> > I use PHPEclipse for this.  It's not Eclipse with PDT, it's PHP Eclipse:
> >
> > http://www.phpeclipse.com/
> >
> > The code formatter built into that formats my code when I hit
> > Ctrl+Shift+F.  No other code formatter works as well for what I've
> > found.  Many formatters just indent, this one will reformatt by putting
> > brackets up or down, and reindent all the code to fit my coding standards.
> >
> > Project is getting a little old, though and doesn't yet support PHP 5.3
> > syntax, but it's still the best I've found.
> 
> I haven't tried this one. I am just so stuck on Kate. I've tried a ton of
> editors and Kate is simply the best one for me hands down.

I have to say, back in the day when I used a GUI editor, Kate was the
best I found. 

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
class Pg_Error
{
    private static $errors =
        array(INTEGRITY_CONST_UNIQUE => 'uniqueness constraint violated');
...
    public static function getMessage($ec)
    {
        $text = '';
        if (array_key_exists($ec, Pg_Error::$errors))
        {
            $text = Pg_Error::$errors[$ec];
        }

        return $text;
    }
...
}

?

Calling it, the array_key_exists call always returns false:
$this->assertEquals('uniqueness constraint violated',
Pg_Error::getMessage(Pg_Error::INTEGRITY_CONST_UNIQUE));
and I can't see what I've done wrong :(

--- End Message ---

Reply via email to