The paper is organized as follows. In Section II, we construct the theory by introducing the fundamental quantities of our formalism and we recall the derivation of the CTMQC algorithm. In Section III, we study two exactly-solvable models consisting of one nuclear mode and two singlet electronic states, S 0 and S 1 . In both cases, the model systems are coupled to a single-mode cavity in resonance with a particular electronic excitation of the system: in model A of Section III B, mimicking the de-excitation process of the nuclear wavepacket via an avoided crossing, the cavity is in resonance with the energy gap between the adiabatic states, S 1 and S 0 , at the Franck-Condon point; in model B of Section III C, representing the spontaneous emission of the system in the vibrational ground state of S 1 , the cavity is in resonance with the energy gap between S 1 and S 0 at the minima of the potentials. In both sections, we study the dynamics, first, from the viewpoint of the exact time-dependent potentials and, then, by employing CTMQC, whose accuracy is evaluated by presenting the comparison with quantum dynamics, multi-trajectory Ehrenfest dynamics and Tully surface hopping. In Section IV, we explore the possibility of reapplying the factorization idea to the marginal photon-nuclear amplitude and related timedependent Schrödinger equation. However, due to the complexity of a "nested exact factorization" procedure, we explore at this stage only an approximate form, namely a mean-fieldlike factorization of the photon-nuclear wavefunction. We summarize our conclusions in Section V.