473,748 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?
Sep 16 '08 #1
25 2840
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.
js*******@attgl obal.net
=============== ===

Sep 16 '08 #2

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.
Sep 16 '08 #3
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.
js*******@attgl obal.net
=============== ===

Sep 16 '08 #4
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.
js*******@attgl obal.net
=============== ===

Sep 16 '08 #5


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'];

Sep 16 '08 #6
Message-ID: <4-*************** *************** @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
Sep 16 '08 #7
Geoff Berrow wrote:
Message-ID: <4-*************** *************** @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.
Sep 16 '08 #8
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.
js*******@attgl obal.net
=============== ===

Sep 16 '08 #9
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
Sep 16 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3690
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. Andrew dalke@dalkescientific.com
3
6756
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: Howto access .RC/.RES Ressource files with portable C++ code ( BCC,MSVC,GNU-C++, OpenWatcom) ? I just wanna access "local language strings", so that I may replace the ..RC file to compile a version of my software for a different language.
6
1475
by: bissatch | last post by:
Hi, How do I go about creating an online WYSIWIG editor where the user can type in a special kind of textarea but the text will appear how it would in a web page (but no html markup present). For example: http://tinymce.moxiecode.com/example_full.php?example=true
5
2279
by: Tia Carr | last post by:
When I press F1 on Date, all I get is two paragraphs on the Date date type. The intellisense feature indicates there are a few dozen methods and properties associated with Date. Where can I get the online help for that? Is it not documented? I have the 2002 version of .NET. Does the 2003 version provide more complete documentation? I also search for msdn online, but of no success. The is a learning process for me to learn the online...
5
1785
by: kichelchen | last post by:
Hi all, Does anybody know, if there is somewhere an editor with highlighter functions to implement in an existing cms with mysql backend? It should be easy to use/install :) Has anyone an idea? I need it because, we are working on that cms, and it would be easier to edit it online. So nobody needs to configure ftp clients, ... Thx :)
1
3333
by: gzeng | last post by:
Hi Everybdy: I am a beginner in C#. I'd like to write a simple online calculator in C#. This calculator will ask a user to input two numbers and then add them and display the result. So, it has two text boxes for a user to input two numbers. It also has a button for the user to get the result after adding these two numbers from input. Can somebody write such a program in C#? I think the program is small. How do I make it online so that...
1
1651
by: Slain | last post by:
I am a new hire in a company and have started working for the development team. Ofcourse, I took some C++ courses in my grad school, but there is such a big difference in the programs you encounter at school versus here, where it sems there is a completely different style of writing. Is there some tool etc to help understand some one else's code. I have been given some responsibilities to fix some minor defects, which involves...
2
3451
by: CC | last post by:
Hi: http://web.newsguy.com/crcarl/python/hexl.py This is my first Python program other than tutorial code snippet experimentation. I chose a hex line editor. I may do a hex screen editor once this is done, if I feel like playing with the curses module. Or move straight to wxPython. This is unfinished, and is really just a hex viewer at this point. It
15
2436
by: dreen1 | last post by:
Hello! Does any one of you know about some kind of PHP IDE (or at least an editor with syntax highlighting) that works online? It would be absolutely great if there was something like Google Docs, but for programmers with at least some features normal IDEs provide (support for JS and HTML would be great too). Reason for such need (at least in my case) is I change computers often. I have all my stuff on USB stick, but each time I go...
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.