Equal length for all the fields in cloze test

Equal length for all the fields in cloze test

par Josep M. Fontana,
Nombre de réponses : 16
I am trying to make all fields in a cloze test to be of equal length. I looked for information here and I saw this thread: https://moodle.org/mod/forum/discuss.php?d=375877

Alas, I tried to follow these instructions but I haven't been able to achieve the desired results. At the beginning I did exactly what was suggested in the thread and I added the string "~%0%standardlength#incorrect" at the end of every question. Doing that did not improve anything and I still got very different lengths for the boxes. Then I assumed that this "command" did not work and simply made the string much longer. This improved things a little bit but the lengths of the fields continue to be different. I include a screen shot so that you can see the differences.

dfa

Now, one thing that I'm really puzzled about is that the longest field is precisely one where the right answer was not the longest. The wrong answer based on the ~%0%standardlength# strategy is of the same length in all the questions. Here's the code that generates the fields in the images:

1. {:SA:=They~=They.~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}
2. {:SA:=The gate to their cage~=The gate to their cage.~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}
3. {:SA:=their cage~=Their cage.~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}
4. {:SA:=Its hinges~=Its hinges.~~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}
5. {:SA:=Their bare hands~=Their bare hands.~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}
6. {:SA:=no~=no.~%0%lengthstandardlengthstandardlengthstandardlength#incorrect}

I don't understand how the length of the different fields is calculated. I thought it would always be of the same length of the longest answer. This doesn't appear to be the case here. Can anybody tell me what I'm doing wrong and how I can achieve the desired goal of having all the boxes to be of the same size? Thanks.

JM
Moyenne des évaluations  -
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Hello Josep,

Indeed, the width of the input boxes seems to vary, even with the trick of identical wrong answers. The input boxes get different 'size' values. This may be a bug that you may want to report in the Tracker.

In the meantime, I suggest that you correct the problem yourself. CSS doesn't seem to be able to override the question code, but jQuery works with its ready() method, which occurs when the question's DOM has been loaded.

The code below works fine. You can adjust the width of the input boxes by changing the size value of "30", which stands for an approximate width of 30 characters:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $(".form-control.mb-1").attr('size',30);
    });
</script>

1. {:SA:=They~=They.}<br>
2. {:SA:=The gate to their cage~=The gate to their cage.}<br>
3. {:SA:=their cage~=Their cage.}<br>
4. {:SA:=Its hinges~=Its hinges.}<br>
5. {:SA:=Their bare hands~=Their bare hands.}<br>
6. {:SA:=no~=no.}<br>

If you have several Cloze questions or sub-questions on the same page and you want to have groups of input boxes of different widths, the jQuery code can be easily modified but it becomes a little more complex. Of course, it would be easier if the bug would get fixed, if it is one.

En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par AL Rachels,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers

Hi Josep,

Indeed, as Dominique mentions, I think a bug has crept in. Moodle has made some "render" changes since that forum post you mention, was made. I know it caused me problems with one of the plugins I maintain.

You might want to install the Cloze editor plugin for the Atto editor or TinyMCE editor, as you have a couple of problems with your questions, that it would probably have prevented. If you read the Cloze documentation section, Detailed syntax explanations, entry 7, and also the section, Troubleshooting: The equal sign (=) doesn't seem to work with SHORTANSER, you will see that you might need to use percentage in your questions.

What is weird to me, I copied your questions and create a Cloze question, and got similar results to what you posted. I then edited the question, copied thestandlength, from the first question, and pasted it over the same thing in the other five. My next preview, 2 through 6 were all the same size, while 1 was shorter.

I created a new version of your question from scratch using the Cloze editor, and when I previewed it, the answer fields were four different sizes.


After editing my question but without making any changes, I again got four different sizes, but NOT in the same places.

Should not be happening, so I think there is a bug. Looking at the HTML of the question does not show any weird spans or anything of that nature.

