Hiding a part of an html page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • systomx
    New Member
    • Nov 2011
    • 9

    Hiding a part of an html page

    I provide online tutorials for my students. Each page contains a question, which the student must answer. The answer is in javascript like this example:
    Code:
    corAns = 17
    I'd like to make it more difficult (I know I can't make it impossible) for the students to look at my code and extract the answer.

    I could encrypt the entire page, but that seems like overkill. Is there a slick way to encrypt one line of code?
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    #2
    Hi systomx,
    why not you save the answers inside a text file and the read that file through AJAX to check the answer , although the preferred way is to save the answers inside a db and then use a AJAX call to the server side script(PHP, ASP) that connects to a database table to verify the answer against tat particular question
    regards,
    Omer Aslam

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Just hash the answer. Then hash the student's answer and compare the hashes.

      Comment

      • omerbutt
        Contributor
        • Nov 2006
        • 638

        #4
        Just hash the answer. Then hash the student's answer and compare the hashes.
        the above method will allow to students to use the same hashing with the four options given as answers and the compare the resulting hash with the one saved in the page :D , i might do that if i was hid student [*evil*]
        regards,
        Omer Aslam

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          It's the best they can do with their limitations.

          If the answers are saved in a text file and then you use AJAX to retrieve the answers, the student can just use AJAX to retrieve the answers.

          This is a repost, and in the other post, the OP said he can't use server side scripting. So that idea is out the window.

          Comment

          • systomx
            New Member
            • Nov 2011
            • 9

            #6
            Thanks for your posts.

            What I have now done is to include the following javascript code in an include file. The include file is called in the HEAD of each of the tutorial pages.
            Code:
            //Code to block access to context menu
            window.oncontextmenu = function() {return false;}
            This blocks right click for Google Chrome, Firefox, and Safari. It does not not work for IE8 or IE9. (Any comments on that?)

            I realize that determined cheaters can get past this roadblock, even without using IE. Nevertheless, it will make it more difficult for them.

            My tutorial pages make use of frames, and I have heard that right click access to page source can be redirected to the parent frame (which doesn't contain my answers). Is this possible? If so, how?

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              That wouldn't stop someone from going to the frame's location directly and pulling up the source that way.

              You can disable the context menu but they can just click on view > source in their toolbar.

              Comment

              • systomx
                New Member
                • Nov 2011
                • 9

                #8
                Rabbit --

                You said "You can disable the context menu but they can just click on view > source in their toolbar."

                Well, yes and no. Using the tools menu/view source on Chrome, Firefox, and Safari shows the parent page (the frameset page), which doesn't have the answer.

                Still, I realize that what I've got is not really a fix for the problem, but more of a deterrent.

                (sigh) I may have to bite the bullet and directly edit my 200+ pages of html to obfuscate the answers.

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  I would move the code to a server-side script and call the script via Ajax to make it smooth.

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    This is a double post and in the original post, the OP said they can't use server side scripting.

                    Comment

                    • Rabbit
                      Recognized Expert MVP
                      • Jan 2007
                      • 12517

                      #11
                      systomx, once they have the source of the parent page, it contains the url of the framed page. They just have to navigate directly to that frame page, which removes the frame, and view the source of that.

                      Comment

                      Working...