IEnumerator executeUpdates(List <jsonValues.instances> instances, int id)
    {
        user.needsWriting();
        StringBuilder sb = new StringBuilder(), modu = new StringBuilder();
        object        m;

        Debug.Log("executeUpdates de " + id);
        // fazer updates aqui de acordo com o que pede, por agora manter assim
        yield return(StartCoroutine("RetrieveCourseTopics"));

        foreach (jsonValues.instances i in instances)
        {
            foreach (jsonValues.updates u in i.updates)
            {
                sb.Append(u.name + ",");
                if (u.name.ToLower().Equals("configuration"))
                {
                    m = user.getCourse().getUndefinedModule(i.id);

                    if (m != null)
                    {
                        Debug.Log("Type in execute: " + m.GetType());
                        if (m.GetType().Equals(typeof(UserInfo.Course.modules)))
                        {
                            UserInfo.Course.modules mod = (UserInfo.Course.modules)m;
                            modu.Append("TEM O NOME: " + mod.name);
                            topics.AddLast(mod.name);
                            Debug.Log(mod.name);
                        }
                        if (m.GetType().Equals(typeof(UserInfo.Course.Folio)))
                        {
                            UserInfo.Course.Folio f = (UserInfo.Course.Folio)m;
                            modu.Append("TEM O NOME: " + f.name);
                            folios.AddLast(f.name);
                            Debug.Log(f.name);
                        }
                        else if (m.GetType().Equals(typeof(UserInfo.Course.Forum)))
                        {
                            UserInfo.Course.Forum fu = (UserInfo.Course.Forum)m;
                            modu.Append("TEM O NOME: " + fu.name);
                            foruns.AddLast(fu.name);
                            Debug.Log(fu.name);
                        }
                    }
                    else
                    {
                        modu.Append("ERRO ID: " + i.id);
                    }
                }
            }

            sb   = new StringBuilder();
            modu = new StringBuilder();
        }
        user.doneWriting();
    }
    /**
     * Metodo para verificar se houve actualizações desde o ultimo login, só serve para por em texto as novidades
     * TODO core_course_check_updates pode ter que ser utilizado para validar informação que afecte o user -> Check if there is updates affecting the user for the given course and contexts.
     * */
    IEnumerator checkNewInfo()
    {
        TimeSpan s = user.datelast - new DateTime(1970, 1, 1);

        //UnityEngine.Debug.Log("Verificar updates: " + cycle);
        cycle++;
        StringBuilder debrief = new StringBuilder("");
        WWW           www; String content; Values v;


        foreach (UserInfo.Course c in user.courses)
        {
            www = new WWW(moodleUrl + "/webservice/rest/server.php" + "?wstoken=" + tutorToken + "&wsfunction=core_course_get_updates_since&courseid=" + c.id + "&since=" + (int)s.TotalSeconds + "&moodlewsrestformat=json");
            yield return(www);

            content = www.text;
            v       = JsonUtility.FromJson <Values>(content);

            if (v.instances.Count > 0)     // Ocurreu algo de novo
            {
                debrief.Append("For Course " + c.fullName + " :\n");
                foreach (jsonValues.instances i in v.instances)
                {
                    if (i.contextlevel.ToLower().Equals("module"))
                    {
                        object m = user.getCourse().getUndefinedModule(i.id);
                        if (m == null)
                        {
                            debrief.Append("A module with the id " + i.id + " was removed\n");
                        }
                        else
                        {
                            if (m.GetType().Equals(typeof(UserInfo.Course.Folio)))
                            {
                                UserInfo.Course.Folio f = (UserInfo.Course.Folio)m;
                                folios.AddLast(f.name);
                                Debug.Log("Fólio");
                            }
                            else if (m.GetType().Equals(typeof(UserInfo.Course.Forum)))
                            {
                                UserInfo.Course.Forum fu = (UserInfo.Course.Forum)m;
                                foruns.AddLast(fu.name);
                                Debug.Log("Fórum");
                            }
                            else if (m.GetType().Equals(typeof(UserInfo.Course.modules)))
                            {
                                UserInfo.Course.modules mod = (UserInfo.Course.modules)m;
                                topics.AddLast(mod.name);
                                Debug.Log("Module");
                            }
                        }
                    }
                    if (i.contextlevel.ToLower().Equals("topic"))
                    {
                        UserInfo.Course.Topic t = user.getCourse().GetTopic(i.id);
                        if (t == null)
                        {
                            debrief.Append("A Topic with the id " + i.id + " was removed\n");
                        }
                        else
                        {
                            debrief.Append("On Topic " + t.name + " something happened\n");
                            Debug.Log("TOPIC");
                            topics.AddLast(t.name);
                        }
                    }
                }
            }
            else if (v.instances.Count == 0)
            {
                debrief.Append(noNewInfo);
            }
            debrief.Append("\n");
        }
        infoUpdates = debrief.ToString();
    }