1. {1:SHORTANSWER:~%100%They#Correct~%100%They.#Correct~%0%lengthstandardlengthstandardlengthstandardlength#Incorrect}

2. {1:SHORTANSWER:~%100%The gate to their cage#Correct~%100%The gate to their cage..#Correct~%0%lengthstandardlengthstandardlengthstandardlength#Incorrect}

3. {1:SHORTANSWER:~%100%their cage#Correct~%100%Their cage.#Correct~%0%lengthstandardlengthstandardlengthstandardlength#Incorrect}

4. {1:SHORTANSWER:~%100%Its hinges#Correct~%100%Its hinges.#Correct~%0%lengthstandardlengthstandardlengthstandardlength#Incorrect}

5. {1:SHORTANSWER:~%100%Their bare hands#Correct~%100%Their bare hands.#Correct~%100%lengthstandardlengthstandardlengthstandardlength#Incorrect}

6. {1:SHORTANSWER:~%100%no#Correct~%100%no.#Correct~%0%lengthstandardlengthstandardlengthstandardlength#Incorrect}


Moyenne des évaluations Useful (1)
En réponse à AL Rachels

Re: Equal length for all the fields in cloze test

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Hello AL,

Just add these few lines in the question text:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $(".form-control.mb-1").attr('size', 50);
    });
</script>

and you get this:

ForumQuiz_20200607_1648.png

I know it's just a workaround, but it's pretty simple. sourire

Moyenne des évaluations Useful (4)
En réponse à AL Rachels

Re: Equal length for all the fields in cloze test

par Josep M. Fontana,
Thanks a lot, Al, for the time you took to test this so that you could help me. I had checked the cloze documentation you mention. I had thought using the '=' was the origin of many of the problems I was having (not only this one but several other problems). I was confident the '=' wasn't the culprit here because, as in other cases, I had tested the alternative with ~%100% and the problem persisted. In the end I have gone back to using '=' because it is simpler and contributes to "cleaner" code; I want to be able to reuse as much of this code as I can and the fewer pieces I have control, the better. I think that whatever the problem was, it seems to have been fixed now.

You also mention the cloze plugin. Unfortunately I work with our institutional Moodle and our IT services are one of the most unhelpful IT services I've ever encountered. I cannot ask them to install any plugins or anything that will make them get their metaphorical asses off their seats. It is rather frustrating but I have to make do with what I have. I work at UPF, which is a public university. There are a lot of good people working here that go out of their way to make your job easier and thus help you fulfil your mission as an educator. The people in charge of our IT department, however, are the embodiment of the worst stereotypes of the public servant that does everything except for serving the public. They make working with Moodle, or with any technology that requires their support, a true nightmare.

JM
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Eoin Campbell,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers
I don't like to boast, but our IT services unit are the most unhelpful I've ever encountered. Luckily our Moodle site is hosted externally, which somewhat limits the damage they do.
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par AL Rachels,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers
Hi Josep and Eoin, I used to run into the same type of "unhelpful" support people when I was in the US Army and also when I retired and became a teacher. I didn't make any "friends" with those types when after my first three years in the army, I started getting belligerent with those types. I would whip out a small notebook or piece of paper and start taking notes regarding who, what, when, where, why, etc. Invariably, they would ask what I was doing and I would tell them I just needed notes to make sure I had my facts straight for when I went over there head. (Whether I meant to do so or not!) I would also ask them to explain why, that if they were there to "support" us users, why wouldn't they do so? For a while, I actually got to have a server for myself on our school network. Finally got my own server at home because a "new" IT person was hired, and he removed all "extra" servers except "his" official ones at the district office. triste
En réponse à AL Rachels

Re: Equal length for all the fields in cloze test

par Josep M. Fontana,
Haha, we could start a competition to see who has the most unhelpful jerks in charge of their IT services.

Misery loves company, though. You guys have made me feel a bit less lonely with your stories about other IT services.

I have considered hosting Moodle on my home server but I have classes with 80 students and I don't know whether the old machine that I have working as a server could handle it. I don't have a lot of broadband, either so that doesn't help.

Cheers and thanks for your help!

JM
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par AL Rachels,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers
I admit that years ago I did opt for business class internet to have enough bandwidth going out of my house but service in my area has improved so regular service now has even more bandwidth. My home brew server uses a run of the mill motherboard using an 8 core, 3.8 GHz AMD cpu with 32 Gbytes of RAM and a 500 Gbyte SSD. An old test script indicated it could handle 54 concurrent users. I would imagine something similar could handle 80 students as long as you staggered quiz starts. I used to do that on my previous server by using lloonngg passwords and just letting part of the class wait while the rest got started.
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Personally, I think that, overall, the IT department of our engineering school does an excellent job. Many of the technicians I have dealt with are very friendly and highly qualified people. But I have often heard some pretty harsh criticism from other teachers about the IT department. It is true that there are always irritating situations and less sympathetic people, on both sides. I always try to be courteous to the technicians, but I also have my share of frustrations in situations where everything is not perfect.

I believe that it is the new IT director who set up a satisfaction survey system for each service request. The teachers' union denounced this practice, no doubt in solidarity with the technicians' union, and recommended that the teachers not respond to it. I answer anyway and I always put five stars. Either way, people are doing what they can.

It is always reassuring to see that I am not the only one having problems. I sometimes ask for the advice of a colleague and, to sum up, he tells me to take a deep breath and, if necessary, refer the problem to the director of our department.

I also realized that taking regular antidepressants and, more recently, a good dose of pop music with quality headphones could help me distance myself from this kind of problem. Many people recommend exercising regularly.

En réponse à Dominique Bauer

Re: Equal length for all the fields in cloze test

par Josep M. Fontana,

Hi Dominique, 

Interesting to hear different stories about IT support. This is somewhat therapeutic for me. I'm not kidding.

I actually don't have any problems with the IT technicians. When I have a technical problem that can be solved directly by them, the technicians that work on our campus are usually prompt, competent and nice. Our campus is pretty small and you get to develop almost a personal relationship with the technicians that have been working there for a few years. I have no complain there; quite the opposite. These rank and file technicians have, in many cases, tried to help me in spite of the kind of culture that the direction of the IT department promotes. Some of them have told me in confidence that I shouldn't be having some or other problem I was having but that their department's policies prevented them from doing what was necessary to help me do what I needed to do (even though in their opinion those solutions would be easy to implement and would not do any harm or create any problems or complications of any kind). 

I even remember a couple of occasions in which they were so frustrated with their inability to help me that they suggested unauthorized alternatives to do what I needed to do asking me to please don't tell anybody they were the ones that showed me how to do that if I was ever caught. Mind you, these were never things that compromised the security of our networks or could cause any damage or inconveniences for any members of our community. These are good professionals that are just as frustrated as I am with the red tape and with the way things are in their department and that just want to do their job well (which is to make it easier for us to do our research and our teaching) in spite of their bosses. 

So, it is not the technicians that are the problem. It is the director of the IT services in our campus and the director of the IT services of the university at large (who happens to be the person who was previously the director of the IT services in our campus) that are the problem. 

I don't know if it works the same way in your organizations, but around here what makes one climb the organizational ladder is usually not merit or competence but rather your brown nosing abilities or your ability to "eliminate" your competitors by different means. I really have no idea how the guy who is now in charge managed to get to the top being so young (rather surprisingly, he went over other more senior people that were waiting in line) but from my experience with him when he was the person in charge of IT in our campus, I suspect he was better than the competition in the use of one of the two methods I described; probably the first method. 

Just to give you an example of what I'm talking about. I could give you a lot of examples like this because I've been working in this university for already 25 years. OK, so my wife also works in the same university and, for a couple of years, she was a vice-provost/deputy vice-chancellor (there are no exact equivalences between these kinds of positions in different university systems but I think this is more or less the kind of rank equivalent in an American or British university). During those years we were having a recurring problem that was making us waste a lot of time and made it virtually impossible for us to make any progress in our project. 

I don't remember the details because this was quite a long time ago but I think it was a problem that could easily be solved if the IT technician we had hired to manage certain technical aspects of our project had the adequate permissions in our server (a virtual machine which is part of the network infrastructure of our campus). I had contacted the IT services to ask if they could help us but the technicians told me that they did not have the authorization to grant these permissions. I insisted and explained how this was necessary for us to do what we needed to do. The technicians were sympathetic and admitted off the record that granting these permissions would not be a problem with the kind of setup we had. They said the boss had told them they could not grant these permissions. Every time we ran into that problem, our technician had to call the university IT services and wait until one of their technicians with the required permissions was available to access our server and guided by our technician via e-mail messages tried to fix the problem. 

This was maddening. The university IT technicians were sometimes inexperienced and were not familiar with the directory structure and applications installed on our server. Our technician could have solved the problems in minutes and was growing tired and frustrated of having to work in these conditions. Some times we had to wait a whole week for someone to be available and our technician had to go over and over again through the whole process of exchanging messages and explaining things that he had explained already a lot of times to other people to solve pretty simple problems. If your server is not working everything has to stop and the deadlines we had were coming closer and closer. This lasted for months. 

I decided to ask my wife for help. I asked her to intervene so that we could put an end to that absurd nightmare. She was reluctant to do that because she is this kind of person but since she was involved in the same project and she saw the gravity of the problem she accepted to write an e-mail message in her name asking for the same thing I had been asking for months. 

In less than 24 hours the problem was solved. My wife received a direct message from the guy who is now the director of the university IT services (back then director of our campus IT services) being all nice and apologetic for the "misunderstanding" (or some bullshit like that), misrepresenting what had happened and why they had not been able to help us and assuring that they were doing their best to help us achieve our goals. Please contact me directly if you have any other problems, blah, blah, blah. 

This is a recreation of something that happened quite a few years ago. The exact details of the problems and of the contents of the messages might not be totally accurate because I didn't think of documenting all of this at the time  (which now I regret) but this really went along the lines of what I just explained. You get the idea. 

Many years later, nothing has changed and problems and situations of this kind are the norm. It gets really tiring. I've just lost the will to try to do anything that would involve the cooperation of the IT services (whether it is for my research or for my teaching) and I always try to solve problems myself. Whatever I can do on my own server, I do it there. But there are certain things that I cannot do on my own and so I have to crash against the same human wall over and over again. 

Very recently I have had some of those enormously frustrating and experiences and, as I said, it felt good to let it out here and see that I'm not alone clin d’œil

JM


En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Josep,

Without going into details, I could for example tell you how I hosted the moodleformulas.org site on a personal account because my School did not see the point of hosting it on its site. I really don't know why, last year I finally got a little help from a technician, but I feel like it was more of a personal initiative on his part rather than following any directive. Whatever.

In my opinion, the story you tell is typical in all institutions around the world. This type of situation is not the exception, it is the norm. Not only in teaching and research, but in all fields of activity.

I envy the projects that we are shown on television where everyone seems to work in harmony. But precisely, it is only fiction.

For me, the reality is when I take a vacation with my wife in an all-inclusive luxury resort. People are generally nice there. My brother says it's just because I pay a lot of money. It may be true, but at least it makes me forget the nightmare of the working world.

We are moving away from the initial subject, but not that much. sourire

En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Daniel Thies,
Avatar Core developers Avatar Plugin developers Avatar Testers
This is more of a feature than a bug. A random number of spaces are added to the maximal value in order to prevent it being used to guest the right answer if the author does not enter any distractors manually. In the case of you question it does lead to some rather poor rendering.
En réponse à Daniel Thies

Re: Equal length for all the fields in cloze test

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Hello Daniel,

I almost suspected it. It makes sense. Thank you for that clarification.

En réponse à Dominique Bauer

Re: Equal length for all the fields in cloze test

par Josep M. Fontana,
Hi,

Thanks a lot to everybody who responded. This has been really helpful. What Daniel says makes sense and it is a very useful feature to have. Nevertheless, don't you think there should be a way to override it? Sometimes the best way to prevent guesses is just to make all the boxes exactly the same length. I thought the ~%0%standardlength was the "official" code to do this and it seemed to be a good idea.

This must have worked at some point but now it doesn't work anymore. The only solution that worked is the one suggested by Dominique. I introduced the lines of JavaScript code and that did the trick.

JM
Moyenne des évaluations Useful (1)
En réponse à Josep M. Fontana

Re: Equal length for all the fields in cloze test

par Daniel Thies,
Avatar Core developers Avatar Plugin developers Avatar Testers
Hi Josep,

Adding ~%0%standardlength is really sort of a hack to get cloze question to do something that it was not really designed to do. I believe that it has always had the random length added because that was helpful for the type of questions that you they anticipated. Dominique's js solution is a good one. I would also suggest one might be able to add a container around the input with an attribute like stype="max-width: 100px; overflow: hidden" to force a maximum length to the box if js is not convenient.
Moyenne des évaluations Useful (1)