User settings defaults - where can they be hacked?

User settings defaults - where can they be hacked?

by Timothy Takemoto -
Number of replies: 10

I would like to be able to tell my students to ignore all the settins between their emails address and their "city" but, for example, the display email default is set to show to other members of the same class, and I would like it to be at the safest setting - show to no one. If I set all the defaults to the safest setting then these setttings can be ignored.
So how do I change the default displayed on the user settings page?

Better still it would be nice to remove most of them including the "city" and self-introduction. Japanese HATE self introductions. I have to tell them to put "nurr" in the self introdcution box.

Tim

Average of ratings: -
In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked?

by Thomas Robb -
You can manually edit the moodle/user/edit.html file and comment out any of the table rows (between 'tr' and '/tr' tags) for items that you don't want displayed. I think you can also do something devious for the description area by forcing it to contain a single space which will satisfy the validation process that forces something to be entered there.

You will find these parameters in the textarea for the description field:

textarea name=description cols=50 rows=10 wrap=virtual

To this you can add one more: value = " "

Of course another way is to block the validation process itself, but that gets messier.
In reply to Thomas Robb

Re: User settings defaults - where can they be hacked?

by Timothy Takemoto -

Thanks a lot Thomas,

I tried editing them out in the past but got that "you need to enter something" problem. Thanks for your devious suggestion.

I can see that value = " " will get around the city or self-description.

<tr valign=top>
    <td align=right><p><?php print_string("city") ?>:</td>
    <td><input type="text" name="city" size="25" maxlength="20" value="<?php p($user->city) ?>">
    <?php if (isset($err["city"])) formerr($err["city"]); ?>
</td>


 Great! I am soo pleased to see that last of that city (Yamaguchi, Yamaguchi-city, Yama guchi, etc) but how about the entries such as the following.

<tr valign=top>
    <td align=right><p><?php print_string('emaildigest') ?>:</td>
    <td><?php
    unset($choices);
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    choose_from_menu ($choices, 'maildigest', $user->maildigest, "") ?>
    </td>
</tr>

This is using the "choose_from_menu" function. It is less clear how to set a default. Peraps it is those quotes at the end that are not being used?

There does exist a default  though. Perhaps it is in another file in the user folder.

Tim

In reply to Timothy Takemoto

User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

Dear Thomas, everyone,

I have a request at the end of this mail!

Please ignore all this bit*****************************************************
I got rid of most of the complicated user login fields that causes me so much stress, since I have to nuture vast numbers (670) of students through the login process.

It is shown below (in Japanese) I have kept:

1) The name fields . It shame they are the wrong way up for Japanese users, but I have used examples of each type. The word for "given name" in Japanese is "underneath name," since Japanese writing runs down the page and given names come second, so the Moodle family-name-above-given-name arrangement, where the surname comes underneath, reallly needs pressing home for Japanese students. This will of course mean that entries in the grade book etc. are far too wide but it is better than about 10% of the students getting the name the 'wrong' way around. I have tried in the past swapping the two fields but then there are times when only one of the names is given (the surname) and then it looks really strange that it is the given name since a lot of Japanese only use their given name with their mother (and very close friends)!

2) The email address, since this is essential, but I have extended the description to ensure that they do not use their mobile phone (since all Japanese students have a mobile phone with email BUT this is not yet supported, quite -- there are moves on the Japanese forum that will make this a possibility soon, but even so, many mobile phones only accept about 200 or so characters)

3) I have changed city to unverisity faculty, since that will be useful in these cross faculty courses.

4) I have kept the language since there will be some non Japanese speaking teachers enrolling. Ideally though it would be nice to have all *students* set to Japanese.

5) I have kept the photo. I have changed the photo itself to something more undesirable, to encourage the upload of portraits. I need to change the helpfile too which makes not very desirable suggestions like using an image from google, or drawing a picture...oh dear. I find it really helps when students have their portrait uploaded. In this visual/shame culture, having your face by your forum posts etc. is much more powerful than having your name only.

6) I only kept one other non-compulsary field and changed that, the webpage field, to "mobile phone email address" so that we teachers can get in touch with students. I have included the words "visible only to your teacher." I think that these fields in the lower half are not only non-compulsary but also viewable only by the teacher. This is probably more important than the fact that they are non-compulsary.  
***************************************************************************************


BUT THE RED writing at the top? That means that it did not work. Some of the compulsary fields were not entered.

I used Thomas Robb's kind hack where I added a " " as default to the deleted self-introduction field. But it is the other, compulsary drop down menus that are causing the problem. But thinking about it, since even the self-introduction field was COMMENTED OUT then the defafult vaule of " " will be ignored!!!! What can I do!? I tried this before. If I comment them out so they are not displayed, they do not do anything!!! AAARRGH!

I would be happy to get these fiels to default to the standard defaults. I would be happier still if I could set the defaults, and then get these fields to default to the defaults I have set. If not then I am going to have about 5% of 670 students ask me about the significance of  each of those drop down menus!!

Why oh why must complicated things like "do you want your mail in html or text format" be COMPULSORY? What about all the people that are using moodle in primary schools?

user login screen abbreviated

All these problems are, I admit, the lamentations of a Moodle user wishing to  use Moodle in a non-socially constructive -- maze, whip, do-it-or-else -- way.

In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

Instead of commenting out those difficult fields, is there a way I can use

<Input type="hidden"..
??

