Online code editor for beginner's PHP class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • doznot

    Online code editor for beginner's PHP class

    Let's say you want to use Moodle to teach an introductory class in PHP
    programming. Some of the students have little or no computer experience.

    In addition to background reading and topics-oriented assignments
    supplied by Moodle, you want to build an online text editor into the
    course, so students can type their PHP programs and HTML directly into
    files on the server, so they don't have to fight with NotePad on Windows
    PCs in a lab, and so beginning students don't have to fight with FTP to
    get their work onto the webserver.

    You could make a form: (no error checking etc. for simplicity)
    $path =
    $_GET['dirpath']. '/myassignment';
    echo '<form action="'.$_SER VER['PHP_SELF'].'" method="post">< br>
    <textarea name="editor">' .@file_get_cont ents($path).'</textarea>
    <input type="submit"></form>';

    if($_SERVER['REQUEST_METHOD '] == 'POST')
    {
    $fp = fopen($path,"w" );
    fwrite($fp,$_PO ST['editor']);
    fclose($fp);
    }

    Most developers like to clean user input with addslashes or htmlentities
    in the POST processing. But if you do that in the "online code editor"
    case you get code that won't run or display. So, if you do not
    addslashes, but you still want to cover your bases, what are the issues?

    Students would have to login (password) to get access to the editor. So
    this editor is not available to the world at large. But trusting
    passworded students still may not be a good idea. fopen would have to be
    limited to specific location patterns. Perhaps you would have to use
    regular expressions to look for javascript, and then to strip it out.
    But what do you do if you want to teach javascript? Is an online editor
    any more dangerous than letting students upload code via FTP?
  • Jerry Stuckle

    #2
    Re: Online code editor for beginner's PHP class

    doznot wrote:
    Let's say you want to use Moodle to teach an introductory class in PHP
    programming. Some of the students have little or no computer experience.
    >
    That's a disaster waiting to happen right there.
    In addition to background reading and topics-oriented assignments
    supplied by Moodle, you want to build an online text editor into the
    course, so students can type their PHP programs and HTML directly into
    files on the server, so they don't have to fight with NotePad on Windows
    PCs in a lab, and so beginning students don't have to fight with FTP to
    get their work onto the webserver.
    >
    Very bad idea. They should be working on their own systems. Why do you
    need the programs on a server, anyway?

    But you could allow them to edit on their own server and upload via http
    if necessary.
    You could make a form: (no error checking etc. for simplicity)
    $path =
    $_GET['dirpath']. '/myassignment';
    echo '<form action="'.$_SER VER['PHP_SELF'].'" method="post">< br>
    <textarea name="editor">' .@file_get_cont ents($path).'</textarea>
    <input type="submit"></form>';
    >
    if($_SERVER['REQUEST_METHOD '] == 'POST')
    {
    $fp = fopen($path,"w" );
    fwrite($fp,$_PO ST['editor']);
    fclose($fp);
    }
    >
    Most developers like to clean user input with addslashes or htmlentities
    in the POST processing. But if you do that in the "online code editor"
    case you get code that won't run or display. So, if you do not
    addslashes, but you still want to cover your bases, what are the issues?
    >
    If you're going to display the code in a browser, htmlentities() is a
    must. Forget addslashes().
    Students would have to login (password) to get access to the editor. So
    this editor is not available to the world at large. But trusting
    passworded students still may not be a good idea. fopen would have to be
    limited to specific location patterns. Perhaps you would have to use
    regular expressions to look for javascript, and then to strip it out.
    But what do you do if you want to teach javascript? Is an online editor
    any more dangerous than letting students upload code via FTP?
    >
    Not a good idea at all.

    If you absolutely must, give each student their own virtual server and
    limit their access to just that directory.

    But I would say this is the wrong way to go.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • doznot

      #3
      Re: Online code editor for beginner's PHP class


      Editing on their own box? I suppose. NotePad never seems to save
      files in the same place twice, so absolute beginning students spend
      half the day looking for the file they just edited.


      Virtual servers is a good idea. I'll look into that.

      They can learn to ssh into their virtual server and use vi or emacs
      a semester later, but not in the first week of PHP 101.


      Comment

      • Jerry Stuckle

        #4
        Re: Online code editor for beginner's PHP class

        doznot wrote:
        >
        Editing on their own box? I suppose. NotePad never seems to save
        files in the same place twice, so absolute beginning students spend
        half the day looking for the file they just edited.
        >
        >
        Virtual servers is a good idea. I'll look into that.
        >
        They can learn to ssh into their virtual server and use vi or emacs
        a semester later, but not in the first week of PHP 101.
        >
        >
        >
        Sure notepad saves the files in the same place twice. It saves the
        files to the same directory as the last time it saved a file.

        Or, better yet, get them a decent editor. I personally prefer Crimsom
        editor for PHP.

        In 20 years of training, I have never forced my students to save files
        on a server. They all work off their own machines.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Jerry Stuckle

          #5
          Re: Online code editor for beginner's PHP class

          doznot wrote:
          >
          Editing on their own box? I suppose. NotePad never seems to save
          files in the same place twice, so absolute beginning students spend
          half the day looking for the file they just edited.
          >
          >
          Virtual servers is a good idea. I'll look into that.
          >
          They can learn to ssh into their virtual server and use vi or emacs
          a semester later, but not in the first week of PHP 101.
          >
          >
          >
          I should qualify that - if you start notepad from a command line, i.e.
          "notepad myfile.php", it will store the file in the current directory.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • doznot

            #6
            Re: Online code editor for beginner's PHP class



            I won't divulge much in the way of details.
            But I'm working in rural schools with limited resources.
            I have a central server, but the client computers the students
            use are Windows labs, hundreds of miles away, in multiple schools,
            with ancient browsers that I have no control over. I am not
            allowed to install new editors on those remote boxes.

            Why do I want them to save code on my server? So the students
            can instantly see their work displayed. When they are
            hundreds of miles away, working on machines I can not
            control, uploading homework assignments to a remote
            server, or editing via some hacked form, is the only way.

            Virtual machines and a name server would be best way
            to go. I'll have to get that together soon.

            In the meantime I've got it hacked so their "save"
            attempts fail, if not attempted in a fixed location,
            on a per-student basis, involving $_SESSION['username'];

            Comment

            • Geoff Berrow

              #7
              Re: Online code editor for beginner's PHP class

              Message-ID: <4-mdnRGgzcbze1LVn Z2dnUVZ_vadnZ2d @bresnan.comfro m doznot
              contained the following:
              I am not
              >allowed to install new editors on those remote boxes.
              You can get a small, lightweight editor that does not need to be
              installed. It's called Notepad2 and is absolutely brilliant. I would
              never inflict Notepad on my students.

              You can get it here http://www.flos-freeware.ch/notepad2.html
              --
              Geoff Berrow 011000100110110 0010000000110
              001101101011011 001000110111101 100111001011
              100110001101101 111001011100111 010101101011
              http://slipperyhill.co.uk - http://4theweb.co.uk

              Comment

              • doznot

                #8
                Re: Online code editor for beginner's PHP class

                Geoff Berrow wrote:
                Message-ID: <4-mdnRGgzcbze1LVn Z2dnUVZ_vadnZ2d @bresnan.comfro m doznot
                contained the following:
                >
                >I am not
                >allowed to install new editors on those remote boxes.
                >
                You can get a small, lightweight editor that does not need to be
                installed.
                ....I'm not sure what this means: " does not need to be installed "
                If it is a windows exe, then it has to be installed on the client
                box somehow, no? And in my case, the client boxes are hundreds of
                miles away.

                Comment

                • Jerry Stuckle

                  #9
                  Re: Online code editor for beginner's PHP class

                  doznot wrote:
                  >
                  >
                  I won't divulge much in the way of details.
                  But I'm working in rural schools with limited resources.
                  I have a central server, but the client computers the students
                  use are Windows labs, hundreds of miles away, in multiple schools,
                  with ancient browsers that I have no control over. I am not
                  allowed to install new editors on those remote boxes.
                  >
                  Why do I want them to save code on my server? So the students
                  can instantly see their work displayed. When they are
                  hundreds of miles away, working on machines I can not
                  control, uploading homework assignments to a remote
                  server, or editing via some hacked form, is the only way.
                  >
                  Virtual machines and a name server would be best way
                  to go. I'll have to get that together soon.
                  >
                  In the meantime I've got it hacked so their "save"
                  attempts fail, if not attempted in a fixed location,
                  on a per-student basis, involving $_SESSION['username'];
                  >
                  >
                  Trying to teach non-computer literate people a programming language
                  remotely? That a prescription for failure before you even begin.

                  People need a few skills before even beginning to program. Basic
                  computer literacy is one of them. An understanding of programming
                  principles is another.


                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Curtis

                    #10
                    Re: Online code editor for beginner's PHP class

                    doznot wrote:
                    >
                    Editing on their own box? I suppose. NotePad never seems to save
                    files in the same place twice, so absolute beginning students spend
                    half the day looking for the file they just edited.
                    >
                    >
                    Virtual servers is a good idea. I'll look into that.
                    >
                    They can learn to ssh into their virtual server and use vi or emacs
                    a semester later, but not in the first week of PHP 101.
                    >
                    >
                    You're putting the cart before the horse. If your students can't even
                    use a text editor and save/find files, they're doomed to fail at
                    becoming decent programmers. It sounds like some of them should be
                    referred to some computer basics course before pursuing programming.

                    To learn the basics of PHP, one doesn't even need a server, as it can
                    be done from the command line.

                    --
                    Curtis

                    Comment

                    • doznot

                      #11
                      Re: Online code editor for beginner's PHP class

                      Jerry Stuckle wrote:
                      Trying to teach non-computer literate people a programming language
                      remotely? That a prescription for failure before you even begin.
                      >
                      My last semester's students didn't see it that way.
                      They started with nothing, and ended up making simple but dynamic pages.
                      Teaching elementary programming (flow control, variables, scope, etc)
                      with web pages as the homework display medium keeps their interest up.

                      You can predict failure all you want.
                      But I already have the success.

                      Comment

                      • Lars Eighner

                        #12
                        Re: Online code editor for beginner's PHP class

                        In our last episode, <ToudnWDELt9ZRl LVnZ2dnUVZ_uGdn Z2d@bresnan.com >, the
                        lovely and talented doznot broadcast on comp.lang.php:
                        Editing on their own box? I suppose. NotePad never seems to save
                        files in the same place twice, so absolute beginning students spend
                        half the day looking for the file they just edited.
                        Then overcoming the drawbacks of MicroSoft products would really be an
                        essential skill for them to learn. Trying to teach someone who cannot use a
                        text editor a scripting language seems pointless and counterproducti ve.

                        It also is skipping some essential cognitive steps. If you cannot type
                        "Hello, world!" on your own machine, save it as a file, and recover the
                        file, you are missing a lot of information necessary to getting PHP to put
                        "Hello, world!" in a web document (although perhaps you can learn a limited
                        amount of PHP CLI).
                        Virtual servers is a good idea. I'll look into that.
                        They can learn to ssh into their virtual server and use vi or emacs
                        a semester later, but not in the first week of PHP 101.
                        --
                        Lars Eighner <http://larseighner.com/usenet@larseigh ner.com
                        Dynamic linking error: Your mistake is now everywhere.

                        Comment

                        • Lars Eighner

                          #13
                          Re: Online code editor for beginner's PHP class

                          In our last episode, <mdWdnYndHMAsa1 LVnZ2dnUVZ_j2dn Z2d@bresnan.com >, the
                          lovely and talented doznot broadcast on comp.lang.php:
                          Jerry Stuckle wrote:
                          >Trying to teach non-computer literate people a programming language
                          >remotely? That a prescription for failure before you even begin.
                          >>
                          My last semester's students didn't see it that way.
                          They started with nothing, and ended up making simple but dynamic pages.
                          Teaching elementary programming (flow control, variables, scope, etc)
                          with web pages as the homework display medium keeps their interest up.
                          You can predict failure all you want.
                          But I already have the success.
                          Then, if you already have the answer, why are you asking us?

                          Students who take Art 101 (Oil Painting) spend the first couple of weeks
                          learning to make stretchers, to stretch canvas, and to prep canvas. Most of
                          us spent a week or two learning to use an IBM 026 (or even more ancient)
                          keypunch before we wrote a line of code.

                          And say, if your students cannot use a text editor, how did they learn HTML?
                          Nearly every day we get questions here from people who think they can use
                          PHP to make web pages when they cannot make a valid HTML document without
                          PHP. If HTML is not a prerequisite of your course, you are simply a quack.

                          --
                          Lars Eighner <http://larseighner.com/usenet@larseigh ner.com
                          War hath no fury like a noncombatant.
                          - Charles Edward Montague

                          Comment

                          • doznot

                            #14
                            Re: Online code editor for beginner's PHP class

                            Lars Eighner wrote:
                            Then, if you already have the answer, why are you asking us?
                            >

                            I asked about security issues.
                            Everybody told me I had a bad idea.

                            But I have a very good idea.
                            I have happy students who learned a great deal in a short period of time.

                            Every educator I have shown this
                            to is pressuring me to publish immediately.
                            But I'll wait a year. When I get all the bugs out I'll publish
                            then, and make a name for myself.

                            It does look like I'll have to get there without much help
                            from usenet. Imagine that.

                            Comment

                            • -Lost

                              #15
                              Re: Online code editor for beginner's PHP class

                              Response to doznot <david.oznot@gm ail.com>:
                              Lars Eighner wrote:
                              >
                              >Then, if you already have the answer, why are you asking us?
                              >
                              I asked about security issues.
                              Everybody told me I had a bad idea.
                              >
                              But I have a very good idea.
                              I have happy students who learned a great deal in a short period
                              of time.
                              >
                              Every educator I have shown this
                              to is pressuring me to publish immediately.
                              But I'll wait a year. When I get all the bugs out I'll publish
                              then, and make a name for myself.
                              >
                              It does look like I'll have to get there without much help
                              from usenet. Imagine that.
                              I can understand your frustration as I've met many a USENET Nazi
                              who preferred arrogant banter as opposed to outright help...

                              ....but I haven't seen them here. Nor in this thread. A REAL
                              teacher seeks to educate, not spoon feed -- which is exactly what
                              Mr. Stuckle did for you (not spoon feed you that is). Geoff also
                              gave you a great pointer on Notepad2 which you just questioned
                              instead of checking it out. Not too swift in my opinion but it's
                              just my opinion.

                              Now, instead of the extremely convoluted method you are pursuing
                              why not have them download an "all-in-one" solution? XAMPP lite
                              for example, easy, quick and doesn't require anything but to
                              install (unless they changed something drastically).

                              Students can simply LEARN to store their code in ONE single place
                              using a VERY good editor like NOTEPAD2 (although I hate it) and
                              open those pages in THEIR browser. It's been my experience those
                              who wish to learn will overcome these minor obstacles. If you
                              don't expect your students to do the same then I'd not allow you to
                              teach my children.

                              No offense, no harm... but stop going on about how useless USENET
                              is and see the words for what they are -- information for you to
                              use, not feel the need to defend yourself.

                              Good luck.

                              --
                              -Lost
                              Remove the extra words to reply by e-mail. Don't e-mail me. I am
                              kidding. No I am not.

                              Comment

                              Working...