The answer is not easily. Here is one of those ulscer making fields. It is not using html but calling on a php function "choose_from_menu," oh dear.  

<!--<tr valign=top>
    <td align=right><p><?php print_string("emaildisplay") ?>:</td>
    <td><?php
    unset($choices);
    $choices["0"] = get_string("emaildisplayno");
    $choices["1"] = get_string("emaildisplayyes");
    $choices["2"] = get_string("emaildisplaycourse");
    choose_from_menu ($choices, "maildisplay", $user->maildisplay, "") ?>
    </td>
</tr>

And here is choose_from_menu, from lib weblib.php

function choose_from_menu ($options, $name, $selected="", $nothing="choose", $script="", $nothingvalue="0", $return=false) {
/// Given an array of value, creates a popup menu to be part of a form
/// $options["value"]["label"]

    if ($nothing == "choose") {
        $nothing = get_string("choose")."...";
    }

    if ($script) {
        $javascript = "onChange=\"$script\"";
    } else {
        $javascript = "";
    }

    $output = "<select name=\"$name\" $javascript>\n";
    if ($nothing) {
        $output .= "   <option value=\"$nothingvalue\"\n";
        if ($nothingvalue === $selected) {
            $output .= " selected=\"true\"";
        }
        $output .= ">$nothing</option>\n";
    }
    if (!empty($options)) {
        foreach ($options as $value => $label) {
            $output .= "   <option value=\"$value\"";
            if ($value == $selected) {
                $output .= " selected=\"true\"";
            }
            if ($label === "") {
                $output .= ">$value</option>\n";
            } else {
                $output .= ">$label</option>\n";
            }
        }
    }
    $output .= "</select>\n";

    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}

Hmm...putting this in a table I think we have

The variables that the choose_from_menu function is waiting forThe defaults that the choose_from_menu function gives things. The variables and values that are passed in the case above.
1st variable passed$options$choices

2nd varibable passed

$name"maildisplay"
3rd variable passed$selected""$user->maildisplay
4th variable passed$nothing"choose"""
5th variable passed$script=""
6th variable passed$nothingvalue"0"
7th variable passed$returnfalse

But what  does it all mean?

There are many ways of going about this.
There is a possibility that by not passing any choices then nothing will be dispalyed but I doubt it.

It seems that choose_from_menu is making a html form. That means that it might be possible to set some variable to a special value so that the form that choose_from_menus makes has

Input type="hidden"

Tim

In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

But hold on a minute. The 7th variable, "$return" cause the choose_from_menu, to non echo the $output. So perhaps choose_from_menu can be used to hide?


But at the same time the default value of this function is set by the $nothingvalue, which is also a part of $output.

so? If I were to set "$return" to true, then that default value would not be echoed.

Er........er.....rrr....

How about

($choices, "maildisplay", $user->maildisplay, "","","emaildisplayno",true)

I am lost.
Tim


In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

But after all that, I have no idea what it is that determines which of these that I can avoid.

It seem that even setting the self description value to " " it must be input, and the most uniform of settings, the county (all my students are from Japan) can not be avoided.

At the same time the complicated settings can be avoided, it seems, so that is a great relief. I still have not worked out how to set their values to a default of my choice though.

shorter login edit.php

In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

I managed to get rid of the most of the drop down menus as above, and the self introduction by

1) Commenting out the table row with the self introduction.
2) Adding a hidden field <INPUT TYPE=hidden NAME=description VALUE=" ">
which ensures that a variable is passed to the checking mechanism.

I can't seem to get rid of the country though. "Country," when interpretted as nationality is kind of a sensitive issue here. Since this is a in house system, and everyone lives in the same country, I could add something longwinded about "This is not your nationality just where you are now" but then,  for the time being I have written "(Japan)."

Come to think of it, another way of dealing with this would be to convert the "country" to university faculty. That would be quite useful. It would leave me wondering what to do with the city field again.

I have found the countries file but I am concerned that they may be being used somewhere other than here. Are they?

I would still love to know how to set the defaults of those other drop down menus.

Tim

In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -

Few! Thanks to Thomas Robb's advice, I managed to get the profile page down to just how I would want it.

The winge about the order of the names was not in order at all, because all I needed to do was change the order of teh rows.

The country drop down box was in fact quite useful because it should enable them to set their faculty.

The city became their student number - quite useful too.

The web page, their mobile phone.

Most of the other information has disappeared. 

I may ask them to send it self introductions but from the main site page.

I enclose my users/edit.php (which does not contain any Japanese, but remember to reverse the order of the names if you are going to use it in Western countries.)

It looks like this, in Japanese I know but it gives you an idea of how small the profile page can become.
sleek profile page

Now I only need to find those drop down menu defaults. Especially the email ones.

Tim 

In reply to Timothy Takemoto

Re: User settings defaults - where can they be hacked please!?

by Sean S -
wow that was a lot of work. I think it would be great if there was some easier way for us to customize the registration/profile fields than hacking the backend.

Anyhow, if I feel daring I think I will try what you did.  
In reply to Sean S

Re: User settings defaults - where can they be hacked please!?

by Timothy Takemoto -
Dear Linguist,
It only took me a long time because I am not very cunning, with php.

If you are happy with the same layout then you can just do what I did and use my edit.html but you should avoid using the webpage field as anything but since it gets http:// stuck onto it. And it is shown to everyone. I had to edit view php as well to make it visible only to the teacher. That is easy though. Just add

&& isteacher()

to the ifstatement.

Tim